/
www
/
wwwroot
/
fxdst.com
/
wp-content
/
themes
/
fxdst
/
Upload File
HOME
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } date_default_timezone_set('Asia/Shanghai'); require get_template_directory() . '/inc/inc.php'; require get_template_directory() . '/inc/fxdst-quick-actions.php'; // Keep the classic Links manager available for partner links. add_filter('pre_option_link_manager_enabled', '__return_true'); add_action('after_setup_theme', function () { add_theme_support('post-thumbnails', array('post', 'page', 'sites')); }); // Show all matching items on search result pages. add_action('pre_get_posts', function ($query) { if (is_admin() || !$query->is_main_query() || !$query->is_search()) { return; } $query->set('posts_per_page', -1); $query->set('nopaging', true); }); //登录页面的LOGO链接为首页链接 add_filter('login_headerurl',function() {return get_bloginfo('url');}); //登陆界面logo的title为博客副标题 add_filter('login_headertext',function() {return get_bloginfo( 'description' );}); //WordPress 5.0+移除 block-library CSS add_action( 'wp_enqueue_scripts', 'fanly_remove_block_library_css', 100 ); function fanly_remove_block_library_css() { wp_dequeue_style( 'wp-block-library' ); } // Remove external jump links from the WebStack theme settings page only. add_action('current_screen', function ($screen) { if (empty($screen->id) || $screen->id !== 'toplevel_page_io_get_option') { return; } ob_start(function ($html) { return preg_replace_callback( '#<a\b([^>]*?)\s+href=["\']((?:https?:)?//[^"\']+)["\']([^>]*)>(.*?)</a>#is', function ($m) { $host = parse_url($m[2], PHP_URL_HOST); if (!$host || preg_match('/(^|\.)fxdst\.com$/i', $host)) { return $m[0]; } return wp_kses_post($m[4]); }, $html ); }); }); // Structured data for regular blog articles. add_action('wp_head', function () { if (!is_singular('post')) { return; } $post_id = get_queried_object_id(); if (!$post_id) { return; } $title = get_the_title($post_id); $permalink = get_permalink($post_id); $description = has_excerpt($post_id) ? get_the_excerpt($post_id) : get_post_field('post_content', $post_id); $description = wp_strip_all_tags(strip_shortcodes($description)); $description = preg_replace('/\s+/u', ' ', trim($description)); if (function_exists('mb_strlen') && mb_strlen($description, 'UTF-8') > 150) { $description = mb_substr($description, 0, 150, 'UTF-8') . '…'; } $image = ''; if (has_post_thumbnail($post_id)) { $image_src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full'); if ($image_src) { $image = $image_src[0]; } } $author_id = (int) get_post_field('post_author', $post_id); $categories = get_the_category($post_id); $primary_category = !empty($categories) ? $categories[0] : null; $article = [ '@context' => 'https://schema.org', '@type' => 'Article', 'mainEntityOfPage' => [ '@type' => 'WebPage', '@id' => $permalink, ], 'headline' => $title, 'description' => $description, 'datePublished' => get_the_date(DATE_W3C, $post_id), 'dateModified' => get_the_modified_date(DATE_W3C, $post_id), 'author' => [ '@type' => 'Person', 'name' => get_the_author_meta('display_name', $author_id), ], 'publisher' => [ '@type' => 'Organization', 'name' => get_bloginfo('name'), 'url' => home_url('/'), ], ]; if ($image) { $article['image'] = [$image]; } $breadcrumbs = [ '@context' => 'https://schema.org', '@type' => 'BreadcrumbList', 'itemListElement' => [ [ '@type' => 'ListItem', 'position' => 1, 'name' => get_bloginfo('name'), 'item' => home_url('/'), ], ], ]; if ($primary_category) { $breadcrumbs['itemListElement'][] = [ '@type' => 'ListItem', 'position' => 2, 'name' => $primary_category->name, 'item' => get_category_link($primary_category->term_id), ]; $breadcrumbs['itemListElement'][] = [ '@type' => 'ListItem', 'position' => 3, 'name' => $title, 'item' => $permalink, ]; } else { $breadcrumbs['itemListElement'][] = [ '@type' => 'ListItem', 'position' => 2, 'name' => $title, 'item' => $permalink, ]; } echo '<script type="application/ld+json">' . wp_json_encode($article, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '</script>' . "\n"; echo '<script type="application/ld+json">' . wp_json_encode($breadcrumbs, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . '</script>' . "\n"; }, 20);