'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 ) { if ( isset( $endpoints['/wp/v2/users'] ) ) { unset( $endpoints['/wp/v2/users'] ); } if ( isset( $endpoints['/wp/v2/users/(?P[\d]+)'] ) ) { unset( $endpoints['/wp/v2/users/(?P[\d]+)'] ); } if ( isset( $endpoints['/wp/v2/comments'] ) ) { unset( $endpoints['/wp/v2/comments'] ); } if ( isset( $endpoints['/wp/v2/comments/(?P[\d]+)'] ) ) { unset( $endpoints['/wp/v2/comments/(?P[\d]+)'] ); } if ( isset( $endpoints['/wp/v2/settings'] ) ) { unset( $endpoints['/wp/v2/settings'] ); } 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' ); } 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' );