'any', 'post_status' => 'publish', 'posts_per_page' => -1 ) ); if( $query->have_posts() ) { while( $query->have_posts() ) { $query->the_post(); $routes[] = array( 'id' => get_the_ID(), 'type' => get_post_type(), 'slug' => basename( get_permalink() ), ); } } wp_reset_postdata(); return $routes; } /* 1 */ function vue_theme_scripts() { wp_enqueue_style( 'style', get_stylesheet_uri() ); if ( defined( 'IS_DEV' ) && IS_DEV === 'true') { wp_register_script( 'vue-theme', 'http://localhost:8081/build/main.js', array( 'jquery' ), false, true ); } else { wp_register_script( 'vue-theme', get_template_directory_uri() . '/build/main.js', array( 'jquery' ), false, true ); } wp_localize_script( 'vue-theme', 'wp', array( 'template' => get_stylesheet_directory_uri(), 'rest' => esc_url_raw( rest_url() ), 'site_name' => get_bloginfo( 'name' ), // 'nonce' => wp_create_nonce( 'wp_rest' ), 'routes' => vue_theme_routes(), ) ); wp_enqueue_script( 'vue-theme' ); } add_action( 'wp_enqueue_scripts', 'vue_theme_scripts' ); /** * disable endpoints in rest api **/ add_filter( 'rest_endpoints', function ( $endpoints ) { $remove = [ 'users', 'users/(?P[\d]+)', 'comments', 'comments/(?P[\d]+)', 'settings', ]; foreach( $remove as $endpoint ) if ( isset( $endpoints['/wp/v2/' . $endpoint] ) ) unset( $endpoints['/wp/v2/' . $endpoint] ); return $endpoints; } ); // Remove wordpress version number from files remove_action( 'wp_head', 'wp_generator' ); // Disable XML-RPC add_filter('xmlrpc_enabled', '__return_false'); // Disable WLManifest remove_action( 'wp_head', 'wlwmanifest_link' ) ; // Disable self ping function disable_pingback( &$links ) { foreach ( $links as $l => $link ) if ( 0 === strpos( $link, get_option( 'home' ) ) ) unset($links[$l]); } add_action( 'pre_ping', 'disable_pingback' ); // Disable RSD (used with self ping and XML-RPC) remove_action( 'wp_head', 'rsd_link' ) ; // Disable post embed function disable_embed() { wp_dequeue_script( 'wp-embed' ); } add_action( 'wp_footer', 'disable_embed' ); // Disable Shortlinking remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); // Remove versions from static assets (prevents cache-ing) function remove_cssjs_ver( $src ) { if( strpos( $src, '?ver=' ) ) $src = remove_query_arg( 'ver', $src ); return $src; } // !:Possible Bug HERE add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 ); add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 ); // Do NOT include jquery function no_default_jquery( ) { if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery', false); } } add_action( 'init', 'no_default_jquery' ); // REMOVE emoji support remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); // REMOVE block CSS function webapptiv_remove_block_library_css() { wp_dequeue_style( 'wp-block-library' ); } // REMOVE wp-container-id class for every block which causes wierd dislay: flex inclusions remove_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 ); // add_action( 'wp_enqueue_scripts', 'webapptiv_remove_block_library_css' ); // header( 'Access-Control-Allow-Origin: http://localhost:8080' ); header( 'Content-Type: application/json' ); // Add featured image support function craft_post_thumbnails() { add_theme_support( 'post-thumbnails' ); } add_action( 'after_setup_theme', 'craft_post_thumbnails' ); // Gutenberg custom stylesheet for editor add_theme_support('editor-styles'); add_editor_style( 'editor-style.css' ); // Custom Dashboard Menu Order function custom_menu_order($menu_ord) { if (!$menu_ord) return true; return array( 'index.php', // this represents the dashboard link 'upload.php', // this is the MEDIA library 'edit.php', // default POST 'edit.php?post_type=artist', 'edit.php?post_type=exhibition', 'edit.php?post_type=event', 'edit.php?post_type=episode', 'edit.php?post_type=short', 'edit.php?post_type=technique', 'edit.php?post_type=guide', 'edit.php?post_type=object', 'edit.php?post_type=publication', 'edit.php?post_type=page', // PAGES ); } add_filter('custom_menu_order', 'custom_menu_order'); add_filter('menu_order', 'custom_menu_order'); /* * Remove COMMENTS in its entirety */ // Removes COMMENTS from admin menu add_action( 'admin_menu', 'remove_admin_menus' ); function remove_admin_menus() { remove_menu_page( 'edit-comments.php' ); } // Removes COMMENTS from post and pages add_action('init', 'remove_comment_support', 100); function remove_comment_support() { remove_post_type_support( 'post', 'comments' ); remove_post_type_support( 'page', 'comments' ); } // Removes COMMENTS from admin bar add_action( 'wp_before_admin_bar_render', 'remove_comments_admin_bar' ); function remove_comments_admin_bar() { global $wp_admin_bar; $wp_admin_bar->remove_menu('comments'); } /* * ADMIN CUSTOM COLUMNS */ // Add the custom columns for ARTIST: add_filter( 'manage_artist_posts_columns', 'set_custom_edit_artist_columns' ); function set_custom_edit_artist_columns($columns) { $date = $columns['date']; unset( $columns['date'] ); $columns['artist_type'] = __('Artist Type' ); $columns['material'] = __('Material' ); $columns['date'] = $date; return $columns; } // Add the data to the custom columns for ARTIST: add_action( 'manage_artist_posts_custom_column' , 'custom_artist_column', 10, 2 ); function custom_artist_column( $column, $post_id ) { switch ( $column ) { // display a list of artist_type terms assigned to the post case 'artist_type' : $terms = get_the_term_list( $post_id , 'artist_type' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; // display a list of material terms assigned to the post case 'material' : $terms = get_the_term_list( $post_id , 'material' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; } } // Add the custom columns for EVENT: add_filter( 'manage_event_posts_columns', 'set_custom_edit_event_columns' ); function set_custom_edit_event_columns($columns) { $date = $columns['date']; unset( $columns['date'] ); $columns['event_type'] = __('Event Type' ); $columns['material'] = __('Material' ); $columns['date'] = $date; return $columns; } // Add the data to the custom columns for EVENT: add_action( 'manage_event_posts_custom_column' , 'custom_event_column', 10, 2 ); function custom_event_column( $column, $post_id ) { switch ( $column ) { case 'event_type' : $terms = get_the_term_list( $post_id , 'event_type' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; // display a list of material terms assigned to the post case 'material' : $terms = get_the_term_list( $post_id , 'material' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; } } // Add the custom columns for EXHIBITION: add_filter( 'manage_exhibition_posts_columns', 'set_custom_edit_exhibition_columns' ); function set_custom_edit_exhibition_columns($columns) { $date = $columns['date']; unset( $columns['date'] ); $columns['material'] = __('Material'); $columns['date'] = $date; return $columns; } // Add the data to the custom columns for EXHIBITION: add_action( 'manage_exhibition_posts_custom_column' , 'custom_exhibition_column', 10, 2 ); function custom_exhibition_column( $column, $post_id ) { switch ( $column ) { case 'material' : $terms = get_the_term_list( $post_id , 'material' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; } } // Add the custom columns for SHORT: add_filter( 'manage_short_posts_columns', 'set_custom_edit_short_columns' ); function set_custom_edit_short_columns($columns) { $date = $columns['date']; unset( $columns['date'] ); $columns['material'] = __('Material'); $columns['date'] = $date; return $columns; } // Add the data to the custom columns for SHORT: add_action( 'manage_short_posts_custom_column' , 'custom_short_column', 10, 2 ); function custom_short_column( $column, $post_id ) { switch ( $column ) { case 'material' : $terms = get_the_term_list( $post_id , 'material' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; } } // Add the custom columns for TECHNIQUE: add_filter( 'manage_technique_posts_columns', 'set_custom_edit_technique_columns' ); function set_custom_edit_technique_columns($columns) { $date = $columns['date']; unset( $columns['date'] ); $columns['material'] = __('Material'); $columns['date'] = $date; return $columns; } // Add the data to the custom columns for TECHNIQUE: add_action( 'manage_technique_posts_custom_column' , 'custom_technique_column', 10, 2 ); function custom_technique_column( $column, $post_id ) { switch ( $column ) { case 'material' : $terms = get_the_term_list( $post_id , 'material' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; } } // Add the custom columns for GUIDE: add_filter( 'manage_guide_posts_columns', 'set_custom_edit_guide_columns' ); function set_custom_edit_guide_columns($columns) { $date = $columns['date']; unset( $columns['date'] ); $columns['material'] = __('Material'); $columns['date'] = $date; return $columns; } // Add the data to the custom columns for GUIDE: add_action( 'manage_guide_posts_custom_column' , 'custom_guide_column', 10, 2 ); function custom_guide_column( $column, $post_id ) { switch ( $column ) { case 'material' : $terms = get_the_term_list( $post_id , 'material' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; } } // Add the custom columns for OBJECT: add_filter( 'manage_object_posts_columns', 'set_custom_edit_object_columns' ); function set_custom_edit_object_columns($columns) { $date = $columns['date']; unset( $columns['date'] ); $columns['material'] = __('Material'); $columns['date'] = $date; return $columns; } // Add the data to the custom columns for OBJECT: add_action( 'manage_object_posts_custom_column' , 'custom_object_column', 10, 2 ); function custom_object_column( $column, $post_id ) { switch ( $column ) { case 'material' : $terms = get_the_term_list( $post_id , 'material' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; } } // Add the custom columns for PUBLICATION: add_filter( 'manage_publication_posts_columns', 'set_custom_edit_publication_columns' ); function set_custom_edit_publication_columns($columns) { $date = $columns['date']; unset( $columns['date'] ); $columns['material'] = __('Material'); $columns['date'] = $date; return $columns; } // Add the data to the custom columns for PUBLICATION: add_action( 'manage_publication_posts_custom_column' , 'custom_publication_column', 10, 2 ); function custom_publication_column( $column, $post_id ) { switch ( $column ) { case 'material' : $terms = get_the_term_list( $post_id , 'material' , '' , ', ' , '' ); echo is_string( $terms ) ? $terms : '—'; break; } } // Add Author to Custom Post Type function add_author_support_to_posts() { $args = array( 'public' => true, '_builtin' => false ); $output = 'names'; $post_types = get_post_types( $args, $output ); foreach ( $post_types as $post_type ) { add_post_type_support( $post_type, 'author' ); } } add_action( 'init', 'add_author_support_to_posts' );