日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁(yè) > php開(kāi)源 > WordPress > WordPress控制面板的十個(gè)非常規(guī)使用技巧

WordPress控制面板的十個(gè)非常規(guī)使用技巧

來(lái)源:程序員人生   發(fā)布時(shí)間:2014-05-25 03:58:01 閱讀次數(shù):3206次

控制面板是WordPress博客的重要組成部分。 登錄WordPress后你首先看到的就是博客后臺(tái)的控制板,你可以在這里管理你博客上的所有文章、版塊布局以及其它各種條目。這里我們要介紹的是十個(gè)WordPress控制面板的非常規(guī)使用技巧。

刪除控制板上的某個(gè)菜單

有各種各樣的原因可能會(huì)讓用戶(hù)想要?jiǎng)h除博客后臺(tái)的某個(gè)菜單。這時(shí)候只需要把下面的代碼復(fù)制到當(dāng)前主題文件夾的functions.php文件里 (下面的代碼將會(huì)刪除$restricted數(shù)組中的所有菜單):


function remove_menus () {
global $menu;
$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'),
__('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
            if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
        }
}
add_action('admin_menu', 'remove_menus');

»來(lái)源

設(shè)計(jì)屬于自己的登錄logo

盡管登錄logo對(duì)改善博客性能和可用性都沒(méi)有多大幫助,但當(dāng)你登錄時(shí)看到的是一個(gè)不同于WordPress傳統(tǒng)登錄logo的logo時(shí),心里總會(huì)有些異樣的滿足感吧。

Custom admin branding插件可以幫你實(shí)現(xiàn)這種效果,此外你也可以通過(guò)在functions.php文件里粘貼下面的代碼來(lái)達(dá)到需要的效果。


function my_custom_login_logo() {
    echo '<style type="text/css">
        h1 a { background-image:url('.get_bloginfo('template_directory').'
/images/custom-login-logo.gif) !important; }
    </style>';
}

add_action('login_head', 'my_custom_login_logo');
»來(lái)源

替換后臺(tái)logo

既然已經(jīng)重設(shè)了登錄頁(yè)面的logo,那么想不想也換換后臺(tái)控制板上的logo呢?

同樣只需要把下面的代碼復(fù)制到functions.php文件。


add_action('admin_head', 'my_custom_logo');

function my_custom_logo() {
   echo '<style type="text/css">
         #header-logo { background-image: url('.get_bloginfo('template_directory').'
/images/custom-logo.gif) !important; }</style>';
}
»來(lái)源

關(guān)閉“請(qǐng)升級(jí)”提醒

WordPress新版本發(fā)布得相當(dāng)頻繁。 如果你不想隔三差五地看到這樣的提示,或者你是在為客戶(hù)開(kāi)發(fā)某個(gè)WordPress網(wǎng)站并認(rèn)為客戶(hù)不必看到升級(jí)提醒,那么請(qǐng)把下面的代碼復(fù)制到functions.php文件。更新文件后WordPress的升級(jí)提醒就不會(huì)繼續(xù)在你面前晃蕩了。


if ( !current_user_can( 'edit_users' ) ) {
  add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
  add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}
»來(lái)源

刪除控制面板widget

Widget是使WordPress功能得以擴(kuò)展的一大功臣。盡管如此,有時(shí)候我們并不需要widget,至少并不需要其中一些widget。

在functions.php里加入下面的代碼可以幫你刪除控制面板的widget:


function example_remove_dashboard_widgets() {
// Globalize the metaboxes array, this holds all the widgets for wp-admin
global $wp_meta_boxes;

// Remove the incomming links widget
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);

// Remove right now
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}

// Hoook into the 'wp_dashboard_setup' action to register our function
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );

»來(lái)源

在控制面板里添加自定義widget

上面的方法說(shuō)的是怎樣刪除控制板中不需要的widget, 而下面我們就來(lái)看看怎么創(chuàng)建新的widget。

下面的代碼應(yīng)該不難明白,同樣只需要復(fù)制到functions.php文件里。 同樣只需要復(fù)制到functions.php文件里。


function example_dashboard_widget_function() {
// Display whatever it is you want to show
    echo "Hello World, I'm a great Dashboard Widget";
}

// Create the function use in the action hook
function example_add_dashboard_widgets() {
    wp_add_dashboard_widget('example_dashboard_widget', 'Example Dashboard Widget', 'example_dashboard_widget_function');
}
// Hoook into the 'wp_dashboard_setup' action to register our other functions
add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' );

»來(lái)源

為WordPress控制面板換色

在不修改WordPress核心文件的情況下,也可以改變WordPress控制面板的顏色甚至字體或者版式。

下面的代碼實(shí)現(xiàn)了一次基本的樣式更改(將原本的灰色header變成藍(lán)色),只要你愿意,其它的更改同樣不在話下(在<style>和</style>標(biāo)簽之間進(jìn)行編輯)。


function custom_colors() {
   echo '<style type="text/css">#wphead{background:#069}</style>';
}

add_action('admin_head', 'custom_colors');

提供幫助性信息

如果你是在幫助其他人開(kāi)發(fā)WordPress網(wǎng)站,在控制面板的某些部分加上“幫助”說(shuō)明必然是相當(dāng)貼心的舉動(dòng)。

在functions.php文件里加上下面的代碼, 讓你的博客后臺(tái)出現(xiàn)一些幫助說(shuō)明類(lèi)的溫馨提示。


function my_admin_help($text, $screen) {
// Check we're only on my Settings page
if (strcmp($screen, MY_PAGEHOOK) == 0 ) {

$text = 'Here is some very useful information to help you use this plugin...';
return $text;
}
// Let the default WP Dashboard help stuff through on other Admin pages
return $text;
}

add_action( 'contextual_help', 'my_admin_help' );
»來(lái)源

在控制面板中監(jiān)視服務(wù)器狀況

WordPress的控制面板API大大加強(qiáng)了控制板widget的實(shí)用性。有這樣一個(gè)強(qiáng)大的widget可以實(shí)現(xiàn)在WordPress控制面板中直接監(jiān)視服務(wù)器運(yùn)行狀態(tài)的功能。

也只需要在functions.php文件里加入下面的代碼:


function slt_PHPErrorsWidget() {
    $logfile = '/home/path/logs/php-errors.log'; // Enter the server path to your logs file here
    $displayErrorsLimit = 100; // The maximum number of errors to display in the widget
    $errorLengthLimit = 300; // The maximum number of characters to display for each error
    $fileCleared = false;
    $userCanClearLog = current_user_can( 'manage_options' );
    // Clear file?
    if ( $userCanClearLog && isset( $_GET["slt-php-errors"] ) && $_GET["slt-php-errors"]=="clear" ) {
        $handle = fopen( $logfile, "w" );
        fclose( $handle );
        $fileCleared = true;
    }
    // Read file
    if ( file_exists( $logfile ) ) {
        $errors = file( $logfile );
        $errors = array_reverse( $errors );
        if ( $fileCleared ) echo '<p><em>File cleared.</em></p>';
        if ( $errors ) {
            echo '<p>'.count( $errors ).' error';
            if ( $errors != 1 ) echo 's';
            echo '.';
            if ( $userCanClearLog ) echo ' [ <b><a href="'.get_bloginfo("url").'/wp-admin/?slt-php-errors=clear"
onclick="return confirm('Are you sure?');">CLEAR LOG FILE</a></b> ]';
            echo '</p>';
            echo '<div id="slt-php-errors" style="height:250px;overflow:scroll;padding:2px;background-color:
#faf9f7;border:1px solid #ccc;">';
            echo '<ol style="padding:0;margin:0;">';
            $i = 0;
            foreach ( $errors as $error ) {
                echo '<li style="padding:2px 4px 6px;border-bottom:1px solid #ececec;">';
                $errorOutput = preg_replace( '/[([^]]+)]/', '<b>[$1]</b>', $error, 1 );
                if ( strlen( $errorOutput ) > $errorLengthLimit ) {
                    echo substr( $errorOutput, 0, $errorLengthLimit ).' [...]';
                } else {
                    echo $errorOutput;
                }
                echo '</li>';
                $i++;
                if ( $i > $displayErrorsLimit ) {
                    echo '<li style="padding:2px;border-bottom:2px solid #ccc;"><em>More than '.$displayErrorsLimit.'
errors in log...</em></li>';
                    break;
                }
            }
            echo '</ol></div>';
        } else {
            echo '<p>No errors currently logged.</p>';
        }
    } else {
        echo '<p><em>There was a problem reading the error log file.</em></p>';
    }
}

// Add widgets
function slt_dashboardWidgets() {
    wp_add_dashboard_widget( 'slt-php-errors', 'PHP errors', 'slt_PHPErrorsWidget' );
}
add_action( 'wp_dashboard_setup', 'slt_dashboardWidgets' );


»來(lái)源

根據(jù)用戶(hù)角色移除相應(yīng)的widget

針對(duì)多用戶(hù)博客。

下面的代碼會(huì)將meta框postcustom從“作者”角色的控制板上刪除。 同樣你只需要在functions.php文件里加上下面的代碼:


function customize_meta_boxes() {
//retrieve current user info
global $current_user;
get_currentuserinfo();

//if current user level is less than 3, remove the postcustom meta box
if ($current_user->user_level < 3)
remove_meta_box('postcustom','post','normal');
}

add_action('admin_init','customize_meta_boxes');
»來(lái)源

原文

生活不易,碼農(nóng)辛苦
如果您覺(jué)得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 午夜毛片 | 免费观看的av| 一区二区亚洲视频 | 男女的隐私视频网站 | 国产精品三级在线 | 一区二区视频在线 | 中文字幕欧美激情 | 亚洲一二三区在线 | 日韩在线视频网站 | 超黄网站 | 成人久久精品 | 成人在线视频网站 | 日韩中文字幕电影 | 国产激情一区二区三区在线观看 | 免费一区二区三区 | 国产精品资源 | 亚洲精品三级 | 亚洲精品婷婷 | 日本三级一区 | 在线免费一区 | 欧美日韩成人在线视频 | 国产精品婷婷久久久久 | 四季av一区二区三区免费观看 | 中文字幕在线不卡视频 | 亚洲欧美色图片 | 精品国产一区二区三区免费 | 国产免费看片 | 久久久久成人免费视频 | 日韩精品久久 | 国产91在线视频 | 国产在线一区不卡 | 久久久久久久国产精品 | 综合精品久久 | 成人欧美一区二区三区黑人动态图 | 国产精品一区二区三区四区五区 | 综合久久国产九一剧情麻豆 | 亚洲国产欧美日韩 | 久久免费福利 | 精品国产1区 | 久久66| 亚洲精品电影网在线观看 |