成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

在Wordpress的Admin中顯示緊急信息的方法

2012-05-06 20:45:13來源:作者:

在 WP Admin 中顯示緊急信息的方法,該代碼將任何登錄的用戶顯示定制的消息:
 

在 WP Admin 中顯示緊急信息的方法,該代碼將任何登錄的用戶顯示定制的消息:
 

/**
 * Generic function to show a message to the user using WP's
 * standard CSS classes to make use of the already-defined
 * message colour scheme.
 *
 * @param $message The message you want to tell the user.
 * @param $errormsg If true, the message is an error, so use
 * the red message style. If false, the message is a status
  * message, so use the yellow information message style.
 */
function showMessage($message, $errormsg = false)
{
    if ($errormsg) {
        echo '<div id="message" class="error">';
    }
    else {
        echo '<div id="message" class="updated fade">';
    }

    echo "<p><strong>$message</strong></p></div>";
}

然后,為管理提醒函數增加鉤子用來顯示定制消息:

/**
 * Just show our message (with possible checking if we only want
 * to show message to certain users.
 */
function showAdminMessages()
{
    // Shows as an error message. You could add a link to the right page if you wanted.
    showMessage("You need to upgrade your database as soon as possible...", true);

    // Only show to admins
    if (user_can('manage_options') {
       showMessage("Hello admins!");
    }
}

/**
  * Call showAdminMessages() when showing other admin
  * messages. The message only gets shown in the admin
  * area, but not on the frontend of your WordPress site.
  */
add_action('admin_notices', 'showAdminMessages');

關鍵詞:Wordpress

贊助商鏈接:

主站蜘蛛池模板: 清水县| 辰溪县| 广安市| 东源县| 云安县| 汉源县| 边坝县| 泽州县| 堆龙德庆县| 五莲县| 长春市| 鞍山市| 合山市| 铜陵市| 鄂托克旗| 沙田区| 红河县| 沁水县| 铜梁县| 洞口县| 融水| 奉新县| 阿拉尔市| 巨野县| 淳安县| 哈密市| 长兴县| 砀山县| 阳西县| 高尔夫| 许昌县| 尼木县| 且末县| 岫岩| 新乐市| 乳源| 泰和县| 佛坪县| 崇仁县| 汉沽区| 永川市|