网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

有哪些实用的WordPress 插件值得推荐?

GG网络技术分享 2025-03-18 16:07 9


/* ------------------------------------------------------------------------- *

* 自定义 functions.php 添加到最后即可

/* ------------------------------------------------------------------------- */

/* File Security Check */

if ( ! defined( "ABSPATH" ) ) { exit; }

/* Sets the path to the parent theme directory. */

if ( !defined( "THEME_DIR" ) ) {

define( "THEME_DIR", get_template_directory() );

}

/* Sets the path to the parent theme directory URI. */

if ( !defined( "THEME_URI" ) ) {

define( "THEME_URI", get_template_directory_uri() );

}

/* ------------------------------------------------------------------------- *

* OptionTree framework integration: Use in theme mode

/* ------------------------------------------------------------------------- */

add_filter( "ot_show_pages", "__return_false" );

add_filter( "ot_show_new_layout", "__return_false" );

add_filter( "ot_theme_mode", "__return_true" );

add_filter( "ot_show_settings_import", "__return_true" );

add_filter( "ot_show_settings_export", "__return_true" );

add_filter( "ot_show_docs", "__return_false" );

load_template( THEME_DIR . "/admin/option/ot-loader.php" );

/* ------------------------------------------------------------------------- *

* Load theme files

/* ------------------------------------------------------------------------- */

function tin_theme_localized($local){

if(ot_get_option("lan_en")=="on"){

$local = "en_US";

}else{

$local = "zh_CN";

}

return $local;

}

add_filter("locale","tin_theme_localized");

if ( ! function_exists( "tin_load" ) ) {

function tin_load() {

// Load theme options

load_template( THEME_DIR . "/admin/theme-options.php" );

// Load custom widgets

load_template( THEME_DIR . "/functions/widgets/tin-tabs.php" );

load_template( THEME_DIR . "/functions/widgets/tin-tabs-h.php" );

load_template( THEME_DIR . "/functions/widgets/tin-tagcloud.php" );

load_template( THEME_DIR . "/functions/widgets/tin-bookmark.php" );

load_template( THEME_DIR . "/functions/widgets/tin-bookmark-h.php" );

load_template( THEME_DIR . "/functions/widgets/tin-hotsearch.php" );

load_template( THEME_DIR . "/functions/widgets/tin-creditsrank.php" );

// Load functions

load_template( THEME_DIR . "/functions/open-social.php" );

load_template( THEME_DIR . "/functions/message.php" );

load_template( THEME_DIR . "/functions/credit.php" );

load_template( THEME_DIR . "/functions/recent-user.php" );

load_template( THEME_DIR . "/functions/tracker.php" );

load_template( THEME_DIR . "/functions/user-page.php" );

load_template( THEME_DIR . "/functions/meta.php" );

load_template( THEME_DIR . "/functions/comment.php" );

load_template( THEME_DIR . "/functions/shortcode.php" );

load_template( THEME_DIR . "/functions/IP.php" );

load_template( THEME_DIR . "/functions/mail.php" );

load_template( THEME_DIR . "/functions/meta-box.php" );

load_template( THEME_DIR . "/functions/newsletter.php" );

load_template( THEME_DIR . "/functions/ua.php" );

load_template( THEME_DIR . "/functions/download.php" );

load_template( THEME_DIR . "/functions/no_category_base.php" );

load_template( THEME_DIR . "/functions/auto-save-image.php" );

load_template( THEME_DIR . "/functions-customize.php" );

if (is_admin()) {require_once( THEME_DIR . "/functions/class-tgm-plugin-activation.php" );}

// Load language

load_theme_textdomain("tinection",THEME_DIR . "/languages");

load_theme_textdomain( "option-tree",THEME_DIR . "/admin/option/languages");

// 移除自动保存和修订版本

if(ot_get_option("wp_auto_save")=="on"){

add_action("wp_print_scripts","tin_disable_autosave" );

remove_action("post_updated","wp_save_post_revision" );

}

//建立Avatar上传文件夹

tin_add_avatar_folder();

}

}

add_action( "after_setup_theme", "tin_load" );

/* ------------------------------------------------------------------------- *

* 移除头部多余信息

/* ------------------------------------------------------------------------- */

function wpbeginner_remove_version(){

return;

}

add_filter("the_generator", "wpbeginner_remove_version");//wordpress的版本号

remove_action("wp_head", "feed_links", 2);//包含文章和评论的feed

remove_action("wp_head","index_rel_link");//当前文章的索引

remove_action("wp_head", "feed_links_extra", 3);// 额外的feed,例如category, tag页

remove_action("wp_head", "start_post_rel_link", 10, 0);// 开始篇

remove_action("wp_head", "parent_post_rel_link", 10, 0);// 父篇

remove_action("wp_head", "adjacent_posts_rel_link", 10, 0); // 上、下篇.

remove_action("wp_head", "adjacent_posts_rel_link_wp_head", 10, 0 );//rel=pre

remove_action("wp_head", "wp_shortlink_wp_head", 10, 0 );//rel=shortlink

remove_action("wp_head", "rel_canonical" );

/* ------------------------------------------------------------------------- *

* 前台替换wordpress自带jquery

/* ------------------------------------------------------------------------- */

if ( !is_admin() ){

function add_scripts() {

if(ot_get_option("jquery_source","local_jq")=="cdn_jq"){$jq = "http://lib.sinaapp.com/js/jquery/1.10.2/jquery-1.10.2.min.js";}else{$jq = THEME_URI . "/includes/js/jquery.min.js";}

wp_deregister_script( "jquery" );

//wp_deregister_script( "jquery ui" );

wp_register_script( "jquery", $jq );

wp_enqueue_script( "jquery" );

wp_register_script( "tinection", THEME_URI ."/includes/js/theme.min.js" );

}

}

add_action("wp_enqueue_scripts", "add_scripts");

/* -------------------------------------------------- *

* WordPress 后台禁用Google Open Sans字体,加速网站

/* ------------------------------------------------- */

function remove_open_sans() {

wp_deregister_style( "open-sans" );

wp_register_style( "open-sans", false );

wp_enqueue_style("open-sans","");

}

add_action( "init", "remove_open_sans" );

/* 后台预览

/* --------- */

add_editor_style("/includes/css/editor-style.css");

/* 建立Avatar上传文件夹

/* ----------- */

function tin_add_avatar_folder() {

$upload = wp_upload_dir();

$upload_dir = $upload["basedir"];

$upload_dir = $upload_dir . "/avatars";

if (! is_dir($upload_dir)) {

mkdir( $upload_dir, 0755 );

}

}

/* 移除自动保存

/* -------------- */

function tin_disable_autosave() {

wp_deregister_script("autosave");

}

//删除已经产生的修订版本请取消下一条语句注释并刷新网站任一页面,完成后可恢复注释

//$wpdb-

标签:

提交需求或反馈

Demand feedback