HEX
Server: nginx/1.17.3
System: Linux iZuf67blrqducrakhrvgozZ 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64
User: root (0)
PHP: 7.3.19
Disabled: passthru,exec,system,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/shenzhouhuazhang.com/wp-content/themes/sy/functions.php
<?php
/*	核心功能实现 
 */
 
function wpkj_remove_dashboard_widget() {
    remove_meta_box( 'dashboard_site_health', 'dashboard', 'normal' );
}
add_action('wp_dashboard_setup', 'wpkj_remove_dashboard_widget' );

function wpkj_remove_site_health_menu(){
    remove_submenu_page( 'tools.php','site-health.php' ); 
}
add_action( 'admin_menu', 'wpkj_remove_site_health_menu' );


function disable_default_dashboard_widgets() {
    remove_meta_box('dashboard_right_now', 'dashboard', 'core');      //概况(Right Now)
    remove_meta_box('dashboard_recent_comments', 'dashboard', 'core'); //近期评论(Recent Comments)
    remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');  //链入链接(Incoming Links)
    remove_meta_box('dashboard_plugins', 'dashboard', 'core');      //插件(Plugins)

    remove_meta_box('dashboard_quick_press', 'dashboard', 'core');  //快速发布(QuickPress)
    remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core'); //近期草稿(Recent Drafts)
    remove_meta_box('dashboard_primary', 'dashboard', 'core');  //WordPress China 博客(WordPress Blog)
    remove_meta_box('dashboard_secondary', 'dashboard', 'core'); //其它 WordPress 新闻(Other WordPress News)
}
add_action('admin_menu', 'disable_default_dashboard_widgets');

define('functions', TEMPLATEPATH.'/functions');
IncludeAll(functions);
function IncludeAll($dir)
{
    $dir = realpath($dir);
    if ($dir) {
        $files = scandir($dir);
        sort($files);
        foreach ($files as $file) {
            if ($file == '.' || $file == '..') {
                continue;
            } elseif (preg_match('/.php$/i', $file)) {
                include_once $dir.'/'.$file;
            }
        }
    }
}



define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
$optionsfile = locate_template( 'options.php' );
load_template( $optionsfile );
add_action( 'optionsframework_custom_scripts', 'optionsframework_custom_scripts' );

function Bing_disable_robots_index_attachment_pages() {
    if ( is_attachment() )
        wp_no_robots();
}
add_action( 'wp_head', 'Bing_disable_robots_index_attachment_pages' );

function custum_fontfamily($initArray){
	$initArray['font_formats'] = "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';";
	return $initArray;
 }
 add_filter('tiny_mce_before_init', 'custum_fontfamily');

function enable_more_buttons($buttons) {
	$buttons[] = 'styleselect';
	$buttons[] = 'fontselect';
	$buttons[] = 'justfyfull';
	return $buttons;
}
add_filter("mce_buttons", "enable_more_buttons");

function exclude_page() {
	global $post;
	if ($post->post_type == 'page') {
		get_sidebar('404');
		echo '<p class="notFound"></p>';
		return true;
	} else {
		return false;
	}
}

	




//后台文章列表添加 浏览数
add_action('manage_posts_custom_column', 'add_postviews_column_content');
add_filter('manage_posts_columns', 'add_postviews_column');
add_action('manage_pages_custom_column', 'add_postviews_column_content');
add_filter('manage_pages_columns', 'add_postviews_column');
function add_postviews_column($defaults) {
	$defaults['views'] = __( 'Views' );
	return $defaults;
}
function add_postviews_column_content($column_name) {
	if ($column_name === 'views' ) {
		if ( function_exists('the_views' ) ) {
			the_views( true, '', '', true );
		}
	}
}
add_filter( 'manage_edit-post_sortable_columns', 'sort_postviews_column');
add_filter( 'manage_edit-page_sortable_columns', 'sort_postviews_column' );
function sort_postviews_column( $defaults ) {
	$defaults['views'] = 'views';
	return $defaults;
}
add_action('pre_get_posts', 'sort_postviews');
function sort_postviews($query) {
	if ( ! is_admin() ) {
		return;
	}
	$orderby = $query->get('orderby');
	if ( 'views' === $orderby ) {
		$query->set( 'meta_key', 'views' );
		$query->set( 'orderby', 'meta_value_num' );
	}
}


add_filter('manage_posts_columns', function($columns){
	$columns['views']	= __('Views');
	return $columns;
});

add_action('manage_posts_custom_column',function($column_name,$id){
	if ($column_name != 'views'){
		return;
	}
	echo get_post_meta($id, "views",true);
},10,2);


// 设置登录界面样式
function admin_login_style() {
    wp_enqueue_style('admin-login', get_template_directory_uri() . '/login/login.css');
	wp_enqueue_script('admin-login-script', get_template_directory_uri() . '/login/login.js');
}
add_action('login_enqueue_scripts', 'admin_login_style');
// 设置登录logourl
// function loginUrl()
// {
//     return home_url();
// }
// add_filter('login_headerurl', 'loginUrl');


//disable update
add_filter('pre_site_transient_update_core', create_function('$a', "return null;")); // 关闭核心提示
add_filter('pre_site_transient_update_plugins', create_function('$a', "return null;")); // 关闭插件提示
add_filter('pre_site_transient_update_themes', create_function('$a', "return null;")); // 关闭主题提示
remove_action('admin_init', '_maybe_update_core'); 
remove_action('admin_init', '_maybe_update_plugins'); 
remove_action('admin_init', '_maybe_update_themes'); 
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );


function pages($query_string){
	global $posts_per_page, $paged; //全局变量
	$my_query = new WP_Query($query_string ."&posts_per_page=-1"); //创建查询对象
	$total_posts = $my_query->post_count; //通过查询对象获取文章总数
	if(empty($paged)) $paged = 1; //当前页码数,如是$paged为空,就让$paged=1
	$prev = $paged - 1; //上一页变量
	$next = $paged + 1; //下一页变量
	$range = 4; //
	$showitems = ($range * 2)+1; //显示多少个分页页码按钮
	$pages = ceil($total_posts/$posts_per_page); //获取总页数
	if(1 != $pages){
	echo "<div class='pagination'>";
	echo ($paged > 2 && $paged+$range+1 > $pages && $showitems < $pages)? "<a href='".get_pagenum_link(1)."'>首页</a>":"";
	echo ($paged > 1 && $showitems < $pages)? "<a href='".get_pagenum_link($prev)."'>上一页</a>":"";for ($i=1; $i <= $pages; $i++){
	if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
	echo ($paged == $i)? "<a href='javascript:;' class='thispage'>".$i."</a>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
	}
	}
	echo ($paged < $pages && $showitems < $pages) ? "<a href='".get_pagenum_link($next)."'>下一页</a>" :"";
	echo ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) ? "<a href='".get_pagenum_link($pages)."'>末页</a>":"";
	echo "</div>\n";
	}
}



// function hidden_admin_logo() {
// 	global $wp_admin_bar;
// 		$wp_admin_bar->remove_menu('wp-logo');
// }
// add_action('wp_before_admin_bar_render', 'hidden_admin_logo', 0);


if ( !function_exists( 'wp_admin_favicon' ) ) {
  function wp_admin_favicon() {
    echo '<link rel="shortcut icon" href="https://www.shenzhouhuazhang.com/wp-content/uploads/2023/12/cacf84f2033808e5a6b73c007b54e78-150x150.png">';
  }
}
add_action( 'admin_head', 'wp_admin_favicon' );





add_filter( 'map_meta_cap', 'ds_disable_core_privacy_tools', 10, 2 );
remove_action( 'init', 'wp_schedule_delete_old_privacy_export_files' );
remove_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' );
function ds_disable_core_privacy_tools( $caps, $cap ) {
	switch ( $cap ) {
		case 'export_others_personal_data':
		case 'erase_others_personal_data':
		case 'manage_privacy_options':
			$caps[] = 'do_not_allow';
			break;
	}
	return $caps;
}

function disable_page_comments( $posts ) {
	if ( is_page()) {
	$posts[0]->comment_status = 'disabled';
	$posts[0]->ping_status = 'disabled';
}
return $posts;
}
add_filter( 'the_posts', 'disable_page_comments' );


add_action( 'admin_menu', 'ytkah_remove_ad_menus' );
function ytkah_remove_ad_menus(){
remove_menu_page( 'index.php' ); //仪表页面,控制台首页
// remove_menu_page( 'edit.php' ); //文章页面
// remove_menu_page( 'edit.php?post_type=acf-field-group' ); //Jetpack等具体插件名
remove_menu_page( 'upload.php' ); //多媒体页面
// remove_menu_page( 'edit.php?post_type=page' ); //页面管理
remove_menu_page( 'edit-comments.php' ); //评论菜单
remove_menu_page( 'my-sites.php' ); //多站点
remove_menu_page( 'plugins.php' ); //插件页面
// remove_menu_page( 'users.php' ); //用户页面
remove_menu_page( 'tools.php' ); //工具页面
// remove_menu_page( 'options-general.php' ); //设置页面
// remove_menu_page( 'cptui_main_menu' ); //cpt ui
}

function get_ssl_avatar($avatar) {

   $avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="https://secure.gravatar.com/avatar/$1?s=$2&d=mm" class="avatar avatar-$2" height="$2" width="$2">',$avatar);

   return $avatar;

}

add_filter('get_avatar', 'get_ssl_avatar');



/*隐藏后台插件菜单*/
function admin_mycss() {
echo'<style type="text/css">
#wp-admin-bar-network-admin .ab-item,#wpadminbar .quicklinks li .blavatar:before {
display: none !important;
}
</style>';
}
add_action('admin_head', 'admin_mycss');