0
我們的網站上開發商在/wp-admin/includes/dashboard.phpWordPress的Dashboard widget工具
這個小工具創建核心WordPress的文件部件有很奇怪的做法「頂一句」是要求句子和URL從儀表板並將其發佈在主頁面的標題中。
如何創建這個儀表板小部件,但不寫它WordPress的核心文件,並與Wordpress 3.8.1和Wordpress Multisite兼容,所以一些網站也可以有他們自己的「頂級句子」?
<div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>">
<div id="top_sentence" class="postbox" style='margin-left: 5px; width: 98%;'>
<?php
require_wp_db();
global $wpdb;
$topSentenceTitle = $wpdb->get_var($wpdb->prepare("SELECT settings_value FROM wp_settings WHERE settings_name like 'top sentence title';" ));
$topSentenceUrl = $wpdb->get_var($wpdb->prepare("SELECT settings_value FROM wp_settings WHERE settings_name like 'top sentence url';"));
$topSentenceResult = "";
if ($_SESSION['top-sentence-updated'] == 'true')
{
$_SESSION['top-sentence-updated'] = '';
$topSentenceResult = 'Updated';
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#top-sentence-result').fadeIn(1000).delay(1000).fadeOut(1000);
});
</script>
<?php
}
if (is_blog_admin() && current_user_can('edit_posts'))
{
?>
<h3 class='hndle'><span>Top sentence</span></h3>
<div class="inside">
<form action='action.php' method='post' style='margin:0;padding:0;'>
//action.php doesn't exist in WordPress 3.8.1
<div style='float: left; width: 100%; margin-bottom: 3px;'>
<h4 id="top-sentence-title" style='float: left;font-size: 12px; font-weight: normal; padding-top: 5px; text-align: right; width: 5.5em;'>
<label for="top-sentence-title-input" style='font-family: "Lucida Grande",Verdana,Arial;margin-right: 10px;vertical-align: middle;cursor: pointer;'>Sentence:</label>
</h4>
<div style='margin: 0 0 1em 5em;'>
<input style='float:right;margin:0;width:99%;' id="top-sentence-title-input" type="text" value="<?= $topSentenceTitle ?>" autocomplete="off" name="top-sentence">
</div>
<div style='clear: both;margin-bottom:5px;'></div>
<h4 id="top-sentence-url" style='float: left;font-size: 12px; font-weight: normal; padding-top: 5px; text-align: right; width: 5.5em;'>
<label for="top-sentence-url-input" style='font-family: "Lucida Grande",Verdana,Arial;margin-right: 10px;vertical-align: middle;cursor: pointer;'>URL:</label>
</h4>
<div style='margin: 0 0 1em 5em;'>
<input style='float:right;margin:0;width:99%;' id="top-sentence-url-input" type="text" value="<?= $topSentenceUrl ?>" autocomplete="off" name="top-sentence-url">
</div>
</div>
<div id='top-sentence-result' style="display: none;margin-left:6em;float: left;margin-top: 5px;color: red;"><span><?= $topSentenceResult ?></span></div>
<div id="publishing-action" style='float:right; width: 100px;'>
<input id="publish_sentence" class="button-primary" type="submit" value="Publish" tabindex="5" accesskey="p" name="do_publish_sentence">
</div>
</form>
<div style='clear: both;'></div>
</div>
<?php
}
?>
</div>