wp_add_dashboard_widget [ WordPress Function ]
wp_add_dashboard_widget ( $widget_id, $widget_name, $callback, $control_callback = null )
| Defined at: |
|
Soorgelijke functies: wp_ajax_dashboard_widgets, add_dashboard_page, wp_dashboard_empty, wp_dashboard_setup, wp_dashboard_cached_rss_widget
No description yet.
Source
<?php
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
$screen = get_current_screen();
global $wp_dashboard_control_callbacks;
if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
$wp_dashboard_control_callbacks[$widget_id] = $control_callback;
if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
$callback = '_wp_dashboard_control_callback';
} else {
list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
}
}
if ( is_blog_admin () )
$side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
else if (is_network_admin() )
$side_widgets = array('dashboard_primary', 'dashboard_secondary');
else
$side_widgets = array();
$location = 'normal';
if ( in_array($widget_id, $side_widgets) )
$location = 'side';
$priority = 'core';
if ( 'dashboard_browser_nag' === $widget_id )
$priority = 'high';
add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority );
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/wp add dashboard widget « WordPress Codex
Function Reference/wp add dashboard widget ... Usage. <?php wp_add_dashboard_widget($widget_id, $widget_name, $callback, $ control_callback ); ?> ...
codex.wordpress.org - Dashboard Widgets API « WordPress Codex
Overview. The Function. The main tool needed to add Dashboard Widgets is the wp_add_dashboard_widget() function: wp_add_dashboard_widget($widget_id ...
codex.wordpress.org - Add WordPress Dashboard Widgets - WP Engineer
Oct 27, 2008 ... The function wp_add_dashboard_widget() is the key, which delivers the new widget; via hook wp_dashboard_setup it will be activated on the ...
wpengineer.com - How to position custom dashboard widgets on side column ...
Nov 30, 2010 ... Neither does the wp_add_dashboard_widget function. So just use the generic add_meta_box and indicate dashboard and placement: ...
wordpress.stackexchange.com