本文整理汇总了PHP中wp_dashboard_trigger_widget_control函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_dashboard_trigger_widget_control函数的具体用法?PHP wp_dashboard_trigger_widget_control怎么用?PHP wp_dashboard_trigger_widget_control使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_dashboard_trigger_widget_control函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _wp_dashboard_control_callback
/**
*
* @param type $dashboard
* @param type $meta_box
*/
function _wp_dashboard_control_callback($dashboard, $meta_box)
{
echo '<form method="post" class="dashboard-widget-control-form">';
wp_dashboard_trigger_widget_control($meta_box['id']);
wp_nonce_field('edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce');
echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
submit_button(__('Submit'));
echo '</form>';
}
示例2: _wp_dashboard_control_callback
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
echo '<form action="" method="post" class="dashboard-widget-control-form">';
wp_dashboard_trigger_widget_control( $meta_box['id'] );
echo "<p class='submit'><input type='hidden' name='widget_id' value='$meta_box[id]' /><input type='submit' value='" . __( 'Submit' ) . "' /></p>";
echo '</form>';
}
示例3: si_dashboard_setup
public static function si_dashboard_setup()
{
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array();
$screen = get_current_screen();
do_action('si_dashboard_setup', $screen->id);
SI_Dashboard::add_dashboard_widgets($screen->id);
if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id'])) {
check_admin_referer('edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce');
ob_start();
// hack - but the same hack wp-admin/widgets.php uses
wp_dashboard_trigger_widget_control($_POST['widget_id']);
ob_end_clean();
wp_redirect(remove_query_arg('edit'));
exit;
}
/** This action is documented in wp-admin/edit-form-advanced.php */
do_action('do_meta_boxes', $screen->id, 'normal', '');
/** This action is documented in wp-admin/edit-form-advanced.php */
do_action('do_meta_boxes', $screen->id, 'side', '');
}
示例4: _sp_help_control_callback
function _sp_help_control_callback($dashboard, $meta_box)
{
echo '<form action="" method="post" class="dashboard-widget-control-form">';
wp_dashboard_trigger_widget_control($meta_box['id']);
echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
submit_button(__('Submit'));
echo '</form>';
}
示例5: wp_dashboard_setup
function wp_dashboard_setup()
{
global $wpdb, $wp_dashboard_sidebars;
$update = false;
$widget_options = get_option('dashboard_widget_options');
if (!$widget_options || !is_array($widget_options)) {
$widget_options = array();
}
/* Register WP Dashboard Dynamic Sidebar */
register_sidebar(array('name' => 'WordPress Dashboard', 'id' => 'wp_dashboard', 'before_widget' => "\t<div class='dashboard-widget-holder %2\$s' id='%1\$s'>\n\n\t\t<div class='dashboard-widget'>\n\n", 'after_widget' => "\t\t</div>\n\n\t</div>\n\n", 'before_title' => "\t\t\t<h3 class='dashboard-widget-title'>", 'after_title' => "</h3>\n\n"));
/* Register Widgets and Controls */
// Recent Comments Widget
$mod_comments = wp_count_comments();
$mod_comments = $mod_comments->moderated;
if (current_user_can('moderate_comments') && $mod_comments) {
$notice = sprintf(__ngettext('%d comment awaiting moderation', '%d comments awaiting moderation', $mod_comments), $mod_comments);
$notice = "<a href='edit-comments.php?comment_status=moderated'>{$notice}</a>";
} else {
$notice = '';
}
wp_register_sidebar_widget('dashboard_recent_comments', __('Recent Comments'), 'wp_dashboard_recent_comments', array('all_link' => 'edit-comments.php', 'notice' => $notice, 'width' => 'half'));
// Incoming Links Widget
if (!isset($widget_options['dashboard_incoming_links'])) {
$update = true;
$widget_options['dashboard_incoming_links'] = array('link' => apply_filters('dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit(get_option('home'))), 'url' => apply_filters('dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit(get_option('home'))), 'items' => 5, 'show_date' => 0);
}
wp_register_sidebar_widget('dashboard_incoming_links', __('Incoming Links'), 'wp_dashboard_empty', array('all_link' => $widget_options['dashboard_incoming_links']['link'], 'feed_link' => $widget_options['dashboard_incoming_links']['url'], 'width' => 'half'), 'wp_dashboard_cached_rss_widget', 'wp_dashboard_incoming_links_output');
wp_register_widget_control('dashboard_incoming_links', __('Incoming Links'), 'wp_dashboard_rss_control', array(), array('widget_id' => 'dashboard_incoming_links', 'form_inputs' => array('title' => false, 'show_summary' => false, 'show_author' => false)));
// WP Plugins Widget
wp_register_sidebar_widget('dashboard_plugins', __('Plugins'), 'wp_dashboard_empty', array('all_link' => 'http://wordpress.org/extend/plugins/', 'feed_link' => 'http://wordpress.org/extend/plugins/rss/topics/', 'width' => 'half'), 'wp_dashboard_cached_rss_widget', 'wp_dashboard_plugins_output', array('http://wordpress.org/extend/plugins/rss/browse/popular/', 'http://wordpress.org/extend/plugins/rss/browse/new/', 'http://wordpress.org/extend/plugins/rss/browse/updated/'));
// Primary feed (Dev Blog) Widget
if (!isset($widget_options['dashboard_primary'])) {
$update = true;
$widget_options['dashboard_primary'] = array('link' => apply_filters('dashboard_primary_link', __('http://wordpress.org/development/')), 'url' => apply_filters('dashboard_primary_feed', __('http://wordpress.org/development/feed/')), 'title' => apply_filters('dashboard_primary_title', __('WordPress Development Blog')), 'items' => 2, 'show_summary' => 1, 'show_author' => 0, 'show_date' => 1);
}
wp_register_sidebar_widget('dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_empty', array('all_link' => $widget_options['dashboard_primary']['link'], 'feed_link' => $widget_options['dashboard_primary']['url'], 'width' => 'half', 'class' => 'widget_rss'), 'wp_dashboard_cached_rss_widget', 'wp_dashboard_rss_output');
wp_register_widget_control('dashboard_primary', __('Primary Feed'), 'wp_dashboard_rss_control', array(), array('widget_id' => 'dashboard_primary'));
// Secondary Feed (Planet) Widget
if (!isset($widget_options['dashboard_secondary'])) {
$update = true;
$widget_options['dashboard_secondary'] = array('link' => apply_filters('dashboard_secondary_link', __('http://planet.wordpress.org/')), 'url' => apply_filters('dashboard_secondary_feed', __('http://planet.wordpress.org/feed/')), 'title' => apply_filters('dashboard_secondary_title', __('Other WordPress News')), 'items' => 15);
}
wp_register_sidebar_widget('dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_empty', array('all_link' => $widget_options['dashboard_secondary']['link'], 'feed_link' => $widget_options['dashboard_secondary']['url'], 'width' => 'full'), 'wp_dashboard_cached_rss_widget', 'wp_dashboard_secondary_output');
wp_register_widget_control('dashboard_secondary', __('Secondary Feed'), 'wp_dashboard_rss_control', array(), array('widget_id' => 'dashboard_secondary', 'form_inputs' => array('show_summary' => false, 'show_author' => false, 'show_date' => false)));
/* Dashboard Widget Template
wp_register_sidebar_widget( $widget_id (unique slug) , $widget_title, $output_callback,
array(
'all_link' => full url for "See All" link,
'feed_link' => full url for "RSS" link,
'width' => 'fourth', 'third', 'half', 'full' (defaults to 'half'),
'height' => 'single', 'double' (defaults to 'single'),
),
$wp_dashboard_empty_callback (only needed if using 'wp_dashboard_empty' as your $output_callback),
$arg, $arg, $arg... (further args passed to callbacks)
);
// optional: if you want users to be able to edit the settings of your widget, you need to register a widget_control
wp_register_widget_control( $widget_id, $widget_control_title, $control_output_callback,
array(), // leave an empty array here: oddity in widget code
array(
'widget_id' => $widget_id, // Yes - again. This is required: oddity in widget code
'arg' => an arg to pass to the $control_output_callback,
'another' => another arg to pass to the $control_output_callback,
...
)
);
*/
// Hook to register new widgets
do_action('wp_dashboard_setup');
// Hard code the sidebar's widgets and order
$dashboard_widgets = array();
$dashboard_widgets[] = 'dashboard_recent_comments';
$dashboard_widgets[] = 'dashboard_incoming_links';
$dashboard_widgets[] = 'dashboard_primary';
if (current_user_can('activate_plugins')) {
$dashboard_widgets[] = 'dashboard_plugins';
}
$dashboard_widgets[] = 'dashboard_secondary';
// Filter widget order
$dashboard_widgets = apply_filters('wp_dashboard_widgets', $dashboard_widgets);
$wp_dashboard_sidebars = array('wp_dashboard' => $dashboard_widgets, 'array_version' => 3.5);
add_filter('dynamic_sidebar_params', 'wp_dashboard_dynamic_sidebar_params');
if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id'])) {
ob_start();
// hack - but the same hack wp-admin/widgets.php uses
wp_dashboard_trigger_widget_control($_POST['widget_id']);
ob_end_clean();
wp_redirect(remove_query_arg('edit'));
exit;
}
if ($update) {
update_option('dashboard_widget_options', $widget_options);
}
}