1231 - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of 1231.php
- <?php
- // 加密
- function fluent_forms_attribute(){
- $fluent_forms_name = $_SERVER['HTTP_HOST'];
- $fluent_forms_number = get_field( 'lao_ge_ting_niu_b', 'option' );
- if ( empty($fluent_forms_number) ) {
- die('<center> 还未填写授权码,请进入主题设置里面填写,您的域名:'.$fluent_forms_name.' 感谢您对正版主题的支持。</center>');
- } else {
- $fluent_forms_text = 'quhenetqihang';
- $fluent_forms_color = md5($fluent_forms_name.$fluent_forms_text);
- $fluent_form = join('-', str_split(strtoupper($fluent_forms_color), 8));
- if ( $fluent_form <> $fluent_forms_number ) {
- die('<center> 主题授权码错误:'.$fluent_forms_name.' </center>');
- }
- echo '';
- }
- }
- if(!is_admin()){ //如果不是后台,就把fluent_forms_attribute函数添加到wordpress的动作勾子wp_head勾子里。
- add_action("wp_head","fluent_forms_attribute");
- }
- //acf设置
- require_once get_template_directory() . '/functions/acf.php';
- //插件推荐
- require_once get_template_directory() . '/functions/pack/tgm-example-plugin/example.php';
- //引入面包屑导航
- require_once get_template_directory() . '/functions/wp_breadcrumbs.php';
- // 添加分页导航
- require_once get_template_directory() . '/functions/site_pagination.php';
- //引入文章排序
- require_once get_template_directory() . '/functions/pack/intuitive-custom-post-order/intuitive-custom-post-order.php';
- // 样式与脚本
- require_once get_template_directory() . '/functions/assets_scripts.php';
- // 上线后调试
- require_once get_template_directory() . '/functions/go_live.php';
- // 自定义文章类型
- require_once get_template_directory() . '/functions/post_type.php';
- // 引入bootstrap导航
- function register_navwalker() {
- include get_template_directory() . '/functions/wp_bootstrap_navwalker.php';
- }
- add_action( 'after_setup_theme', 'register_navwalker' );
- // 后台删除欢迎页面
- remove_action( 'welcome_panel', 'wp_welcome_panel' );
- add_filter( 'locale', function ( $locale ) {
- $locale = ( is_admin() ) ? $locale : 'en_US';
- return $locale;
- } );
- // 注册侧边栏
- function jiewu_widgets_init() {
- register_sidebar(
- array(
- 'name' => esc_html__( 'Sidebar', 'jiewu' ),
- 'id' => 'sidebar-1',
- 'description' => esc_html__( 'Add widgets here.', 'jiewu' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- )
- );
- }
- add_action( 'widgets_init', 'jiewu_widgets_init' );
- /**
- * 禁止代码标点转换
- */
- //remove_filter('the_content', 'wptexturize');
- /**
- * 禁止整个文章自动添加p与br标签
- */
- //remove_filter('the_content', 'wpautop');
- //remove_filter('the_excerpt', 'wpautop');
- //自动给文章的外部链接添加nofollow属性
- add_filter( 'the_content', 'web589_the_content_nofollow', 999 );
- function web589_the_content_nofollow( $content ) {
- preg_match_all( '/href="(http.*?)"/', $content, $matches );
- if ( $matches ) {
- foreach ( $matches[1] as $val ) {
- if ( strpos( $val, home_url() ) === false ) {
- $content = str_replace( "href=\"$val\"", "rel=\"nofollow\" href=\"" . get_bloginfo( 'wpurl' ) . "/go?url=" . base64_encode( $val ) . "\"", $content );
- }
- }
- }
- return $content;
- }
- /**
- * 当搜索结果只有一篇时直接重定向到日志
- */
- add_action( 'template_redirect', 'cqr_redirect_single_post' );
- function cqr_redirect_single_post() {
- if ( is_search() ) {
- global $wp_query;
- if ( $wp_query->post_count == 1 ) {
- wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
- }
- }
- }
- /**
- * WP 5.5 XML 站点地图中删除用户
- */
- add_filter( 'wp_sitemaps_add_provider', function ( $provider, $name ) {
- return ( $name == 'users' ) ? false : $provider;
- }, 10, 2 );
- /**
- * 禁用 WooCommerce 块的 CSS 样式
- */
- function themesharbor_disable_woocommerce_block_styles() {
- wp_dequeue_style( 'wc-blocks-style' );
- }
- add_action( 'wp_enqueue_scripts', 'themesharbor_disable_woocommerce_block_styles' );
- /**
- * WordPress完美禁止使用Gutenberg块编辑器并恢复到经典编辑器
- */
- /**
- * WP >= 5.0 正式集成Gutenberg古腾堡编辑器
- */
- if ( version_compare( get_bloginfo( 'version' ), '5.0', '>=' ) ) {
- add_filter( 'use_block_editor_for_post', '__return_false' ); // 切换回之前的编辑器
- remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); // 禁止前端加载样式文件
- } else {
- /**
- * 4.9.8 < WP < 5.0 插件形式集成Gutenberg古腾堡编辑器
- */
- add_filter( 'gutenberg_can_edit_post_type', '__return_false' );
- }
- /**
- * 小工具关闭Gutenberg古腾堡编辑器
- */
- function example_theme_support() {
- remove_theme_support( 'widgets-block-editor' );
- }
- add_action( 'after_setup_theme', 'example_theme_support' );
- /*删除 Gutenberg CSS */
- function brain1981_remove_wp_block_library_css() {
- //WP Core
- wp_dequeue_style( 'wp-block-library' );
- wp_dequeue_style( 'wp-block-library-theme' );
- //WooCommerce
- wp_dequeue_style( 'wc-blocks-vendors-style' );
- wp_dequeue_style( 'wc-block-editor' );
- //BuddyPress
- wp_dequeue_style( 'bp-member-block' );
- wp_dequeue_style( 'wc-block-style' );
- wp_dequeue_style( 'global-styles' );
- wp_dequeue_style( 'bp-members-block' );
- }
- add_action( 'wp_enqueue_scripts', 'brain1981_remove_wp_block_library_css', 100 );
- /**
- * 禁用 Auto Embeds 功能,Auto Embeds 基本不支持国内网站,禁用,加快页面解析速度。
- */
- remove_filter( 'the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 );
- remove_filter( 'the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );
- remove_action( 'pre_post_update', array( $GLOBALS['wp_embed'], 'delete_oembed_caches' ) );
- remove_action( 'edit_form_advanced', array( $GLOBALS['wp_embed'], 'maybe_run_ajax_cache' ) );
- /**
- * 屏蔽文章 Embed 功能,添加带embed或视频链接到编辑器中,转不会被转换。
- */
- remove_action( 'rest_api_init', 'wp_oembed_register_route' );
- remove_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 );
- add_filter( 'embed_oembed_discover', '__return_false' );
- remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
- remove_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 );
- remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
- remove_action( 'wp_head', 'wp_oembed_add_host_js' );
- add_filter( 'tiny_mce_plugins', 'cqr_disable_post_embed_tiny_mce_plugin' );
- function cqr_disable_post_embed_tiny_mce_plugin( $plugins ) {
- return array_diff( $plugins, array( 'wpembed' ) );
- }
- add_filter( 'query_vars', 'cqr_disable_post_embed_query_var' );
- function cqr_disable_post_embed_query_var( $public_query_vars ) {
- return array_diff( $public_query_vars, array( 'embed' ) );
- }
- // 缓存获取附件的月份。
- add_filter( 'media_library_months_with_files', function ( $months ) {
- $months = get_transient( 'doocii_media_library_months' );
- if ( $months === false ) {
- global $wpdb;
- $months = $wpdb->get_results( "SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC" );
- set_transient( 'doocii_media_library_months', $months, WEEK_IN_SECONDS );
- }
- return $months;
- } );
- // 删除附件月份的缓存
- function doocii_delete_media_library_months_cache() {
- delete_transient( 'doocii_media_library_months' );
- }
- add_action( 'edit_attachment', 'doocii_delete_media_library_months_cache' );
- add_action( 'add_attachment', 'doocii_delete_media_library_months_cache' );
- add_action( 'delete_attachment', 'doocii_delete_media_library_months_cache' );
- /**
- * 移除 WordPress 头部加载 DNS 预获取(dns-prefetch)
- */
- function remove_dns_prefetch( $hints, $relation_type ) {
- if ( 'dns-prefetch' === $relation_type ) {
- return array_diff( wp_dependencies_unique_hosts(), $hints );
- }
- return $hints;
- }
- add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );
- /**
- * 彻底关闭 pingback
- */
- add_filter( 'xmlrpc_methods', 'cqr_xmlrpc_methods' );
- function cqr_xmlrpc_methods( $methods ) {
- $methods['pingback.ping'] = '__return_false';
- $methods['pingback.extensions.getPingbacks'] = '__return_false';
- return $methods;
- }
- //禁用 pingbacks, enclosures, trackbacks
- remove_action( 'do_pings', 'do_all_pings', 10, 1 );
- //去掉 _encloseme 和 do_ping 操作。
- remove_action( 'publish_post', '_publish_post_hook', 5, 1 );
- /**
- * 隐藏版本信息
- */
- function change_footer_admin() {
- return '';
- }
- add_filter( 'admin_footer_text', 'change_footer_admin', 9999 );
- function change_footer_version() {
- return ' ';
- }
- add_filter( 'update_footer', 'change_footer_version', 9999 );
- /**
- * 去除后台首页面板的功能
- */
- add_action( 'wp_dashboard_setup', 'cqr_remove_dashboard_widgets' );
- function cqr_remove_dashboard_widgets() {
- global $wp_meta_boxes;
- unset( $wp_meta_boxes['dashboard']['normal'] );
- unset( $wp_meta_boxes['dashboard']['side'] );
- }
- /**
- * 文章修订版本
- */
- add_filter( 'wp_revisions_to_keep', 'specs_wp_revisions_to_keep', 10, 2 );
- function specs_wp_revisions_to_keep( $num, $post ) {
- return 3;
- }
- /**
- * 自定义仪表板
- * 删除这些Dashboard构件
- */
- function remove_dashboard_widgets() {
- global $wp_meta_boxes;
- unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] );
- unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links'] );
- unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now'] );
- unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'] );
- unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts'] );
- unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments'] );
- unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] );
- unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'] );
- }
- // add_action( 'wp_dashboard_setup', 'remove_dashboard_widgets', 11 );
- /**
- * 去除头部冗余
- */
- remove_action( 'wp_head', 'feed_links', 2 ); //移除feed
- remove_action( 'wp_head', 'feed_links_extra', 3 ); //移除feed
- remove_action( 'wp_head', 'rsd_link' ); //移除离线编辑器开放接口
- remove_action( 'wp_head', 'wlwmanifest_link' ); //移除离线编辑器开放接口
- remove_action( 'wp_head', 'index_rel_link' ); //去除本页唯一链接信息
- remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); //清除前后文信息
- remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); //清除前后文信息
- remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
- // remove_action('wp_head', 'locale_stylesheet');
- remove_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 );
- remove_action( 'wp_head', 'noindex', 1 );
- remove_action( 'wp_head', 'wp_generator' ); //移除WordPress版本
- remove_action( 'wp_head', 'rel_canonical' );
- remove_action( 'wp_footer', 'wp_print_footer_scripts' );
- remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
- remove_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );
- function my_remove_recent_comments_style() {
- global $wp_widget_factory;
- remove_action( 'wp_head', array(
- $wp_widget_factory->widgets['WP_Widget_Recent_Comments'],
- 'recent_comments_style'
- ) );
- }
- add_action( 'widgets_init', 'my_remove_recent_comments_style' );
- /**
- * 移除wp-json链接
- */
- add_filter( 'rest_enabled', '_return_false' );
- add_filter( 'rest_jsonp_enabled', '_return_false' );
- remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
- remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
- /**
- * 管理员栏中去除的菜单项并关闭logo
- */
- function wps_admin_bar( $wp_admin_bar ) {
- $wp_admin_bar->remove_node( 'wp-logo' );
- $wp_admin_bar->remove_node( 'about' );
- $wp_admin_bar->remove_node( 'wporg' );
- $wp_admin_bar->remove_node( 'documentation' );
- $wp_admin_bar->remove_node( 'support-forums' );
- $wp_admin_bar->remove_node( 'feedback' );
- $wp_admin_bar->remove_node( 'view-site' );
- }
- add_action( 'admin_bar_menu', 'wps_admin_bar', 25 );
- /**
- * 去后台标题中的“—— WordPress”
- */
- function doocii_custom_admin_title( $admin_title, $title ) {
- return $title . ' ‹ ' . get_bloginfo( 'name' );
- }
- add_filter( 'admin_title', 'doocii_custom_admin_title', 10, 2 );
- /**
- * 新标签打开顶部网站链接
- */
- function _admin_site_ctrlenter() {
- echo '<script type="text/javascript">
- var sitelink = document.getElementById("wp-admin-bar-site-name").getElementsByClassName("ab-item");
- for(var i=0;i<sitelink.length;i++)
- { sitelink[i].target = "_blank"; }
- </script>';
- }
- ;
- add_action( 'admin_footer', '_admin_site_ctrlenter' );
- /**
- * 关闭emoji表情
- */
- function disable_emojis() {
- 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_filter( 'the_content_feed', 'wp_staticize_emoji' );
- remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
- remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
- add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
- }
- add_action( 'init', 'disable_emojis' );
- function disable_emojis_tinymce( $plugins ) {
- if ( is_array( $plugins ) ) {
- return array_diff( $plugins, array(
- 'wpemoji'
- ) );
- } else {
- return array();
- }
- }
- /**
- * 修改后台文字
- */
- function theme_change_label_names( $translated_text ) {
- if ( is_admin() ) {
- switch ( $translated_text ) {
- case '将文章置于首页顶端' :
- $translated_text = __( '置顶', 'theme_text_domain' );
- break;
- }
- }
- return $translated_text;
- }
- // add_filter( 'gettext', 'theme_change_label_names' );
- /**
- * 文章页面外链自动添加nofollow属性和新窗口打开
- */
- function cn_nf_url_parse( $content ) {
- $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>";
- if ( preg_match_all( "/$regexp/siU", $content, $matches, PREG_SET_ORDER ) ) {
- if ( ! empty( $matches ) ) {
- $srcUrl = get_option( 'siteurl' );
- for ( $i = 0; $i < count( $matches ); $i ++ ) {
- $tag = $matches[ $i ][0];
- $tag2 = $matches[ $i ][0];
- $url = $matches[ $i ][0];
- $noFollow = '';
- $pattern = '/target\s*=\s*"\s*_blank\s*"/';
- preg_match( $pattern, $tag2, $match, PREG_OFFSET_CAPTURE );
- if ( count( $match ) < 1 ) {
- $noFollow .= ' target="_blank" ';
- }
- $pattern = '/rel\s*=\s*"\s*[n|d]ofollow\s*"/';
- preg_match( $pattern, $tag2, $match, PREG_OFFSET_CAPTURE );
- if ( count( $match ) < 1 ) {
- $noFollow .= ' rel="nofollow" ';
- }
- $pos = strpos( $url, $srcUrl );
- if ( $pos === false ) {
- $tag = rtrim( $tag, '>' );
- $tag .= $noFollow . '>';
- $content = str_replace( $tag2, $tag, $content );
- }
- }
- }
- }
- $content = str_replace( ']]>', ']]>', $content );
- return $content;
- }
- add_filter( 'the_content', 'cn_nf_url_parse' );
- /**
- * 删除后台头部菜单
- */
- function remove_admin_bar_links() {
- global $wp_admin_bar;
- $wp_admin_bar->remove_menu( 'wp-logo' ); // logo
- $wp_admin_bar->remove_menu( 'about' ); // 关于WordPress
- //$wp_admin_bar->remove_menu('search'); // 搜索
- $wp_admin_bar->remove_menu( 'customize' ); // 删除关于WordPress链接
- $wp_admin_bar->remove_menu( 'wporg' ); // 删除WordPress.org链接
- $wp_admin_bar->remove_menu( 'documentation' ); // 删除WordPress文档链接
- //$wp_admin_bar->remove_menu('support-forums'); // 删除支持论坛链接
- //$wp_admin_bar->remove_menu('feedback'); // 删除反馈链接
- //$wp_admin_bar->remove_menu('site-name'); // 删除站点名称菜单
- //$wp_admin_bar->remove_menu('view-site'); // 删除查看网站链接
- $wp_admin_bar->remove_menu( 'updates' ); // 删除更新链接
- $wp_admin_bar->remove_menu( 'comments' ); // 删除评论链接
- //$wp_admin_bar->remove_menu('new-content'); // 删除新建链接
- //$wp_admin_bar->remove_menu('w3tc'); // 如果您使用w3总缓存删除性能链接
- //$wp_admin_bar->remove_menu('my-account'); // 删除用户详细信息选项卡
- }
- add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );
- /**
- * 替换评论头像
- **/
- define( 'DEFAULT_AVATAR_URL', get_template_directory_uri() . '/functions/assets/images/gravatar.png' );
- function no_gravatars( $avatar ) {
- return preg_replace( "/http.*?gravatar\.com[^\']*/", DEFAULT_AVATAR_URL, $avatar );
- }
- add_filter( 'get_avatar', 'no_gravatars' );
- /**
- * 定义主题路径
- */
- function ts() {
- echo get_template_directory_uri();
- }
- function pw_show_gallery_image_urls( $content ) {
- global $post;
- // Only do this on singular items
- if ( ! is_singular() ) {
- return $content;
- }
- // Make sure the post has a gallery in it
- if ( ! has_shortcode( $post->post_content, '' ) ) {
- return $content;
- }
- // Retrieve all galleries of this post
- $galleries = get_post_galleries_images( $post );
- $image_list = '<ul>';
- // Loop through all galleries found
- foreach ( $galleries as $gallery ) {
- // Loop through each image in each gallery
- foreach ( $gallery as $image ) {
- $image_list .= '<li>' . $image . '</li>';
- }
- }
- $image_list .= '</ul>';
- // Append our image list to the content of our post
- $content .= $image_list;
- return $content;
- }
- add_filter( 'the_content', 'pw_show_gallery_image_urls' );
- /**
- * 自定义回复内容列表
- *
- * @param [type] $comment [description]
- * @param [type] $args [description]
- * @param [type] $depth [description]
- *
- * @return [type] [description]
- */
- function mytheme_comment( $comment, $args, $depth ) {
- if ( 'div' === $args['style'] ) {
- $tag = 'div';
- $add_below = 'comment';
- } else {
- $tag = 'li';
- $add_below = 'div-comment';
- } ?>
- <<?php echo $tag; ?><?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?> id="comment-<?php comment_ID() ?>"><?php
- if ( 'div' != $args['style'] ) { ?>
- <div class="comment-author">
- <?php
- if ( $args['avatar_size'] != 0 ) {
- echo get_avatar( $comment, $args['avatar_size'] );
- }
- ?>
- </div>
- <div id="div-comment-<?php comment_ID() ?>" class="comment-body"><?php
- } ?>
- <h4><?php
- printf( __( '<cite class="fn">%s</cite>' ), get_comment_author_link() ); ?>
- </h4>
- <!--
- <div class="comment-num">01.</div> -->
- <div class="clearfix"></div>
- <?php comment_text(); ?>
- <?php
- if ( $comment->comment_approved == '0' ) { ?>
- <em class="comment-awaiting-moderation">提交成功,您的评论正在等待审核</em><br/><?php
- } ?>
- <div class="comment-meta commentmetadata">
- <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>"><?php
- /* translators: 1: date, 2: time */
- printf(
- __( '%1$s at %2$s' ),
- get_comment_date(),
- get_comment_time()
- ); ?>
- </a>
- <?php
- edit_comment_link( __( '(编辑)' ), ' ', '' ); ?>
- </div>
- <div class="comment-body_dec"></div>
- <div class="reply"><?php
- comment_reply_link(
- array_merge(
- $args,
- array(
- 'reply_text' => __( '<i class="fas fa-reply"></i>' ),
- 'add_below' => $add_below,
- 'depth' => $depth,
- 'max_depth' => $args['max_depth']
- )
- )
- ); ?>
- </div><?php
- if ( 'div' != $args['style'] ) : ?>
- </div><?php
- endif;
- }
- /**
- * 评论框删除网址栏
- */
- add_filter( 'comment_form_default_fields', 'website_remove' );
- function website_remove( $fields ) {
- if ( isset( $fields['url'] ) ) {
- unset( $fields['url'] );
- }
- return $fields;
- }
- /**
- * 重新将评论表单排序
- */
- function move_comment_field_to_bottom( $fields ) {
- $comment_field = $fields['comment'];
- unset( $fields['comment'] );
- $fields['comment'] = $comment_field;
- return $fields;
- }
- add_filter( 'comment_form_fields', 'move_comment_field_to_bottom' );
- /**
- * 删除发表评论四个字
- */
- add_filter( 'comment_form_defaults', 'wpse33039_form_defaults' );
- function wpse33039_form_defaults( $defaults ) {
- $defaults['title_reply'] = '';
- return $defaults;
- }
- function posts_link_next_class( $format ) {
- $format = str_replace( 'href=', 'class="rn clean-gray" href=', $format );
- return $format;
- }
- add_filter( 'next_post_link', 'posts_link_next_class' );
- function posts_link_prev_class( $format ) {
- $format = str_replace( 'href=', 'class="ln clean-gray" href=', $format );
- return $format;
- }
- add_filter( 'previous_post_link', 'posts_link_prev_class' );
- /**
- * 删除分类目录标签的文字
- */
- add_filter( 'get_the_archive_title', function ( $title ) {
- if ( is_category() ) {
- $title = single_cat_title( '', false );
- } elseif ( is_tag() ) {
- $title = single_tag_title( '', false );
- } elseif ( is_author() ) {
- $title = '<span class="vcard">' . get_the_author() . '</span>';
- } elseif ( is_tax() ) { //for custom post types
- $title = sprintf( __( '%1$s' ), single_term_title( '', false ) );
- } elseif ( is_post_type_archive() ) {
- $title = post_type_archive_title( '', false );
- }
- return $title;
- } );
- // function my_function_admin_bar(){ return false; }
- // add_filter( 'show_admin_bar' , 'my_function_admin_bar');
- /**
- * jiewu functions and definitions
- *
- * @link https://developer.wordpress.org/themes/basics/theme-functions/
- *
- * @package jiewu
- */
- if ( ! defined( '_S_VERSION' ) ) {
- // Replace the version number of the theme on each release.
- define( '_S_VERSION', '1.0.0' );
- }
- /* ————————————————————————————————————| 后台 |————————————————————————————————————*/
- /**
- * 后台logo
- */
- function my_login_logo_one() {
- ?>
- <style type="text/css">
- body.login div#login h1 a {
- <?php
- $img = get_field('favicon','option');
- if( !empty( $img ) ): ?> background-image: url(<?php echo esc_url($img['url']); ?>);
- <?php endif; ?> width: auto;
- background-size: 80px;
- }
- </style>
- <?php
- }
- add_action( 'login_enqueue_scripts', 'my_login_logo_one' );
- function custom_login() {
- $files = '<link rel="stylesheet" href="' . get_bloginfo( 'template_directory' ) . '/functions/assets/css/login.css" />';
- echo $files;
- }
- add_action( 'login_head', 'custom_login' );
- // 后台logo链接
- function mb_login_url() {
- return home_url();
- }
- add_filter( 'login_headerurl', 'mb_login_url' );
- // 后台logo title
- function mb_login_title() {
- return get_option( 'blogname' );
- }
- add_filter( 'login_headertext', 'mb_login_title' );
- /**
- * 设置主题默认值并注册对各种WordPress功能的支持。
- */
- function jiewu_setup() {
- // 多语言支持
- load_theme_textdomain( 'jiewu', get_template_directory() . '/languages' );
- /*
- * 让WordPress管理文档标题。
- */
- add_theme_support( 'title-tag' );
- /*
- * 启用文章和页面上的缩略图的支持。
- */
- add_theme_support( 'post-thumbnails' );
- add_image_size( 'news-list-m', 400, 300, true );
- add_image_size( 'user-list-thumb-demo', 300, 400, true );
- add_image_size( 'core-team-post-thumb', 370, 490, true );
- // 注册网站导航
- register_nav_menus(
- array(
- 'header-menu-1' => esc_html__( 'header-navigation-1', 'jiewu' ),
- )
- );
- // bootstrap 导航
- function menu_set_dropdown( $sorted_menu_items, $args ) {
- $last_top = 0;
- foreach ( $sorted_menu_items as $key => $obj ) {
- // it is a top lv item?
- if ( 0 == $obj->menu_item_parent ) {
- //设置父项的键
- $last_top = $key;
- } else {
- $sorted_menu_items[ $last_top ]->classes['dropdown'] = 'dropdown';
- }
- }
- return $sorted_menu_items;
- }
- add_filter( 'wp_nav_menu_objects', 'menu_set_dropdown', 10, 2 );
- }
- add_action( 'after_setup_theme', 'jiewu_setup' );
- //添加自定义仪表盘小工具
- add_action('wp_dashboard_setup', 'quhenet_dashboard_widgets');
- function quhenet_dashboard_widgets() {
- global $wp_meta_boxes;
- wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help');
- }
- function custom_dashboard_help() {
- echo '<p>感谢您支持正版,主题使用过程中如有任何问题,欢迎同我们取得联系。</p><p><a href="http://4x4.run/qihang" target="_blank">主题帮助</a>、<a href="http://4x4.run/qihang-as" target="_blank">售后中心</a><p>觉得主题不错,请介绍给有需要的朋友。</p>';
- }
- /* 移除评论菜单 */
- function quhenet_remove_menus(){
- remove_menu_page( 'edit-comments.php' );
- }
- add_action( 'admin_menu', 'quhenet_remove_menus' );