| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/dashboard.php.tar |
home/xbodynamge/www/wp-admin/includes/dashboard.php 0000644 00000157710 15111541422 0016446 0 ustar 00 <?php
/**
* WordPress Dashboard Widget Administration Screen API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Registers dashboard widgets.
*
* Handles POST data, sets up filters.
*
* @since 2.5.0
*
* @global array $wp_registered_widgets
* @global array $wp_registered_widget_controls
* @global array $wp_dashboard_control_callbacks
*/
function wp_dashboard_setup() {
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array();
$screen = get_current_screen();
/* Register Widgets and Controls */
$response = wp_check_browser_version();
if ( $response && $response['upgrade'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
if ( $response['insecure'] )
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
else
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
}
// Right Now
if ( is_blog_admin() && current_user_can('edit_posts') )
wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
if ( is_network_admin() )
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
// Activity Widget
if ( is_blog_admin() ) {
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
}
// QuickPress Widget
if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
$quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) );
wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
}
// WordPress Events and News
wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' );
if ( is_network_admin() ) {
/**
* Fires after core widgets for the Network Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_network_dashboard_setup' );
/**
* Filters the list of widgets to load for the Network Admin dashboard.
*
* @since 3.1.0
*
* @param array $dashboard_widgets An array of dashboard widgets.
*/
$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
} elseif ( is_user_admin() ) {
/**
* Fires after core widgets for the User Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_user_dashboard_setup' );
/**
* Filters the list of widgets to load for the User Admin dashboard.
*
* @since 3.1.0
*
* @param array $dashboard_widgets An array of dashboard widgets.
*/
$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
} else {
/**
* Fires after core widgets for the admin dashboard have been registered.
*
* @since 2.5.0
*/
do_action( 'wp_dashboard_setup' );
/**
* Filters the list of widgets to load for the admin dashboard.
*
* @since 2.5.0
*
* @param array $dashboard_widgets An array of dashboard widgets.
*/
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
}
foreach ( $dashboard_widgets as $widget_id ) {
$name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
}
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/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
/** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'side', '' );
}
/**
* Adds a new dashboard widget.
*
* @since 2.7.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param string $widget_id Widget ID (used in the 'id' attribute for the widget).
* @param string $widget_name Title of the widget.
* @param callable $callback Function that fills the widget with the desired content.
* The function should echo its output.
* @param callable $control_callback Optional. Function that outputs controls for the widget. Default null.
* @param array $callback_args Optional. Data that should be set as the $args property of the widget array
* (which is the second parameter passed to your callback). Default null.
*/
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {
$screen = get_current_screen();
global $wp_dashboard_control_callbacks;
$private_callback_args = array( '__widget_basename' => $widget_name );
if ( is_null( $callback_args ) ) {
$callback_args = $private_callback_args;
} else if ( is_array( $callback_args ) ) {
$callback_args = array_merge( $callback_args, $private_callback_args );
}
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>';
}
}
$side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
$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, $callback_args );
}
/**
* Outputs controls for the current dashboard widget.
*
* @access private
* @since 2.7.0
*
* @param mixed $dashboard
* @param array $meta_box
*/
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">';
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>';
}
/**
* Displays the dashboard.
*
* @since 2.5.0
*/
function wp_dashboard() {
$screen = get_current_screen();
$columns = absint( $screen->get_columns() );
$columns_css = '';
if ( $columns ) {
$columns_css = " columns-$columns";
}
?>
<div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>">
<div id="postbox-container-1" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
</div>
<div id="postbox-container-2" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'side', '' ); ?>
</div>
<div id="postbox-container-3" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column3', '' ); ?>
</div>
<div id="postbox-container-4" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column4', '' ); ?>
</div>
</div>
<?php
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
}
//
// Dashboard Widgets
//
/**
* Dashboard widget that displays some basic stats about the site.
*
* Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8.
*
* @since 2.7.0
*/
function wp_dashboard_right_now() {
?>
<div class="main">
<ul>
<?php
// Posts and Pages
foreach ( array( 'post', 'page' ) as $post_type ) {
$num_posts = wp_count_posts( $post_type );
if ( $num_posts && $num_posts->publish ) {
if ( 'post' == $post_type ) {
$text = _n( '%s Post', '%s Posts', $num_posts->publish );
} else {
$text = _n( '%s Page', '%s Pages', $num_posts->publish );
}
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
$post_type_object = get_post_type_object( $post_type );
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
} else {
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
}
}
}
// Comments
$num_comm = wp_count_comments();
if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
?>
<li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
<?php
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
/* translators: %s: number of comments in moderation */
$text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
/* translators: %s: number of comments in moderation */
$aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
?>
<li class="comment-mod-count<?php
if ( ! $num_comm->moderated ) {
echo ' hidden';
}
?>"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php esc_attr_e( $aria_label ); ?>"><?php echo $text; ?></a></li>
<?php
}
/**
* Filters the array of extra elements to list in the 'At a Glance'
* dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'. Each element
* is wrapped in list-item tags on output.
*
* @since 3.8.0
*
* @param array $items Array of extra 'At a Glance' widget items.
*/
$elements = apply_filters( 'dashboard_glance_items', array() );
if ( $elements ) {
echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n";
}
?>
</ul>
<?php
update_right_now_message();
// Check if search engines are asked not to index this site.
if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) {
/**
* Filters the link title attribute for the 'Search Engines Discouraged'
* message displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
* @since 4.5.0 The default for `$title` was updated to an empty string.
*
* @param string $title Default attribute text.
*/
$title = apply_filters( 'privacy_on_link_title', '' );
/**
* Filters the link label for the 'Search Engines Discouraged' message
* displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
*
* @param string $content Default text.
*/
$content = apply_filters( 'privacy_on_link_text' , __( 'Search Engines Discouraged' ) );
$title_attr = '' === $title ? '' : " title='$title'";
echo "<p><a href='options-reading.php'$title_attr>$content</a></p>";
}
?>
</div>
<?php
/*
* activity_box_end has a core action, but only prints content when multisite.
* Using an output buffer is the only way to really check if anything's displayed here.
*/
ob_start();
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.5.0
*/
do_action( 'rightnow_end' );
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.0.0
*/
do_action( 'activity_box_end' );
$actions = ob_get_clean();
if ( !empty( $actions ) ) : ?>
<div class="sub">
<?php echo $actions; ?>
</div>
<?php endif;
}
/**
* @since 3.1.0
*/
function wp_network_dashboard_right_now() {
$actions = array();
if ( current_user_can('create_sites') )
$actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>';
if ( current_user_can('create_users') )
$actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
$c_users = get_user_count();
$c_blogs = get_blog_count();
/* translators: %s: number of users on the network */
$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
/* translators: %s: number of sites on the network */
$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
/* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */
$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
if ( $actions ) {
echo '<ul class="subsubsub">';
foreach ( $actions as $class => $action ) {
$actions[ $class ] = "\t<li class='$class'>$action";
}
echo implode( " |</li>\n", $actions ) . "</li>\n";
echo '</ul>';
}
?>
<br class="clear" />
<p class="youhave"><?php echo $sentence; ?></p>
<?php
/**
* Fires in the Network Admin 'Right Now' dashboard widget
* just before the user and site search form fields.
*
* @since MU (3.0.0)
*
* @param null $unused
*/
do_action( 'wpmuadminresult', '' );
?>
<form action="<?php echo network_admin_url('users.php'); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?>
</p>
</form>
<form action="<?php echo network_admin_url('sites.php'); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?>
</p>
</form>
<?php
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_rightnow_end' );
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_activity_box_end' );
}
/**
* The Quick Draft widget display and creation of drafts.
*
* @since 3.8.0
*
* @global int $post_ID
*
* @param string $error_msg Optional. Error message. Default false.
*/
function wp_dashboard_quick_press( $error_msg = false ) {
global $post_ID;
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
if ( $last_post_id ) {
$post = get_post( $last_post_id );
if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
$post = get_default_post_to_edit( 'post', true );
update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
} else {
$post->post_title = ''; // Remove the auto draft title
}
} else {
$post = get_default_post_to_edit( 'post' , true);
$user_id = get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) )
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
}
$post_ID = (int) $post->ID;
?>
<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
<?php if ( $error_msg ) : ?>
<div class="error"><?php echo $error_msg; ?></div>
<?php endif; ?>
<div class="input-text-wrap" id="title-wrap">
<label class="screen-reader-text prompt" for="title" id="title-prompt-text">
<?php
/** This filter is documented in wp-admin/edit-form-advanced.php */
echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
?>
</label>
<input type="text" name="post_title" id="title" autocomplete="off" />
</div>
<div class="textarea-wrap" id="description-wrap">
<label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What’s on your mind?' ); ?></label>
<textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
</div>
<p class="submit">
<input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />
<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
<input type="hidden" name="post_type" value="post" />
<?php wp_nonce_field( 'add-post' ); ?>
<?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>
<br class="clear" />
</p>
</form>
<?php
wp_dashboard_recent_drafts();
}
/**
* Show recent drafts of the user on the dashboard.
*
* @since 2.7.0
*
* @param array $drafts
*/
function wp_dashboard_recent_drafts( $drafts = false ) {
if ( ! $drafts ) {
$query_args = array(
'post_type' => 'post',
'post_status' => 'draft',
'author' => get_current_user_id(),
'posts_per_page' => 4,
'orderby' => 'modified',
'order' => 'DESC'
);
/**
* Filters the post query arguments for the 'Recent Drafts' dashboard widget.
*
* @since 4.4.0
*
* @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
*/
$query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
$drafts = get_posts( $query_args );
if ( ! $drafts ) {
return;
}
}
echo '<div class="drafts">';
if ( count( $drafts ) > 3 ) {
echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . __( 'View all drafts' ) . "</a></p>\n";
}
echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
$drafts = array_slice( $drafts, 0, 3 );
foreach ( $drafts as $draft ) {
$url = get_edit_post_link( $draft->ID );
$title = _draft_or_post_title( $draft->ID );
echo "<li>\n";
/* translators: %s: post title */
echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
echo '<p>' . $the_content . '</p>';
}
echo "</li>\n";
}
echo "</ul>\n</div>";
}
/**
* Outputs a row for the Recent Comments widget.
*
* @access private
* @since 2.7.0
*
* @global WP_Comment $comment
*
* @param WP_Comment $comment The current comment.
* @param bool $show_date Optional. Whether to display the date.
*/
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$GLOBALS['comment'] = clone $comment;
if ( $comment->comment_post_ID > 0 ) {
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
$comment_post_url = get_the_permalink( $comment->comment_post_ID );
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
} else {
$comment_post_link = '';
}
$actions_string = '';
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
// Pre-order it: Approve | Reply | Edit | Spam | Trash.
$actions = array(
'approve' => '', 'unapprove' => '',
'reply' => '',
'edit' => '',
'spam' => '',
'trash' => '', 'delete' => '',
'view' => '',
);
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>". __( 'Edit' ) . '</a>';
$actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '" href="#">' . __( 'Reply' ) . '</a>';
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
if ( ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
}
$actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>';
/**
* Filters the action links displayed for each comment in the 'Recent Comments'
* dashboard widget.
*
* @since 2.6.0
*
* @param array $actions An array of comment actions. Default actions include:
* 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
* 'Delete', and 'Trash'.
* @param WP_Comment $comment The comment object.
*/
$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
$i = 0;
foreach ( $actions as $action => $link ) {
++$i;
( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span
if ( 'reply' == $action || 'quickedit' == $action ) {
$action .= ' hide-if-no-js';
}
if ( 'view' === $action && '1' !== $comment->comment_approved ) {
$action .= ' hidden';
}
$actions_string .= "<span class='$action'>$sep$link</span>";
}
}
?>
<li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
<?php echo get_avatar( $comment, 50, 'mystery' ); ?>
<?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Comments might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
__( 'From %1$s on %2$s %3$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: comment author, 2: notification if the comment is pending */
__( 'From %1$s %2$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<?php
else :
switch ( $comment->comment_type ) {
case 'pingback' :
$type = __( 'Pingback' );
break;
case 'trackback' :
$type = __( 'Trackback' );
break;
default :
$type = ucwords( $comment->comment_type );
}
$type = esc_html( $type );
?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
_x( '%1$s on %2$s %3$s', 'dashboard' ),
"<strong>$type</strong>",
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: type of comment, 2: notification if the comment is pending */
_x( '%1$s %2$s', 'dashboard' ),
"<strong>$type</strong>",
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<p class="comment-author"><?php comment_author_link( $comment ); ?></p>
<?php endif; // comment_type ?>
<blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
<?php if ( $actions_string ) : ?>
<p class="row-actions"><?php echo $actions_string; ?></p>
<?php endif; ?>
</div>
</li>
<?php
$GLOBALS['comment'] = null;
}
/**
* Callback function for Activity widget.
*
* @since 3.8.0
*/
function wp_dashboard_site_activity() {
echo '<div id="activity-widget">';
$future_posts = wp_dashboard_recent_posts( array(
'max' => 5,
'status' => 'future',
'order' => 'ASC',
'title' => __( 'Publishing Soon' ),
'id' => 'future-posts',
) );
$recent_posts = wp_dashboard_recent_posts( array(
'max' => 5,
'status' => 'publish',
'order' => 'DESC',
'title' => __( 'Recently Published' ),
'id' => 'published-posts',
) );
$recent_comments = wp_dashboard_recent_comments();
if ( !$future_posts && !$recent_posts && !$recent_comments ) {
echo '<div class="no-activity">';
echo '<p class="smiley" aria-hidden="true"></p>';
echo '<p>' . __( 'No activity yet!' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
/**
* Generates Publishing Soon and Recently Published sections.
*
* @since 3.8.0
*
* @param array $args {
* An array of query and display arguments.
*
* @type int $max Number of posts to display.
* @type string $status Post status.
* @type string $order Designates ascending ('ASC') or descending ('DESC') order.
* @type string $title Section title.
* @type string $id The container id.
* }
* @return bool False if no posts were found. True otherwise.
*/
function wp_dashboard_recent_posts( $args ) {
$query_args = array(
'post_type' => 'post',
'post_status' => $args['status'],
'orderby' => 'date',
'order' => $args['order'],
'posts_per_page' => intval( $args['max'] ),
'no_found_rows' => true,
'cache_results' => false,
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
);
/**
* Filters the query arguments used for the Recent Posts widget.
*
* @since 4.2.0
*
* @param array $query_args The arguments passed to WP_Query to produce the list of posts.
*/
$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
$posts = new WP_Query( $query_args );
if ( $posts->have_posts() ) {
echo '<div id="' . $args['id'] . '" class="activity-block">';
echo '<h3>' . $args['title'] . '</h3>';
echo '<ul>';
$today = date( 'Y-m-d', current_time( 'timestamp' ) );
$tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
while ( $posts->have_posts() ) {
$posts->the_post();
$time = get_the_time( 'U' );
if ( date( 'Y-m-d', $time ) == $today ) {
$relative = __( 'Today' );
} elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
$relative = __( 'Tomorrow' );
} elseif ( date( 'Y', $time ) !== date( 'Y', current_time( 'timestamp' ) ) ) {
/* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS Y' ), $time );
} else {
/* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS' ), $time );
}
// Use the post edit link for those who can edit, the permalink otherwise.
$recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();
$draft_or_post_title = _draft_or_post_title();
printf(
'<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
/* translators: 1: relative date, 2: time */
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ),
$recent_post_link,
/* translators: %s: post title */
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ),
$draft_or_post_title
);
}
echo '</ul>';
echo '</div>';
} else {
return false;
}
wp_reset_postdata();
return true;
}
/**
* Show Comments section.
*
* @since 3.8.0
*
* @param int $total_items Optional. Number of comments to query. Default 5.
* @return bool False if no comments were found. True otherwise.
*/
function wp_dashboard_recent_comments( $total_items = 5 ) {
// Select all comment types and filter out spam later for better query performance.
$comments = array();
$comments_query = array(
'number' => $total_items * 5,
'offset' => 0
);
if ( ! current_user_can( 'edit_posts' ) )
$comments_query['status'] = 'approve';
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
if ( ! is_array( $possible ) ) {
break;
}
foreach ( $possible as $comment ) {
if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) )
continue;
$comments[] = $comment;
if ( count( $comments ) == $total_items )
break 2;
}
$comments_query['offset'] += $comments_query['number'];
$comments_query['number'] = $total_items * 10;
}
if ( $comments ) {
echo '<div id="latest-comments" class="activity-block">';
echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
foreach ( $comments as $comment ) {
$comment_post = get_post( $comment->comment_post_ID );
if (
current_user_can( 'edit_post', $comment->comment_post_ID ) ||
(
empty( $comment_post->post_password ) &&
current_user_can( 'read_post', $comment->comment_post_ID )
)
) {
_wp_dashboard_recent_comments_row( $comment );
}
}
echo '</ul>';
if ( current_user_can( 'edit_posts' ) ) {
echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>';
_get_list_table( 'WP_Comments_List_Table' )->views();
}
wp_comment_reply( -1, false, 'dashboard', false );
wp_comment_trashnotice();
echo '</div>';
} else {
return false;
}
return true;
}
/**
* Display generic dashboard RSS widget feed.
*
* @since 2.5.0
*
* @param string $widget_id
*/
function wp_dashboard_rss_output( $widget_id ) {
$widgets = get_option( 'dashboard_widget_options' );
echo '<div class="rss-widget">';
wp_widget_rss_output( $widgets[ $widget_id ] );
echo "</div>";
}
/**
* Checks to see if all of the feed url in $check_urls are cached.
*
* If $check_urls is empty, look for the rss feed url found in the dashboard
* widget options of $widget_id. If cached, call $callback, a function that
* echoes out output for this widget. If not cache, echo a "Loading..." stub
* which is later replaced by Ajax call (see top of /wp-admin/index.php)
*
* @since 2.5.0
*
* @param string $widget_id
* @param callable $callback
* @param array $check_urls RSS feeds
* @return bool False on failure. True on success.
*/
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
$doing_ajax = wp_doing_ajax();
if ( empty($check_urls) ) {
$widgets = get_option( 'dashboard_widget_options' );
if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) {
echo $loading;
return false;
}
$check_urls = array( $widgets[$widget_id]['url'] );
}
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
if ( false !== ( $output = get_transient( $cache_key ) ) ) {
echo $output;
return true;
}
if ( ! $doing_ajax ) {
echo $loading;
return false;
}
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 3 );
array_unshift( $args, $widget_id, $check_urls );
ob_start();
call_user_func_array( $callback, $args );
set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
}
return true;
}
//
// Dashboard Widgets Controls
//
/**
* Calls widget control callback.
*
* @since 2.5.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param int $widget_control_id Registered Widget ID.
*/
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
global $wp_dashboard_control_callbacks;
if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) {
call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
}
}
/**
* The RSS dashboard widget control.
*
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
* from RSS-type widgets.
*
* @since 2.5.0
*
* @param string $widget_id
* @param array $form_inputs
*/
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
$widget_options = array();
if ( !isset($widget_options[$widget_id]) )
$widget_options[$widget_id] = array();
$number = 1; // Hack to use wp_widget_rss_form()
$widget_options[$widget_id]['number'] = $number;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
$_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] );
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
$widget_options[$widget_id]['number'] = $number;
// Title is optional. If black, fill it if possible.
if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
$rss = fetch_feed($widget_options[$widget_id]['url']);
if ( is_wp_error($rss) ) {
$widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
} else {
$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
$rss->__destruct();
unset($rss);
}
}
update_option( 'dashboard_widget_options', $widget_options );
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
delete_transient( $cache_key );
}
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
}
/**
* Renders the Events and News dashboard widget.
*
* @since 4.8.0
*/
function wp_dashboard_events_news() {
wp_print_community_events_markup();
?>
<div class="wordpress-news hide-if-no-js">
<?php wp_dashboard_primary(); ?>
</div>
<p class="community-events-footer">
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://make.wordpress.org/community/meetups-landing-page',
__( 'Meetups' ),
/* translators: accessibility text */
__( '(opens in a new window)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://central.wordcamp.org/schedule/',
__( 'WordCamps' ),
/* translators: accessibility text */
__( '(opens in a new window)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
__( 'News' ),
/* translators: accessibility text */
__( '(opens in a new window)' )
);
?>
</p>
<?php
}
/**
* Prints the markup for the Community Events section of the Events and News Dashboard widget.
*
* @since 4.8.0
*/
function wp_print_community_events_markup() {
?>
<div class="community-events-errors notice notice-error inline hide-if-js">
<p class="hide-if-js">
<?php _e( 'This widget requires JavaScript.' ); ?>
</p>
<p class="community-events-error-occurred" aria-hidden="true">
<?php _e( 'An error occurred. Please try again.' ); ?>
</p>
<p class="community-events-could-not-locate" aria-hidden="true"></p>
</div>
<div class="community-events-loading hide-if-no-js">
<?php _e( 'Loading…' ); ?>
</div>
<?php
/*
* Hide the main element when the page first loads, because the content
* won't be ready until wp.communityEvents.renderEventsTemplate() has run.
*/
?>
<div id="community-events" class="community-events" aria-hidden="true">
<div class="activity-block">
<p>
<span id="community-events-location-message"></span>
<button class="button-link community-events-toggle-location" aria-label="<?php esc_attr_e( 'Edit city' ); ?>" aria-expanded="false">
<span class="dashicons dashicons-edit"></span>
</button>
</p>
<form class="community-events-form" aria-hidden="true" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post">
<label for="community-events-location">
<?php _e( 'City:' ); ?>
</label>
<?php
/* translators: Replace with a city related to your locale.
* Test that it matches the expected location and has upcoming
* events before including it. If no cities related to your
* locale have events, then use a city related to your locale
* that would be recognizable to most users. Use only the city
* name itself, without any region or country. Use the endonym
* (native locale name) instead of the English name if possible.
*/
?>
<input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" />
<?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?>
<button class="community-events-cancel button-link" type="button" aria-expanded="false">
<?php _e( 'Cancel' ); ?>
</button>
<span class="spinner"></span>
</form>
</div>
<ul class="community-events-results activity-block last"></ul>
</div>
<?php
}
/**
* Renders the events templates for the Event and News widget.
*
* @since 4.8.0
*/
function wp_print_community_events_templates() {
?>
<script id="tmpl-community-events-attend-event-near" type="text/template">
<?php printf(
/* translators: %s: the name of a city */
__( 'Attend an upcoming event near %s.' ),
'<strong>{{ data.location.description }}</strong>'
); ?>
</script>
<script id="tmpl-community-events-could-not-locate" type="text/template">
<?php printf(
/* translators: %s is the name of the city we couldn't locate.
* Replace the examples with cities in your locale, but test
* that they match the expected location before including them.
* Use endonyms (native locale names) whenever possible.
*/
__( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
'<em>{{data.unknownCity}}</em>'
); ?>
</script>
<script id="tmpl-community-events-event-list" type="text/template">
<# _.each( data.events, function( event ) { #>
<li class="event event-{{ event.type }} wp-clearfix">
<div class="event-info">
<div class="dashicons event-icon" aria-hidden="true"></div>
<div class="event-info-inner">
<a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
<span class="event-city">{{ event.location.location }}</span>
</div>
</div>
<div class="event-date-time">
<span class="event-date">{{ event.formatted_date }}</span>
<# if ( 'meetup' === event.type ) { #>
<span class="event-time">{{ event.formatted_time }}</span>
<# } #>
</div>
</li>
<# } ) #>
</script>
<script id="tmpl-community-events-no-upcoming-events" type="text/template">
<li class="event-none">
<# if ( data.location.description ) { #>
<?php printf(
/* translators: 1: the city the user searched for, 2: meetup organization documentation URL */
__( 'There aren’t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ),
'{{ data.location.description }}',
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
); ?>
<# } else { #>
<?php printf(
/* translators: %s: meetup organization documentation URL */
__( 'There aren’t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ),
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
); ?>
<# } #>
</li>
</script>
<?php
}
/**
* WordPress News dashboard widget.
*
* @since 2.7.0
* @since 4.8.0 Removed popular plugins feed.
*/
function wp_dashboard_primary() {
$feeds = array(
'news' => array(
/**
* Filters the primary link URL for the 'WordPress News' dashboard widget.
*
* @since 2.5.0
*
* @param string $link The widget's primary link URL.
*/
'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
/**
* Filters the primary feed URL for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's primary feed URL.
*/
'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
/**
* Filters the primary link title for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's primary link.
*/
'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
'items' => 1,
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
),
'planet' => array(
/**
* Filters the secondary link URL for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $link The widget's secondary link URL.
*/
'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
/**
* Filters the secondary feed URL for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's secondary feed URL.
*/
'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
/**
* Filters the secondary link title for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's secondary link.
*/
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
/**
* Filters the number of secondary link items for the 'WordPress News' dashboard widget.
*
* @since 4.4.0
*
* @param string $items How many items to show in the secondary feed.
*/
'items' => apply_filters( 'dashboard_secondary_items', 3 ),
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
)
);
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds );
}
/**
* Display the WordPress news feeds.
*
* @since 3.8.0
* @since 4.8.0 Removed popular plugins feed.
*
* @param string $widget_id Widget ID.
* @param array $feeds Array of RSS feeds.
*/
function wp_dashboard_primary_output( $widget_id, $feeds ) {
foreach ( $feeds as $type => $args ) {
$args['type'] = $type;
echo '<div class="rss-widget">';
wp_widget_rss_output( $args['url'], $args );
echo "</div>";
}
}
/**
* Display file upload quota on dashboard.
*
* Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now().
*
* @since 3.0.0
*
* @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
*/
function wp_dashboard_quota() {
if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) )
return true;
$quota = get_space_allowed();
$used = get_space_used();
if ( $used > $quota )
$percentused = '100';
else
$percentused = ( $used / $quota ) * 100;
$used_class = ( $percentused >= 70 ) ? ' warning' : '';
$used = round( $used, 2 );
$percentused = number_format( $percentused );
?>
<h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
<div class="mu-storage">
<ul>
<li class="storage-count">
<?php $text = sprintf(
/* translators: %s: number of megabytes */
__( '%s MB Space Allowed' ),
number_format_i18n( $quota )
);
printf(
'<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
); ?>
</li><li class="storage-count <?php echo $used_class; ?>">
<?php $text = sprintf(
/* translators: 1: number of megabytes, 2: percentage */
__( '%1$s MB (%2$s%%) Space Used' ),
number_format_i18n( $used, 2 ),
$percentused
);
printf(
'<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
); ?>
</li>
</ul>
</div>
<?php
}
// Display Browser Nag Meta Box
function wp_dashboard_browser_nag() {
$notice = '';
$response = wp_check_browser_version();
if ( $response ) {
if ( $response['insecure'] ) {
/* translators: %s: browser name and link */
$msg = sprintf( __( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
} else {
/* translators: %s: browser name and link */
$msg = sprintf( __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
}
$browser_nag_class = '';
if ( !empty( $response['img_src'] ) ) {
$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src'];
$notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
$browser_nag_class = ' has-browser-icon';
}
$notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
$browsehappy = 'https://browsehappy.com/';
$locale = get_user_locale();
if ( 'en_US' !== $locale )
$browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
$notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>';
$notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
$notice .= '<div class="clear"></div>';
}
/**
* Filters the notice output for the 'Browse Happy' nag meta box.
*
* @since 3.2.0
*
* @param string $notice The notice content.
* @param array $response An array containing web browser information.
*/
echo apply_filters( 'browse-happy-notice', $notice, $response );
}
/**
* @since 3.2.0
*
* @param array $classes
* @return array
*/
function dashboard_browser_nag_class( $classes ) {
$response = wp_check_browser_version();
if ( $response && $response['insecure'] )
$classes[] = 'browser-insecure';
return $classes;
}
/**
* Check if the user needs a browser update
*
* @since 3.2.0
*
* @return array|bool False on failure, array of browser data on success.
*/
function wp_check_browser_version() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
return false;
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
// include an unmodified $wp_version
include( ABSPATH . WPINC . '/version.php' );
$url = 'http://api.wordpress.org/core/browse-happy/1.1/';
$options = array(
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' )
);
if ( wp_http_supports( array( 'ssl' ) ) ) {
$url = set_url_scheme( $url, 'https' );
}
$response = wp_remote_post( $url, $options );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
return false;
/**
* Response should be an array with:
* 'platform' - string - A user-friendly platform name, if it can be determined
* 'name' - string - A user-friendly browser name
* 'version' - string - The version of the browser the user is using
* 'current_version' - string - The most recent version of the browser
* 'upgrade' - boolean - Whether the browser needs an upgrade
* 'insecure' - boolean - Whether the browser is deemed insecure
* 'update_url' - string - The url to visit to upgrade
* 'img_src' - string - An image representing the browser
* 'img_src_ssl' - string - An image (over SSL) representing the browser
*/
$response = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $response ) )
return false;
set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
}
return $response;
}
/**
* Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
*/
function wp_dashboard_empty() {}
/**
* Displays a welcome panel to introduce users to WordPress.
*
* @since 3.3.0
*/
function wp_welcome_panel() {
?>
<div class="welcome-panel-content">
<h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
<p class="about-description"><?php _e( 'We’ve assembled some links to get you started:' ); ?></p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<?php if ( current_user_can( 'customize' ) ) : ?>
<h3><?php _e( 'Get Started' ); ?></h3>
<a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php endif; ?>
<a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
<?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?>
<p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), $themes_link ); ?></p>
<?php endif; ?>
</div>
<div class="welcome-panel-column">
<h3><?php _e( 'Next Steps' ); ?></h3>
<ul>
<?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<?php else : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h3><?php _e( 'More Actions' ); ?></h3>
<ul>
<?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?>
<li><div class="welcome-icon welcome-widgets-menus"><?php
if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) {
printf( __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ),
admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) );
} elseif ( current_theme_supports( 'widgets' ) ) {
echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>';
} else {
echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>';
}
?></div></li>
<?php endif; ?>
<?php if ( current_user_can( 'manage_options' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
</ul>
</div>
</div>
</div>
<?php
}
home/xbodynamge/www/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php 0000644 00000002640 15112337667 0023714 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( isset( $_GET['allow_tracking'] ) && check_admin_referer( 'wpseo_activate_tracking', 'nonce' ) ) {
WPSEO_Options::set( 'yoast_tracking', ( $_GET['allow_tracking'] === 'yes' ) );
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
wp_safe_redirect( wp_unslash( $_SERVER['HTTP_REFERER'] ), 307 );
exit;
}
}
$yform = Yoast_Form::get_instance();
$yform->admin_header( true, 'wpseo' );
do_action( 'wpseo_all_admin_notices' );
$dashboard_tabs = new WPSEO_Option_Tabs( 'dashboard' );
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'dashboard',
__( 'Dashboard', 'wordpress-seo' ),
[
'save_button' => false,
]
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'features',
__( 'Features', 'wordpress-seo' )
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'integrations',
__( 'Integrations', 'wordpress-seo' ),
[
'save_button' => false,
]
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'webmaster-tools',
__( 'Webmaster Tools', 'wordpress-seo' )
)
);
/**
* Allows the addition of tabs to the dashboard by calling $dashboard_tabs->add_tab().
*/
do_action( 'wpseo_settings_tabs_dashboard', $dashboard_tabs );
$dashboard_tabs->display( $yform );
do_action( 'wpseo_dashboard' );
$yform->admin_footer();
home/xbodynamge/crosstraining/wp-admin/includes/dashboard.php 0000644 00000157710 15112446503 0020514 0 ustar 00 <?php
/**
* WordPress Dashboard Widget Administration Screen API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Registers dashboard widgets.
*
* Handles POST data, sets up filters.
*
* @since 2.5.0
*
* @global array $wp_registered_widgets
* @global array $wp_registered_widget_controls
* @global array $wp_dashboard_control_callbacks
*/
function wp_dashboard_setup() {
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array();
$screen = get_current_screen();
/* Register Widgets and Controls */
$response = wp_check_browser_version();
if ( $response && $response['upgrade'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
if ( $response['insecure'] )
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
else
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
}
// Right Now
if ( is_blog_admin() && current_user_can('edit_posts') )
wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
if ( is_network_admin() )
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
// Activity Widget
if ( is_blog_admin() ) {
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
}
// QuickPress Widget
if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
$quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) );
wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
}
// WordPress Events and News
wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' );
if ( is_network_admin() ) {
/**
* Fires after core widgets for the Network Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_network_dashboard_setup' );
/**
* Filters the list of widgets to load for the Network Admin dashboard.
*
* @since 3.1.0
*
* @param array $dashboard_widgets An array of dashboard widgets.
*/
$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
} elseif ( is_user_admin() ) {
/**
* Fires after core widgets for the User Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_user_dashboard_setup' );
/**
* Filters the list of widgets to load for the User Admin dashboard.
*
* @since 3.1.0
*
* @param array $dashboard_widgets An array of dashboard widgets.
*/
$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
} else {
/**
* Fires after core widgets for the admin dashboard have been registered.
*
* @since 2.5.0
*/
do_action( 'wp_dashboard_setup' );
/**
* Filters the list of widgets to load for the admin dashboard.
*
* @since 2.5.0
*
* @param array $dashboard_widgets An array of dashboard widgets.
*/
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
}
foreach ( $dashboard_widgets as $widget_id ) {
$name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
}
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/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
/** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'side', '' );
}
/**
* Adds a new dashboard widget.
*
* @since 2.7.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param string $widget_id Widget ID (used in the 'id' attribute for the widget).
* @param string $widget_name Title of the widget.
* @param callable $callback Function that fills the widget with the desired content.
* The function should echo its output.
* @param callable $control_callback Optional. Function that outputs controls for the widget. Default null.
* @param array $callback_args Optional. Data that should be set as the $args property of the widget array
* (which is the second parameter passed to your callback). Default null.
*/
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {
$screen = get_current_screen();
global $wp_dashboard_control_callbacks;
$private_callback_args = array( '__widget_basename' => $widget_name );
if ( is_null( $callback_args ) ) {
$callback_args = $private_callback_args;
} else if ( is_array( $callback_args ) ) {
$callback_args = array_merge( $callback_args, $private_callback_args );
}
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>';
}
}
$side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
$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, $callback_args );
}
/**
* Outputs controls for the current dashboard widget.
*
* @access private
* @since 2.7.0
*
* @param mixed $dashboard
* @param array $meta_box
*/
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">';
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>';
}
/**
* Displays the dashboard.
*
* @since 2.5.0
*/
function wp_dashboard() {
$screen = get_current_screen();
$columns = absint( $screen->get_columns() );
$columns_css = '';
if ( $columns ) {
$columns_css = " columns-$columns";
}
?>
<div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>">
<div id="postbox-container-1" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
</div>
<div id="postbox-container-2" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'side', '' ); ?>
</div>
<div id="postbox-container-3" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column3', '' ); ?>
</div>
<div id="postbox-container-4" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column4', '' ); ?>
</div>
</div>
<?php
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
}
//
// Dashboard Widgets
//
/**
* Dashboard widget that displays some basic stats about the site.
*
* Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8.
*
* @since 2.7.0
*/
function wp_dashboard_right_now() {
?>
<div class="main">
<ul>
<?php
// Posts and Pages
foreach ( array( 'post', 'page' ) as $post_type ) {
$num_posts = wp_count_posts( $post_type );
if ( $num_posts && $num_posts->publish ) {
if ( 'post' == $post_type ) {
$text = _n( '%s Post', '%s Posts', $num_posts->publish );
} else {
$text = _n( '%s Page', '%s Pages', $num_posts->publish );
}
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
$post_type_object = get_post_type_object( $post_type );
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
} else {
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
}
}
}
// Comments
$num_comm = wp_count_comments();
if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
?>
<li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
<?php
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
/* translators: %s: number of comments in moderation */
$text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
/* translators: %s: number of comments in moderation */
$aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
?>
<li class="comment-mod-count<?php
if ( ! $num_comm->moderated ) {
echo ' hidden';
}
?>"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php esc_attr_e( $aria_label ); ?>"><?php echo $text; ?></a></li>
<?php
}
/**
* Filters the array of extra elements to list in the 'At a Glance'
* dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'. Each element
* is wrapped in list-item tags on output.
*
* @since 3.8.0
*
* @param array $items Array of extra 'At a Glance' widget items.
*/
$elements = apply_filters( 'dashboard_glance_items', array() );
if ( $elements ) {
echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n";
}
?>
</ul>
<?php
update_right_now_message();
// Check if search engines are asked not to index this site.
if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) {
/**
* Filters the link title attribute for the 'Search Engines Discouraged'
* message displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
* @since 4.5.0 The default for `$title` was updated to an empty string.
*
* @param string $title Default attribute text.
*/
$title = apply_filters( 'privacy_on_link_title', '' );
/**
* Filters the link label for the 'Search Engines Discouraged' message
* displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
*
* @param string $content Default text.
*/
$content = apply_filters( 'privacy_on_link_text' , __( 'Search Engines Discouraged' ) );
$title_attr = '' === $title ? '' : " title='$title'";
echo "<p><a href='options-reading.php'$title_attr>$content</a></p>";
}
?>
</div>
<?php
/*
* activity_box_end has a core action, but only prints content when multisite.
* Using an output buffer is the only way to really check if anything's displayed here.
*/
ob_start();
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.5.0
*/
do_action( 'rightnow_end' );
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.0.0
*/
do_action( 'activity_box_end' );
$actions = ob_get_clean();
if ( !empty( $actions ) ) : ?>
<div class="sub">
<?php echo $actions; ?>
</div>
<?php endif;
}
/**
* @since 3.1.0
*/
function wp_network_dashboard_right_now() {
$actions = array();
if ( current_user_can('create_sites') )
$actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>';
if ( current_user_can('create_users') )
$actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
$c_users = get_user_count();
$c_blogs = get_blog_count();
/* translators: %s: number of users on the network */
$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
/* translators: %s: number of sites on the network */
$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
/* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */
$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
if ( $actions ) {
echo '<ul class="subsubsub">';
foreach ( $actions as $class => $action ) {
$actions[ $class ] = "\t<li class='$class'>$action";
}
echo implode( " |</li>\n", $actions ) . "</li>\n";
echo '</ul>';
}
?>
<br class="clear" />
<p class="youhave"><?php echo $sentence; ?></p>
<?php
/**
* Fires in the Network Admin 'Right Now' dashboard widget
* just before the user and site search form fields.
*
* @since MU (3.0.0)
*
* @param null $unused
*/
do_action( 'wpmuadminresult', '' );
?>
<form action="<?php echo network_admin_url('users.php'); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?>
</p>
</form>
<form action="<?php echo network_admin_url('sites.php'); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?>
</p>
</form>
<?php
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_rightnow_end' );
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_activity_box_end' );
}
/**
* The Quick Draft widget display and creation of drafts.
*
* @since 3.8.0
*
* @global int $post_ID
*
* @param string $error_msg Optional. Error message. Default false.
*/
function wp_dashboard_quick_press( $error_msg = false ) {
global $post_ID;
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
if ( $last_post_id ) {
$post = get_post( $last_post_id );
if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
$post = get_default_post_to_edit( 'post', true );
update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
} else {
$post->post_title = ''; // Remove the auto draft title
}
} else {
$post = get_default_post_to_edit( 'post' , true);
$user_id = get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) )
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
}
$post_ID = (int) $post->ID;
?>
<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
<?php if ( $error_msg ) : ?>
<div class="error"><?php echo $error_msg; ?></div>
<?php endif; ?>
<div class="input-text-wrap" id="title-wrap">
<label class="screen-reader-text prompt" for="title" id="title-prompt-text">
<?php
/** This filter is documented in wp-admin/edit-form-advanced.php */
echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
?>
</label>
<input type="text" name="post_title" id="title" autocomplete="off" />
</div>
<div class="textarea-wrap" id="description-wrap">
<label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What’s on your mind?' ); ?></label>
<textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
</div>
<p class="submit">
<input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />
<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
<input type="hidden" name="post_type" value="post" />
<?php wp_nonce_field( 'add-post' ); ?>
<?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>
<br class="clear" />
</p>
</form>
<?php
wp_dashboard_recent_drafts();
}
/**
* Show recent drafts of the user on the dashboard.
*
* @since 2.7.0
*
* @param array $drafts
*/
function wp_dashboard_recent_drafts( $drafts = false ) {
if ( ! $drafts ) {
$query_args = array(
'post_type' => 'post',
'post_status' => 'draft',
'author' => get_current_user_id(),
'posts_per_page' => 4,
'orderby' => 'modified',
'order' => 'DESC'
);
/**
* Filters the post query arguments for the 'Recent Drafts' dashboard widget.
*
* @since 4.4.0
*
* @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
*/
$query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
$drafts = get_posts( $query_args );
if ( ! $drafts ) {
return;
}
}
echo '<div class="drafts">';
if ( count( $drafts ) > 3 ) {
echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . __( 'View all drafts' ) . "</a></p>\n";
}
echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
$drafts = array_slice( $drafts, 0, 3 );
foreach ( $drafts as $draft ) {
$url = get_edit_post_link( $draft->ID );
$title = _draft_or_post_title( $draft->ID );
echo "<li>\n";
/* translators: %s: post title */
echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
echo '<p>' . $the_content . '</p>';
}
echo "</li>\n";
}
echo "</ul>\n</div>";
}
/**
* Outputs a row for the Recent Comments widget.
*
* @access private
* @since 2.7.0
*
* @global WP_Comment $comment
*
* @param WP_Comment $comment The current comment.
* @param bool $show_date Optional. Whether to display the date.
*/
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$GLOBALS['comment'] = clone $comment;
if ( $comment->comment_post_ID > 0 ) {
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
$comment_post_url = get_the_permalink( $comment->comment_post_ID );
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
} else {
$comment_post_link = '';
}
$actions_string = '';
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
// Pre-order it: Approve | Reply | Edit | Spam | Trash.
$actions = array(
'approve' => '', 'unapprove' => '',
'reply' => '',
'edit' => '',
'spam' => '',
'trash' => '', 'delete' => '',
'view' => '',
);
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>". __( 'Edit' ) . '</a>';
$actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '" href="#">' . __( 'Reply' ) . '</a>';
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
if ( ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
}
$actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>';
/**
* Filters the action links displayed for each comment in the 'Recent Comments'
* dashboard widget.
*
* @since 2.6.0
*
* @param array $actions An array of comment actions. Default actions include:
* 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
* 'Delete', and 'Trash'.
* @param WP_Comment $comment The comment object.
*/
$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
$i = 0;
foreach ( $actions as $action => $link ) {
++$i;
( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span
if ( 'reply' == $action || 'quickedit' == $action ) {
$action .= ' hide-if-no-js';
}
if ( 'view' === $action && '1' !== $comment->comment_approved ) {
$action .= ' hidden';
}
$actions_string .= "<span class='$action'>$sep$link</span>";
}
}
?>
<li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
<?php echo get_avatar( $comment, 50, 'mystery' ); ?>
<?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Comments might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
__( 'From %1$s on %2$s %3$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: comment author, 2: notification if the comment is pending */
__( 'From %1$s %2$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<?php
else :
switch ( $comment->comment_type ) {
case 'pingback' :
$type = __( 'Pingback' );
break;
case 'trackback' :
$type = __( 'Trackback' );
break;
default :
$type = ucwords( $comment->comment_type );
}
$type = esc_html( $type );
?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
_x( '%1$s on %2$s %3$s', 'dashboard' ),
"<strong>$type</strong>",
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: type of comment, 2: notification if the comment is pending */
_x( '%1$s %2$s', 'dashboard' ),
"<strong>$type</strong>",
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<p class="comment-author"><?php comment_author_link( $comment ); ?></p>
<?php endif; // comment_type ?>
<blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
<?php if ( $actions_string ) : ?>
<p class="row-actions"><?php echo $actions_string; ?></p>
<?php endif; ?>
</div>
</li>
<?php
$GLOBALS['comment'] = null;
}
/**
* Callback function for Activity widget.
*
* @since 3.8.0
*/
function wp_dashboard_site_activity() {
echo '<div id="activity-widget">';
$future_posts = wp_dashboard_recent_posts( array(
'max' => 5,
'status' => 'future',
'order' => 'ASC',
'title' => __( 'Publishing Soon' ),
'id' => 'future-posts',
) );
$recent_posts = wp_dashboard_recent_posts( array(
'max' => 5,
'status' => 'publish',
'order' => 'DESC',
'title' => __( 'Recently Published' ),
'id' => 'published-posts',
) );
$recent_comments = wp_dashboard_recent_comments();
if ( !$future_posts && !$recent_posts && !$recent_comments ) {
echo '<div class="no-activity">';
echo '<p class="smiley" aria-hidden="true"></p>';
echo '<p>' . __( 'No activity yet!' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
/**
* Generates Publishing Soon and Recently Published sections.
*
* @since 3.8.0
*
* @param array $args {
* An array of query and display arguments.
*
* @type int $max Number of posts to display.
* @type string $status Post status.
* @type string $order Designates ascending ('ASC') or descending ('DESC') order.
* @type string $title Section title.
* @type string $id The container id.
* }
* @return bool False if no posts were found. True otherwise.
*/
function wp_dashboard_recent_posts( $args ) {
$query_args = array(
'post_type' => 'post',
'post_status' => $args['status'],
'orderby' => 'date',
'order' => $args['order'],
'posts_per_page' => intval( $args['max'] ),
'no_found_rows' => true,
'cache_results' => false,
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
);
/**
* Filters the query arguments used for the Recent Posts widget.
*
* @since 4.2.0
*
* @param array $query_args The arguments passed to WP_Query to produce the list of posts.
*/
$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
$posts = new WP_Query( $query_args );
if ( $posts->have_posts() ) {
echo '<div id="' . $args['id'] . '" class="activity-block">';
echo '<h3>' . $args['title'] . '</h3>';
echo '<ul>';
$today = date( 'Y-m-d', current_time( 'timestamp' ) );
$tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
while ( $posts->have_posts() ) {
$posts->the_post();
$time = get_the_time( 'U' );
if ( date( 'Y-m-d', $time ) == $today ) {
$relative = __( 'Today' );
} elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
$relative = __( 'Tomorrow' );
} elseif ( date( 'Y', $time ) !== date( 'Y', current_time( 'timestamp' ) ) ) {
/* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS Y' ), $time );
} else {
/* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS' ), $time );
}
// Use the post edit link for those who can edit, the permalink otherwise.
$recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();
$draft_or_post_title = _draft_or_post_title();
printf(
'<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
/* translators: 1: relative date, 2: time */
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ),
$recent_post_link,
/* translators: %s: post title */
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ),
$draft_or_post_title
);
}
echo '</ul>';
echo '</div>';
} else {
return false;
}
wp_reset_postdata();
return true;
}
/**
* Show Comments section.
*
* @since 3.8.0
*
* @param int $total_items Optional. Number of comments to query. Default 5.
* @return bool False if no comments were found. True otherwise.
*/
function wp_dashboard_recent_comments( $total_items = 5 ) {
// Select all comment types and filter out spam later for better query performance.
$comments = array();
$comments_query = array(
'number' => $total_items * 5,
'offset' => 0
);
if ( ! current_user_can( 'edit_posts' ) )
$comments_query['status'] = 'approve';
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
if ( ! is_array( $possible ) ) {
break;
}
foreach ( $possible as $comment ) {
if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) )
continue;
$comments[] = $comment;
if ( count( $comments ) == $total_items )
break 2;
}
$comments_query['offset'] += $comments_query['number'];
$comments_query['number'] = $total_items * 10;
}
if ( $comments ) {
echo '<div id="latest-comments" class="activity-block">';
echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
foreach ( $comments as $comment ) {
$comment_post = get_post( $comment->comment_post_ID );
if (
current_user_can( 'edit_post', $comment->comment_post_ID ) ||
(
empty( $comment_post->post_password ) &&
current_user_can( 'read_post', $comment->comment_post_ID )
)
) {
_wp_dashboard_recent_comments_row( $comment );
}
}
echo '</ul>';
if ( current_user_can( 'edit_posts' ) ) {
echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>';
_get_list_table( 'WP_Comments_List_Table' )->views();
}
wp_comment_reply( -1, false, 'dashboard', false );
wp_comment_trashnotice();
echo '</div>';
} else {
return false;
}
return true;
}
/**
* Display generic dashboard RSS widget feed.
*
* @since 2.5.0
*
* @param string $widget_id
*/
function wp_dashboard_rss_output( $widget_id ) {
$widgets = get_option( 'dashboard_widget_options' );
echo '<div class="rss-widget">';
wp_widget_rss_output( $widgets[ $widget_id ] );
echo "</div>";
}
/**
* Checks to see if all of the feed url in $check_urls are cached.
*
* If $check_urls is empty, look for the rss feed url found in the dashboard
* widget options of $widget_id. If cached, call $callback, a function that
* echoes out output for this widget. If not cache, echo a "Loading..." stub
* which is later replaced by Ajax call (see top of /wp-admin/index.php)
*
* @since 2.5.0
*
* @param string $widget_id
* @param callable $callback
* @param array $check_urls RSS feeds
* @return bool False on failure. True on success.
*/
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
$doing_ajax = wp_doing_ajax();
if ( empty($check_urls) ) {
$widgets = get_option( 'dashboard_widget_options' );
if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) {
echo $loading;
return false;
}
$check_urls = array( $widgets[$widget_id]['url'] );
}
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
if ( false !== ( $output = get_transient( $cache_key ) ) ) {
echo $output;
return true;
}
if ( ! $doing_ajax ) {
echo $loading;
return false;
}
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 3 );
array_unshift( $args, $widget_id, $check_urls );
ob_start();
call_user_func_array( $callback, $args );
set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
}
return true;
}
//
// Dashboard Widgets Controls
//
/**
* Calls widget control callback.
*
* @since 2.5.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param int $widget_control_id Registered Widget ID.
*/
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
global $wp_dashboard_control_callbacks;
if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) {
call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
}
}
/**
* The RSS dashboard widget control.
*
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
* from RSS-type widgets.
*
* @since 2.5.0
*
* @param string $widget_id
* @param array $form_inputs
*/
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
$widget_options = array();
if ( !isset($widget_options[$widget_id]) )
$widget_options[$widget_id] = array();
$number = 1; // Hack to use wp_widget_rss_form()
$widget_options[$widget_id]['number'] = $number;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
$_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] );
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
$widget_options[$widget_id]['number'] = $number;
// Title is optional. If black, fill it if possible.
if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
$rss = fetch_feed($widget_options[$widget_id]['url']);
if ( is_wp_error($rss) ) {
$widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
} else {
$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
$rss->__destruct();
unset($rss);
}
}
update_option( 'dashboard_widget_options', $widget_options );
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
delete_transient( $cache_key );
}
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
}
/**
* Renders the Events and News dashboard widget.
*
* @since 4.8.0
*/
function wp_dashboard_events_news() {
wp_print_community_events_markup();
?>
<div class="wordpress-news hide-if-no-js">
<?php wp_dashboard_primary(); ?>
</div>
<p class="community-events-footer">
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://make.wordpress.org/community/meetups-landing-page',
__( 'Meetups' ),
/* translators: accessibility text */
__( '(opens in a new window)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://central.wordcamp.org/schedule/',
__( 'WordCamps' ),
/* translators: accessibility text */
__( '(opens in a new window)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
__( 'News' ),
/* translators: accessibility text */
__( '(opens in a new window)' )
);
?>
</p>
<?php
}
/**
* Prints the markup for the Community Events section of the Events and News Dashboard widget.
*
* @since 4.8.0
*/
function wp_print_community_events_markup() {
?>
<div class="community-events-errors notice notice-error inline hide-if-js">
<p class="hide-if-js">
<?php _e( 'This widget requires JavaScript.' ); ?>
</p>
<p class="community-events-error-occurred" aria-hidden="true">
<?php _e( 'An error occurred. Please try again.' ); ?>
</p>
<p class="community-events-could-not-locate" aria-hidden="true"></p>
</div>
<div class="community-events-loading hide-if-no-js">
<?php _e( 'Loading…' ); ?>
</div>
<?php
/*
* Hide the main element when the page first loads, because the content
* won't be ready until wp.communityEvents.renderEventsTemplate() has run.
*/
?>
<div id="community-events" class="community-events" aria-hidden="true">
<div class="activity-block">
<p>
<span id="community-events-location-message"></span>
<button class="button-link community-events-toggle-location" aria-label="<?php esc_attr_e( 'Edit city' ); ?>" aria-expanded="false">
<span class="dashicons dashicons-edit"></span>
</button>
</p>
<form class="community-events-form" aria-hidden="true" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post">
<label for="community-events-location">
<?php _e( 'City:' ); ?>
</label>
<?php
/* translators: Replace with a city related to your locale.
* Test that it matches the expected location and has upcoming
* events before including it. If no cities related to your
* locale have events, then use a city related to your locale
* that would be recognizable to most users. Use only the city
* name itself, without any region or country. Use the endonym
* (native locale name) instead of the English name if possible.
*/
?>
<input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" />
<?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?>
<button class="community-events-cancel button-link" type="button" aria-expanded="false">
<?php _e( 'Cancel' ); ?>
</button>
<span class="spinner"></span>
</form>
</div>
<ul class="community-events-results activity-block last"></ul>
</div>
<?php
}
/**
* Renders the events templates for the Event and News widget.
*
* @since 4.8.0
*/
function wp_print_community_events_templates() {
?>
<script id="tmpl-community-events-attend-event-near" type="text/template">
<?php printf(
/* translators: %s: the name of a city */
__( 'Attend an upcoming event near %s.' ),
'<strong>{{ data.location.description }}</strong>'
); ?>
</script>
<script id="tmpl-community-events-could-not-locate" type="text/template">
<?php printf(
/* translators: %s is the name of the city we couldn't locate.
* Replace the examples with cities in your locale, but test
* that they match the expected location before including them.
* Use endonyms (native locale names) whenever possible.
*/
__( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
'<em>{{data.unknownCity}}</em>'
); ?>
</script>
<script id="tmpl-community-events-event-list" type="text/template">
<# _.each( data.events, function( event ) { #>
<li class="event event-{{ event.type }} wp-clearfix">
<div class="event-info">
<div class="dashicons event-icon" aria-hidden="true"></div>
<div class="event-info-inner">
<a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
<span class="event-city">{{ event.location.location }}</span>
</div>
</div>
<div class="event-date-time">
<span class="event-date">{{ event.formatted_date }}</span>
<# if ( 'meetup' === event.type ) { #>
<span class="event-time">{{ event.formatted_time }}</span>
<# } #>
</div>
</li>
<# } ) #>
</script>
<script id="tmpl-community-events-no-upcoming-events" type="text/template">
<li class="event-none">
<# if ( data.location.description ) { #>
<?php printf(
/* translators: 1: the city the user searched for, 2: meetup organization documentation URL */
__( 'There aren’t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ),
'{{ data.location.description }}',
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
); ?>
<# } else { #>
<?php printf(
/* translators: %s: meetup organization documentation URL */
__( 'There aren’t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ),
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
); ?>
<# } #>
</li>
</script>
<?php
}
/**
* WordPress News dashboard widget.
*
* @since 2.7.0
* @since 4.8.0 Removed popular plugins feed.
*/
function wp_dashboard_primary() {
$feeds = array(
'news' => array(
/**
* Filters the primary link URL for the 'WordPress News' dashboard widget.
*
* @since 2.5.0
*
* @param string $link The widget's primary link URL.
*/
'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
/**
* Filters the primary feed URL for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's primary feed URL.
*/
'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
/**
* Filters the primary link title for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's primary link.
*/
'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
'items' => 1,
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
),
'planet' => array(
/**
* Filters the secondary link URL for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $link The widget's secondary link URL.
*/
'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
/**
* Filters the secondary feed URL for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's secondary feed URL.
*/
'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
/**
* Filters the secondary link title for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's secondary link.
*/
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
/**
* Filters the number of secondary link items for the 'WordPress News' dashboard widget.
*
* @since 4.4.0
*
* @param string $items How many items to show in the secondary feed.
*/
'items' => apply_filters( 'dashboard_secondary_items', 3 ),
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
)
);
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds );
}
/**
* Display the WordPress news feeds.
*
* @since 3.8.0
* @since 4.8.0 Removed popular plugins feed.
*
* @param string $widget_id Widget ID.
* @param array $feeds Array of RSS feeds.
*/
function wp_dashboard_primary_output( $widget_id, $feeds ) {
foreach ( $feeds as $type => $args ) {
$args['type'] = $type;
echo '<div class="rss-widget">';
wp_widget_rss_output( $args['url'], $args );
echo "</div>";
}
}
/**
* Display file upload quota on dashboard.
*
* Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now().
*
* @since 3.0.0
*
* @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
*/
function wp_dashboard_quota() {
if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) )
return true;
$quota = get_space_allowed();
$used = get_space_used();
if ( $used > $quota )
$percentused = '100';
else
$percentused = ( $used / $quota ) * 100;
$used_class = ( $percentused >= 70 ) ? ' warning' : '';
$used = round( $used, 2 );
$percentused = number_format( $percentused );
?>
<h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
<div class="mu-storage">
<ul>
<li class="storage-count">
<?php $text = sprintf(
/* translators: %s: number of megabytes */
__( '%s MB Space Allowed' ),
number_format_i18n( $quota )
);
printf(
'<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
); ?>
</li><li class="storage-count <?php echo $used_class; ?>">
<?php $text = sprintf(
/* translators: 1: number of megabytes, 2: percentage */
__( '%1$s MB (%2$s%%) Space Used' ),
number_format_i18n( $used, 2 ),
$percentused
);
printf(
'<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
); ?>
</li>
</ul>
</div>
<?php
}
// Display Browser Nag Meta Box
function wp_dashboard_browser_nag() {
$notice = '';
$response = wp_check_browser_version();
if ( $response ) {
if ( $response['insecure'] ) {
/* translators: %s: browser name and link */
$msg = sprintf( __( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
} else {
/* translators: %s: browser name and link */
$msg = sprintf( __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
}
$browser_nag_class = '';
if ( !empty( $response['img_src'] ) ) {
$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src'];
$notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
$browser_nag_class = ' has-browser-icon';
}
$notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
$browsehappy = 'https://browsehappy.com/';
$locale = get_user_locale();
if ( 'en_US' !== $locale )
$browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
$notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>';
$notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
$notice .= '<div class="clear"></div>';
}
/**
* Filters the notice output for the 'Browse Happy' nag meta box.
*
* @since 3.2.0
*
* @param string $notice The notice content.
* @param array $response An array containing web browser information.
*/
echo apply_filters( 'browse-happy-notice', $notice, $response );
}
/**
* @since 3.2.0
*
* @param array $classes
* @return array
*/
function dashboard_browser_nag_class( $classes ) {
$response = wp_check_browser_version();
if ( $response && $response['insecure'] )
$classes[] = 'browser-insecure';
return $classes;
}
/**
* Check if the user needs a browser update
*
* @since 3.2.0
*
* @return array|bool False on failure, array of browser data on success.
*/
function wp_check_browser_version() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
return false;
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
// include an unmodified $wp_version
include( ABSPATH . WPINC . '/version.php' );
$url = 'http://api.wordpress.org/core/browse-happy/1.1/';
$options = array(
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' )
);
if ( wp_http_supports( array( 'ssl' ) ) ) {
$url = set_url_scheme( $url, 'https' );
}
$response = wp_remote_post( $url, $options );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
return false;
/**
* Response should be an array with:
* 'platform' - string - A user-friendly platform name, if it can be determined
* 'name' - string - A user-friendly browser name
* 'version' - string - The version of the browser the user is using
* 'current_version' - string - The most recent version of the browser
* 'upgrade' - boolean - Whether the browser needs an upgrade
* 'insecure' - boolean - Whether the browser is deemed insecure
* 'update_url' - string - The url to visit to upgrade
* 'img_src' - string - An image representing the browser
* 'img_src_ssl' - string - An image (over SSL) representing the browser
*/
$response = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $response ) )
return false;
set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
}
return $response;
}
/**
* Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
*/
function wp_dashboard_empty() {}
/**
* Displays a welcome panel to introduce users to WordPress.
*
* @since 3.3.0
*/
function wp_welcome_panel() {
?>
<div class="welcome-panel-content">
<h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
<p class="about-description"><?php _e( 'We’ve assembled some links to get you started:' ); ?></p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<?php if ( current_user_can( 'customize' ) ) : ?>
<h3><?php _e( 'Get Started' ); ?></h3>
<a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php endif; ?>
<a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
<?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?>
<p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), $themes_link ); ?></p>
<?php endif; ?>
</div>
<div class="welcome-panel-column">
<h3><?php _e( 'Next Steps' ); ?></h3>
<ul>
<?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<?php else : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h3><?php _e( 'More Actions' ); ?></h3>
<ul>
<?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?>
<li><div class="welcome-icon welcome-widgets-menus"><?php
if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) {
printf( __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ),
admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) );
} elseif ( current_theme_supports( 'widgets' ) ) {
echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>';
} else {
echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>';
}
?></div></li>
<?php endif; ?>
<?php if ( current_user_can( 'manage_options' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
</ul>
</div>
</div>
</div>
<?php
}
home/xbodynamge/lebauwcentre/wp-admin/includes/dashboard.php 0000644 00000165674 15112446611 0020317 0 ustar 00 <?php
/**
* WordPress Dashboard Widget Administration Screen API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Registers dashboard widgets.
*
* Handles POST data, sets up filters.
*
* @since 2.5.0
*
* @global array $wp_registered_widgets
* @global array $wp_registered_widget_controls
* @global array $wp_dashboard_control_callbacks
*/
function wp_dashboard_setup() {
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array();
$screen = get_current_screen();
/* Register Widgets and Controls */
$response = wp_check_browser_version();
if ( $response && $response['upgrade'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
if ( $response['insecure'] ) {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
} else {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
}
}
// PHP Version.
$response = wp_check_php_version();
if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] && current_user_can( 'update_php' ) ) {
add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' );
}
// Right Now
if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
}
if ( is_network_admin() ) {
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
}
// Activity Widget
if ( is_blog_admin() ) {
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
}
// QuickPress Widget
if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
$quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) );
wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
}
// WordPress Events and News
wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' );
if ( is_network_admin() ) {
/**
* Fires after core widgets for the Network Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_network_dashboard_setup' );
/**
* Filters the list of widgets to load for the Network Admin dashboard.
*
* @since 3.1.0
*
* @param string[] $dashboard_widgets An array of dashboard widget IDs.
*/
$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
} elseif ( is_user_admin() ) {
/**
* Fires after core widgets for the User Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_user_dashboard_setup' );
/**
* Filters the list of widgets to load for the User Admin dashboard.
*
* @since 3.1.0
*
* @param string[] $dashboard_widgets An array of dashboard widget IDs.
*/
$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
} else {
/**
* Fires after core widgets for the admin dashboard have been registered.
*
* @since 2.5.0
*/
do_action( 'wp_dashboard_setup' );
/**
* Filters the list of widgets to load for the admin dashboard.
*
* @since 2.5.0
*
* @param string[] $dashboard_widgets An array of dashboard widget IDs.
*/
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
}
foreach ( $dashboard_widgets as $widget_id ) {
$name = empty( $wp_registered_widgets[ $widget_id ]['all_link'] ) ? $wp_registered_widgets[ $widget_id ]['name'] : $wp_registered_widgets[ $widget_id ]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __( 'View all' ) . '</a>';
wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] );
}
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/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
/** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'side', '' );
}
/**
* Adds a new dashboard widget.
*
* @since 2.7.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param string $widget_id Widget ID (used in the 'id' attribute for the widget).
* @param string $widget_name Title of the widget.
* @param callable $callback Function that fills the widget with the desired content.
* The function should echo its output.
* @param callable $control_callback Optional. Function that outputs controls for the widget. Default null.
* @param array $callback_args Optional. Data that should be set as the $args property of the widget array
* (which is the second parameter passed to your callback). Default null.
*/
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {
$screen = get_current_screen();
global $wp_dashboard_control_callbacks;
$private_callback_args = array( '__widget_basename' => $widget_name );
if ( is_null( $callback_args ) ) {
$callback_args = $private_callback_args;
} elseif ( is_array( $callback_args ) ) {
$callback_args = array_merge( $callback_args, $private_callback_args );
}
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>';
}
}
$side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
$location = 'normal';
if ( in_array( $widget_id, $side_widgets ) ) {
$location = 'side';
}
$high_priority_widgets = array( 'dashboard_browser_nag', 'dashboard_php_nag' );
$priority = 'core';
if ( in_array( $widget_id, $high_priority_widgets, true ) ) {
$priority = 'high';
}
add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );
}
/**
* Outputs controls for the current dashboard widget.
*
* @access private
* @since 2.7.0
*
* @param mixed $dashboard
* @param array $meta_box
*/
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">';
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>';
}
/**
* Displays the dashboard.
*
* @since 2.5.0
*/
function wp_dashboard() {
$screen = get_current_screen();
$columns = absint( $screen->get_columns() );
$columns_css = '';
if ( $columns ) {
$columns_css = " columns-$columns";
}
?>
<div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>">
<div id="postbox-container-1" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
</div>
<div id="postbox-container-2" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'side', '' ); ?>
</div>
<div id="postbox-container-3" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column3', '' ); ?>
</div>
<div id="postbox-container-4" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column4', '' ); ?>
</div>
</div>
<?php
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
}
//
// Dashboard Widgets
//
/**
* Dashboard widget that displays some basic stats about the site.
*
* Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8.
*
* @since 2.7.0
*/
function wp_dashboard_right_now() {
?>
<div class="main">
<ul>
<?php
// Posts and Pages
foreach ( array( 'post', 'page' ) as $post_type ) {
$num_posts = wp_count_posts( $post_type );
if ( $num_posts && $num_posts->publish ) {
if ( 'post' == $post_type ) {
$text = _n( '%s Post', '%s Posts', $num_posts->publish );
} else {
$text = _n( '%s Page', '%s Pages', $num_posts->publish );
}
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
$post_type_object = get_post_type_object( $post_type );
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
} else {
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
}
}
}
// Comments
$num_comm = wp_count_comments();
if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
?>
<li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
<?php
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
/* translators: %s: number of comments in moderation */
$text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n );
?>
<li class="comment-mod-count
<?php
if ( ! $num_comm->moderated ) {
echo ' hidden';
}
?>
"><a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a></li>
<?php
}
/**
* Filters the array of extra elements to list in the 'At a Glance'
* dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'. Each element
* is wrapped in list-item tags on output.
*
* @since 3.8.0
*
* @param string[] $items Array of extra 'At a Glance' widget items.
*/
$elements = apply_filters( 'dashboard_glance_items', array() );
if ( $elements ) {
echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n";
}
?>
</ul>
<?php
update_right_now_message();
// Check if search engines are asked not to index this site.
if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) {
/**
* Filters the link title attribute for the 'Search Engines Discouraged'
* message displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
* @since 4.5.0 The default for `$title` was updated to an empty string.
*
* @param string $title Default attribute text.
*/
$title = apply_filters( 'privacy_on_link_title', '' );
/**
* Filters the link label for the 'Search Engines Discouraged' message
* displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
*
* @param string $content Default text.
*/
$content = apply_filters( 'privacy_on_link_text', __( 'Search Engines Discouraged' ) );
$title_attr = '' === $title ? '' : " title='$title'";
echo "<p><a href='options-reading.php'$title_attr>$content</a></p>";
}
?>
</div>
<?php
/*
* activity_box_end has a core action, but only prints content when multisite.
* Using an output buffer is the only way to really check if anything's displayed here.
*/
ob_start();
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.5.0
*/
do_action( 'rightnow_end' );
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.0.0
*/
do_action( 'activity_box_end' );
$actions = ob_get_clean();
if ( ! empty( $actions ) ) :
?>
<div class="sub">
<?php echo $actions; ?>
</div>
<?php
endif;
}
/**
* @since 3.1.0
*/
function wp_network_dashboard_right_now() {
$actions = array();
if ( current_user_can( 'create_sites' ) ) {
$actions['create-site'] = '<a href="' . network_admin_url( 'site-new.php' ) . '">' . __( 'Create a New Site' ) . '</a>';
}
if ( current_user_can( 'create_users' ) ) {
$actions['create-user'] = '<a href="' . network_admin_url( 'user-new.php' ) . '">' . __( 'Create a New User' ) . '</a>';
}
$c_users = get_user_count();
$c_blogs = get_blog_count();
/* translators: %s: number of users on the network */
$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
/* translators: %s: number of sites on the network */
$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
/* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */
$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
if ( $actions ) {
echo '<ul class="subsubsub">';
foreach ( $actions as $class => $action ) {
$actions[ $class ] = "\t<li class='$class'>$action";
}
echo implode( " |</li>\n", $actions ) . "</li>\n";
echo '</ul>';
}
?>
<br class="clear" />
<p class="youhave"><?php echo $sentence; ?></p>
<?php
/**
* Fires in the Network Admin 'Right Now' dashboard widget
* just before the user and site search form fields.
*
* @since MU (3.0.0)
*/
do_action( 'wpmuadminresult' );
?>
<form action="<?php echo network_admin_url( 'users.php' ); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?>
</p>
</form>
<form action="<?php echo network_admin_url( 'sites.php' ); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?>
</p>
</form>
<?php
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_rightnow_end' );
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_activity_box_end' );
}
/**
* The Quick Draft widget display and creation of drafts.
*
* @since 3.8.0
*
* @global int $post_ID
*
* @param string $error_msg Optional. Error message. Default false.
*/
function wp_dashboard_quick_press( $error_msg = false ) {
global $post_ID;
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
if ( $last_post_id ) {
$post = get_post( $last_post_id );
if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
$post = get_default_post_to_edit( 'post', true );
update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
} else {
$post->post_title = ''; // Remove the auto draft title
}
} else {
$post = get_default_post_to_edit( 'post', true );
$user_id = get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
}
}
$post_ID = (int) $post->ID;
?>
<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
<?php if ( $error_msg ) : ?>
<div class="error"><?php echo $error_msg; ?></div>
<?php endif; ?>
<div class="input-text-wrap" id="title-wrap">
<label for="title">
<?php
/** This filter is documented in wp-admin/edit-form-advanced.php */
echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
?>
</label>
<input type="text" name="post_title" id="title" autocomplete="off" />
</div>
<div class="textarea-wrap" id="description-wrap">
<label for="content"><?php _e( 'Content' ); ?></label>
<textarea name="content" id="content" placeholder="<?php esc_attr_e( 'What’s on your mind?' ); ?>" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
</div>
<p class="submit">
<input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />
<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
<input type="hidden" name="post_type" value="post" />
<?php wp_nonce_field( 'add-post' ); ?>
<?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>
<br class="clear" />
</p>
</form>
<?php
wp_dashboard_recent_drafts();
}
/**
* Show recent drafts of the user on the dashboard.
*
* @since 2.7.0
*
* @param WP_Post[] $drafts Optional. Array of posts to display. Default false.
*/
function wp_dashboard_recent_drafts( $drafts = false ) {
if ( ! $drafts ) {
$query_args = array(
'post_type' => 'post',
'post_status' => 'draft',
'author' => get_current_user_id(),
'posts_per_page' => 4,
'orderby' => 'modified',
'order' => 'DESC',
);
/**
* Filters the post query arguments for the 'Recent Drafts' dashboard widget.
*
* @since 4.4.0
*
* @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
*/
$query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
$drafts = get_posts( $query_args );
if ( ! $drafts ) {
return;
}
}
echo '<div class="drafts">';
if ( count( $drafts ) > 3 ) {
echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . __( 'View all drafts' ) . "</a></p>\n";
}
echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
$drafts = array_slice( $drafts, 0, 3 );
foreach ( $drafts as $draft ) {
$url = get_edit_post_link( $draft->ID );
$title = _draft_or_post_title( $draft->ID );
echo "<li>\n";
/* translators: %s: post title */
echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
echo '<p>' . $the_content . '</p>';
}
echo "</li>\n";
}
echo "</ul>\n</div>";
}
/**
* Outputs a row for the Recent Comments widget.
*
* @access private
* @since 2.7.0
*
* @global WP_Comment $comment
*
* @param WP_Comment $comment The current comment.
* @param bool $show_date Optional. Whether to display the date.
*/
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$GLOBALS['comment'] = clone $comment;
if ( $comment->comment_post_ID > 0 ) {
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
$comment_post_url = get_the_permalink( $comment->comment_post_ID );
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
} else {
$comment_post_link = '';
}
$actions_string = '';
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
// Pre-order it: Approve | Reply | Edit | Spam | Trash.
$actions = array(
'approve' => '',
'unapprove' => '',
'reply' => '',
'edit' => '',
'spam' => '',
'trash' => '',
'delete' => '',
'view' => '',
);
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a aria-button-if-js' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>';
$actions['reply'] = '<button type="button" onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\'' . $comment->comment_post_ID . '\');" class="vim-r button-link hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '">' . __( 'Reply' ) . '</button>';
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
if ( ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
}
$actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>';
/**
* Filters the action links displayed for each comment in the 'Recent Comments'
* dashboard widget.
*
* @since 2.6.0
*
* @param string[] $actions An array of comment actions. Default actions include:
* 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
* 'Delete', and 'Trash'.
* @param WP_Comment $comment The comment object.
*/
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
$i = 0;
foreach ( $actions as $action => $link ) {
++$i;
( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span
if ( 'reply' == $action || 'quickedit' == $action ) {
$action .= ' hide-if-no-js';
}
if ( 'view' === $action && '1' !== $comment->comment_approved ) {
$action .= ' hidden';
}
$actions_string .= "<span class='$action'>$sep$link</span>";
}
}
?>
<li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
<?php echo get_avatar( $comment, 50, 'mystery' ); ?>
<?php if ( ! $comment->comment_type || 'comment' == $comment->comment_type ) : ?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Comments might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
__( 'From %1$s on %2$s %3$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: comment author, 2: notification if the comment is pending */
__( 'From %1$s %2$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<?php
else :
switch ( $comment->comment_type ) {
case 'pingback':
$type = __( 'Pingback' );
break;
case 'trackback':
$type = __( 'Trackback' );
break;
default:
$type = ucwords( $comment->comment_type );
}
$type = esc_html( $type );
?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
_x( '%1$s on %2$s %3$s', 'dashboard' ),
"<strong>$type</strong>",
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: type of comment, 2: notification if the comment is pending */
_x( '%1$s %2$s', 'dashboard' ),
"<strong>$type</strong>",
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<p class="comment-author"><?php comment_author_link( $comment ); ?></p>
<?php endif; // comment_type ?>
<blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
<?php if ( $actions_string ) : ?>
<p class="row-actions"><?php echo $actions_string; ?></p>
<?php endif; ?>
</div>
</li>
<?php
$GLOBALS['comment'] = null;
}
/**
* Callback function for Activity widget.
*
* @since 3.8.0
*/
function wp_dashboard_site_activity() {
echo '<div id="activity-widget">';
$future_posts = wp_dashboard_recent_posts(
array(
'max' => 5,
'status' => 'future',
'order' => 'ASC',
'title' => __( 'Publishing Soon' ),
'id' => 'future-posts',
)
);
$recent_posts = wp_dashboard_recent_posts(
array(
'max' => 5,
'status' => 'publish',
'order' => 'DESC',
'title' => __( 'Recently Published' ),
'id' => 'published-posts',
)
);
$recent_comments = wp_dashboard_recent_comments();
if ( ! $future_posts && ! $recent_posts && ! $recent_comments ) {
echo '<div class="no-activity">';
echo '<p class="smiley" aria-hidden="true"></p>';
echo '<p>' . __( 'No activity yet!' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
/**
* Generates Publishing Soon and Recently Published sections.
*
* @since 3.8.0
*
* @param array $args {
* An array of query and display arguments.
*
* @type int $max Number of posts to display.
* @type string $status Post status.
* @type string $order Designates ascending ('ASC') or descending ('DESC') order.
* @type string $title Section title.
* @type string $id The container id.
* }
* @return bool False if no posts were found. True otherwise.
*/
function wp_dashboard_recent_posts( $args ) {
$query_args = array(
'post_type' => 'post',
'post_status' => $args['status'],
'orderby' => 'date',
'order' => $args['order'],
'posts_per_page' => intval( $args['max'] ),
'no_found_rows' => true,
'cache_results' => false,
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
);
/**
* Filters the query arguments used for the Recent Posts widget.
*
* @since 4.2.0
*
* @param array $query_args The arguments passed to WP_Query to produce the list of posts.
*/
$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
$posts = new WP_Query( $query_args );
if ( $posts->have_posts() ) {
echo '<div id="' . $args['id'] . '" class="activity-block">';
echo '<h3>' . $args['title'] . '</h3>';
echo '<ul>';
$today = current_time( 'Y-m-d' );
$tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
$year = current_time( 'Y' );
while ( $posts->have_posts() ) {
$posts->the_post();
$time = get_the_time( 'U' );
if ( date( 'Y-m-d', $time ) == $today ) {
$relative = __( 'Today' );
} elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
$relative = __( 'Tomorrow' );
} elseif ( date( 'Y', $time ) !== $year ) {
/* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS Y' ), $time );
} else {
/* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS' ), $time );
}
// Use the post edit link for those who can edit, the permalink otherwise.
$recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();
$draft_or_post_title = _draft_or_post_title();
printf(
'<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
/* translators: 1: relative date, 2: time */
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ),
$recent_post_link,
/* translators: %s: post title */
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ),
$draft_or_post_title
);
}
echo '</ul>';
echo '</div>';
} else {
return false;
}
wp_reset_postdata();
return true;
}
/**
* Show Comments section.
*
* @since 3.8.0
*
* @param int $total_items Optional. Number of comments to query. Default 5.
* @return bool False if no comments were found. True otherwise.
*/
function wp_dashboard_recent_comments( $total_items = 5 ) {
// Select all comment types and filter out spam later for better query performance.
$comments = array();
$comments_query = array(
'number' => $total_items * 5,
'offset' => 0,
);
if ( ! current_user_can( 'edit_posts' ) ) {
$comments_query['status'] = 'approve';
}
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
if ( ! is_array( $possible ) ) {
break;
}
foreach ( $possible as $comment ) {
if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) {
continue;
}
$comments[] = $comment;
if ( count( $comments ) == $total_items ) {
break 2;
}
}
$comments_query['offset'] += $comments_query['number'];
$comments_query['number'] = $total_items * 10;
}
if ( $comments ) {
echo '<div id="latest-comments" class="activity-block">';
echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
foreach ( $comments as $comment ) {
$comment_post = get_post( $comment->comment_post_ID );
if (
current_user_can( 'edit_post', $comment->comment_post_ID ) ||
(
empty( $comment_post->post_password ) &&
current_user_can( 'read_post', $comment->comment_post_ID )
)
) {
_wp_dashboard_recent_comments_row( $comment );
}
}
echo '</ul>';
if ( current_user_can( 'edit_posts' ) ) {
echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>';
_get_list_table( 'WP_Comments_List_Table' )->views();
}
wp_comment_reply( -1, false, 'dashboard', false );
wp_comment_trashnotice();
echo '</div>';
} else {
return false;
}
return true;
}
/**
* Display generic dashboard RSS widget feed.
*
* @since 2.5.0
*
* @param string $widget_id
*/
function wp_dashboard_rss_output( $widget_id ) {
$widgets = get_option( 'dashboard_widget_options' );
echo '<div class="rss-widget">';
wp_widget_rss_output( $widgets[ $widget_id ] );
echo '</div>';
}
/**
* Checks to see if all of the feed url in $check_urls are cached.
*
* If $check_urls is empty, look for the rss feed url found in the dashboard
* widget options of $widget_id. If cached, call $callback, a function that
* echoes out output for this widget. If not cache, echo a "Loading..." stub
* which is later replaced by Ajax call (see top of /wp-admin/index.php)
*
* @since 2.5.0
*
* @param string $widget_id
* @param callable $callback
* @param array $check_urls RSS feeds
* @return bool False on failure. True on success.
*/
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
$doing_ajax = wp_doing_ajax();
if ( empty( $check_urls ) ) {
$widgets = get_option( 'dashboard_widget_options' );
if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) {
echo $loading;
return false;
}
$check_urls = array( $widgets[ $widget_id ]['url'] );
}
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
if ( false !== ( $output = get_transient( $cache_key ) ) ) {
echo $output;
return true;
}
if ( ! $doing_ajax ) {
echo $loading;
return false;
}
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 3 );
array_unshift( $args, $widget_id, $check_urls );
ob_start();
call_user_func_array( $callback, $args );
set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
}
return true;
}
//
// Dashboard Widgets Controls
//
/**
* Calls widget control callback.
*
* @since 2.5.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param int $widget_control_id Registered Widget ID.
*/
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
global $wp_dashboard_control_callbacks;
if ( is_scalar( $widget_control_id ) && $widget_control_id && isset( $wp_dashboard_control_callbacks[ $widget_control_id ] ) && is_callable( $wp_dashboard_control_callbacks[ $widget_control_id ] ) ) {
call_user_func(
$wp_dashboard_control_callbacks[ $widget_control_id ],
'',
array(
'id' => $widget_control_id,
'callback' => $wp_dashboard_control_callbacks[ $widget_control_id ],
)
);
}
}
/**
* The RSS dashboard widget control.
*
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
* from RSS-type widgets.
*
* @since 2.5.0
*
* @param string $widget_id
* @param array $form_inputs
*/
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( ! $widget_options = get_option( 'dashboard_widget_options' ) ) {
$widget_options = array();
}
if ( ! isset( $widget_options[ $widget_id ] ) ) {
$widget_options[ $widget_id ] = array();
}
$number = 1; // Hack to use wp_widget_rss_form()
$widget_options[ $widget_id ]['number'] = $number;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) {
$_POST['widget-rss'][ $number ] = wp_unslash( $_POST['widget-rss'][ $number ] );
$widget_options[ $widget_id ] = wp_widget_rss_process( $_POST['widget-rss'][ $number ] );
$widget_options[ $widget_id ]['number'] = $number;
// Title is optional. If black, fill it if possible.
if ( ! $widget_options[ $widget_id ]['title'] && isset( $_POST['widget-rss'][ $number ]['title'] ) ) {
$rss = fetch_feed( $widget_options[ $widget_id ]['url'] );
if ( is_wp_error( $rss ) ) {
$widget_options[ $widget_id ]['title'] = htmlentities( __( 'Unknown Feed' ) );
} else {
$widget_options[ $widget_id ]['title'] = htmlentities( strip_tags( $rss->get_title() ) );
$rss->__destruct();
unset( $rss );
}
}
update_option( 'dashboard_widget_options', $widget_options );
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
delete_transient( $cache_key );
}
wp_widget_rss_form( $widget_options[ $widget_id ], $form_inputs );
}
/**
* Renders the Events and News dashboard widget.
*
* @since 4.8.0
*/
function wp_dashboard_events_news() {
wp_print_community_events_markup();
?>
<div class="wordpress-news hide-if-no-js">
<?php wp_dashboard_primary(); ?>
</div>
<p class="community-events-footer">
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://make.wordpress.org/community/meetups-landing-page',
__( 'Meetups' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://central.wordcamp.org/schedule/',
__( 'WordCamps' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
__( 'News' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
</p>
<?php
}
/**
* Prints the markup for the Community Events section of the Events and News Dashboard widget.
*
* @since 4.8.0
*/
function wp_print_community_events_markup() {
?>
<div class="community-events-errors notice notice-error inline hide-if-js">
<p class="hide-if-js">
<?php _e( 'This widget requires JavaScript.' ); ?>
</p>
<p class="community-events-error-occurred" aria-hidden="true">
<?php _e( 'An error occurred. Please try again.' ); ?>
</p>
<p class="community-events-could-not-locate" aria-hidden="true"></p>
</div>
<div class="community-events-loading hide-if-no-js">
<?php _e( 'Loading…' ); ?>
</div>
<?php
/*
* Hide the main element when the page first loads, because the content
* won't be ready until wp.communityEvents.renderEventsTemplate() has run.
*/
?>
<div id="community-events" class="community-events" aria-hidden="true">
<div class="activity-block">
<p>
<span id="community-events-location-message"></span>
<button class="button-link community-events-toggle-location" aria-label="<?php esc_attr_e( 'Edit city' ); ?>" aria-expanded="false">
<span class="dashicons dashicons-edit"></span>
</button>
</p>
<form class="community-events-form" aria-hidden="true" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post">
<label for="community-events-location">
<?php _e( 'City:' ); ?>
</label>
<?php
/* translators: Replace with a city related to your locale.
* Test that it matches the expected location and has upcoming
* events before including it. If no cities related to your
* locale have events, then use a city related to your locale
* that would be recognizable to most users. Use only the city
* name itself, without any region or country. Use the endonym
* (native locale name) instead of the English name if possible.
*/
?>
<input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" />
<?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?>
<button class="community-events-cancel button-link" type="button" aria-expanded="false">
<?php _e( 'Cancel' ); ?>
</button>
<span class="spinner"></span>
</form>
</div>
<ul class="community-events-results activity-block last"></ul>
</div>
<?php
}
/**
* Renders the events templates for the Event and News widget.
*
* @since 4.8.0
*/
function wp_print_community_events_templates() {
?>
<script id="tmpl-community-events-attend-event-near" type="text/template">
<?php
printf(
/* translators: %s: the name of a city */
__( 'Attend an upcoming event near %s.' ),
'<strong>{{ data.location.description }}</strong>'
);
?>
</script>
<script id="tmpl-community-events-could-not-locate" type="text/template">
<?php
printf(
/* translators: %s is the name of the city we couldn't locate.
* Replace the examples with cities in your locale, but test
* that they match the expected location before including them.
* Use endonyms (native locale names) whenever possible.
*/
__( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
'<em>{{data.unknownCity}}</em>'
);
?>
</script>
<script id="tmpl-community-events-event-list" type="text/template">
<# _.each( data.events, function( event ) { #>
<li class="event event-{{ event.type }} wp-clearfix">
<div class="event-info">
<div class="dashicons event-icon" aria-hidden="true"></div>
<div class="event-info-inner">
<a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
<span class="event-city">{{ event.location.location }}</span>
</div>
</div>
<div class="event-date-time">
<span class="event-date">{{ event.formatted_date }}</span>
<# if ( 'meetup' === event.type ) { #>
<span class="event-time">{{ event.formatted_time }}</span>
<# } #>
</div>
</li>
<# } ) #>
</script>
<script id="tmpl-community-events-no-upcoming-events" type="text/template">
<li class="event-none">
<# if ( data.location.description ) { #>
<?php
printf(
/* translators: 1: the city the user searched for, 2: meetup organization documentation URL */
__( 'There aren’t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ),
'{{ data.location.description }}',
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
);
?>
<# } else { #>
<?php
printf(
/* translators: %s: meetup organization documentation URL */
__( 'There aren’t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ),
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
);
?>
<# } #>
</li>
</script>
<?php
}
/**
* 'WordPress Events and News' dashboard widget.
*
* @since 2.7.0
* @since 4.8.0 Removed popular plugins feed.
*/
function wp_dashboard_primary() {
$feeds = array(
'news' => array(
/**
* Filters the primary link URL for the 'WordPress Events and News' dashboard widget.
*
* @since 2.5.0
*
* @param string $link The widget's primary link URL.
*/
'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
/**
* Filters the primary feed URL for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's primary feed URL.
*/
'url' => apply_filters( 'dashboard_primary_feed', __( 'https://wordpress.org/news/feed/' ) ),
/**
* Filters the primary link title for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's primary link.
*/
'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
'items' => 1,
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
),
'planet' => array(
/**
* Filters the secondary link URL for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $link The widget's secondary link URL.
*/
'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
/**
* Filters the secondary feed URL for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's secondary feed URL.
*/
'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
/**
* Filters the secondary link title for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's secondary link.
*/
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
/**
* Filters the number of secondary link items for the 'WordPress Events and News' dashboard widget.
*
* @since 4.4.0
*
* @param string $items How many items to show in the secondary feed.
*/
'items' => apply_filters( 'dashboard_secondary_items', 3 ),
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
),
);
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds );
}
/**
* Display the WordPress events and news feeds.
*
* @since 3.8.0
* @since 4.8.0 Removed popular plugins feed.
*
* @param string $widget_id Widget ID.
* @param array $feeds Array of RSS feeds.
*/
function wp_dashboard_primary_output( $widget_id, $feeds ) {
foreach ( $feeds as $type => $args ) {
$args['type'] = $type;
echo '<div class="rss-widget">';
wp_widget_rss_output( $args['url'], $args );
echo '</div>';
}
}
/**
* Display file upload quota on dashboard.
*
* Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now().
*
* @since 3.0.0
*
* @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
*/
function wp_dashboard_quota() {
if ( ! is_multisite() || ! current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) {
return true;
}
$quota = get_space_allowed();
$used = get_space_used();
if ( $used > $quota ) {
$percentused = '100';
} else {
$percentused = ( $used / $quota ) * 100;
}
$used_class = ( $percentused >= 70 ) ? ' warning' : '';
$used = round( $used, 2 );
$percentused = number_format( $percentused );
?>
<h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
<div class="mu-storage">
<ul>
<li class="storage-count">
<?php
$text = sprintf(
/* translators: %s: number of megabytes */
__( '%s MB Space Allowed' ),
number_format_i18n( $quota )
);
printf(
'<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
);
?>
</li><li class="storage-count <?php echo $used_class; ?>">
<?php
$text = sprintf(
/* translators: 1: number of megabytes, 2: percentage */
__( '%1$s MB (%2$s%%) Space Used' ),
number_format_i18n( $used, 2 ),
$percentused
);
printf(
'<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
);
?>
</li>
</ul>
</div>
<?php
}
// Display Browser Nag Meta Box
function wp_dashboard_browser_nag() {
$notice = '';
$response = wp_check_browser_version();
if ( $response ) {
if ( $response['insecure'] ) {
/* translators: %s: browser name and link */
$msg = sprintf(
__( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
} else {
/* translators: %s: browser name and link */
$msg = sprintf(
__( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
}
$browser_nag_class = '';
if ( ! empty( $response['img_src'] ) ) {
$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) ) ? $response['img_src_ssl'] : $response['img_src'];
$notice .= '<div class="alignright browser-icon"><a href="' . esc_attr( $response['update_url'] ) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
$browser_nag_class = ' has-browser-icon';
}
$notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
$browsehappy = 'https://browsehappy.com/';
$locale = get_user_locale();
if ( 'en_US' !== $locale ) {
$browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
}
$notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>';
$notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
$notice .= '<div class="clear"></div>';
}
/**
* Filters the notice output for the 'Browse Happy' nag meta box.
*
* @since 3.2.0
*
* @param string $notice The notice content.
* @param array $response An array containing web browser information. See `wp_check_browser_version()`.
*/
echo apply_filters( 'browse-happy-notice', $notice, $response );
}
/**
* @since 3.2.0
*
* @param array $classes
* @return array
*/
function dashboard_browser_nag_class( $classes ) {
$response = wp_check_browser_version();
if ( $response && $response['insecure'] ) {
$classes[] = 'browser-insecure';
}
return $classes;
}
/**
* Check if the user needs a browser update
*
* @since 3.2.0
*
* @return array|bool False on failure, array of browser data on success.
*/
function wp_check_browser_version() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
if ( false === ( $response = get_site_transient( 'browser_' . $key ) ) ) {
// include an unmodified $wp_version
include( ABSPATH . WPINC . '/version.php' );
$url = 'http://api.wordpress.org/core/browse-happy/1.1/';
$options = array(
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
);
if ( wp_http_supports( array( 'ssl' ) ) ) {
$url = set_url_scheme( $url, 'https' );
}
$response = wp_remote_post( $url, $options );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
return false;
}
/**
* Response should be an array with:
* 'platform' - string - A user-friendly platform name, if it can be determined
* 'name' - string - A user-friendly browser name
* 'version' - string - The version of the browser the user is using
* 'current_version' - string - The most recent version of the browser
* 'upgrade' - boolean - Whether the browser needs an upgrade
* 'insecure' - boolean - Whether the browser is deemed insecure
* 'update_url' - string - The url to visit to upgrade
* 'img_src' - string - An image representing the browser
* 'img_src_ssl' - string - An image (over SSL) representing the browser
*/
$response = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $response ) ) {
return false;
}
set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
}
return $response;
}
/**
* Displays the PHP update nag.
*
* @since 5.1.0
*/
function wp_dashboard_php_nag() {
$response = wp_check_php_version();
if ( ! $response ) {
return;
}
if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
$msg = __( 'WordPress has detected that your site is running on an insecure version of PHP.' );
} else {
$msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
}
?>
<p><?php echo $msg; ?></p>
<h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
<p><?php _e( 'PHP is the programming language we use to build and maintain WordPress. Newer versions of PHP are both faster and more secure, so updating will have a positive effect on your site’s performance.' ); ?></p>
<p class="button-container">
<?php
printf(
'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
esc_url( wp_get_update_php_url() ),
__( 'Learn more about updating PHP' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
</p>
<?php
wp_update_php_annotation();
wp_direct_php_update_button();
}
/**
* Adds an additional class to the PHP nag if the current version is insecure.
*
* @since 5.1.0
*
* @param array $classes Metabox classes.
* @return array Modified metabox classes.
*/
function dashboard_php_nag_class( $classes ) {
$response = wp_check_php_version();
if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
$classes[] = 'php-insecure';
}
return $classes;
}
/**
* Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
*/
function wp_dashboard_empty() {}
/**
* Displays a welcome panel to introduce users to WordPress.
*
* @since 3.3.0
*/
function wp_welcome_panel() {
?>
<div class="welcome-panel-content">
<h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
<p class="about-description"><?php _e( 'We’ve assembled some links to get you started:' ); ?></p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<?php if ( current_user_can( 'customize' ) ) : ?>
<h3><?php _e( 'Get Started' ); ?></h3>
<a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php endif; ?>
<a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
<?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?>
<p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), $themes_link ); ?></p>
<?php endif; ?>
</div>
<div class="welcome-panel-column">
<h3><?php _e( 'Next Steps' ); ?></h3>
<ul>
<?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<?php else : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-setup-home">' . __( 'Set up your homepage' ) . '</a>', current_user_can( 'customize' ) ? add_query_arg( 'autofocus[section]', 'static_front_page', admin_url( 'customize.php' ) ) : admin_url( 'options-reading.php' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h3><?php _e( 'More Actions' ); ?></h3>
<ul>
<?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?>
<li><div class="welcome-icon welcome-widgets-menus">
<?php
if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) {
printf(
__( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ),
admin_url( 'widgets.php' ),
admin_url( 'nav-menus.php' )
);
} elseif ( current_theme_supports( 'widgets' ) ) {
echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>';
} else {
echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>';
}
?>
</div></li>
<?php endif; ?>
<?php if ( current_user_can( 'manage_options' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
</ul>
</div>
</div>
</div>
<?php
}
home/xbodynamge/namtation/wp-admin/includes/dashboard.php 0000644 00000165674 15112522622 0017626 0 ustar 00 <?php
/**
* WordPress Dashboard Widget Administration Screen API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Registers dashboard widgets.
*
* Handles POST data, sets up filters.
*
* @since 2.5.0
*
* @global array $wp_registered_widgets
* @global array $wp_registered_widget_controls
* @global array $wp_dashboard_control_callbacks
*/
function wp_dashboard_setup() {
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array();
$screen = get_current_screen();
/* Register Widgets and Controls */
$response = wp_check_browser_version();
if ( $response && $response['upgrade'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
if ( $response['insecure'] ) {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
} else {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
}
}
// PHP Version.
$response = wp_check_php_version();
if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] && current_user_can( 'update_php' ) ) {
add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' );
}
// Right Now
if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
}
if ( is_network_admin() ) {
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
}
// Activity Widget
if ( is_blog_admin() ) {
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
}
// QuickPress Widget
if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
$quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) );
wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
}
// WordPress Events and News
wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' );
if ( is_network_admin() ) {
/**
* Fires after core widgets for the Network Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_network_dashboard_setup' );
/**
* Filters the list of widgets to load for the Network Admin dashboard.
*
* @since 3.1.0
*
* @param string[] $dashboard_widgets An array of dashboard widget IDs.
*/
$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
} elseif ( is_user_admin() ) {
/**
* Fires after core widgets for the User Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_user_dashboard_setup' );
/**
* Filters the list of widgets to load for the User Admin dashboard.
*
* @since 3.1.0
*
* @param string[] $dashboard_widgets An array of dashboard widget IDs.
*/
$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
} else {
/**
* Fires after core widgets for the admin dashboard have been registered.
*
* @since 2.5.0
*/
do_action( 'wp_dashboard_setup' );
/**
* Filters the list of widgets to load for the admin dashboard.
*
* @since 2.5.0
*
* @param string[] $dashboard_widgets An array of dashboard widget IDs.
*/
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
}
foreach ( $dashboard_widgets as $widget_id ) {
$name = empty( $wp_registered_widgets[ $widget_id ]['all_link'] ) ? $wp_registered_widgets[ $widget_id ]['name'] : $wp_registered_widgets[ $widget_id ]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __( 'View all' ) . '</a>';
wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] );
}
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/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
/** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'side', '' );
}
/**
* Adds a new dashboard widget.
*
* @since 2.7.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param string $widget_id Widget ID (used in the 'id' attribute for the widget).
* @param string $widget_name Title of the widget.
* @param callable $callback Function that fills the widget with the desired content.
* The function should echo its output.
* @param callable $control_callback Optional. Function that outputs controls for the widget. Default null.
* @param array $callback_args Optional. Data that should be set as the $args property of the widget array
* (which is the second parameter passed to your callback). Default null.
*/
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {
$screen = get_current_screen();
global $wp_dashboard_control_callbacks;
$private_callback_args = array( '__widget_basename' => $widget_name );
if ( is_null( $callback_args ) ) {
$callback_args = $private_callback_args;
} elseif ( is_array( $callback_args ) ) {
$callback_args = array_merge( $callback_args, $private_callback_args );
}
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>';
}
}
$side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
$location = 'normal';
if ( in_array( $widget_id, $side_widgets ) ) {
$location = 'side';
}
$high_priority_widgets = array( 'dashboard_browser_nag', 'dashboard_php_nag' );
$priority = 'core';
if ( in_array( $widget_id, $high_priority_widgets, true ) ) {
$priority = 'high';
}
add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );
}
/**
* Outputs controls for the current dashboard widget.
*
* @access private
* @since 2.7.0
*
* @param mixed $dashboard
* @param array $meta_box
*/
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">';
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>';
}
/**
* Displays the dashboard.
*
* @since 2.5.0
*/
function wp_dashboard() {
$screen = get_current_screen();
$columns = absint( $screen->get_columns() );
$columns_css = '';
if ( $columns ) {
$columns_css = " columns-$columns";
}
?>
<div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>">
<div id="postbox-container-1" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
</div>
<div id="postbox-container-2" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'side', '' ); ?>
</div>
<div id="postbox-container-3" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column3', '' ); ?>
</div>
<div id="postbox-container-4" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column4', '' ); ?>
</div>
</div>
<?php
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
}
//
// Dashboard Widgets
//
/**
* Dashboard widget that displays some basic stats about the site.
*
* Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8.
*
* @since 2.7.0
*/
function wp_dashboard_right_now() {
?>
<div class="main">
<ul>
<?php
// Posts and Pages
foreach ( array( 'post', 'page' ) as $post_type ) {
$num_posts = wp_count_posts( $post_type );
if ( $num_posts && $num_posts->publish ) {
if ( 'post' == $post_type ) {
$text = _n( '%s Post', '%s Posts', $num_posts->publish );
} else {
$text = _n( '%s Page', '%s Pages', $num_posts->publish );
}
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
$post_type_object = get_post_type_object( $post_type );
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
} else {
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
}
}
}
// Comments
$num_comm = wp_count_comments();
if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
?>
<li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
<?php
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
/* translators: %s: number of comments in moderation */
$text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n );
?>
<li class="comment-mod-count
<?php
if ( ! $num_comm->moderated ) {
echo ' hidden';
}
?>
"><a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a></li>
<?php
}
/**
* Filters the array of extra elements to list in the 'At a Glance'
* dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'. Each element
* is wrapped in list-item tags on output.
*
* @since 3.8.0
*
* @param string[] $items Array of extra 'At a Glance' widget items.
*/
$elements = apply_filters( 'dashboard_glance_items', array() );
if ( $elements ) {
echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n";
}
?>
</ul>
<?php
update_right_now_message();
// Check if search engines are asked not to index this site.
if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) {
/**
* Filters the link title attribute for the 'Search Engines Discouraged'
* message displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
* @since 4.5.0 The default for `$title` was updated to an empty string.
*
* @param string $title Default attribute text.
*/
$title = apply_filters( 'privacy_on_link_title', '' );
/**
* Filters the link label for the 'Search Engines Discouraged' message
* displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
*
* @param string $content Default text.
*/
$content = apply_filters( 'privacy_on_link_text', __( 'Search Engines Discouraged' ) );
$title_attr = '' === $title ? '' : " title='$title'";
echo "<p><a href='options-reading.php'$title_attr>$content</a></p>";
}
?>
</div>
<?php
/*
* activity_box_end has a core action, but only prints content when multisite.
* Using an output buffer is the only way to really check if anything's displayed here.
*/
ob_start();
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.5.0
*/
do_action( 'rightnow_end' );
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.0.0
*/
do_action( 'activity_box_end' );
$actions = ob_get_clean();
if ( ! empty( $actions ) ) :
?>
<div class="sub">
<?php echo $actions; ?>
</div>
<?php
endif;
}
/**
* @since 3.1.0
*/
function wp_network_dashboard_right_now() {
$actions = array();
if ( current_user_can( 'create_sites' ) ) {
$actions['create-site'] = '<a href="' . network_admin_url( 'site-new.php' ) . '">' . __( 'Create a New Site' ) . '</a>';
}
if ( current_user_can( 'create_users' ) ) {
$actions['create-user'] = '<a href="' . network_admin_url( 'user-new.php' ) . '">' . __( 'Create a New User' ) . '</a>';
}
$c_users = get_user_count();
$c_blogs = get_blog_count();
/* translators: %s: number of users on the network */
$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
/* translators: %s: number of sites on the network */
$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
/* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */
$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
if ( $actions ) {
echo '<ul class="subsubsub">';
foreach ( $actions as $class => $action ) {
$actions[ $class ] = "\t<li class='$class'>$action";
}
echo implode( " |</li>\n", $actions ) . "</li>\n";
echo '</ul>';
}
?>
<br class="clear" />
<p class="youhave"><?php echo $sentence; ?></p>
<?php
/**
* Fires in the Network Admin 'Right Now' dashboard widget
* just before the user and site search form fields.
*
* @since MU (3.0.0)
*/
do_action( 'wpmuadminresult' );
?>
<form action="<?php echo network_admin_url( 'users.php' ); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?>
</p>
</form>
<form action="<?php echo network_admin_url( 'sites.php' ); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?>
</p>
</form>
<?php
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_rightnow_end' );
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_activity_box_end' );
}
/**
* The Quick Draft widget display and creation of drafts.
*
* @since 3.8.0
*
* @global int $post_ID
*
* @param string $error_msg Optional. Error message. Default false.
*/
function wp_dashboard_quick_press( $error_msg = false ) {
global $post_ID;
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
if ( $last_post_id ) {
$post = get_post( $last_post_id );
if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
$post = get_default_post_to_edit( 'post', true );
update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
} else {
$post->post_title = ''; // Remove the auto draft title
}
} else {
$post = get_default_post_to_edit( 'post', true );
$user_id = get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
}
}
$post_ID = (int) $post->ID;
?>
<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
<?php if ( $error_msg ) : ?>
<div class="error"><?php echo $error_msg; ?></div>
<?php endif; ?>
<div class="input-text-wrap" id="title-wrap">
<label for="title">
<?php
/** This filter is documented in wp-admin/edit-form-advanced.php */
echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
?>
</label>
<input type="text" name="post_title" id="title" autocomplete="off" />
</div>
<div class="textarea-wrap" id="description-wrap">
<label for="content"><?php _e( 'Content' ); ?></label>
<textarea name="content" id="content" placeholder="<?php esc_attr_e( 'What’s on your mind?' ); ?>" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
</div>
<p class="submit">
<input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />
<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
<input type="hidden" name="post_type" value="post" />
<?php wp_nonce_field( 'add-post' ); ?>
<?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>
<br class="clear" />
</p>
</form>
<?php
wp_dashboard_recent_drafts();
}
/**
* Show recent drafts of the user on the dashboard.
*
* @since 2.7.0
*
* @param WP_Post[] $drafts Optional. Array of posts to display. Default false.
*/
function wp_dashboard_recent_drafts( $drafts = false ) {
if ( ! $drafts ) {
$query_args = array(
'post_type' => 'post',
'post_status' => 'draft',
'author' => get_current_user_id(),
'posts_per_page' => 4,
'orderby' => 'modified',
'order' => 'DESC',
);
/**
* Filters the post query arguments for the 'Recent Drafts' dashboard widget.
*
* @since 4.4.0
*
* @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
*/
$query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
$drafts = get_posts( $query_args );
if ( ! $drafts ) {
return;
}
}
echo '<div class="drafts">';
if ( count( $drafts ) > 3 ) {
echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . __( 'View all drafts' ) . "</a></p>\n";
}
echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
$drafts = array_slice( $drafts, 0, 3 );
foreach ( $drafts as $draft ) {
$url = get_edit_post_link( $draft->ID );
$title = _draft_or_post_title( $draft->ID );
echo "<li>\n";
/* translators: %s: post title */
echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
echo '<p>' . $the_content . '</p>';
}
echo "</li>\n";
}
echo "</ul>\n</div>";
}
/**
* Outputs a row for the Recent Comments widget.
*
* @access private
* @since 2.7.0
*
* @global WP_Comment $comment
*
* @param WP_Comment $comment The current comment.
* @param bool $show_date Optional. Whether to display the date.
*/
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$GLOBALS['comment'] = clone $comment;
if ( $comment->comment_post_ID > 0 ) {
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
$comment_post_url = get_the_permalink( $comment->comment_post_ID );
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
} else {
$comment_post_link = '';
}
$actions_string = '';
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
// Pre-order it: Approve | Reply | Edit | Spam | Trash.
$actions = array(
'approve' => '',
'unapprove' => '',
'reply' => '',
'edit' => '',
'spam' => '',
'trash' => '',
'delete' => '',
'view' => '',
);
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a aria-button-if-js' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>';
$actions['reply'] = '<button type="button" onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\'' . $comment->comment_post_ID . '\');" class="vim-r button-link hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '">' . __( 'Reply' ) . '</button>';
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
if ( ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
}
$actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>';
/**
* Filters the action links displayed for each comment in the 'Recent Comments'
* dashboard widget.
*
* @since 2.6.0
*
* @param string[] $actions An array of comment actions. Default actions include:
* 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
* 'Delete', and 'Trash'.
* @param WP_Comment $comment The comment object.
*/
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
$i = 0;
foreach ( $actions as $action => $link ) {
++$i;
( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span
if ( 'reply' == $action || 'quickedit' == $action ) {
$action .= ' hide-if-no-js';
}
if ( 'view' === $action && '1' !== $comment->comment_approved ) {
$action .= ' hidden';
}
$actions_string .= "<span class='$action'>$sep$link</span>";
}
}
?>
<li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
<?php echo get_avatar( $comment, 50, 'mystery' ); ?>
<?php if ( ! $comment->comment_type || 'comment' == $comment->comment_type ) : ?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Comments might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
__( 'From %1$s on %2$s %3$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: comment author, 2: notification if the comment is pending */
__( 'From %1$s %2$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<?php
else :
switch ( $comment->comment_type ) {
case 'pingback':
$type = __( 'Pingback' );
break;
case 'trackback':
$type = __( 'Trackback' );
break;
default:
$type = ucwords( $comment->comment_type );
}
$type = esc_html( $type );
?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
_x( '%1$s on %2$s %3$s', 'dashboard' ),
"<strong>$type</strong>",
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: type of comment, 2: notification if the comment is pending */
_x( '%1$s %2$s', 'dashboard' ),
"<strong>$type</strong>",
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<p class="comment-author"><?php comment_author_link( $comment ); ?></p>
<?php endif; // comment_type ?>
<blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
<?php if ( $actions_string ) : ?>
<p class="row-actions"><?php echo $actions_string; ?></p>
<?php endif; ?>
</div>
</li>
<?php
$GLOBALS['comment'] = null;
}
/**
* Callback function for Activity widget.
*
* @since 3.8.0
*/
function wp_dashboard_site_activity() {
echo '<div id="activity-widget">';
$future_posts = wp_dashboard_recent_posts(
array(
'max' => 5,
'status' => 'future',
'order' => 'ASC',
'title' => __( 'Publishing Soon' ),
'id' => 'future-posts',
)
);
$recent_posts = wp_dashboard_recent_posts(
array(
'max' => 5,
'status' => 'publish',
'order' => 'DESC',
'title' => __( 'Recently Published' ),
'id' => 'published-posts',
)
);
$recent_comments = wp_dashboard_recent_comments();
if ( ! $future_posts && ! $recent_posts && ! $recent_comments ) {
echo '<div class="no-activity">';
echo '<p class="smiley" aria-hidden="true"></p>';
echo '<p>' . __( 'No activity yet!' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
/**
* Generates Publishing Soon and Recently Published sections.
*
* @since 3.8.0
*
* @param array $args {
* An array of query and display arguments.
*
* @type int $max Number of posts to display.
* @type string $status Post status.
* @type string $order Designates ascending ('ASC') or descending ('DESC') order.
* @type string $title Section title.
* @type string $id The container id.
* }
* @return bool False if no posts were found. True otherwise.
*/
function wp_dashboard_recent_posts( $args ) {
$query_args = array(
'post_type' => 'post',
'post_status' => $args['status'],
'orderby' => 'date',
'order' => $args['order'],
'posts_per_page' => intval( $args['max'] ),
'no_found_rows' => true,
'cache_results' => false,
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
);
/**
* Filters the query arguments used for the Recent Posts widget.
*
* @since 4.2.0
*
* @param array $query_args The arguments passed to WP_Query to produce the list of posts.
*/
$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
$posts = new WP_Query( $query_args );
if ( $posts->have_posts() ) {
echo '<div id="' . $args['id'] . '" class="activity-block">';
echo '<h3>' . $args['title'] . '</h3>';
echo '<ul>';
$today = current_time( 'Y-m-d' );
$tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
$year = current_time( 'Y' );
while ( $posts->have_posts() ) {
$posts->the_post();
$time = get_the_time( 'U' );
if ( date( 'Y-m-d', $time ) == $today ) {
$relative = __( 'Today' );
} elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
$relative = __( 'Tomorrow' );
} elseif ( date( 'Y', $time ) !== $year ) {
/* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS Y' ), $time );
} else {
/* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS' ), $time );
}
// Use the post edit link for those who can edit, the permalink otherwise.
$recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();
$draft_or_post_title = _draft_or_post_title();
printf(
'<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
/* translators: 1: relative date, 2: time */
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ),
$recent_post_link,
/* translators: %s: post title */
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ),
$draft_or_post_title
);
}
echo '</ul>';
echo '</div>';
} else {
return false;
}
wp_reset_postdata();
return true;
}
/**
* Show Comments section.
*
* @since 3.8.0
*
* @param int $total_items Optional. Number of comments to query. Default 5.
* @return bool False if no comments were found. True otherwise.
*/
function wp_dashboard_recent_comments( $total_items = 5 ) {
// Select all comment types and filter out spam later for better query performance.
$comments = array();
$comments_query = array(
'number' => $total_items * 5,
'offset' => 0,
);
if ( ! current_user_can( 'edit_posts' ) ) {
$comments_query['status'] = 'approve';
}
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
if ( ! is_array( $possible ) ) {
break;
}
foreach ( $possible as $comment ) {
if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) {
continue;
}
$comments[] = $comment;
if ( count( $comments ) == $total_items ) {
break 2;
}
}
$comments_query['offset'] += $comments_query['number'];
$comments_query['number'] = $total_items * 10;
}
if ( $comments ) {
echo '<div id="latest-comments" class="activity-block">';
echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
foreach ( $comments as $comment ) {
$comment_post = get_post( $comment->comment_post_ID );
if (
current_user_can( 'edit_post', $comment->comment_post_ID ) ||
(
empty( $comment_post->post_password ) &&
current_user_can( 'read_post', $comment->comment_post_ID )
)
) {
_wp_dashboard_recent_comments_row( $comment );
}
}
echo '</ul>';
if ( current_user_can( 'edit_posts' ) ) {
echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>';
_get_list_table( 'WP_Comments_List_Table' )->views();
}
wp_comment_reply( -1, false, 'dashboard', false );
wp_comment_trashnotice();
echo '</div>';
} else {
return false;
}
return true;
}
/**
* Display generic dashboard RSS widget feed.
*
* @since 2.5.0
*
* @param string $widget_id
*/
function wp_dashboard_rss_output( $widget_id ) {
$widgets = get_option( 'dashboard_widget_options' );
echo '<div class="rss-widget">';
wp_widget_rss_output( $widgets[ $widget_id ] );
echo '</div>';
}
/**
* Checks to see if all of the feed url in $check_urls are cached.
*
* If $check_urls is empty, look for the rss feed url found in the dashboard
* widget options of $widget_id. If cached, call $callback, a function that
* echoes out output for this widget. If not cache, echo a "Loading..." stub
* which is later replaced by Ajax call (see top of /wp-admin/index.php)
*
* @since 2.5.0
*
* @param string $widget_id
* @param callable $callback
* @param array $check_urls RSS feeds
* @return bool False on failure. True on success.
*/
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
$doing_ajax = wp_doing_ajax();
if ( empty( $check_urls ) ) {
$widgets = get_option( 'dashboard_widget_options' );
if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) {
echo $loading;
return false;
}
$check_urls = array( $widgets[ $widget_id ]['url'] );
}
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
if ( false !== ( $output = get_transient( $cache_key ) ) ) {
echo $output;
return true;
}
if ( ! $doing_ajax ) {
echo $loading;
return false;
}
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 3 );
array_unshift( $args, $widget_id, $check_urls );
ob_start();
call_user_func_array( $callback, $args );
set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
}
return true;
}
//
// Dashboard Widgets Controls
//
/**
* Calls widget control callback.
*
* @since 2.5.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param int $widget_control_id Registered Widget ID.
*/
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
global $wp_dashboard_control_callbacks;
if ( is_scalar( $widget_control_id ) && $widget_control_id && isset( $wp_dashboard_control_callbacks[ $widget_control_id ] ) && is_callable( $wp_dashboard_control_callbacks[ $widget_control_id ] ) ) {
call_user_func(
$wp_dashboard_control_callbacks[ $widget_control_id ],
'',
array(
'id' => $widget_control_id,
'callback' => $wp_dashboard_control_callbacks[ $widget_control_id ],
)
);
}
}
/**
* The RSS dashboard widget control.
*
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
* from RSS-type widgets.
*
* @since 2.5.0
*
* @param string $widget_id
* @param array $form_inputs
*/
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( ! $widget_options = get_option( 'dashboard_widget_options' ) ) {
$widget_options = array();
}
if ( ! isset( $widget_options[ $widget_id ] ) ) {
$widget_options[ $widget_id ] = array();
}
$number = 1; // Hack to use wp_widget_rss_form()
$widget_options[ $widget_id ]['number'] = $number;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) {
$_POST['widget-rss'][ $number ] = wp_unslash( $_POST['widget-rss'][ $number ] );
$widget_options[ $widget_id ] = wp_widget_rss_process( $_POST['widget-rss'][ $number ] );
$widget_options[ $widget_id ]['number'] = $number;
// Title is optional. If black, fill it if possible.
if ( ! $widget_options[ $widget_id ]['title'] && isset( $_POST['widget-rss'][ $number ]['title'] ) ) {
$rss = fetch_feed( $widget_options[ $widget_id ]['url'] );
if ( is_wp_error( $rss ) ) {
$widget_options[ $widget_id ]['title'] = htmlentities( __( 'Unknown Feed' ) );
} else {
$widget_options[ $widget_id ]['title'] = htmlentities( strip_tags( $rss->get_title() ) );
$rss->__destruct();
unset( $rss );
}
}
update_option( 'dashboard_widget_options', $widget_options );
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
delete_transient( $cache_key );
}
wp_widget_rss_form( $widget_options[ $widget_id ], $form_inputs );
}
/**
* Renders the Events and News dashboard widget.
*
* @since 4.8.0
*/
function wp_dashboard_events_news() {
wp_print_community_events_markup();
?>
<div class="wordpress-news hide-if-no-js">
<?php wp_dashboard_primary(); ?>
</div>
<p class="community-events-footer">
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://make.wordpress.org/community/meetups-landing-page',
__( 'Meetups' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://central.wordcamp.org/schedule/',
__( 'WordCamps' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
__( 'News' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
</p>
<?php
}
/**
* Prints the markup for the Community Events section of the Events and News Dashboard widget.
*
* @since 4.8.0
*/
function wp_print_community_events_markup() {
?>
<div class="community-events-errors notice notice-error inline hide-if-js">
<p class="hide-if-js">
<?php _e( 'This widget requires JavaScript.' ); ?>
</p>
<p class="community-events-error-occurred" aria-hidden="true">
<?php _e( 'An error occurred. Please try again.' ); ?>
</p>
<p class="community-events-could-not-locate" aria-hidden="true"></p>
</div>
<div class="community-events-loading hide-if-no-js">
<?php _e( 'Loading…' ); ?>
</div>
<?php
/*
* Hide the main element when the page first loads, because the content
* won't be ready until wp.communityEvents.renderEventsTemplate() has run.
*/
?>
<div id="community-events" class="community-events" aria-hidden="true">
<div class="activity-block">
<p>
<span id="community-events-location-message"></span>
<button class="button-link community-events-toggle-location" aria-label="<?php esc_attr_e( 'Edit city' ); ?>" aria-expanded="false">
<span class="dashicons dashicons-edit"></span>
</button>
</p>
<form class="community-events-form" aria-hidden="true" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post">
<label for="community-events-location">
<?php _e( 'City:' ); ?>
</label>
<?php
/* translators: Replace with a city related to your locale.
* Test that it matches the expected location and has upcoming
* events before including it. If no cities related to your
* locale have events, then use a city related to your locale
* that would be recognizable to most users. Use only the city
* name itself, without any region or country. Use the endonym
* (native locale name) instead of the English name if possible.
*/
?>
<input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" />
<?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?>
<button class="community-events-cancel button-link" type="button" aria-expanded="false">
<?php _e( 'Cancel' ); ?>
</button>
<span class="spinner"></span>
</form>
</div>
<ul class="community-events-results activity-block last"></ul>
</div>
<?php
}
/**
* Renders the events templates for the Event and News widget.
*
* @since 4.8.0
*/
function wp_print_community_events_templates() {
?>
<script id="tmpl-community-events-attend-event-near" type="text/template">
<?php
printf(
/* translators: %s: the name of a city */
__( 'Attend an upcoming event near %s.' ),
'<strong>{{ data.location.description }}</strong>'
);
?>
</script>
<script id="tmpl-community-events-could-not-locate" type="text/template">
<?php
printf(
/* translators: %s is the name of the city we couldn't locate.
* Replace the examples with cities in your locale, but test
* that they match the expected location before including them.
* Use endonyms (native locale names) whenever possible.
*/
__( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
'<em>{{data.unknownCity}}</em>'
);
?>
</script>
<script id="tmpl-community-events-event-list" type="text/template">
<# _.each( data.events, function( event ) { #>
<li class="event event-{{ event.type }} wp-clearfix">
<div class="event-info">
<div class="dashicons event-icon" aria-hidden="true"></div>
<div class="event-info-inner">
<a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
<span class="event-city">{{ event.location.location }}</span>
</div>
</div>
<div class="event-date-time">
<span class="event-date">{{ event.formatted_date }}</span>
<# if ( 'meetup' === event.type ) { #>
<span class="event-time">{{ event.formatted_time }}</span>
<# } #>
</div>
</li>
<# } ) #>
</script>
<script id="tmpl-community-events-no-upcoming-events" type="text/template">
<li class="event-none">
<# if ( data.location.description ) { #>
<?php
printf(
/* translators: 1: the city the user searched for, 2: meetup organization documentation URL */
__( 'There aren’t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ),
'{{ data.location.description }}',
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
);
?>
<# } else { #>
<?php
printf(
/* translators: %s: meetup organization documentation URL */
__( 'There aren’t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ),
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
);
?>
<# } #>
</li>
</script>
<?php
}
/**
* 'WordPress Events and News' dashboard widget.
*
* @since 2.7.0
* @since 4.8.0 Removed popular plugins feed.
*/
function wp_dashboard_primary() {
$feeds = array(
'news' => array(
/**
* Filters the primary link URL for the 'WordPress Events and News' dashboard widget.
*
* @since 2.5.0
*
* @param string $link The widget's primary link URL.
*/
'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
/**
* Filters the primary feed URL for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's primary feed URL.
*/
'url' => apply_filters( 'dashboard_primary_feed', __( 'https://wordpress.org/news/feed/' ) ),
/**
* Filters the primary link title for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's primary link.
*/
'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
'items' => 1,
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
),
'planet' => array(
/**
* Filters the secondary link URL for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $link The widget's secondary link URL.
*/
'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
/**
* Filters the secondary feed URL for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's secondary feed URL.
*/
'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
/**
* Filters the secondary link title for the 'WordPress Events and News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's secondary link.
*/
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
/**
* Filters the number of secondary link items for the 'WordPress Events and News' dashboard widget.
*
* @since 4.4.0
*
* @param string $items How many items to show in the secondary feed.
*/
'items' => apply_filters( 'dashboard_secondary_items', 3 ),
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
),
);
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds );
}
/**
* Display the WordPress events and news feeds.
*
* @since 3.8.0
* @since 4.8.0 Removed popular plugins feed.
*
* @param string $widget_id Widget ID.
* @param array $feeds Array of RSS feeds.
*/
function wp_dashboard_primary_output( $widget_id, $feeds ) {
foreach ( $feeds as $type => $args ) {
$args['type'] = $type;
echo '<div class="rss-widget">';
wp_widget_rss_output( $args['url'], $args );
echo '</div>';
}
}
/**
* Display file upload quota on dashboard.
*
* Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now().
*
* @since 3.0.0
*
* @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
*/
function wp_dashboard_quota() {
if ( ! is_multisite() || ! current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) {
return true;
}
$quota = get_space_allowed();
$used = get_space_used();
if ( $used > $quota ) {
$percentused = '100';
} else {
$percentused = ( $used / $quota ) * 100;
}
$used_class = ( $percentused >= 70 ) ? ' warning' : '';
$used = round( $used, 2 );
$percentused = number_format( $percentused );
?>
<h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
<div class="mu-storage">
<ul>
<li class="storage-count">
<?php
$text = sprintf(
/* translators: %s: number of megabytes */
__( '%s MB Space Allowed' ),
number_format_i18n( $quota )
);
printf(
'<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
);
?>
</li><li class="storage-count <?php echo $used_class; ?>">
<?php
$text = sprintf(
/* translators: 1: number of megabytes, 2: percentage */
__( '%1$s MB (%2$s%%) Space Used' ),
number_format_i18n( $used, 2 ),
$percentused
);
printf(
'<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
);
?>
</li>
</ul>
</div>
<?php
}
// Display Browser Nag Meta Box
function wp_dashboard_browser_nag() {
$notice = '';
$response = wp_check_browser_version();
if ( $response ) {
if ( $response['insecure'] ) {
/* translators: %s: browser name and link */
$msg = sprintf(
__( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
} else {
/* translators: %s: browser name and link */
$msg = sprintf(
__( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
}
$browser_nag_class = '';
if ( ! empty( $response['img_src'] ) ) {
$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) ) ? $response['img_src_ssl'] : $response['img_src'];
$notice .= '<div class="alignright browser-icon"><a href="' . esc_attr( $response['update_url'] ) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
$browser_nag_class = ' has-browser-icon';
}
$notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
$browsehappy = 'https://browsehappy.com/';
$locale = get_user_locale();
if ( 'en_US' !== $locale ) {
$browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
}
$notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>';
$notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
$notice .= '<div class="clear"></div>';
}
/**
* Filters the notice output for the 'Browse Happy' nag meta box.
*
* @since 3.2.0
*
* @param string $notice The notice content.
* @param array $response An array containing web browser information. See `wp_check_browser_version()`.
*/
echo apply_filters( 'browse-happy-notice', $notice, $response );
}
/**
* @since 3.2.0
*
* @param array $classes
* @return array
*/
function dashboard_browser_nag_class( $classes ) {
$response = wp_check_browser_version();
if ( $response && $response['insecure'] ) {
$classes[] = 'browser-insecure';
}
return $classes;
}
/**
* Check if the user needs a browser update
*
* @since 3.2.0
*
* @return array|bool False on failure, array of browser data on success.
*/
function wp_check_browser_version() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
if ( false === ( $response = get_site_transient( 'browser_' . $key ) ) ) {
// include an unmodified $wp_version
include( ABSPATH . WPINC . '/version.php' );
$url = 'http://api.wordpress.org/core/browse-happy/1.1/';
$options = array(
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
);
if ( wp_http_supports( array( 'ssl' ) ) ) {
$url = set_url_scheme( $url, 'https' );
}
$response = wp_remote_post( $url, $options );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
return false;
}
/**
* Response should be an array with:
* 'platform' - string - A user-friendly platform name, if it can be determined
* 'name' - string - A user-friendly browser name
* 'version' - string - The version of the browser the user is using
* 'current_version' - string - The most recent version of the browser
* 'upgrade' - boolean - Whether the browser needs an upgrade
* 'insecure' - boolean - Whether the browser is deemed insecure
* 'update_url' - string - The url to visit to upgrade
* 'img_src' - string - An image representing the browser
* 'img_src_ssl' - string - An image (over SSL) representing the browser
*/
$response = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $response ) ) {
return false;
}
set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
}
return $response;
}
/**
* Displays the PHP update nag.
*
* @since 5.1.0
*/
function wp_dashboard_php_nag() {
$response = wp_check_php_version();
if ( ! $response ) {
return;
}
if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
$msg = __( 'WordPress has detected that your site is running on an insecure version of PHP.' );
} else {
$msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
}
?>
<p><?php echo $msg; ?></p>
<h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
<p><?php _e( 'PHP is the programming language we use to build and maintain WordPress. Newer versions of PHP are both faster and more secure, so updating will have a positive effect on your site’s performance.' ); ?></p>
<p class="button-container">
<?php
printf(
'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
esc_url( wp_get_update_php_url() ),
__( 'Learn more about updating PHP' ),
/* translators: accessibility text */
__( '(opens in a new tab)' )
);
?>
</p>
<?php
wp_update_php_annotation();
wp_direct_php_update_button();
}
/**
* Adds an additional class to the PHP nag if the current version is insecure.
*
* @since 5.1.0
*
* @param array $classes Metabox classes.
* @return array Modified metabox classes.
*/
function dashboard_php_nag_class( $classes ) {
$response = wp_check_php_version();
if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
$classes[] = 'php-insecure';
}
return $classes;
}
/**
* Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
*/
function wp_dashboard_empty() {}
/**
* Displays a welcome panel to introduce users to WordPress.
*
* @since 3.3.0
*/
function wp_welcome_panel() {
?>
<div class="welcome-panel-content">
<h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
<p class="about-description"><?php _e( 'We’ve assembled some links to get you started:' ); ?></p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<?php if ( current_user_can( 'customize' ) ) : ?>
<h3><?php _e( 'Get Started' ); ?></h3>
<a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php endif; ?>
<a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
<?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?>
<p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), $themes_link ); ?></p>
<?php endif; ?>
</div>
<div class="welcome-panel-column">
<h3><?php _e( 'Next Steps' ); ?></h3>
<ul>
<?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<?php else : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-setup-home">' . __( 'Set up your homepage' ) . '</a>', current_user_can( 'customize' ) ? add_query_arg( 'autofocus[section]', 'static_front_page', admin_url( 'customize.php' ) ) : admin_url( 'options-reading.php' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h3><?php _e( 'More Actions' ); ?></h3>
<ul>
<?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?>
<li><div class="welcome-icon welcome-widgets-menus">
<?php
if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) {
printf(
__( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ),
admin_url( 'widgets.php' ),
admin_url( 'nav-menus.php' )
);
} elseif ( current_theme_supports( 'widgets' ) ) {
echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>';
} else {
echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>';
}
?>
</div></li>
<?php endif; ?>
<?php if ( current_user_can( 'manage_options' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
</ul>
</div>
</div>
</div>
<?php
}
home/xbodynamge/dev/wp-admin/includes/dashboard.php 0000604 00000157267 15112547100 0016403 0 ustar 00 <?php
/**
* WordPress Dashboard Widget Administration Screen API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Registers dashboard widgets.
*
* Handles POST data, sets up filters.
*
* @since 2.5.0
*
* @global array $wp_registered_widgets
* @global array $wp_registered_widget_controls
* @global array $wp_dashboard_control_callbacks
*/
function wp_dashboard_setup() {
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array();
$screen = get_current_screen();
/* Register Widgets and Controls */
$response = wp_check_browser_version();
if ( $response && $response['upgrade'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
if ( $response['insecure'] )
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
else
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
}
// Right Now
if ( is_blog_admin() && current_user_can('edit_posts') )
wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
if ( is_network_admin() )
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
// Activity Widget
if ( is_blog_admin() ) {
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
}
// QuickPress Widget
if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
$quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) );
wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
}
// WordPress Events and News
wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' );
if ( is_network_admin() ) {
/**
* Fires after core widgets for the Network Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_network_dashboard_setup' );
/**
* Filters the list of widgets to load for the Network Admin dashboard.
*
* @since 3.1.0
*
* @param array $dashboard_widgets An array of dashboard widgets.
*/
$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
} elseif ( is_user_admin() ) {
/**
* Fires after core widgets for the User Admin dashboard have been registered.
*
* @since 3.1.0
*/
do_action( 'wp_user_dashboard_setup' );
/**
* Filters the list of widgets to load for the User Admin dashboard.
*
* @since 3.1.0
*
* @param array $dashboard_widgets An array of dashboard widgets.
*/
$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
} else {
/**
* Fires after core widgets for the admin dashboard have been registered.
*
* @since 2.5.0
*/
do_action( 'wp_dashboard_setup' );
/**
* Filters the list of widgets to load for the admin dashboard.
*
* @since 2.5.0
*
* @param array $dashboard_widgets An array of dashboard widgets.
*/
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
}
foreach ( $dashboard_widgets as $widget_id ) {
$name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
}
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/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
/** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'side', '' );
}
/**
* Adds a new dashboard widget.
*
* @since 2.7.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param string $widget_id Widget ID (used in the 'id' attribute for the widget).
* @param string $widget_name Title of the widget.
* @param callable $callback Function that fills the widget with the desired content.
* The function should echo its output.
* @param callable $control_callback Optional. Function that outputs controls for the widget. Default null.
* @param array $callback_args Optional. Data that should be set as the $args property of the widget array
* (which is the second parameter passed to your callback). Default null.
*/
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {
$screen = get_current_screen();
global $wp_dashboard_control_callbacks;
$private_callback_args = array( '__widget_basename' => $widget_name );
if ( is_null( $callback_args ) ) {
$callback_args = $private_callback_args;
} else if ( is_array( $callback_args ) ) {
$callback_args = array_merge( $callback_args, $private_callback_args );
}
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>';
}
}
$side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
$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, $callback_args );
}
/**
* Outputs controls for the current dashboard widget.
*
* @access private
* @since 2.7.0
*
* @param mixed $dashboard
* @param array $meta_box
*/
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">';
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>';
}
/**
* Displays the dashboard.
*
* @since 2.5.0
*/
function wp_dashboard() {
$screen = get_current_screen();
$columns = absint( $screen->get_columns() );
$columns_css = '';
if ( $columns ) {
$columns_css = " columns-$columns";
}
?>
<div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>">
<div id="postbox-container-1" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
</div>
<div id="postbox-container-2" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'side', '' ); ?>
</div>
<div id="postbox-container-3" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column3', '' ); ?>
</div>
<div id="postbox-container-4" class="postbox-container">
<?php do_meta_boxes( $screen->id, 'column4', '' ); ?>
</div>
</div>
<?php
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
}
//
// Dashboard Widgets
//
/**
* Dashboard widget that displays some basic stats about the site.
*
* Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8.
*
* @since 2.7.0
*/
function wp_dashboard_right_now() {
?>
<div class="main">
<ul>
<?php
// Posts and Pages
foreach ( array( 'post', 'page' ) as $post_type ) {
$num_posts = wp_count_posts( $post_type );
if ( $num_posts && $num_posts->publish ) {
if ( 'post' == $post_type ) {
$text = _n( '%s Post', '%s Posts', $num_posts->publish );
} else {
$text = _n( '%s Page', '%s Pages', $num_posts->publish );
}
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
$post_type_object = get_post_type_object( $post_type );
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
} else {
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
}
}
}
// Comments
$num_comm = wp_count_comments();
if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
?>
<li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
<?php
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
/* translators: %s: number of comments in moderation */
$text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
/* translators: %s: number of comments in moderation */
$aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
?>
<li class="comment-mod-count<?php
if ( ! $num_comm->moderated ) {
echo ' hidden';
}
?>"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php esc_attr_e( $aria_label ); ?>"><?php echo $text; ?></a></li>
<?php
}
/**
* Filters the array of extra elements to list in the 'At a Glance'
* dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'. Each element
* is wrapped in list-item tags on output.
*
* @since 3.8.0
*
* @param array $items Array of extra 'At a Glance' widget items.
*/
$elements = apply_filters( 'dashboard_glance_items', array() );
if ( $elements ) {
echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n";
}
?>
</ul>
<?php
update_right_now_message();
// Check if search engines are asked not to index this site.
if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) {
/**
* Filters the link title attribute for the 'Search Engines Discouraged'
* message displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
* @since 4.5.0 The default for `$title` was updated to an empty string.
*
* @param string $title Default attribute text.
*/
$title = apply_filters( 'privacy_on_link_title', '' );
/**
* Filters the link label for the 'Search Engines Discouraged' message
* displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
*
* @param string $content Default text.
*/
$content = apply_filters( 'privacy_on_link_text' , __( 'Search Engines Discouraged' ) );
$title_attr = '' === $title ? '' : " title='$title'";
echo "<p><a href='options-reading.php'$title_attr>$content</a></p>";
}
?>
</div>
<?php
/*
* activity_box_end has a core action, but only prints content when multisite.
* Using an output buffer is the only way to really check if anything's displayed here.
*/
ob_start();
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.5.0
*/
do_action( 'rightnow_end' );
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 2.0.0
*/
do_action( 'activity_box_end' );
$actions = ob_get_clean();
if ( !empty( $actions ) ) : ?>
<div class="sub">
<?php echo $actions; ?>
</div>
<?php endif;
}
/**
* @since 3.1.0
*/
function wp_network_dashboard_right_now() {
$actions = array();
if ( current_user_can('create_sites') )
$actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>';
if ( current_user_can('create_users') )
$actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
$c_users = get_user_count();
$c_blogs = get_blog_count();
/* translators: %s: number of users on the network */
$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
/* translators: %s: number of sites on the network */
$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
/* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */
$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
if ( $actions ) {
echo '<ul class="subsubsub">';
foreach ( $actions as $class => $action ) {
$actions[ $class ] = "\t<li class='$class'>$action";
}
echo implode( " |</li>\n", $actions ) . "</li>\n";
echo '</ul>';
}
?>
<br class="clear" />
<p class="youhave"><?php echo $sentence; ?></p>
<?php
/**
* Fires in the Network Admin 'Right Now' dashboard widget
* just before the user and site search form fields.
*
* @since MU (3.0.0)
*
* @param null $unused
*/
do_action( 'wpmuadminresult', '' );
?>
<form action="<?php echo network_admin_url('users.php'); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?>
</p>
</form>
<form action="<?php echo network_admin_url('sites.php'); ?>" method="get">
<p>
<label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?>
</p>
</form>
<?php
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_rightnow_end' );
/**
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
*
* @since MU (3.0.0)
*/
do_action( 'mu_activity_box_end' );
}
/**
* The Quick Draft widget display and creation of drafts.
*
* @since 3.8.0
*
* @global int $post_ID
*
* @param string $error_msg Optional. Error message. Default false.
*/
function wp_dashboard_quick_press( $error_msg = false ) {
global $post_ID;
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
if ( $last_post_id ) {
$post = get_post( $last_post_id );
if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
$post = get_default_post_to_edit( 'post', true );
update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
} else {
$post->post_title = ''; // Remove the auto draft title
}
} else {
$post = get_default_post_to_edit( 'post' , true);
$user_id = get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) )
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
}
$post_ID = (int) $post->ID;
?>
<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
<?php if ( $error_msg ) : ?>
<div class="error"><?php echo $error_msg; ?></div>
<?php endif; ?>
<div class="input-text-wrap" id="title-wrap">
<label class="screen-reader-text prompt" for="title" id="title-prompt-text">
<?php
/** This filter is documented in wp-admin/edit-form-advanced.php */
echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
?>
</label>
<input type="text" name="post_title" id="title" autocomplete="off" />
</div>
<div class="textarea-wrap" id="description-wrap">
<label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What’s on your mind?' ); ?></label>
<textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
</div>
<p class="submit">
<input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />
<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
<input type="hidden" name="post_type" value="post" />
<?php wp_nonce_field( 'add-post' ); ?>
<?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>
<br class="clear" />
</p>
</form>
<?php
wp_dashboard_recent_drafts();
}
/**
* Show recent drafts of the user on the dashboard.
*
* @since 2.7.0
*
* @param array $drafts
*/
function wp_dashboard_recent_drafts( $drafts = false ) {
if ( ! $drafts ) {
$query_args = array(
'post_type' => 'post',
'post_status' => 'draft',
'author' => get_current_user_id(),
'posts_per_page' => 4,
'orderby' => 'modified',
'order' => 'DESC'
);
/**
* Filters the post query arguments for the 'Recent Drafts' dashboard widget.
*
* @since 4.4.0
*
* @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
*/
$query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
$drafts = get_posts( $query_args );
if ( ! $drafts ) {
return;
}
}
echo '<div class="drafts">';
if ( count( $drafts ) > 3 ) {
echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . __( 'View all drafts' ) . "</a></p>\n";
}
echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
$drafts = array_slice( $drafts, 0, 3 );
foreach ( $drafts as $draft ) {
$url = get_edit_post_link( $draft->ID );
$title = _draft_or_post_title( $draft->ID );
echo "<li>\n";
/* translators: %s: post title */
echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
echo '<p>' . $the_content . '</p>';
}
echo "</li>\n";
}
echo "</ul>\n</div>";
}
/**
* Outputs a row for the Recent Comments widget.
*
* @access private
* @since 2.7.0
*
* @global WP_Comment $comment
*
* @param WP_Comment $comment The current comment.
* @param bool $show_date Optional. Whether to display the date.
*/
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$GLOBALS['comment'] = clone $comment;
if ( $comment->comment_post_ID > 0 ) {
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
$comment_post_url = get_the_permalink( $comment->comment_post_ID );
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
} else {
$comment_post_link = '';
}
$actions_string = '';
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
// Pre-order it: Approve | Reply | Edit | Spam | Trash.
$actions = array(
'approve' => '', 'unapprove' => '',
'reply' => '',
'edit' => '',
'spam' => '',
'trash' => '', 'delete' => '',
'view' => '',
);
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>". __( 'Edit' ) . '</a>';
$actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '" href="#">' . __( 'Reply' ) . '</a>';
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
if ( ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
}
$actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>';
/**
* Filters the action links displayed for each comment in the 'Recent Comments'
* dashboard widget.
*
* @since 2.6.0
*
* @param array $actions An array of comment actions. Default actions include:
* 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
* 'Delete', and 'Trash'.
* @param WP_Comment $comment The comment object.
*/
$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
$i = 0;
foreach ( $actions as $action => $link ) {
++$i;
( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span
if ( 'reply' == $action || 'quickedit' == $action ) {
$action .= ' hide-if-no-js';
}
if ( 'view' === $action && '1' !== $comment->comment_approved ) {
$action .= ' hidden';
}
$actions_string .= "<span class='$action'>$sep$link</span>";
}
}
?>
<li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
<?php echo get_avatar( $comment, 50, 'mystery' ); ?>
<?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Comments might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
__( 'From %1$s on %2$s %3$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: comment author, 2: notification if the comment is pending */
__( 'From %1$s %2$s' ),
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<?php
else :
switch ( $comment->comment_type ) {
case 'pingback' :
$type = __( 'Pingback' );
break;
case 'trackback' :
$type = __( 'Trackback' );
break;
default :
$type = ucwords( $comment->comment_type );
}
$type = esc_html( $type );
?>
<div class="dashboard-comment-wrap has-row-actions">
<p class="comment-meta">
<?php
// Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
if ( $comment_post_link ) {
printf(
/* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
_x( '%1$s on %2$s %3$s', 'dashboard' ),
"<strong>$type</strong>",
$comment_post_link,
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
} else {
printf(
/* translators: 1: type of comment, 2: notification if the comment is pending */
_x( '%1$s %2$s', 'dashboard' ),
"<strong>$type</strong>",
'<span class="approve">' . __( '[Pending]' ) . '</span>'
);
}
?>
</p>
<p class="comment-author"><?php comment_author_link( $comment ); ?></p>
<?php endif; // comment_type ?>
<blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
<?php if ( $actions_string ) : ?>
<p class="row-actions"><?php echo $actions_string; ?></p>
<?php endif; ?>
</div>
</li>
<?php
$GLOBALS['comment'] = null;
}
/**
* Callback function for Activity widget.
*
* @since 3.8.0
*/
function wp_dashboard_site_activity() {
echo '<div id="activity-widget">';
$future_posts = wp_dashboard_recent_posts( array(
'max' => 5,
'status' => 'future',
'order' => 'ASC',
'title' => __( 'Publishing Soon' ),
'id' => 'future-posts',
) );
$recent_posts = wp_dashboard_recent_posts( array(
'max' => 5,
'status' => 'publish',
'order' => 'DESC',
'title' => __( 'Recently Published' ),
'id' => 'published-posts',
) );
$recent_comments = wp_dashboard_recent_comments();
if ( !$future_posts && !$recent_posts && !$recent_comments ) {
echo '<div class="no-activity">';
echo '<p class="smiley" aria-hidden="true"></p>';
echo '<p>' . __( 'No activity yet!' ) . '</p>';
echo '</div>';
}
echo '</div>';
}
/**
* Generates Publishing Soon and Recently Published sections.
*
* @since 3.8.0
*
* @param array $args {
* An array of query and display arguments.
*
* @type int $max Number of posts to display.
* @type string $status Post status.
* @type string $order Designates ascending ('ASC') or descending ('DESC') order.
* @type string $title Section title.
* @type string $id The container id.
* }
* @return bool False if no posts were found. True otherwise.
*/
function wp_dashboard_recent_posts( $args ) {
$query_args = array(
'post_type' => 'post',
'post_status' => $args['status'],
'orderby' => 'date',
'order' => $args['order'],
'posts_per_page' => intval( $args['max'] ),
'no_found_rows' => true,
'cache_results' => false,
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
);
/**
* Filters the query arguments used for the Recent Posts widget.
*
* @since 4.2.0
*
* @param array $query_args The arguments passed to WP_Query to produce the list of posts.
*/
$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
$posts = new WP_Query( $query_args );
if ( $posts->have_posts() ) {
echo '<div id="' . $args['id'] . '" class="activity-block">';
echo '<h3>' . $args['title'] . '</h3>';
echo '<ul>';
$today = date( 'Y-m-d', current_time( 'timestamp' ) );
$tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
while ( $posts->have_posts() ) {
$posts->the_post();
$time = get_the_time( 'U' );
if ( date( 'Y-m-d', $time ) == $today ) {
$relative = __( 'Today' );
} elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
$relative = __( 'Tomorrow' );
} elseif ( date( 'Y', $time ) !== date( 'Y', current_time( 'timestamp' ) ) ) {
/* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS Y' ), $time );
} else {
/* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */
$relative = date_i18n( __( 'M jS' ), $time );
}
// Use the post edit link for those who can edit, the permalink otherwise.
$recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();
$draft_or_post_title = _draft_or_post_title();
printf(
'<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
/* translators: 1: relative date, 2: time */
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ),
$recent_post_link,
/* translators: %s: post title */
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ),
$draft_or_post_title
);
}
echo '</ul>';
echo '</div>';
} else {
return false;
}
wp_reset_postdata();
return true;
}
/**
* Show Comments section.
*
* @since 3.8.0
*
* @param int $total_items Optional. Number of comments to query. Default 5.
* @return bool False if no comments were found. True otherwise.
*/
function wp_dashboard_recent_comments( $total_items = 5 ) {
// Select all comment types and filter out spam later for better query performance.
$comments = array();
$comments_query = array(
'number' => $total_items * 5,
'offset' => 0
);
if ( ! current_user_can( 'edit_posts' ) )
$comments_query['status'] = 'approve';
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
if ( ! is_array( $possible ) ) {
break;
}
foreach ( $possible as $comment ) {
if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) )
continue;
$comments[] = $comment;
if ( count( $comments ) == $total_items )
break 2;
}
$comments_query['offset'] += $comments_query['number'];
$comments_query['number'] = $total_items * 10;
}
if ( $comments ) {
echo '<div id="latest-comments" class="activity-block">';
echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
foreach ( $comments as $comment )
_wp_dashboard_recent_comments_row( $comment );
echo '</ul>';
if ( current_user_can( 'edit_posts' ) ) {
echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>';
_get_list_table( 'WP_Comments_List_Table' )->views();
}
wp_comment_reply( -1, false, 'dashboard', false );
wp_comment_trashnotice();
echo '</div>';
} else {
return false;
}
return true;
}
/**
* Display generic dashboard RSS widget feed.
*
* @since 2.5.0
*
* @param string $widget_id
*/
function wp_dashboard_rss_output( $widget_id ) {
$widgets = get_option( 'dashboard_widget_options' );
echo '<div class="rss-widget">';
wp_widget_rss_output( $widgets[ $widget_id ] );
echo "</div>";
}
/**
* Checks to see if all of the feed url in $check_urls are cached.
*
* If $check_urls is empty, look for the rss feed url found in the dashboard
* widget options of $widget_id. If cached, call $callback, a function that
* echoes out output for this widget. If not cache, echo a "Loading..." stub
* which is later replaced by Ajax call (see top of /wp-admin/index.php)
*
* @since 2.5.0
*
* @param string $widget_id
* @param callable $callback
* @param array $check_urls RSS feeds
* @return bool False on failure. True on success.
*/
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
$doing_ajax = wp_doing_ajax();
if ( empty($check_urls) ) {
$widgets = get_option( 'dashboard_widget_options' );
if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) {
echo $loading;
return false;
}
$check_urls = array( $widgets[$widget_id]['url'] );
}
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
if ( false !== ( $output = get_transient( $cache_key ) ) ) {
echo $output;
return true;
}
if ( ! $doing_ajax ) {
echo $loading;
return false;
}
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 3 );
array_unshift( $args, $widget_id, $check_urls );
ob_start();
call_user_func_array( $callback, $args );
set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
}
return true;
}
//
// Dashboard Widgets Controls
//
/**
* Calls widget control callback.
*
* @since 2.5.0
*
* @global array $wp_dashboard_control_callbacks
*
* @param int $widget_control_id Registered Widget ID.
*/
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
global $wp_dashboard_control_callbacks;
if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) {
call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
}
}
/**
* The RSS dashboard widget control.
*
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
* from RSS-type widgets.
*
* @since 2.5.0
*
* @param string $widget_id
* @param array $form_inputs
*/
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
$widget_options = array();
if ( !isset($widget_options[$widget_id]) )
$widget_options[$widget_id] = array();
$number = 1; // Hack to use wp_widget_rss_form()
$widget_options[$widget_id]['number'] = $number;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
$_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] );
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
$widget_options[$widget_id]['number'] = $number;
// Title is optional. If black, fill it if possible.
if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
$rss = fetch_feed($widget_options[$widget_id]['url']);
if ( is_wp_error($rss) ) {
$widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
} else {
$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
$rss->__destruct();
unset($rss);
}
}
update_option( 'dashboard_widget_options', $widget_options );
$locale = get_user_locale();
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
delete_transient( $cache_key );
}
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
}
/**
* Renders the Events and News dashboard widget.
*
* @since 4.8.0
*/
function wp_dashboard_events_news() {
wp_print_community_events_markup();
?>
<div class="wordpress-news hide-if-no-js">
<?php wp_dashboard_primary(); ?>
</div>
<p class="community-events-footer">
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://make.wordpress.org/community/meetups-landing-page',
__( 'Meetups' ),
/* translators: accessibility text */
__( '(opens in a new window)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
'https://central.wordcamp.org/schedule/',
__( 'WordCamps' ),
/* translators: accessibility text */
__( '(opens in a new window)' )
);
?>
|
<?php
printf(
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
__( 'News' ),
/* translators: accessibility text */
__( '(opens in a new window)' )
);
?>
</p>
<?php
}
/**
* Prints the markup for the Community Events section of the Events and News Dashboard widget.
*
* @since 4.8.0
*/
function wp_print_community_events_markup() {
?>
<div class="community-events-errors notice notice-error inline hide-if-js">
<p class="hide-if-js">
<?php _e( 'This widget requires JavaScript.' ); ?>
</p>
<p class="community-events-error-occurred" aria-hidden="true">
<?php _e( 'An error occurred. Please try again.' ); ?>
</p>
<p class="community-events-could-not-locate" aria-hidden="true"></p>
</div>
<div class="community-events-loading hide-if-no-js">
<?php _e( 'Loading…' ); ?>
</div>
<?php
/*
* Hide the main element when the page first loads, because the content
* won't be ready until wp.communityEvents.renderEventsTemplate() has run.
*/
?>
<div id="community-events" class="community-events" aria-hidden="true">
<div class="activity-block">
<p>
<span id="community-events-location-message"></span>
<button class="button-link community-events-toggle-location" aria-label="<?php esc_attr_e( 'Edit city' ); ?>" aria-expanded="false">
<span class="dashicons dashicons-edit"></span>
</button>
</p>
<form class="community-events-form" aria-hidden="true" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post">
<label for="community-events-location">
<?php _e( 'City:' ); ?>
</label>
<?php
/* translators: Replace with a city related to your locale.
* Test that it matches the expected location and has upcoming
* events before including it. If no cities related to your
* locale have events, then use a city related to your locale
* that would be recognizable to most users. Use only the city
* name itself, without any region or country. Use the endonym
* (native locale name) instead of the English name if possible.
*/
?>
<input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" />
<?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?>
<button class="community-events-cancel button-link" type="button" aria-expanded="false">
<?php _e( 'Cancel' ); ?>
</button>
<span class="spinner"></span>
</form>
</div>
<ul class="community-events-results activity-block last"></ul>
</div>
<?php
}
/**
* Renders the events templates for the Event and News widget.
*
* @since 4.8.0
*/
function wp_print_community_events_templates() {
?>
<script id="tmpl-community-events-attend-event-near" type="text/template">
<?php printf(
/* translators: %s: the name of a city */
__( 'Attend an upcoming event near %s.' ),
'<strong>{{ data.location.description }}</strong>'
); ?>
</script>
<script id="tmpl-community-events-could-not-locate" type="text/template">
<?php printf(
/* translators: %s is the name of the city we couldn't locate.
* Replace the examples with cities in your locale, but test
* that they match the expected location before including them.
* Use endonyms (native locale names) whenever possible.
*/
__( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
'<em>{{data.unknownCity}}</em>'
); ?>
</script>
<script id="tmpl-community-events-event-list" type="text/template">
<# _.each( data.events, function( event ) { #>
<li class="event event-{{ event.type }} wp-clearfix">
<div class="event-info">
<div class="dashicons event-icon" aria-hidden="true"></div>
<div class="event-info-inner">
<a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
<span class="event-city">{{ event.location.location }}</span>
</div>
</div>
<div class="event-date-time">
<span class="event-date">{{ event.formatted_date }}</span>
<# if ( 'meetup' === event.type ) { #>
<span class="event-time">{{ event.formatted_time }}</span>
<# } #>
</div>
</li>
<# } ) #>
</script>
<script id="tmpl-community-events-no-upcoming-events" type="text/template">
<li class="event-none">
<# if ( data.location.description ) { #>
<?php printf(
/* translators: 1: the city the user searched for, 2: meetup organization documentation URL */
__( 'There aren’t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ),
'{{ data.location.description }}',
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
); ?>
<# } else { #>
<?php printf(
/* translators: %s: meetup organization documentation URL */
__( 'There aren’t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ),
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
); ?>
<# } #>
</li>
</script>
<?php
}
/**
* WordPress News dashboard widget.
*
* @since 2.7.0
* @since 4.8.0 Removed popular plugins feed.
*/
function wp_dashboard_primary() {
$feeds = array(
'news' => array(
/**
* Filters the primary link URL for the 'WordPress News' dashboard widget.
*
* @since 2.5.0
*
* @param string $link The widget's primary link URL.
*/
'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
/**
* Filters the primary feed URL for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's primary feed URL.
*/
'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
/**
* Filters the primary link title for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's primary link.
*/
'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
'items' => 1,
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
),
'planet' => array(
/**
* Filters the secondary link URL for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $link The widget's secondary link URL.
*/
'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
/**
* Filters the secondary feed URL for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $url The widget's secondary feed URL.
*/
'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
/**
* Filters the secondary link title for the 'WordPress News' dashboard widget.
*
* @since 2.3.0
*
* @param string $title Title attribute for the widget's secondary link.
*/
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
/**
* Filters the number of secondary link items for the 'WordPress News' dashboard widget.
*
* @since 4.4.0
*
* @param string $items How many items to show in the secondary feed.
*/
'items' => apply_filters( 'dashboard_secondary_items', 3 ),
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
)
);
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds );
}
/**
* Display the WordPress news feeds.
*
* @since 3.8.0
* @since 4.8.0 Removed popular plugins feed.
*
* @param string $widget_id Widget ID.
* @param array $feeds Array of RSS feeds.
*/
function wp_dashboard_primary_output( $widget_id, $feeds ) {
foreach ( $feeds as $type => $args ) {
$args['type'] = $type;
echo '<div class="rss-widget">';
wp_widget_rss_output( $args['url'], $args );
echo "</div>";
}
}
/**
* Display file upload quota on dashboard.
*
* Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now().
*
* @since 3.0.0
*
* @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
*/
function wp_dashboard_quota() {
if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) )
return true;
$quota = get_space_allowed();
$used = get_space_used();
if ( $used > $quota )
$percentused = '100';
else
$percentused = ( $used / $quota ) * 100;
$used_class = ( $percentused >= 70 ) ? ' warning' : '';
$used = round( $used, 2 );
$percentused = number_format( $percentused );
?>
<h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
<div class="mu-storage">
<ul>
<li class="storage-count">
<?php $text = sprintf(
/* translators: %s: number of megabytes */
__( '%s MB Space Allowed' ),
number_format_i18n( $quota )
);
printf(
'<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
); ?>
</li><li class="storage-count <?php echo $used_class; ?>">
<?php $text = sprintf(
/* translators: 1: number of megabytes, 2: percentage */
__( '%1$s MB (%2$s%%) Space Used' ),
number_format_i18n( $used, 2 ),
$percentused
);
printf(
'<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
); ?>
</li>
</ul>
</div>
<?php
}
// Display Browser Nag Meta Box
function wp_dashboard_browser_nag() {
$notice = '';
$response = wp_check_browser_version();
if ( $response ) {
if ( $response['insecure'] ) {
/* translators: %s: browser name and link */
$msg = sprintf( __( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
} else {
/* translators: %s: browser name and link */
$msg = sprintf( __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
}
$browser_nag_class = '';
if ( !empty( $response['img_src'] ) ) {
$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src'];
$notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
$browser_nag_class = ' has-browser-icon';
}
$notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
$browsehappy = 'https://browsehappy.com/';
$locale = get_user_locale();
if ( 'en_US' !== $locale )
$browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
$notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>';
$notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
$notice .= '<div class="clear"></div>';
}
/**
* Filters the notice output for the 'Browse Happy' nag meta box.
*
* @since 3.2.0
*
* @param string $notice The notice content.
* @param array $response An array containing web browser information.
*/
echo apply_filters( 'browse-happy-notice', $notice, $response );
}
/**
* @since 3.2.0
*
* @param array $classes
* @return array
*/
function dashboard_browser_nag_class( $classes ) {
$response = wp_check_browser_version();
if ( $response && $response['insecure'] )
$classes[] = 'browser-insecure';
return $classes;
}
/**
* Check if the user needs a browser update
*
* @since 3.2.0
*
* @return array|bool False on failure, array of browser data on success.
*/
function wp_check_browser_version() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
return false;
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
// include an unmodified $wp_version
include( ABSPATH . WPINC . '/version.php' );
$url = 'http://api.wordpress.org/core/browse-happy/1.1/';
$options = array(
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' )
);
if ( wp_http_supports( array( 'ssl' ) ) ) {
$url = set_url_scheme( $url, 'https' );
}
$response = wp_remote_post( $url, $options );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
return false;
/**
* Response should be an array with:
* 'platform' - string - A user-friendly platform name, if it can be determined
* 'name' - string - A user-friendly browser name
* 'version' - string - The version of the browser the user is using
* 'current_version' - string - The most recent version of the browser
* 'upgrade' - boolean - Whether the browser needs an upgrade
* 'insecure' - boolean - Whether the browser is deemed insecure
* 'update_url' - string - The url to visit to upgrade
* 'img_src' - string - An image representing the browser
* 'img_src_ssl' - string - An image (over SSL) representing the browser
*/
$response = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $response ) )
return false;
set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
}
return $response;
}
/**
* Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
*/
function wp_dashboard_empty() {}
/**
* Displays a welcome panel to introduce users to WordPress.
*
* @since 3.3.0
*/
function wp_welcome_panel() {
?>
<div class="welcome-panel-content">
<h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
<p class="about-description"><?php _e( 'We’ve assembled some links to get you started:' ); ?></p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<?php if ( current_user_can( 'customize' ) ) : ?>
<h3><?php _e( 'Get Started' ); ?></h3>
<a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php endif; ?>
<a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
<?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
<?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?>
<p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), $themes_link ); ?></p>
<?php endif; ?>
</div>
<div class="welcome-panel-column">
<h3><?php _e( 'Next Steps' ); ?></h3>
<ul>
<?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<?php else : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h3><?php _e( 'More Actions' ); ?></h3>
<ul>
<?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?>
<li><div class="welcome-icon welcome-widgets-menus"><?php
if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) {
printf( __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ),
admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) );
} elseif ( current_theme_supports( 'widgets' ) ) {
echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>';
} else {
echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>';
}
?></div></li>
<?php endif; ?>
<?php if ( current_user_can( 'manage_options' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
<?php endif; ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
</ul>
</div>
</div>
</div>
<?php
}
home/xbodynamge/lebauwcentre/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php 0000644 00000002640 15113070403 0025527 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( isset( $_GET['allow_tracking'] ) && check_admin_referer( 'wpseo_activate_tracking', 'nonce' ) ) {
WPSEO_Options::set( 'yoast_tracking', ( $_GET['allow_tracking'] === 'yes' ) );
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
wp_safe_redirect( wp_unslash( $_SERVER['HTTP_REFERER'] ), 307 );
exit;
}
}
$yform = Yoast_Form::get_instance();
$yform->admin_header( true, 'wpseo' );
do_action( 'wpseo_all_admin_notices' );
$dashboard_tabs = new WPSEO_Option_Tabs( 'dashboard' );
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'dashboard',
__( 'Dashboard', 'wordpress-seo' ),
[
'save_button' => false,
]
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'features',
__( 'Features', 'wordpress-seo' )
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'integrations',
__( 'Integrations', 'wordpress-seo' ),
[
'save_button' => false,
]
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'webmaster-tools',
__( 'Webmaster Tools', 'wordpress-seo' )
)
);
/**
* Allows the addition of tabs to the dashboard by calling $dashboard_tabs->add_tab().
*/
do_action( 'wpseo_settings_tabs_dashboard', $dashboard_tabs );
$dashboard_tabs->display( $yform );
do_action( 'wpseo_dashboard' );
$yform->admin_footer();
home/xbodynamge/namtation/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php 0000644 00000002640 15113634236 0025053 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( isset( $_GET['allow_tracking'] ) && check_admin_referer( 'wpseo_activate_tracking', 'nonce' ) ) {
WPSEO_Options::set( 'yoast_tracking', ( $_GET['allow_tracking'] === 'yes' ) );
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
wp_safe_redirect( wp_unslash( $_SERVER['HTTP_REFERER'] ), 307 );
exit;
}
}
$yform = Yoast_Form::get_instance();
$yform->admin_header( true, 'wpseo' );
do_action( 'wpseo_all_admin_notices' );
$dashboard_tabs = new WPSEO_Option_Tabs( 'dashboard' );
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'dashboard',
__( 'Dashboard', 'wordpress-seo' ),
[
'save_button' => false,
]
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'features',
__( 'Features', 'wordpress-seo' )
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'integrations',
__( 'Integrations', 'wordpress-seo' ),
[
'save_button' => false,
]
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'webmaster-tools',
__( 'Webmaster Tools', 'wordpress-seo' )
)
);
/**
* Allows the addition of tabs to the dashboard by calling $dashboard_tabs->add_tab().
*/
do_action( 'wpseo_settings_tabs_dashboard', $dashboard_tabs );
$dashboard_tabs->display( $yform );
do_action( 'wpseo_dashboard' );
$yform->admin_footer();
xbodynamge/lebauwcentre/wp-content/plugins/wordpress-seo/admin/views/tabs/dashboard/dashboard.php 0000644 00000002356 15113751312 0030377 0 ustar 00 home <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
use Yoast\WP\SEO\Conditionals\Indexables_Page_Conditional;
/**
* Notifications template variables.
*
* @noinspection PhpUnusedLocalVariableInspection
*
* @var array
*/
$notifications_data = Yoast_Notifications::get_template_variables();
$wpseo_contributors_phrase = sprintf(
/* translators: %1$s expands to Yoast SEO */
__( 'See who contributed to %1$s.', 'wordpress-seo' ),
'Yoast SEO'
);
?>
<div class="tab-block">
<div class="yoast-notifications">
<div class="yoast-container yoast-container__error">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-errors.php'; ?>
</div>
<div class="yoast-container yoast-container__warning">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-warnings.php'; ?>
</div>
</div>
</div>
<?php
if ( YoastSEO()->classes->get( Indexables_Page_Conditional::class )->is_met() ) {
?>
<div class="tab-block">
<div id="wpseo-indexables-page"></div>
</div>
<?php
}
?>
<div class="tab-block">
<h2><?php esc_html_e( 'Credits', 'wordpress-seo' ); ?></h2>
<p>
<a href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/yoast-seo-credits' ); ?>"><?php echo esc_html( $wpseo_contributors_phrase ); ?></a>
</p>
</div>
home/xbodynamge/www/wp-content/plugins/wordpress-seo/admin/views/tabs/dashboard/dashboard.php 0000644 00000002356 15113753125 0026626 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
use Yoast\WP\SEO\Conditionals\Indexables_Page_Conditional;
/**
* Notifications template variables.
*
* @noinspection PhpUnusedLocalVariableInspection
*
* @var array
*/
$notifications_data = Yoast_Notifications::get_template_variables();
$wpseo_contributors_phrase = sprintf(
/* translators: %1$s expands to Yoast SEO */
__( 'See who contributed to %1$s.', 'wordpress-seo' ),
'Yoast SEO'
);
?>
<div class="tab-block">
<div class="yoast-notifications">
<div class="yoast-container yoast-container__error">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-errors.php'; ?>
</div>
<div class="yoast-container yoast-container__warning">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-warnings.php'; ?>
</div>
</div>
</div>
<?php
if ( YoastSEO()->classes->get( Indexables_Page_Conditional::class )->is_met() ) {
?>
<div class="tab-block">
<div id="wpseo-indexables-page"></div>
</div>
<?php
}
?>
<div class="tab-block">
<h2><?php esc_html_e( 'Credits', 'wordpress-seo' ); ?></h2>
<p>
<a href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/yoast-seo-credits' ); ?>"><?php echo esc_html( $wpseo_contributors_phrase ); ?></a>
</p>
</div>
home/xbodynamge/crosstraining/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php 0000644 00000002640 15114053536 0025745 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
if ( ! defined( 'WPSEO_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( isset( $_GET['allow_tracking'] ) && check_admin_referer( 'wpseo_activate_tracking', 'nonce' ) ) {
WPSEO_Options::set( 'yoast_tracking', ( $_GET['allow_tracking'] === 'yes' ) );
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
wp_safe_redirect( wp_unslash( $_SERVER['HTTP_REFERER'] ), 307 );
exit;
}
}
$yform = Yoast_Form::get_instance();
$yform->admin_header( true, 'wpseo' );
do_action( 'wpseo_all_admin_notices' );
$dashboard_tabs = new WPSEO_Option_Tabs( 'dashboard' );
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'dashboard',
__( 'Dashboard', 'wordpress-seo' ),
[
'save_button' => false,
]
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'features',
__( 'Features', 'wordpress-seo' )
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'integrations',
__( 'Integrations', 'wordpress-seo' ),
[
'save_button' => false,
]
)
);
$dashboard_tabs->add_tab(
new WPSEO_Option_Tab(
'webmaster-tools',
__( 'Webmaster Tools', 'wordpress-seo' )
)
);
/**
* Allows the addition of tabs to the dashboard by calling $dashboard_tabs->add_tab().
*/
do_action( 'wpseo_settings_tabs_dashboard', $dashboard_tabs );
$dashboard_tabs->display( $yform );
do_action( 'wpseo_dashboard' );
$yform->admin_footer();
xbodynamge/crosstraining/wp-content/plugins/wordpress-seo/admin/views/tabs/dashboard/dashboard.php 0000644 00000002356 15114316614 0030607 0 ustar 00 home <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
use Yoast\WP\SEO\Conditionals\Indexables_Page_Conditional;
/**
* Notifications template variables.
*
* @noinspection PhpUnusedLocalVariableInspection
*
* @var array
*/
$notifications_data = Yoast_Notifications::get_template_variables();
$wpseo_contributors_phrase = sprintf(
/* translators: %1$s expands to Yoast SEO */
__( 'See who contributed to %1$s.', 'wordpress-seo' ),
'Yoast SEO'
);
?>
<div class="tab-block">
<div class="yoast-notifications">
<div class="yoast-container yoast-container__error">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-errors.php'; ?>
</div>
<div class="yoast-container yoast-container__warning">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-warnings.php'; ?>
</div>
</div>
</div>
<?php
if ( YoastSEO()->classes->get( Indexables_Page_Conditional::class )->is_met() ) {
?>
<div class="tab-block">
<div id="wpseo-indexables-page"></div>
</div>
<?php
}
?>
<div class="tab-block">
<h2><?php esc_html_e( 'Credits', 'wordpress-seo' ); ?></h2>
<p>
<a href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/yoast-seo-credits' ); ?>"><?php echo esc_html( $wpseo_contributors_phrase ); ?></a>
</p>
</div>
home/xbodynamge/namtation/wp-content/plugins/wordpress-seo/admin/views/tabs/dashboard/dashboard.php 0000644 00000002356 15114447206 0027775 0 ustar 00 <?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
use Yoast\WP\SEO\Conditionals\Indexables_Page_Conditional;
/**
* Notifications template variables.
*
* @noinspection PhpUnusedLocalVariableInspection
*
* @var array
*/
$notifications_data = Yoast_Notifications::get_template_variables();
$wpseo_contributors_phrase = sprintf(
/* translators: %1$s expands to Yoast SEO */
__( 'See who contributed to %1$s.', 'wordpress-seo' ),
'Yoast SEO'
);
?>
<div class="tab-block">
<div class="yoast-notifications">
<div class="yoast-container yoast-container__error">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-errors.php'; ?>
</div>
<div class="yoast-container yoast-container__warning">
<?php require WPSEO_PATH . 'admin/views/partial-notifications-warnings.php'; ?>
</div>
</div>
</div>
<?php
if ( YoastSEO()->classes->get( Indexables_Page_Conditional::class )->is_met() ) {
?>
<div class="tab-block">
<div id="wpseo-indexables-page"></div>
</div>
<?php
}
?>
<div class="tab-block">
<h2><?php esc_html_e( 'Credits', 'wordpress-seo' ); ?></h2>
<p>
<a href="<?php WPSEO_Shortlinker::show( 'https://yoa.st/yoast-seo-credits' ); ?>"><?php echo esc_html( $wpseo_contributors_phrase ); ?></a>
</p>
</div>
home/xbodynamge/lebauwcentre/wp-content/themes/onepress/inc/admin/dashboard.php 0000644 00000115560 15114542167 0024051 0 ustar 00 <?php
class Onepress_Dashboard {
private static $_instance = null;
static function get_instance(){
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
function init(){
add_action('switch_theme', array( $this, 'reset_recommended_actions' ) );
if ( is_admin() ) {
add_action('admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
add_action('admin_menu', array( $this, 'theme_info' ));
/* activation notice */
add_action( 'load-themes.php', array( $this, 'activation_admin_notice' ) );
add_action( 'admin_init', array( $this, 'admin_dismiss_actions' ) );
}
}
function reset_recommended_actions () {
delete_option('onepress_actions_dismiss');
}
/**
* Add theme dashboard page
*/
/**
* Check maybe show admin notice
* @since 2.0.8
*/
function maybe_show_switch_theme_notice(){
if ( get_option( 'onepress_dismiss_switch_theme_notice' ) ) {
return false;
}
$keys = array(
'onepress_hcl1_largetext',
'onepress_hcl1_smalltext',
'onepress_hcl2_content',
'onepress_features_boxes',
'onepress_services',
'onepress_videolightbox_title',
'onepress_gallery_source',
'onepress_team_members',
'onepress_contact_text',
'onepress_contact_address',
);
foreach( $keys as $k ) {
if ( get_theme_mod( $k ) ) {
return false;
}
}
return true;
}
/**
* Enqueue scripts for admin page only: Theme info page
*/
function admin_scripts( $hook ) {
if ( $hook === 'widgets.php' || $hook === 'appearance_page_ft_onepress' ) {
wp_enqueue_style( 'onepress-admin-css', get_template_directory_uri() . '/assets/css/admin.css' );
// Add recommend plugin css
wp_enqueue_style( 'plugin-install' );
wp_enqueue_script( 'plugin-install' );
wp_enqueue_script( 'updates' );
add_thickbox();
}
}
function theme_info() {
$actions = $this->get_recommended_actions();
$number_count = $actions['number_notice'];
if ( $number_count > 0 ){
$update_label = sprintf( _n( '%1$s action required', '%1$s actions required', $number_count, 'onepress' ), $number_count );
$count = "<span class='update-plugins count-".esc_attr( $number_count )."' title='".esc_attr( $update_label )."'><span class='update-count'>" . number_format_i18n($number_count) . "</span></span>";
$menu_title = sprintf( esc_html__('OnePress Theme %s', 'onepress'), $count );
} else {
$menu_title = esc_html__('OnePress Theme', 'onepress');
}
add_theme_page( esc_html__( 'OnePress Dashboard', 'onepress' ), $menu_title, 'edit_theme_options', 'ft_onepress', array( $this, 'theme_info_page' ));
}
/**
* Add admin notice when active theme, just show one timetruongsa@200811
*
* @return bool|null
*/
function admin_notice() {
$actions = $this->get_recommended_actions();
$number_action = $actions['number_notice'];
if ( $number_action > 0 ) {
$theme_data = wp_get_theme();
?>
<div class="updated notice notice-success notice-alt is-dismissible">
<p><?php printf( __( 'Welcome! Thank you for choosing %1$s! To fully take advantage of the best our theme can offer please make sure you visit our <a href="%2$s">Welcome page</a>', 'onepress' ), $theme_data->Name, admin_url( 'themes.php?page=ft_onepress' ) ); ?></p>
</div>
<?php
}
}
function admin_import_notice(){
?>
<div class="updated notice notice-success notice-alt is-dismissible">
<p><?php printf( esc_html__( 'Save time by import our demo data, your website will be set up and ready to customize in minutes. %s', 'onepress' ), '<a class="button button-secondary" href="'.esc_url( add_query_arg( array( 'page' => 'ft_onepress&tab=demo-data-importer' ), admin_url( 'themes.php' ) ) ).'">'.esc_html__( 'Import Demo Data', 'onepress' ).'</a>' ); ?></p>
</div>
<?php
}
function activation_admin_notice(){
global $pagenow;
if ( is_admin() && ('themes.php' == $pagenow) && isset( $_GET['activated'] ) ) {
add_action( 'admin_notices', array( $this, 'admin_notice' ) );
add_action( 'admin_notices', array( $this, 'admin_import_notice' ) );
}
}
function render_section_settings( $key, $section, $see_only = false ){
$active_value = Onepress_Config::is_section_active( $key ) ? 1 : false;
?>
<div class="onepress-admin-section <?php echo $see_only ? 'see-only' : ''; ?>">
<div class="onepress-admin-section-inner">
<div class="admin-section-header">
<label>
<?php if ( ! $see_only ) { ?>
<span class="switch-button">
<input <?php checked( $active_value, 1 ); ?> name="section_<?php echo esc_attr( $key ); ?>" value="1" type="checkbox">
<span class="switch-slider"></span>
</span>
<?php } ?>
<?php echo $section['label']; // WPCS: XSS OK. ?>
</label>
<?php if ( $see_only ) { ?>
<span class="note-bubble"><?php _e( 'Plus Feature', 'onepress' ); ?></span>
<?php } ?>
</div>
</div>
</div>
<?php
}
/**
* Section settings
*
* @since 2.1.1
*/
function sections_settings(){
$sections = Onepress_Config::get_sections();
if ( isset( $_POST['submit'] ) ) {
Onepress_Config::save_settings( $_POST );
?>
<div id="sections-manager-notice" class="updated notice notice-success is-dismissible"><p><?php _e( 'Settings saved', 'onepress' ); ?></p></div>
<?php
}
echo '<div class="onepress-admin-sections-wrapper">';
echo '<h3>'.__( 'Customizer Section Manager', 'onepress' ).'</h3>';
echo '<p class="description">'.__( 'Disable (or enable) unused sections to improve Customizer loading speed. Your section settings is still saved.', 'onepress' ).'</p>';
echo '<form method="post" action="?page=ft_onepress" class="onepress-admin-sections-form">';
echo '<div class="onepress-admin-sections">';
foreach( $sections as $key => $section ) {
$this->render_section_settings( $key, $section );
}
if ( ! class_exists( 'OnePress_Plus' ) ) {
foreach ( Onepress_Config::get_plus_sections() as $key => $section ) {
$this->render_section_settings( $key, $section, true );
}
}
echo '</div>';
submit_button( );
echo '</form>';
echo '</div>';
}
function theme_info_page() {
$theme_data = wp_get_theme('onepress');
if ( isset( $_GET['onepress_action_dismiss'] ) ) {
$actions_dismiss = get_option( 'onepress_actions_dismiss' );
if ( ! is_array( $actions_dismiss ) ) {
$actions_dismiss = array();
}
$actions_dismiss[ sanitize_text_field( $_GET['onepress_action_dismiss'] ) ] = 'dismiss';
update_option( 'onepress_actions_dismiss', $actions_dismiss );
}
// Check for current viewing tab
$tab = null;
if ( isset( $_GET['tab'] ) ) {
$tab = sanitize_text_field( $_GET['tab'] );
} else {
$tab = null;
}
$actions_r = $this->get_recommended_actions();
$number_action = $actions_r['number_notice'];
$actions = $actions_r['actions'];
$current_action_link = admin_url( 'themes.php?page=ft_onepress&tab=recommended_actions' );
$recommend_plugins = get_theme_support( 'recommend-plugins' );
if ( is_array( $recommend_plugins ) && isset( $recommend_plugins[0] ) ){
$recommend_plugins = $recommend_plugins[0];
} else {
$recommend_plugins[] = array();
}
?>
<div class="wrap about-wrap theme_info_wrapper">
<h1><?php printf(esc_html__('Welcome to OnePress - Version %1s', 'onepress'), $theme_data->Version ); ?></h1>
<div class="about-text"><?php esc_html_e( 'OnePress is a creative and flexible WordPress ONE PAGE theme well suited for business, portfolio, digital agency, product showcase, freelancers websites.', 'onepress' ); ?></div>
<a target="_blank" href="<?php echo esc_url('https://www.famethemes.com/?utm_source=theme_dashboard_page&utm_medium=badge_link&utm_campaign=onepress'); ?>" class="famethemes-badge wp-badge"><span>FameThemes</span></a>
<hr class="wp-header-end">
<h2 class="nav-tab-wrapper">
<a href="?page=ft_onepress" class="nav-tab<?php echo is_null($tab) ? ' nav-tab-active' : null; ?>"><?php esc_html_e( 'Overview', 'onepress' ) ?></a>
<a href="?page=ft_onepress&tab=recommended_actions" class="nav-tab<?php echo $tab == 'recommended_actions' ? ' nav-tab-active' : null; ?>"><?php esc_html_e( 'Recommended Actions', 'onepress' ); echo ( $number_action > 0 ) ? "<span class='theme-action-count'>{$number_action}</span>" : ''; ?></a>
<?php if ( ! class_exists('OnePress_Plus') ) { ?>
<a href="?page=ft_onepress&tab=free_pro" class="nav-tab<?php echo $tab == 'free_pro' ? ' nav-tab-active' : null; ?>"><?php esc_html_e( 'Free vs PLUS', 'onepress' ); ?></span></a>
<?php } ?>
<a href="?page=ft_onepress&tab=demo-data-importer" class="nav-tab<?php echo $tab == 'demo-data-importer' ? ' nav-tab-active' : null; ?>"><?php esc_html_e( 'Demo Import', 'onepress' ); ?></span></a>
<?php do_action( 'onepress_admin_more_tabs', $tab ); ?>
</h2>
<?php if ( is_null( $tab ) ) { ?>
<div class="theme_info info-tab-content">
<div class="theme_info_column clearfix">
<div class="theme_info_left">
<?php
$this->sections_settings();
?>
</div>
<div class="theme_info_right">
<div class="theme_link">
<h3><?php esc_html_e( 'Theme Customizer', 'onepress' ); ?></h3>
<p class="about"><?php printf(esc_html__('%s supports the Theme Customizer for all theme settings. Click "Customize" to start customize your site.', 'onepress'), $theme_data->Name); ?></p>
<p>
<a href="<?php echo admin_url('customize.php'); ?>" class="button button-primary"><?php esc_html_e('Start Customize', 'onepress'); ?></a>
</p>
</div>
<div class="theme_link">
<h3><?php esc_html_e( 'Theme Documentation', 'onepress' ); ?></h3>
<p class="about"><?php printf(esc_html__('Need any help to setup and configure %s? Please have a look at our documentations instructions.', 'onepress'), $theme_data->Name); ?></p>
<p>
<a href="<?php echo esc_url( 'http://docs.famethemes.com/category/112-onepress' ); ?>" target="_blank" class="button button-secondary"><?php esc_html_e('OnePress Documentation', 'onepress'); ?></a>
</p>
<?php do_action( 'onepress_dashboard_theme_links' ); ?>
</div>
<div class="theme_link">
<h3><?php esc_html_e( 'Having Trouble, Need Support?', 'onepress' ); ?></h3>
<p class="about"><?php printf(esc_html__('Support for %s WordPress theme is conducted through FameThemes support ticket system.', 'onepress'), $theme_data->Name); ?></p>
<p>
<a href="<?php echo esc_url('https://www.famethemes.com/dashboard/tickets/' ); ?>" target="_blank" class="button button-secondary"><?php echo sprintf( esc_html__('Create a support ticket', 'onepress'), $theme_data->Name); ?></a>
</p>
</div>
</div>
</div>
</div>
<?php } ?>
<?php if ( $tab == 'recommended_actions' ) { ?>
<div class="action-required-tab info-tab-content">
<?php if ( is_child_theme() ){
$child_theme = wp_get_theme();
?>
<form method="post" action="<?php echo esc_attr( $current_action_link ); ?>" class="demo-import-boxed copy-settings-form">
<p>
<strong> <?php printf( esc_html__( 'You\'re using %1$s theme, It\'s a child theme of OnePress', 'onepress' ) , $child_theme->Name ); ?></strong>
</p>
<p><?php printf( esc_html__( "Child theme uses it's own theme setting name, would you like to copy setting data from parent theme to this child theme?", 'onepress' ) ); ?></p>
<p>
<?php
$select = '<select name="copy_from">';
$select .= '<option value="">'.esc_html__( 'From Theme', 'onepress' ).'</option>';
$select .= '<option value="onepress">OnePress</option>';
$select .= '<option value="'.esc_attr( $child_theme->get_stylesheet() ).'">'.( $child_theme->Name ).'</option>';
$select .='</select>';
$select_2 = '<select name="copy_to">';
$select_2 .= '<option value="">'.esc_html__( 'To Theme', 'onepress' ).'</option>';
$select_2 .= '<option value="onepress">OnePress</option>';
$select_2 .= '<option value="'.esc_attr( $child_theme->get_stylesheet() ).'">'.( $child_theme->Name ).'</option>';
$select_2 .='</select>';
echo $select . ' to '. $select_2;
?>
<input type="submit" class="button button-secondary" value="<?php esc_attr_e( 'Copy now', 'onepress' ); ?>">
</p>
<?php if ( isset( $_GET['copied'] ) && $_GET['copied'] == 1 ) { ?>
<p><?php esc_html_e( 'Your settings were copied.', 'onepress' ); ?></p>
<?php } ?>
</form>
<?php } ?>
<?php if ( $actions_r['number_active'] > 0 ) { ?>
<?php $actions = wp_parse_args( $actions, array( 'page_on_front' => '', 'page_template' ) ) ?>
<?php if ( $actions['recommend_plugins'] == 'active' ) { ?>
<div id="plugin-filter" class="recommend-plugins action-required">
<a title="" class="dismiss" href="<?php echo add_query_arg( array( 'onepress_action_notice' => 'recommend_plugins' ), $current_action_link ); ?>">
<?php if ( $actions_r['hide_by_click']['recommend_plugins'] == 'hide' ) { ?>
<span class="dashicons dashicons-hidden"></span>
<?php } else { ?>
<span class="dashicons dashicons-visibility"></span>
<?php } ?>
</a>
<h3><?php esc_html_e( 'Recommend Plugins', 'onepress' ); ?></h3>
<?php
$this->render_recommend_plugins( $recommend_plugins );
?>
</div>
<?php } ?>
<?php if ( $actions['page_on_front'] == 'active' ) { ?>
<div class="theme_link action-required">
<a title="<?php esc_attr_e( 'Dismiss', 'onepress' ); ?>" class="dismiss" href="<?php echo add_query_arg( array( 'onepress_action_notice' => 'page_on_front' ), $current_action_link ); ?>">
<?php if ( $actions_r['hide_by_click']['page_on_front'] == 'hide' ) { ?>
<span class="dashicons dashicons-hidden"></span>
<?php } else { ?>
<span class="dashicons dashicons-visibility"></span>
<?php } ?>
</a>
<h3><?php esc_html_e( 'Switch "Front page displays" to "A static page"', 'onepress' ); ?></h3>
<div class="about">
<p><?php _e( 'In order to have the one page look for your website, please go to Customize -> Static Front Page and switch "Front page displays" to "A static page".', 'onepress' ); ?></p>
</div>
<p>
<a href="<?php echo admin_url('options-reading.php'); ?>" class="button"><?php esc_html_e('Setup front page displays', 'onepress'); ?></a>
</p>
</div>
<?php } ?>
<?php if ( $actions['page_template'] == 'active' ) { ?>
<div class="theme_link action-required">
<a title="<?php esc_attr_e( 'Dismiss', 'onepress' ); ?>" class="dismiss" href="<?php echo add_query_arg( array( 'onepress_action_notice' => 'page_template' ), $current_action_link ); ?>">
<?php if ( $actions_r['hide_by_click']['page_template'] == 'hide' ) { ?>
<span class="dashicons dashicons-hidden"></span>
<?php } else { ?>
<span class="dashicons dashicons-visibility"></span>
<?php } ?>
</a>
<h3><?php esc_html_e( 'Set your homepage page template to "Frontpage".', 'onepress' ); ?></h3>
<div class="about">
<p><?php esc_html_e( 'In order to change homepage section contents, you will need to set template "Frontpage" for your homepage.', 'onepress' ); ?></p>
</div>
<p>
<?php
$front_page = get_option( 'page_on_front' );
if ( $front_page <= 0 ) {
?>
<a href="<?php echo admin_url('options-reading.php'); ?>" class="button"><?php esc_html_e('Setup front page displays', 'onepress'); ?></a>
<?php
}
if ( $front_page > 0 && get_post_meta( $front_page, '_wp_page_template', true ) != 'template-frontpage.php' ) {
?>
<a href="<?php echo get_edit_post_link( $front_page ); ?>" class="button"><?php esc_html_e('Change homepage page template', 'onepress'); ?></a>
<?php
}
?>
</p>
</div>
<?php } ?>
<?php do_action( 'onepress_more_required_details', $actions ); ?>
<?php } else { ?>
<h3><?php printf( __( 'Keep %s updated', 'onepress' ) , $theme_data->Name ); ?></h3>
<p><?php _e( 'Hooray! There are no required actions for you right now.', 'onepress' ); ?></p>
<?php } ?>
</div>
<?php } ?>
<?php if ( ! class_exists('OnePress_Plus') ) { ?>
<?php if ( $tab == 'free_pro' ) { ?>
<div id="free_pro" class="freepro-tab-content info-tab-content">
<table class="free-pro-table">
<thead><tr><th></th><th>OnePress</th><th>OnePress Plus</th></tr></thead>
<tbody>
<tr>
<td>
<h4>WooCommerce Support</h4>
</td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Hero Section</h4>
</td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h5>- Full Screen</h5>
</td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h5>- Background Video</h5>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h5>- Background Slides</h5>
</td>
<td class="only-pro"><span class="dashicons-before ">2</span></td>
<td class="only-lite"><span class="dashicons-before">Unlimited</span></td>
</tr>
<tr>
<td>
<h4>About Section</h4>
</td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h5>- Number of items</h5>
</td>
<td class="only-pro"><span class="dashicons-before ">3</span></td>
<td class="only-lite"><span class="dashicons-before">Unlimited</span></td>
</tr>
<tr>
<td>
<h4>Service Section</h4>
</td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h5>- Number of items</h5>
</td>
<td class="only-pro"><span class="dashicons-before ">4</span></td>
<td class="only-lite"><span class="dashicons-before">Unlimited</span></td>
</tr>
<tr>
<td>
<h4>Counter Section</h4>
</td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h5>- Number of counter items</h5>
</td>
<td class="only-pro"><span class="dashicons-before ">4</span></td>
<td class="only-lite"><span class="dashicons-before">Unlimited</span></td>
</tr>
<tr>
<td>
<h4>Team Section</h4>
</td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h5>- Number of members</h5>
</td>
<td class="only-pro"><span class="dashicons-before ">4</span></td>
<td class="only-lite"><span class="dashicons-before">Unlimited</span></td>
</tr>
<tr>
<td>
<h4>Latest News Section</h4>
</td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Contact Section</h4>
</td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Drag and drop section orders</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Add New Section</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Styling for all sections</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Google Map Section</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Pricing Section</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Testimonial Section</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Call To Action Section</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Projects Section</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Typography Options</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>Footer Copyright Editor</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr>
<td>
<h4>24/7 Priority Support</h4>
</td>
<td class="only-pro"><span class="dashicons-before dashicons-no-alt"></span></td>
<td class="only-lite"><span class="dashicons-before dashicons-yes"></span></td>
</tr>
<tr class="ti-about-page-text-center"><td></td><td colspan="2"><a href="https://www.famethemes.com/plugins/onepress-plus/?utm_source=theme_dashboard&utm_medium=compare_table&utm_campaign=onepress" target="_blank" class="button button-primary button-hero"><?php esc_attr_e('Get OnePress Plus now!', 'onepress') ?></a></td></tr>
</tbody>
</table>
</div>
<?php } ?>
<?php } ?>
<?php if ( $tab == 'demo-data-importer' ) { ?>
<div class="demo-import-tab-content info-tab-content">
<?php if ( has_action( 'onepress_demo_import_content_tab' ) ) {
do_action( 'onepress_demo_import_content_tab' );
} else { ?>
<div id="plugin-filter" class="demo-import-boxed">
<?php
$plugin_name = 'famethemes-demo-importer';
$status = is_dir( WP_PLUGIN_DIR . '/' . $plugin_name );
$button_class = 'install-now button';
$button_txt = esc_html__( 'Install Now', 'onepress' );
if ( ! $status ) {
$install_url = wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => $plugin_name
),
network_admin_url( 'update.php' )
),
'install-plugin_'.$plugin_name
);
} else {
$install_url = add_query_arg(array(
'action' => 'activate',
'plugin' => rawurlencode( $plugin_name . '/' . $plugin_name . '.php' ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce('activate-plugin_' . $plugin_name . '/' . $plugin_name . '.php'),
), network_admin_url('plugins.php'));
$button_class = 'activate-now button-primary';
$button_txt = esc_html__( 'Active Now', 'onepress' );
}
$detail_link = add_query_arg(
array(
'tab' => 'plugin-information',
'plugin' => $plugin_name,
'TB_iframe' => 'true',
'width' => '772',
'height' => '349',
),
network_admin_url( 'plugin-install.php' )
);
echo '<p>';
printf( esc_html__(
'%1$s you will need to install and activate the %2$s plugin first.', 'onepress' ),
'<b>'.esc_html__( 'Hey.', 'onepress' ).'</b>',
'<a class="thickbox open-plugin-details-modal" href="'.esc_url( $detail_link ).'">'.esc_html__( 'FameThemes Demo Importer', 'onepress' ).'</a>'
);
echo '</p>';
echo '<p class="plugin-card-'.esc_attr( $plugin_name ).'"><a href="'.esc_url( $install_url ).'" data-slug="'.esc_attr( $plugin_name ).'" class="'.esc_attr( $button_class ).'">'.$button_txt.'</a></p>';
?>
</div>
<?php } ?>
</div>
<?php } ?>
<?php do_action( 'onepress_more_tabs_details', $actions ); ?>
</div> <!-- END .theme_info -->
<script type="text/javascript">
jQuery( document).ready( function( $ ){
$( 'body').addClass( 'about-php' );
$( '.copy-settings-form').on( 'submit', function(){
var c = confirm( '<?php echo esc_attr_e( 'Are you sure want to copy ?', 'onepress' ); ?>' );
if ( ! c ) {
return false;
}
} );
} );
</script>
<?php
}
function render_recommend_plugins( $recommend_plugins = array() ){
foreach ( $recommend_plugins as $plugin_slug => $plugin_info ) {
$plugin_info = wp_parse_args( $plugin_info, array(
'name' => '',
'active_filename' => '',
) );
$plugin_name = $plugin_info['name'];
$status = is_dir( WP_PLUGIN_DIR . '/' . $plugin_slug );
$button_class = 'install-now button';
if ( $plugin_info['active_filename'] ) {
$active_file_name = $plugin_info['active_filename'] ;
} else {
$active_file_name = $plugin_slug . '/' . $plugin_slug . '.php';
}
if ( ! is_plugin_active( $active_file_name ) ) {
$button_txt = esc_html__( 'Install Now', 'onepress' );
if ( ! $status ) {
$install_url = wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => $plugin_slug
),
network_admin_url( 'update.php' )
),
'install-plugin_'.$plugin_slug
);
} else {
$install_url = add_query_arg(array(
'action' => 'activate',
'plugin' => rawurlencode( $active_file_name ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce('activate-plugin_' . $active_file_name ),
), network_admin_url('plugins.php'));
$button_class = 'activate-now button-primary';
$button_txt = esc_html__( 'Active Now', 'onepress' );
}
$detail_link = add_query_arg(
array(
'tab' => 'plugin-information',
'plugin' => $plugin_slug,
'TB_iframe' => 'true',
'width' => '772',
'height' => '349',
),
network_admin_url( 'plugin-install.php' )
);
echo '<div class="rcp">';
echo '<h4 class="rcp-name">';
echo esc_html( $plugin_name );
echo '</h4>';
echo '<p class="action-btn plugin-card-'.esc_attr( $plugin_slug ).'"><a href="'.esc_url( $install_url ).'" data-slug="'.esc_attr( $plugin_slug ).'" class="'.esc_attr( $button_class ).'">'.$button_txt.'</a></p>';
echo '<a class="plugin-detail thickbox open-plugin-details-modal" href="'.esc_url( $detail_link ).'">'.esc_html__( 'Details', 'onepress' ).'</a>';
echo '</div>';
}
}
}
function admin_dismiss_actions(){
// Action for dismiss
if ( isset( $_GET['onepress_action_notice'] ) ) {
$actions_dismiss = get_option( 'onepress_actions_dismiss' );
if ( ! is_array( $actions_dismiss ) ) {
$actions_dismiss = array();
}
$action_key = sanitize_text_field( $_GET['onepress_action_notice'] );
if ( isset( $actions_dismiss[ $action_key ] ) && $actions_dismiss[ $action_key ] == 'hide' ){
$actions_dismiss[ $action_key ] = 'show';
} else {
$actions_dismiss[ $action_key ] = 'hide';
}
update_option( 'onepress_actions_dismiss', $actions_dismiss );
$url = wp_unslash( $_SERVER['REQUEST_URI'] );
$url = remove_query_arg( 'onepress_action_notice', $url );
wp_redirect( $url );
die();
}
// Action for copy options
if ( isset( $_POST['copy_from'] ) && isset( $_POST['copy_to'] ) ) {
$from = sanitize_text_field( $_POST['copy_from'] );
$to = sanitize_text_field( $_POST['copy_to'] );
if ( $from && $to ) {
$mods = get_option("theme_mods_" . $from);
update_option("theme_mods_" . $to, $mods);
$url = wp_unslash( $_SERVER['REQUEST_URI'] );
$url = add_query_arg(array('copied' => 1), $url);
wp_redirect($url);
die();
}
}
}
/**
* Get theme actions required
*
* @return array|mixed|void
*/
function get_recommended_actions( ) {
$actions = array();
$front_page = get_option( 'page_on_front' );
$actions['page_on_front'] = 'dismiss';
$actions['page_template'] = 'dismiss';
$actions['recommend_plugins'] = 'dismiss';
if ( 'page' != get_option( 'show_on_front' ) ) {
$front_page = 0;
}
if ( $front_page <= 0 ) {
$actions['page_on_front'] = 'active';
$actions['page_template'] = 'active';
} else {
if ( get_post_meta( $front_page, '_wp_page_template', true ) == 'template-frontpage.php' ) {
$actions['page_template'] = 'dismiss';
} else {
$actions['page_template'] = 'active';
}
}
$recommend_plugins = get_theme_support( 'recommend-plugins' );
if ( is_array( $recommend_plugins ) && isset( $recommend_plugins[0] ) ){
$recommend_plugins = $recommend_plugins[0];
} else {
$recommend_plugins[] = array();
}
if ( ! empty( $recommend_plugins ) ) {
foreach ( $recommend_plugins as $plugin_slug => $plugin_info ) {
$plugin_info = wp_parse_args( $plugin_info, array(
'name' => '',
'active_filename' => '',
) );
if ( $plugin_info['active_filename'] ) {
$active_file_name = $plugin_info['active_filename'] ;
} else {
$active_file_name = $plugin_slug . '/' . $plugin_slug . '.php';
}
if ( ! is_plugin_active( $active_file_name ) ) {
$actions['recommend_plugins'] = 'active';
}
}
}
$actions = apply_filters( 'onepress_get_recommended_actions', $actions );
$hide_by_click = get_option( 'onepress_actions_dismiss' );
if ( ! is_array( $hide_by_click ) ) {
$hide_by_click = array();
}
$n_active = $n_dismiss = 0;
$number_notice = 0;
foreach ( $actions as $k => $v ) {
if ( ! isset( $hide_by_click[ $k ] ) ) {
$hide_by_click[ $k ] = false;
}
if ( $v == 'active' ) {
$n_active ++ ;
$number_notice ++ ;
if ( $hide_by_click[ $k ] ) {
if ( $hide_by_click[ $k ] == 'hide' ) {
$number_notice -- ;
}
}
} else if ( $v == 'dismiss' ) {
$n_dismiss ++ ;
}
}
$return = array(
'actions' => $actions,
'number_actions' => count( $actions ),
'number_active' => $n_active,
'number_dismiss' => $n_dismiss,
'hide_by_click' => $hide_by_click,
'number_notice' => $number_notice,
);
if ( $return['number_notice'] < 0 ) {
$return['number_notice'] = 0;
}
return $return;
}
}
Onepress_Dashboard::get_instance()->init();
home/xbodynamge/lebauwcentre/wp-content/themes/customify/inc/admin/dashboard.php 0000644 00000063043 15114701343 0024224 0 ustar 00 <?php
class Customify_Dashboard {
static $_instance;
public $title;
public $config;
public $current_tab = '';
public $url = '';
static function get_instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
self::$_instance->url = admin_url( 'admin.php' );
self::$_instance->url = add_query_arg(
array( 'page' => 'customify' ),
self::$_instance->url
);
self::$_instance->title = __( 'Customify Options', 'customify' );
add_action( 'admin_menu', array( self::$_instance, 'add_menu' ), 5 );
add_action( 'admin_enqueue_scripts', array( self::$_instance, 'scripts' ) );
add_action( 'customify/dashboard/main', array( self::$_instance, 'copy_theme_settings' ), 5 );
add_action( 'customify/dashboard/main', array( self::$_instance, 'box_links' ), 10 );
add_action( 'customify/dashboard/main', array( self::$_instance, 'pro_modules_box' ), 15 );
add_action( 'customify/dashboard/sidebar', array( self::$_instance, 'box_plugins' ), 10 );
add_action( 'customify/dashboard/sidebar', array( self::$_instance, 'box_recommend_plugins' ), 20 );
add_action( 'customify/dashboard/sidebar', array( self::$_instance, 'box_community' ), 25 );
add_action( 'admin_notices', array( self::$_instance, 'admin_notice' ) );
add_action( 'admin_init', array( self::$_instance, 'admin_init' ) );
// Tabs.
add_action( 'customify/dashboard/tab/changelog', array( self::$_instance, 'tab_changelog' ) );
}
return self::$_instance;
}
function add_url_args( $args = array() ) {
return add_query_arg( $args, self::$_instance->url );
}
/**
* Add admin notice when active theme.
*/
function admin_notice() {
global $pagenow;
if ( is_admin() && ( 'themes.php' == $pagenow ) && isset( $_GET['activated'] ) ) {
customify_maybe_change_header_version();
?>
<div class="customify-notice-wrapper notice is-dismissible">
<div class="customify-notice">
<div class="customify-notice-img">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/admin/customify_logo@2x.png' ); ?>" alt="<?php esc_attr_e( 'logo', 'customify' ); ?>">
</div>
<div class="customify-notice-content">
<div class="customify-notice-heading"><?php _e( 'Thanks for installing Customify, you rock! <img draggable="false" class="emoji" alt="" src="https://s.w.org/images/core/emoji/2.4/svg/1f918.svg">', 'customify' ); ?></div>
<p><?php printf( __( 'To fully take advantage of the best our theme can offer please make sure you visit our <a href="%1$s">Customify options page</a>.', 'customify' ), esc_url( admin_url( 'themes.php?page=customify' ) ) ); ?></p>
<?php if ( is_child_theme() ) { ?>
<?php $child_theme = wp_get_theme(); ?>
<?php printf( esc_html__( 'You\'re using %1$s theme, It\'s a child theme of %2$s.', 'customify' ), '<strong>' . $child_theme->Name . '</strong>', '<strong>' . esc_html__( 'Customify', 'customify' ). '</strong>' ); // phpcs:ignore ?>
<?php
$copy_link_args = array(
'page' => 'customify',
'action' => 'show_copy_settings',
);
$copy_link = add_query_arg( $copy_link_args, admin_url( 'themes.php' ) );
?>
<?php printf( '%s <a href="%s" class="go-to-setting">%s</a>', esc_html__( 'Now you can copy setting data from parent theme to this child theme', 'customify' ), esc_url( $copy_link ), esc_html__( 'Copy Settings', 'customify' ) ); ?>
<?php } ?>
</div>
</div>
</div>
<?php
}
if ( isset( $_GET['copied'] ) && 1 == $_GET['copied'] ) {
?>
<div class="notice notice-success is-dismissible">
<p><strong><span class="dashicons dashicons-yes" style="color: #79ba49;"></span> <?php esc_html_e( 'Your theme settings were copied.', 'customify' ); ?></strong></p>
</div>
<?php
}
}
function add_menu() {
add_theme_page(
$this->title,
$this->title,
'manage_options',
'customify',
array( $this, 'page' )
);
}
/**
* Register scripts
*
* @param string $id
*/
function scripts( $id ) {
if ( 'appearance_page_customify' != $id && 'themes.php' != $id ) {
return;
}
$suffix = Customify()->get_asset_suffix();
wp_enqueue_style( 'customify-admin', esc_url( get_template_directory_uri() ) . '/assets/css/admin/dashboard' . $suffix . '.css', false, Customify::$version );
if ( 'themes' != $id ) {
wp_enqueue_style( 'plugin-install' );
wp_enqueue_script( 'plugin-install' );
wp_enqueue_script( 'updates' );
add_thickbox();
}
}
function setup() {
$theme = wp_get_theme();
if ( is_child_theme() ) {
$theme = $theme->parent();
}
$this->config = array(
'name' => $theme->get( 'Name' ),
'theme_uri' => $theme->get( 'ThemeURI' ),
'desc' => $theme->get( 'Description' ),
'author' => $theme->get( 'Author' ),
'author_uri' => $theme->get( 'AuthorURI' ),
'version' => $theme->get( 'Version' ),
);
$this->current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : ''; // phpcs:ignore
}
function page() {
$this->setup();
$this->page_header();
echo '<div class="wrap">';
$cb = apply_filters( 'customify/dashboard/content_cb', false );
if ( ! is_callable( $cb ) ) {
$cb = array( $this, 'page_inner' );
}
if ( is_callable( $cb ) ) {
call_user_func_array( $cb, array( $this ) );
}
echo '</div>';
}
public function page_header() {
?>
<div class="cd-header">
<div class="cd-row">
<div class="cd-header-inner">
<a href="https://pressmaximum.com" target="_blank" class="cd-branding">
<img src="<?php echo esc_url( get_template_directory_uri() ) . '/assets/images/admin/customify_logo@2x.png'; ?>" alt="<?php esc_attr_e( 'logo', 'customify' ); ?>">
</a>
<span class="cd-version"><?php echo esc_html( $this->config['version'] ); ?></span>
<a class="cd-top-link" href="<?php echo esc_url( $this->add_url_args( array( 'tab' => 'changelog' ) ) ); ?>"><?php _e( 'Changelog', 'customify' ); ?></a>
</div>
</div>
</div>
<?php
}
function tab_changelog() {
global $wp_filesystem;
WP_Filesystem();
$file = get_template_directory() . '/changelog.txt';
if ( file_exists( $file ) ) {
$file_contents = $wp_filesystem->get_contents( $file );
}
?>
<p>
<a class="button button-secondary" href="<?php echo esc_url( $this->url ); ?>"><?php _e( 'Back', 'customify' ); ?></a>
</p>
<?php
do_action( 'customify/dashboard/changelog/before' );
?>
<div class="cd-box theme-changelog">
<div class="cd-box-top"><?php _e( 'Changelog', 'customify' ); ?></div>
<div class="cd-box-content">
<pre style="width: 100%; max-height: 60vh; overflow: auto"><?php echo esc_textarea( $file_contents ); ?></pre>
</div>
</div>
<?php
do_action( 'customify/dashboard/changelog/after' );
}
function admin_init() {
// Action for copy options.
if ( isset( $_POST['copy_from'] ) && isset( $_POST['copy_to'] ) ) {
$from = sanitize_text_field( $_POST['copy_from'] );
$to = sanitize_text_field( $_POST['copy_to'] );
if ( $from && $to ) {
$mods = get_option( 'theme_mods_' . $from );
update_option( 'theme_mods_' . $to, $mods );
$url = wp_unslash( $_SERVER['REQUEST_URI'] );
$url = add_query_arg( array( 'copied' => 1 ), $url );
wp_redirect( $url );
die();
}
}
}
function copy_theme_settings() {
if ( is_child_theme() && isset( $_GET['action'] ) && 'show_copy_settings' == $_GET['action'] ) {
$child_theme = wp_get_theme();
$current_action_link = admin_url( 'themes.php?page=customify' );
?>
<div class="cd-box copy-theme-settings">
<div class="cd-box-top">
<?php _e( 'Copy Settings', 'customify' ); ?>
<button type="button" class="notice-dismiss js-dismiss-notice" data-base_url="<?php echo esc_url( admin_url( 'themes.php?page=customify' ) ); ?>"></button>
</div>
<div class="cd-box-content">
<form method="post" action="<?php echo esc_attr( $current_action_link ); ?>" class="demo-import-boxed copy-settings-form">
<p>
<strong> <?php printf( esc_html__( 'You\'re using %1$s theme, It\'s a child theme of Customify', 'customify' ), $child_theme->Name ); // phpcs:ignore ?></strong>
</p>
<p><?php printf( esc_html__( "Child theme uses it's own theme setting name, would you like to copy setting data from parent theme to this child theme?", 'customify' ) ); ?></p>
<div class="form-fields">
<div class="select-theme-fields">
<?php
$select = '<select name="copy_from">';
$select .= '<option value="">' . esc_html__( 'From Theme', 'customify' ) . '</option>';
$select .= '<option value="customify">Customify</option>';
$select .= '<option value="' . esc_attr( $child_theme->get_stylesheet() ) . '">' . ( $child_theme->Name ) . '</option>'; // phpcs:ignore
$select .= '</select>';
$select_2 = '<select name="copy_to">';
$select_2 .= '<option value="">' . esc_html__( 'To Theme', 'customify' ) . '</option>';
$select_2 .= '<option value="customify">Customify</option>';
$select_2 .= '<option value="' . esc_attr( $child_theme->get_stylesheet() ) . '">' . ( $child_theme->Name ) . '</option>'; // phpcs:ignore
$select_2 .= '</select>';
echo sprintf( '%1$s <span>%2$s</span> %3$s', $select, esc_html__( 'To', 'customify' ), $select_2 );
?>
</div>
<div class="submit-field">
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Copy now', 'customify' ); ?>">
</div>
</div>
</form>
</div>
</div>
<?php
}
}
function box_links() {
$url = admin_url( 'customize.php' );
$links = array(
array(
'label' => __( 'Logo & Site Identity', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'section' => 'title_tagline' ) ), $url ),
),
array(
'label' => __( 'Layout Settings', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'section' => 'global_layout_section' ) ), $url ),
),
array(
'label' => __( 'Header Builder', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'panel' => 'header_settings' ) ), $url ),
),
array(
'label' => __( 'Footer Builder', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'panel' => 'footer_settings' ) ), $url ),
),
array(
'label' => __( 'Styling', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'panel' => 'styling_panel' ) ), $url ),
),
array(
'label' => __( 'Typography', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'panel' => 'typography_panel' ) ), $url ),
),
array(
'label' => __( 'Sidebar Settings', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'section' => 'sidebar_layout_section' ) ), $url ),
),
array(
'label' => __( 'Titlebar Settings', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'section' => 'titlebar' ) ), $url ),
),
array(
'label' => __( 'Blog Posts', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'panel' => 'blog_panel' ) ), $url ),
),
array(
'label' => __( 'Homepage Settings', 'customify' ),
'url' => add_query_arg( array( 'autofocus' => array( 'section' => 'static_front_page' ) ), $url ),
),
);
$links = apply_filters( 'customify/dashboard/links', $links );
?>
<div class="cd-box">
<div class="cd-box-top"><?php _e( 'Links to Customizer Settings', 'customify' ); ?></div>
<div class="cd-box-content">
<ul class="cd-list-flex">
<?php foreach ( $links as $l ) { ?>
<li class="">
<a class="cd-quick-setting-link" href="<?php echo esc_url( $l['url'] ); ?>" target="_blank"><?php echo esc_html( $l['label'] ); ?></a>
</li>
<?php } ?>
</ul>
</div>
</div>
<?php
}
/**
* Display community info
*/
function box_community() {
?>
<div class="cd-box">
<div class="cd-box-top"><?php _e( 'Join the community!', 'customify' ); ?></div>
<div class="cd-box-content">
<p><?php _e( 'Join the Facebook group for updates, discussions, chat with other Customify lovers.', 'customify' ); ?></p>
<a target="_blank" href="https://www.facebook.com/groups/133106770857743"><?php _e( 'Join Our Facebook Group → ', 'customify' ); ?></a>
</div>
</div>
<?php
}
/**
* Display recommend plugins
*/
function box_plugins() {
?>
<div class="cd-box box-plugins">
<div class="cd-box-top"><?php _e( 'Customify ready to import sites', 'customify' ); ?></div>
<div class="cd-sites-thumb">
<img src="<?php echo esc_url( get_template_directory_uri() ) . '/assets/images/admin/sites_thumbnail.jpg'; ?>">
</div>
<div class="cd-box-content">
<p><?php _e( '<strong>Customify Sites</strong> is a free add-on for the Customify theme which help you browse and import ready made websites with few clicks.', 'customify' ); ?></p>
<?php
$plugin_slug = 'customify-sites';
$plugin_info = array(
'name' => 'customify-sites',
'active_filename' => 'customify-sites/customify-sites.php',
);
$plugin_info = wp_parse_args(
$plugin_info,
array(
'name' => '',
'active_filename' => '',
)
);
$status = is_dir( WP_PLUGIN_DIR . '/' . $plugin_slug );
$button_class = 'install-now button'; if ( $plugin_info['active_filename'] ) {
$active_file_name = $plugin_info['active_filename'];
} else {
$active_file_name = $plugin_slug . '/' . $plugin_slug . '.php';
}
$sites_url = add_query_arg(
array(
'page' => 'customify-sites',
),
admin_url( 'themes.php' )
);
$view_site_txt = __( 'View Site Library', 'customify' );
if ( ! is_plugin_active( $active_file_name ) ) {
$button_txt = esc_html__( 'Install Now', 'customify' );
if ( ! $status ) {
$install_url = wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => $plugin_slug,
),
network_admin_url( 'update.php' )
),
'install-plugin_' . $plugin_slug
);
} else {
$install_url = add_query_arg(
array(
'action' => 'activate',
'plugin' => rawurlencode( $active_file_name ),
'plugin_status' => 'all',
'paged' => '1',
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $active_file_name ),
),
network_admin_url( 'plugins.php' )
);
$button_class = 'activate-now button-primary';
$button_txt = esc_html__( 'Active Now', 'customify' );
}
$detail_link = add_query_arg(
array(
'tab' => 'plugin-information',
'plugin' => $plugin_slug,
'TB_iframe' => 'true',
'width' => '772',
'height' => '349',
),
network_admin_url( 'plugin-install.php' )
);
echo '<div class="rcp">';
echo '<p class="action-btn plugin-card-' . esc_attr( $plugin_slug ) . '"><a href="' . esc_url( $install_url ) . '" data-slug="' . esc_attr( $plugin_slug ) . '" class="' . esc_attr( $button_class ) . '">' . $button_txt . '</a></p>'; // WPCS: XSS OK.
echo '<a class="plugin-detail thickbox open-plugin-details-modal" href="' . esc_url( $detail_link ) . '">' . esc_html__( 'Details', 'customify' ) . '</a>';
echo '</div>';
} else {
echo '<div class="rcp">';
echo '<p ><a href="' . esc_url( $sites_url ) . '" data-slug="' . esc_attr( $plugin_slug ) . '" class="view-site-library">' . $view_site_txt . '</a></p>'; // // WPCS: XSS OK.
echo '</div>';
}
?>
<script type="text/javascript">
jQuery( document ).ready( function($){
var sites_url = <?php echo json_encode( $sites_url ); // phpcs:ignore ?>;
var view_sites = <?php echo json_encode( $view_site_txt ); // phpcs:ignore ?>;
$( '#plugin-filter .box-plugins' ).on( 'click', '.activate-now', function( e ){
e.preventDefault();
var button = $( this );
var url = button.attr('href');
button.addClass( 'button installing updating-message' );
$.get( url, function( ){
$( '.rcp .plugin-detail' ).hide();
button.attr( 'href', sites_url );
button.attr( 'class', 'view-site-library' );
button.text( view_sites );
} );
} );
} );
</script>
</div>
</div>
<?php
}
function get_plugin_file( $plugin_slug ) {
$installed_plugins = get_plugins();
foreach ( (array) $installed_plugins as $plugin_file => $info ) {
if ( strpos( $plugin_file, $plugin_slug . '/' ) === 0 ) {
return $plugin_file;
}
}
return false;
}
function get_first_tag( $content ) {
$content = wp_kses(
$content,
array(
'a' => array(
'href' => array(),
'title' => array(),
),
'br' => array(),
'p' => array(),
'em' => array(),
'strong' => array(),
)
);
$content = substr( $content, 0, strpos( $content, '</p>' ) + 4 );
return $content;
}
function box_recommend_plugins() {
$list_plugins = array(
'themeisle-companion',
'elementor',
'beaver-builder-lite-version',
'wpforms-lite',
);
$list_plugins = apply_filters( 'customify/recommend-plugins', $list_plugins );
$key = 'customify_plugins_info_' . wp_hash( json_encode( $list_plugins ) ); // phpcs:ignore
$plugins_info = get_transient( $key );
if ( false === $plugins_info ) {
$plugins_info = array();
if ( ! function_exists( 'plugins_api' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin-install.php';
}
foreach ( $list_plugins as $slug ) {
$info = plugins_api( 'plugin_information', array( 'slug' => $slug ) );
if ( ! is_wp_error( $info ) ) {
$plugins_info[ $slug ] = $info;
}
}
set_transient( $key, $plugins_info );
}
$html = '';
foreach ( $plugins_info as $plugin_slug => $info ) {
$status = is_dir( WP_PLUGIN_DIR . '/' . $plugin_slug );
$plugin_file = $this->get_plugin_file( $plugin_slug );
if ( ! is_plugin_active( $plugin_file ) ) {
$html .= '<div class="cd-list-item">';
$html .= '<p class="cd-list-name">' . esc_html( $info->name ) . '</p>';
if ( $status ) {
$button_class = 'activate-now';
$button_txt = esc_html__( 'Activate', 'customify' );
$url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ); // phpcs:ignore
} else {
$button_class = 'install-now';
$button_txt = esc_html__( 'Install Now', 'customify' );
$url = wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => $plugin_slug,
),
network_admin_url( 'update.php' )
),
'install-plugin_' . $plugin_slug
);
}
$detail_link = add_query_arg(
array(
'tab' => 'plugin-information',
'plugin' => $plugin_slug,
'TB_iframe' => 'true',
'width' => '772',
'height' => '349',
),
network_admin_url( 'plugin-install.php' )
);
$class = 'action-btn plugin-card-' . $plugin_slug;
$html .= '<div class="rcp">';
$html .= '<p class="' . esc_attr( $class ) . '"><a href="' . esc_url( $url ) . '" data-slug="' . esc_attr( $plugin_slug ) . '" class="' . esc_attr( $button_class ) . '">' . $button_txt . '</a></p>';
$html .= '<a class="plugin-detail thickbox open-plugin-details-modal" href="' . esc_url( $detail_link ) . '">' . esc_html__( 'Details', 'customify' ) . '</a>';
$html .= '</div>';
$html .= '</div>';
}
} // end foreach
if ( $html ) {
?>
<div class="cd-box">
<div class="cd-box-top"><?php _e( 'Recommend Plugins', 'customify' ); ?></div>
<div class="cd-box-content cd-list-border">
<?php
echo $html; // WPCS: XSS OK.
?>
</div>
</div>
<?php
}
}
function pro_modules_box() {
$modules = array(
array(
'name' => __( 'Header Transparent', 'customify' ),
'desc' => __( 'Make your website stand out with transparent header modules.', 'customify' ),
'url' => 'https://pressmaximum.com/docs/customify/customify-pro-modules/header-transparent/',
),
array(
'name' => __( 'Header Sticky', 'customify' ),
'desc' => __( 'Let your header accessible when users scroll up or down in unique style.', 'customify' ),
'url' => 'https://pressmaximum.com/docs/customify/customify-pro-modules/header-sticky/',
),
array(
'name' => __( 'Header and Footer Builder Booster', 'customify' ),
'desc' => __( 'Get more header and footer builder items, plus advanced styling options.', 'customify' ),
'url' => 'https://pressmaximum.com/docs/customify/customify-pro-modules/advanced-header-footer-builder/',
),
array(
'name' => __( 'Scroll To Top', 'customify' ),
'desc' => __( 'Get a better user experience with a scroll to top button with beautiful animation.', 'customify' ),
'url' => 'https://pressmaximum.com/docs/customify/customify-pro-modules/scroll-to-top/',
),
array(
'name' => __( 'Blog Pro', 'customify' ),
'desc' => __( 'Take advantage of the Blog Pro module to show off your posts in any layouts.', 'customify' ),
'url' => 'https://pressmaximum.com/docs/customify/customify-pro-modules/blog-pro/',
),
array(
'name' => __( 'Advanced Styling', 'customify' ),
'desc' => __( 'Control the layout and typography setting for page header title, page header cover and more.', 'customify' ),
'url' => 'https://pressmaximum.com/docs/customify/customify-pro-modules/advanced-styling/',
),
array(
'name' => __( 'Portfolio', 'customify' ),
'desc' => __( 'Show off your best project in a beautiful way.', 'customify' ),
'url' => 'https://pressmaximum.com/docs/customify/customify-pro-modules/portfolio/',
),
array(
'name' => __( 'Multiple Headers', 'customify' ),
'desc' => __( 'Create unique header for each page, post, archive or WooCommerce pages.', 'customify' ),
'url' => 'https://pressmaximum.com/docs/customify/customify-pro-modules/multiple-headers/',
),
array(
'name' => __( 'Mega Menu', 'customify' ),
'desc' => __( 'Create mega menu for your sites that need more space for navigation.', 'customify' ),
'url' => 'https://pressmaximum.com/docs/customify/customify-pro-modules/mega-menu/',
),
array(
'name' => __( 'Multilingual Integration', 'customify' ),
'desc' => __( 'WPML multilingual plugin support, plus a fully customized language switcher header builder item.', 'customify' ),
'url' => '',
),
array(
'name' => __( 'Custom Fonts', 'customify' ),
'desc' => __( 'Custom Fonts module allows you to add your self-hosted fonts and use them on your Customify powered websites.', 'customify' ),
'url' => '',
),
array(
'name' => __( 'Typekit', 'customify' ),
'desc' => __( 'Typekit module allows you to add Typekit fonts and use them on your Customify powered websites.', 'customify' ),
'url' => '',
),
array(
'name' => __( 'Customify Hooks', 'customify' ),
'desc' => __( 'Add custom hook scripts.', 'customify' ),
'url' => '',
),
array(
'name' => __( 'WooCommerce Booster', 'customify' ),
'desc' => __( 'Gives you creative control of style and layout options for your shop.', 'customify' ),
'url' => '',
),
array(
'name' => __( 'Single Product Layouts', 'customify' ),
'desc' => __( 'More beautiful layouts for your single product.', 'customify' ),
'url' => '',
'sub' => true,
),
array(
'name' => __( 'Off Canvas Filter', 'customify' ),
'desc' => __( 'Add off canvas products filter for shop and product archive pages.', 'customify' ),
'url' => '',
'sub' => true,
),
array(
'name' => __( 'Product Gallery Slider', 'customify' ),
'desc' => __( 'Add slider for product gallery.', 'customify' ),
'url' => '',
'sub' => true,
),
array(
'name' => __( 'Quick View', 'customify' ),
'desc' => __( 'Add product quick view modal for product listing..', 'customify' ),
'url' => '',
'sub' => true,
),
array(
'name' => __( 'Infinity Scroll.', 'customify' ),
'desc' => __( 'Loads the next posts, products automatically when the reader approaches the bottom of the page.', 'customify' ),
'url' => '',
),
);
?>
<div class="cd-box">
<div class="cd-box-top"><?php _e( 'Customify Pro Modules', 'customify' ); ?>
<a class="cd-upgrade" target="_blank" href="https://pressmaximum.com/customify/pro-upgrade/?utm_source=theme_dashboard&utm_medium=links&utm_campaign=pro_modules"><?php _e( 'Upgrade Now →', 'customify' ); ?></a></div>
<div class="cd-box-content cd-modules">
<?php foreach ( $modules as $m ) { ?>
<div class="cd-module-item <?php echo isset( $m['sub'] ) && $m['sub'] ? 'cd-sub-module' : ''; ?>">
<div class="cd-module-info">
<div class="cd-module-name"><?php echo esc_html( $m['name'] ); ?></div>
<?php if ( isset( $m['desc'] ) ) { ?>
<div class="cd-module-desc"><?php echo esc_html( $m['desc'] ); ?></div>
<?php } ?>
</div>
</div>
<?php } ?>
</div>
</div>
<?php
}
private function page_inner() {
?>
<div id="plugin-filter" class="cd-row metabox-holder">
<hr class="wp-header-end">
<?php
do_action( 'customify/dashboard/start', $this );
if ( $this->current_tab && has_action( 'customify/dashboard/tab/' . $this->current_tab ) ) {
do_action( 'customify/dashboard/tab/' . $this->current_tab, $this );
} else {
?>
<div class="cd-main">
<?php do_action( 'customify/dashboard/main', $this ); ?>
</div>
<div class="cd-sidebar">
<?php do_action( 'customify/dashboard/sidebar', $this ); ?>
</div>
<?php
}
do_action( 'customify/dashboard/end', $this );
?>
</div>
<?php
}
}
Customify_Dashboard::get_instance();