[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/includes/ -> dashboard.php (source)

   1  <?php
   2  /**
   3   * WordPress Dashboard Widget Administration Screen API
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  /**
  10   * Registers dashboard widgets.
  11   *
  12   * Handles POST data, sets up filters.
  13   *
  14   * @since 2.5.0
  15   *
  16   * @global array $wp_registered_widgets
  17   * @global array $wp_registered_widget_controls
  18   * @global array $wp_dashboard_control_callbacks
  19   */
  20  function wp_dashboard_setup() {
  21      global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
  22      $wp_dashboard_control_callbacks = array();
  23      $screen                         = get_current_screen();
  24  
  25      /* Register Widgets and Controls */
  26  
  27      $response = wp_check_browser_version();
  28  
  29      if ( $response && $response['upgrade'] ) {
  30          add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
  31          if ( $response['insecure'] ) {
  32              wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
  33          } else {
  34              wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
  35          }
  36      }
  37  
  38      // PHP Version.
  39      $response = wp_check_php_version();
  40      if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] && current_user_can( 'update_php' ) ) {
  41          add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
  42          wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' );
  43      }
  44  
  45      // Right Now
  46      if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
  47          wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
  48      }
  49  
  50      if ( is_network_admin() ) {
  51          wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
  52      }
  53  
  54      // Activity Widget
  55      if ( is_blog_admin() ) {
  56          wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
  57      }
  58  
  59      // QuickPress Widget
  60      if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
  61          $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' ) );
  62          wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
  63      }
  64  
  65      // WordPress Events and News
  66      wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' );
  67  
  68      if ( is_network_admin() ) {
  69  
  70          /**
  71           * Fires after core widgets for the Network Admin dashboard have been registered.
  72           *
  73           * @since 3.1.0
  74           */
  75          do_action( 'wp_network_dashboard_setup' );
  76  
  77          /**
  78           * Filters the list of widgets to load for the Network Admin dashboard.
  79           *
  80           * @since 3.1.0
  81           *
  82           * @param string[] $dashboard_widgets An array of dashboard widget IDs.
  83           */
  84          $dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
  85      } elseif ( is_user_admin() ) {
  86  
  87          /**
  88           * Fires after core widgets for the User Admin dashboard have been registered.
  89           *
  90           * @since 3.1.0
  91           */
  92          do_action( 'wp_user_dashboard_setup' );
  93  
  94          /**
  95           * Filters the list of widgets to load for the User Admin dashboard.
  96           *
  97           * @since 3.1.0
  98           *
  99           * @param string[] $dashboard_widgets An array of dashboard widget IDs.
 100           */
 101          $dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
 102      } else {
 103  
 104          /**
 105           * Fires after core widgets for the admin dashboard have been registered.
 106           *
 107           * @since 2.5.0
 108           */
 109          do_action( 'wp_dashboard_setup' );
 110  
 111          /**
 112           * Filters the list of widgets to load for the admin dashboard.
 113           *
 114           * @since 2.5.0
 115           *
 116           * @param string[] $dashboard_widgets An array of dashboard widget IDs.
 117           */
 118          $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
 119      }
 120  
 121      foreach ( $dashboard_widgets as $widget_id ) {
 122          $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>';
 123          wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] );
 124      }
 125  
 126      if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) {
 127          check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' );
 128          ob_start(); // hack - but the same hack wp-admin/widgets.php uses
 129          wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
 130          ob_end_clean();
 131          wp_redirect( remove_query_arg( 'edit' ) );
 132          exit;
 133      }
 134  
 135      /** This action is documented in wp-admin/includes/meta-boxes.php */
 136      do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
 137  
 138      /** This action is documented in wp-admin/includes/meta-boxes.php */
 139      do_action( 'do_meta_boxes', $screen->id, 'side', '' );
 140  }
 141  
 142  /**
 143   * Adds a new dashboard widget.
 144   *
 145   * @since 2.7.0
 146   *
 147   * @global array $wp_dashboard_control_callbacks
 148   *
 149   * @param string   $widget_id        Widget ID  (used in the 'id' attribute for the widget).
 150   * @param string   $widget_name      Title of the widget.
 151   * @param callable $callback         Function that fills the widget with the desired content.
 152   *                                   The function should echo its output.
 153   * @param callable $control_callback Optional. Function that outputs controls for the widget. Default null.
 154   * @param array    $callback_args    Optional. Data that should be set as the $args property of the widget array
 155   *                                   (which is the second parameter passed to your callback). Default null.
 156   */
 157  function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {
 158      $screen = get_current_screen();
 159      global $wp_dashboard_control_callbacks;
 160  
 161      $private_callback_args = array( '__widget_basename' => $widget_name );
 162  
 163      if ( is_null( $callback_args ) ) {
 164          $callback_args = $private_callback_args;
 165      } elseif ( is_array( $callback_args ) ) {
 166          $callback_args = array_merge( $callback_args, $private_callback_args );
 167      }
 168  
 169      if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
 170          $wp_dashboard_control_callbacks[ $widget_id ] = $control_callback;
 171          if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
 172              list($url)    = explode( '#', add_query_arg( 'edit', false ), 2 );
 173              $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
 174              $callback     = '_wp_dashboard_control_callback';
 175          } else {
 176              list($url)    = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
 177              $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
 178          }
 179      }
 180  
 181      $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
 182  
 183      $location = 'normal';
 184      if ( in_array( $widget_id, $side_widgets ) ) {
 185          $location = 'side';
 186      }
 187  
 188      $high_priority_widgets = array( 'dashboard_browser_nag', 'dashboard_php_nag' );
 189  
 190      $priority = 'core';
 191      if ( in_array( $widget_id, $high_priority_widgets, true ) ) {
 192          $priority = 'high';
 193      }
 194  
 195      add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );
 196  }
 197  
 198  /**
 199   * Outputs controls for the current dashboard widget.
 200   *
 201   * @access private
 202   * @since 2.7.0
 203   *
 204   * @param mixed $dashboard
 205   * @param array $meta_box
 206   */
 207  function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
 208      echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">';
 209      wp_dashboard_trigger_widget_control( $meta_box['id'] );
 210      wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' );
 211      echo '<input type="hidden" name="widget_id" value="' . esc_attr( $meta_box['id'] ) . '" />';
 212      submit_button( __( 'Submit' ) );
 213      echo '</form>';
 214  }
 215  
 216  /**
 217   * Displays the dashboard.
 218   *
 219   * @since 2.5.0
 220   */
 221  function wp_dashboard() {
 222      $screen      = get_current_screen();
 223      $columns     = absint( $screen->get_columns() );
 224      $columns_css = '';
 225      if ( $columns ) {
 226          $columns_css = " columns-$columns";
 227      }
 228  
 229      ?>
 230  <div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>">
 231      <div id="postbox-container-1" class="postbox-container">
 232      <?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
 233      </div>
 234      <div id="postbox-container-2" class="postbox-container">
 235      <?php do_meta_boxes( $screen->id, 'side', '' ); ?>
 236      </div>
 237      <div id="postbox-container-3" class="postbox-container">
 238      <?php do_meta_boxes( $screen->id, 'column3', '' ); ?>
 239      </div>
 240      <div id="postbox-container-4" class="postbox-container">
 241      <?php do_meta_boxes( $screen->id, 'column4', '' ); ?>
 242      </div>
 243  </div>
 244  
 245      <?php
 246      wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
 247      wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
 248  
 249  }
 250  
 251  //
 252  // Dashboard Widgets
 253  //
 254  
 255  /**
 256   * Dashboard widget that displays some basic stats about the site.
 257   *
 258   * Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8.
 259   *
 260   * @since 2.7.0
 261   */
 262  function wp_dashboard_right_now() {
 263      ?>
 264      <div class="main">
 265      <ul>
 266      <?php
 267      // Posts and Pages
 268      foreach ( array( 'post', 'page' ) as $post_type ) {
 269          $num_posts = wp_count_posts( $post_type );
 270          if ( $num_posts && $num_posts->publish ) {
 271              if ( 'post' == $post_type ) {
 272                  $text = _n( '%s Post', '%s Posts', $num_posts->publish );
 273              } else {
 274                  $text = _n( '%s Page', '%s Pages', $num_posts->publish );
 275              }
 276              $text             = sprintf( $text, number_format_i18n( $num_posts->publish ) );
 277              $post_type_object = get_post_type_object( $post_type );
 278              if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
 279                  printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
 280              } else {
 281                  printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
 282              }
 283          }
 284      }
 285      // Comments
 286      $num_comm = wp_count_comments();
 287      if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
 288          $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
 289          ?>
 290          <li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
 291          <?php
 292          $moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
 293          /* translators: %s: number of comments in moderation */
 294          $text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n );
 295          ?>
 296          <li class="comment-mod-count
 297          <?php
 298          if ( ! $num_comm->moderated ) {
 299              echo ' hidden';
 300          }
 301          ?>
 302          "><a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a></li>
 303          <?php
 304      }
 305  
 306      /**
 307       * Filters the array of extra elements to list in the 'At a Glance'
 308       * dashboard widget.
 309       *
 310       * Prior to 3.8.0, the widget was named 'Right Now'. Each element
 311       * is wrapped in list-item tags on output.
 312       *
 313       * @since 3.8.0
 314       *
 315       * @param string[] $items Array of extra 'At a Glance' widget items.
 316       */
 317      $elements = apply_filters( 'dashboard_glance_items', array() );
 318  
 319      if ( $elements ) {
 320          echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n";
 321      }
 322  
 323      ?>
 324      </ul>
 325      <?php
 326      update_right_now_message();
 327  
 328      // Check if search engines are asked not to index this site.
 329      if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) {
 330  
 331          /**
 332           * Filters the link title attribute for the 'Search Engines Discouraged'
 333           * message displayed in the 'At a Glance' dashboard widget.
 334           *
 335           * Prior to 3.8.0, the widget was named 'Right Now'.
 336           *
 337           * @since 3.0.0
 338           * @since 4.5.0 The default for `$title` was updated to an empty string.
 339           *
 340           * @param string $title Default attribute text.
 341           */
 342          $title = apply_filters( 'privacy_on_link_title', '' );
 343  
 344          /**
 345           * Filters the link label for the 'Search Engines Discouraged' message
 346           * displayed in the 'At a Glance' dashboard widget.
 347           *
 348           * Prior to 3.8.0, the widget was named 'Right Now'.
 349           *
 350           * @since 3.0.0
 351           *
 352           * @param string $content Default text.
 353           */
 354          $content    = apply_filters( 'privacy_on_link_text', __( 'Search Engines Discouraged' ) );
 355          $title_attr = '' === $title ? '' : " title='$title'";
 356  
 357          echo "<p><a href='options-reading.php'$title_attr>$content</a></p>";
 358      }
 359      ?>
 360      </div>
 361      <?php
 362      /*
 363       * activity_box_end has a core action, but only prints content when multisite.
 364       * Using an output buffer is the only way to really check if anything's displayed here.
 365       */
 366      ob_start();
 367  
 368      /**
 369       * Fires at the end of the 'At a Glance' dashboard widget.
 370       *
 371       * Prior to 3.8.0, the widget was named 'Right Now'.
 372       *
 373       * @since 2.5.0
 374       */
 375      do_action( 'rightnow_end' );
 376  
 377      /**
 378       * Fires at the end of the 'At a Glance' dashboard widget.
 379       *
 380       * Prior to 3.8.0, the widget was named 'Right Now'.
 381       *
 382       * @since 2.0.0
 383       */
 384      do_action( 'activity_box_end' );
 385  
 386      $actions = ob_get_clean();
 387  
 388      if ( ! empty( $actions ) ) :
 389          ?>
 390      <div class="sub">
 391          <?php echo $actions; ?>
 392      </div>
 393          <?php
 394      endif;
 395  }
 396  
 397  /**
 398   * @since 3.1.0
 399   */
 400  function wp_network_dashboard_right_now() {
 401      $actions = array();
 402      if ( current_user_can( 'create_sites' ) ) {
 403          $actions['create-site'] = '<a href="' . network_admin_url( 'site-new.php' ) . '">' . __( 'Create a New Site' ) . '</a>';
 404      }
 405      if ( current_user_can( 'create_users' ) ) {
 406          $actions['create-user'] = '<a href="' . network_admin_url( 'user-new.php' ) . '">' . __( 'Create a New User' ) . '</a>';
 407      }
 408  
 409      $c_users = get_user_count();
 410      $c_blogs = get_blog_count();
 411  
 412      /* translators: %s: number of users on the network */
 413      $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
 414      /* translators: %s: number of sites on the network */
 415      $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
 416  
 417      /* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */
 418      $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
 419  
 420      if ( $actions ) {
 421          echo '<ul class="subsubsub">';
 422          foreach ( $actions as $class => $action ) {
 423              $actions[ $class ] = "\t<li class='$class'>$action";
 424          }
 425          echo implode( " |</li>\n", $actions ) . "</li>\n";
 426          echo '</ul>';
 427      }
 428      ?>
 429      <br class="clear" />
 430  
 431      <p class="youhave"><?php echo $sentence; ?></p>
 432  
 433  
 434      <?php
 435          /**
 436           * Fires in the Network Admin 'Right Now' dashboard widget
 437           * just before the user and site search form fields.
 438           *
 439           * @since MU (3.0.0)
 440           */
 441          do_action( 'wpmuadminresult' );
 442      ?>
 443  
 444      <form action="<?php echo network_admin_url( 'users.php' ); ?>" method="get">
 445          <p>
 446              <label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
 447              <input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
 448              <?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?>
 449          </p>
 450      </form>
 451  
 452      <form action="<?php echo network_admin_url( 'sites.php' ); ?>" method="get">
 453          <p>
 454              <label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
 455              <input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
 456              <?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?>
 457          </p>
 458      </form>
 459      <?php
 460      /**
 461       * Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
 462       *
 463       * @since MU (3.0.0)
 464       */
 465      do_action( 'mu_rightnow_end' );
 466  
 467      /**
 468       * Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
 469       *
 470       * @since MU (3.0.0)
 471       */
 472      do_action( 'mu_activity_box_end' );
 473  }
 474  
 475  /**
 476   * The Quick Draft widget display and creation of drafts.
 477   *
 478   * @since 3.8.0
 479   *
 480   * @global int $post_ID
 481   *
 482   * @param string $error_msg Optional. Error message. Default false.
 483   */
 484  function wp_dashboard_quick_press( $error_msg = false ) {
 485      global $post_ID;
 486  
 487      if ( ! current_user_can( 'edit_posts' ) ) {
 488          return;
 489      }
 490  
 491      /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
 492      $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
 493      if ( $last_post_id ) {
 494          $post = get_post( $last_post_id );
 495          if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
 496              $post = get_default_post_to_edit( 'post', true );
 497              update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
 498          } else {
 499              $post->post_title = ''; // Remove the auto draft title
 500          }
 501      } else {
 502          $post    = get_default_post_to_edit( 'post', true );
 503          $user_id = get_current_user_id();
 504          // Don't create an option if this is a super admin who does not belong to this site.
 505          if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
 506              update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
 507          }
 508      }
 509  
 510      $post_ID = (int) $post->ID;
 511      ?>
 512  
 513      <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
 514  
 515          <?php if ( $error_msg ) : ?>
 516          <div class="error"><?php echo $error_msg; ?></div>
 517          <?php endif; ?>
 518  
 519          <div class="input-text-wrap" id="title-wrap">
 520              <label for="title">
 521                  <?php
 522                  /** This filter is documented in wp-admin/edit-form-advanced.php */
 523                  echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
 524                  ?>
 525              </label>
 526              <input type="text" name="post_title" id="title" autocomplete="off" />
 527          </div>
 528  
 529          <div class="textarea-wrap" id="description-wrap">
 530              <label for="content"><?php _e( 'Content' ); ?></label>
 531              <textarea name="content" id="content" placeholder="<?php esc_attr_e( 'What&#8217;s on your mind?' ); ?>" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
 532          </div>
 533  
 534          <p class="submit">
 535              <input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />
 536              <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
 537              <input type="hidden" name="post_type" value="post" />
 538              <?php wp_nonce_field( 'add-post' ); ?>
 539              <?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>
 540              <br class="clear" />
 541          </p>
 542  
 543      </form>
 544      <?php
 545      wp_dashboard_recent_drafts();
 546  }
 547  
 548  /**
 549   * Show recent drafts of the user on the dashboard.
 550   *
 551   * @since 2.7.0
 552   *
 553   * @param WP_Post[] $drafts Optional. Array of posts to display. Default false.
 554   */
 555  function wp_dashboard_recent_drafts( $drafts = false ) {
 556      if ( ! $drafts ) {
 557          $query_args = array(
 558              'post_type'      => 'post',
 559              'post_status'    => 'draft',
 560              'author'         => get_current_user_id(),
 561              'posts_per_page' => 4,
 562              'orderby'        => 'modified',
 563              'order'          => 'DESC',
 564          );
 565  
 566          /**
 567           * Filters the post query arguments for the 'Recent Drafts' dashboard widget.
 568           *
 569           * @since 4.4.0
 570           *
 571           * @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
 572           */
 573          $query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
 574  
 575          $drafts = get_posts( $query_args );
 576          if ( ! $drafts ) {
 577              return;
 578          }
 579      }
 580  
 581      echo '<div class="drafts">';
 582      if ( count( $drafts ) > 3 ) {
 583          echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . __( 'View all drafts' ) . "</a></p>\n";
 584      }
 585      echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
 586  
 587      /* translators: Maximum number of words used in a preview of a draft on the dashboard. */
 588      $draft_length = intval( _x( '10', 'draft_length' ) );
 589  
 590      $drafts = array_slice( $drafts, 0, 3 );
 591      foreach ( $drafts as $draft ) {
 592          $url   = get_edit_post_link( $draft->ID );
 593          $title = _draft_or_post_title( $draft->ID );
 594          echo "<li>\n";
 595          /* translators: %s: post title */
 596          echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
 597          echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
 598          $the_content = wp_trim_words( $draft->post_content, $draft_length );
 599          if ( $the_content ) {
 600              echo '<p>' . $the_content . '</p>';
 601          }
 602          echo "</li>\n";
 603      }
 604      echo "</ul>\n</div>";
 605  }
 606  
 607  /**
 608   * Outputs a row for the Recent Comments widget.
 609   *
 610   * @access private
 611   * @since 2.7.0
 612   *
 613   * @global WP_Comment $comment
 614   *
 615   * @param WP_Comment $comment   The current comment.
 616   * @param bool       $show_date Optional. Whether to display the date.
 617   */
 618  function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
 619      $GLOBALS['comment'] = clone $comment;
 620  
 621      if ( $comment->comment_post_ID > 0 ) {
 622  
 623          $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
 624          $comment_post_url   = get_the_permalink( $comment->comment_post_ID );
 625          $comment_post_link  = "<a href='$comment_post_url'>$comment_post_title</a>";
 626      } else {
 627          $comment_post_link = '';
 628      }
 629  
 630      $actions_string = '';
 631      if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
 632          // Pre-order it: Approve | Reply | Edit | Spam | Trash.
 633          $actions = array(
 634              'approve'   => '',
 635              'unapprove' => '',
 636              'reply'     => '',
 637              'edit'      => '',
 638              'spam'      => '',
 639              'trash'     => '',
 640              'delete'    => '',
 641              'view'      => '',
 642          );
 643  
 644          $del_nonce     = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
 645          $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
 646  
 647          $approve_url   = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
 648          $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
 649          $spam_url      = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 650          $trash_url     = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 651          $delete_url    = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 652  
 653          $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>';
 654          $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>';
 655          $actions['edit']      = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>';
 656          $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>';
 657          $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>';
 658  
 659          if ( ! EMPTY_TRASH_DAYS ) {
 660              $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>';
 661          } else {
 662              $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>';
 663          }
 664  
 665          $actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>';
 666  
 667          /**
 668           * Filters the action links displayed for each comment in the 'Recent Comments'
 669           * dashboard widget.
 670           *
 671           * @since 2.6.0
 672           *
 673           * @param string[]   $actions An array of comment actions. Default actions include:
 674           *                            'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
 675           *                            'Delete', and 'Trash'.
 676           * @param WP_Comment $comment The comment object.
 677           */
 678          $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
 679  
 680          $i = 0;
 681          foreach ( $actions as $action => $link ) {
 682              ++$i;
 683              ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
 684  
 685              // Reply and quickedit need a hide-if-no-js span
 686              if ( 'reply' == $action || 'quickedit' == $action ) {
 687                  $action .= ' hide-if-no-js';
 688              }
 689  
 690              if ( 'view' === $action && '1' !== $comment->comment_approved ) {
 691                  $action .= ' hidden';
 692              }
 693              $actions_string .= "<span class='$action'>$sep$link</span>";
 694          }
 695      }
 696      ?>
 697  
 698          <li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
 699  
 700              <?php echo get_avatar( $comment, 50, 'mystery' ); ?>
 701  
 702              <?php if ( ! $comment->comment_type || 'comment' == $comment->comment_type ) : ?>
 703  
 704              <div class="dashboard-comment-wrap has-row-actions">
 705              <p class="comment-meta">
 706                  <?php
 707                  // Comments might not have a post they relate to, e.g. programmatically created ones.
 708                  if ( $comment_post_link ) {
 709                      printf(
 710                          /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
 711                          __( 'From %1$s on %2$s %3$s' ),
 712                          '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
 713                          $comment_post_link,
 714                          '<span class="approve">' . __( '[Pending]' ) . '</span>'
 715                      );
 716                  } else {
 717                      printf(
 718                          /* translators: 1: comment author, 2: notification if the comment is pending */
 719                          __( 'From %1$s %2$s' ),
 720                          '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
 721                          '<span class="approve">' . __( '[Pending]' ) . '</span>'
 722                      );
 723                  }
 724                  ?>
 725              </p>
 726  
 727                  <?php
 728              else :
 729                  switch ( $comment->comment_type ) {
 730                      case 'pingback':
 731                          $type = __( 'Pingback' );
 732                          break;
 733                      case 'trackback':
 734                          $type = __( 'Trackback' );
 735                          break;
 736                      default:
 737                          $type = ucwords( $comment->comment_type );
 738                  }
 739                  $type = esc_html( $type );
 740                  ?>
 741              <div class="dashboard-comment-wrap has-row-actions">
 742              <p class="comment-meta">
 743                  <?php
 744                  // Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
 745                  if ( $comment_post_link ) {
 746                      printf(
 747                          /* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
 748                          _x( '%1$s on %2$s %3$s', 'dashboard' ),
 749                          "<strong>$type</strong>",
 750                          $comment_post_link,
 751                          '<span class="approve">' . __( '[Pending]' ) . '</span>'
 752                      );
 753                  } else {
 754                      printf(
 755                          /* translators: 1: type of comment, 2: notification if the comment is pending */
 756                          _x( '%1$s %2$s', 'dashboard' ),
 757                          "<strong>$type</strong>",
 758                          '<span class="approve">' . __( '[Pending]' ) . '</span>'
 759                      );
 760                  }
 761                  ?>
 762              </p>
 763              <p class="comment-author"><?php comment_author_link( $comment ); ?></p>
 764  
 765              <?php endif; // comment_type ?>
 766              <blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
 767              <?php if ( $actions_string ) : ?>
 768              <p class="row-actions"><?php echo $actions_string; ?></p>
 769              <?php endif; ?>
 770              </div>
 771          </li>
 772      <?php
 773      $GLOBALS['comment'] = null;
 774  }
 775  
 776  /**
 777   * Callback function for Activity widget.
 778   *
 779   * @since 3.8.0
 780   */
 781  function wp_dashboard_site_activity() {
 782  
 783      echo '<div id="activity-widget">';
 784  
 785      $future_posts = wp_dashboard_recent_posts(
 786          array(
 787              'max'    => 5,
 788              'status' => 'future',
 789              'order'  => 'ASC',
 790              'title'  => __( 'Publishing Soon' ),
 791              'id'     => 'future-posts',
 792          )
 793      );
 794      $recent_posts = wp_dashboard_recent_posts(
 795          array(
 796              'max'    => 5,
 797              'status' => 'publish',
 798              'order'  => 'DESC',
 799              'title'  => __( 'Recently Published' ),
 800              'id'     => 'published-posts',
 801          )
 802      );
 803  
 804      $recent_comments = wp_dashboard_recent_comments();
 805  
 806      if ( ! $future_posts && ! $recent_posts && ! $recent_comments ) {
 807          echo '<div class="no-activity">';
 808          echo '<p class="smiley" aria-hidden="true"></p>';
 809          echo '<p>' . __( 'No activity yet!' ) . '</p>';
 810          echo '</div>';
 811      }
 812  
 813      echo '</div>';
 814  }
 815  
 816  /**
 817   * Generates Publishing Soon and Recently Published sections.
 818   *
 819   * @since 3.8.0
 820   *
 821   * @param array $args {
 822   *     An array of query and display arguments.
 823   *
 824   *     @type int    $max     Number of posts to display.
 825   *     @type string $status  Post status.
 826   *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 827   *     @type string $title   Section title.
 828   *     @type string $id      The container id.
 829   * }
 830   * @return bool False if no posts were found. True otherwise.
 831   */
 832  function wp_dashboard_recent_posts( $args ) {
 833      $query_args = array(
 834          'post_type'      => 'post',
 835          'post_status'    => $args['status'],
 836          'orderby'        => 'date',
 837          'order'          => $args['order'],
 838          'posts_per_page' => intval( $args['max'] ),
 839          'no_found_rows'  => true,
 840          'cache_results'  => false,
 841          'perm'           => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
 842      );
 843  
 844      /**
 845       * Filters the query arguments used for the Recent Posts widget.
 846       *
 847       * @since 4.2.0
 848       *
 849       * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
 850       */
 851      $query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
 852      $posts      = new WP_Query( $query_args );
 853  
 854      if ( $posts->have_posts() ) {
 855  
 856          echo '<div id="' . $args['id'] . '" class="activity-block">';
 857  
 858          echo '<h3>' . $args['title'] . '</h3>';
 859  
 860          echo '<ul>';
 861  
 862          $today    = current_time( 'Y-m-d' );
 863          $tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
 864          $year     = current_time( 'Y' );
 865  
 866          while ( $posts->have_posts() ) {
 867              $posts->the_post();
 868  
 869              $time = get_the_time( 'U' );
 870              if ( gmdate( 'Y-m-d', $time ) == $today ) {
 871                  $relative = __( 'Today' );
 872              } elseif ( gmdate( 'Y-m-d', $time ) == $tomorrow ) {
 873                  $relative = __( 'Tomorrow' );
 874              } elseif ( gmdate( 'Y', $time ) !== $year ) {
 875                  /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
 876                  $relative = date_i18n( __( 'M jS Y' ), $time );
 877              } else {
 878                  /* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */
 879                  $relative = date_i18n( __( 'M jS' ), $time );
 880              }
 881  
 882              // Use the post edit link for those who can edit, the permalink otherwise.
 883              $recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();
 884  
 885              $draft_or_post_title = _draft_or_post_title();
 886              printf(
 887                  '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
 888                  /* translators: 1: relative date, 2: time */
 889                  sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ),
 890                  $recent_post_link,
 891                  /* translators: %s: post title */
 892                  esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $draft_or_post_title ) ),
 893                  $draft_or_post_title
 894              );
 895          }
 896  
 897          echo '</ul>';
 898          echo '</div>';
 899  
 900      } else {
 901          return false;
 902      }
 903  
 904      wp_reset_postdata();
 905  
 906      return true;
 907  }
 908  
 909  /**
 910   * Show Comments section.
 911   *
 912   * @since 3.8.0
 913   *
 914   * @param int $total_items Optional. Number of comments to query. Default 5.
 915   * @return bool False if no comments were found. True otherwise.
 916   */
 917  function wp_dashboard_recent_comments( $total_items = 5 ) {
 918      // Select all comment types and filter out spam later for better query performance.
 919      $comments = array();
 920  
 921      $comments_query = array(
 922          'number' => $total_items * 5,
 923          'offset' => 0,
 924      );
 925      if ( ! current_user_can( 'edit_posts' ) ) {
 926          $comments_query['status'] = 'approve';
 927      }
 928  
 929      while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
 930          if ( ! is_array( $possible ) ) {
 931              break;
 932          }
 933          foreach ( $possible as $comment ) {
 934              if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) {
 935                  continue;
 936              }
 937              $comments[] = $comment;
 938              if ( count( $comments ) == $total_items ) {
 939                  break 2;
 940              }
 941          }
 942          $comments_query['offset'] += $comments_query['number'];
 943          $comments_query['number']  = $total_items * 10;
 944      }
 945  
 946      if ( $comments ) {
 947          echo '<div id="latest-comments" class="activity-block">';
 948          echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
 949  
 950          echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
 951          foreach ( $comments as $comment ) {
 952              _wp_dashboard_recent_comments_row( $comment );
 953          }
 954          echo '</ul>';
 955  
 956          if ( current_user_can( 'edit_posts' ) ) {
 957              echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>';
 958              _get_list_table( 'WP_Comments_List_Table' )->views();
 959          }
 960  
 961          wp_comment_reply( -1, false, 'dashboard', false );
 962          wp_comment_trashnotice();
 963  
 964          echo '</div>';
 965      } else {
 966          return false;
 967      }
 968      return true;
 969  }
 970  
 971  /**
 972   * Display generic dashboard RSS widget feed.
 973   *
 974   * @since 2.5.0
 975   *
 976   * @param string $widget_id
 977   */
 978  function wp_dashboard_rss_output( $widget_id ) {
 979      $widgets = get_option( 'dashboard_widget_options' );
 980      echo '<div class="rss-widget">';
 981      wp_widget_rss_output( $widgets[ $widget_id ] );
 982      echo '</div>';
 983  }
 984  
 985  /**
 986   * Checks to see if all of the feed url in $check_urls are cached.
 987   *
 988   * If $check_urls is empty, look for the rss feed url found in the dashboard
 989   * widget options of $widget_id. If cached, call $callback, a function that
 990   * echoes out output for this widget. If not cache, echo a "Loading..." stub
 991   * which is later replaced by Ajax call (see top of /wp-admin/index.php)
 992   *
 993   * @since 2.5.0
 994   *
 995   * @param string   $widget_id  The widget ID.
 996   * @param callable $callback   The callback funtion used to display each feed.
 997   * @param array    $check_urls RSS feeds
 998   * @param mixed    ...$args    Optional additional parameters to pass to the callback function when it's called.
 999   * @return bool False on failure. True on success.
1000   */
1001  function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
1002      $loading    = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&hellip;' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
1003      $doing_ajax = wp_doing_ajax();
1004  
1005      if ( empty( $check_urls ) ) {
1006          $widgets = get_option( 'dashboard_widget_options' );
1007          if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) {
1008              echo $loading;
1009              return false;
1010          }
1011          $check_urls = array( $widgets[ $widget_id ]['url'] );
1012      }
1013  
1014      $locale    = get_user_locale();
1015      $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
1016      $output    = get_transient( $cache_key );
1017      if ( false !== $output ) {
1018          echo $output;
1019          return true;
1020      }
1021  
1022      if ( ! $doing_ajax ) {
1023          echo $loading;
1024          return false;
1025      }
1026  
1027      if ( $callback && is_callable( $callback ) ) {
1028          $args = array_slice( func_get_args(), 3 );
1029          array_unshift( $args, $widget_id, $check_urls );
1030          ob_start();
1031          call_user_func_array( $callback, $args );
1032          set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
1033      }
1034  
1035      return true;
1036  }
1037  
1038  //
1039  // Dashboard Widgets Controls
1040  //
1041  
1042  /**
1043   * Calls widget control callback.
1044   *
1045   * @since 2.5.0
1046   *
1047   * @global array $wp_dashboard_control_callbacks
1048   *
1049   * @param int $widget_control_id Registered Widget ID.
1050   */
1051  function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
1052      global $wp_dashboard_control_callbacks;
1053  
1054      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 ] ) ) {
1055          call_user_func(
1056              $wp_dashboard_control_callbacks[ $widget_control_id ],
1057              '',
1058              array(
1059                  'id'       => $widget_control_id,
1060                  'callback' => $wp_dashboard_control_callbacks[ $widget_control_id ],
1061              )
1062          );
1063      }
1064  }
1065  
1066  /**
1067   * The RSS dashboard widget control.
1068   *
1069   * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
1070   * from RSS-type widgets.
1071   *
1072   * @since 2.5.0
1073   *
1074   * @param string $widget_id
1075   * @param array $form_inputs
1076   */
1077  function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
1078      $widget_options = get_option( 'dashboard_widget_options' );
1079      if ( ! $widget_options ) {
1080          $widget_options = array();
1081      }
1082  
1083      if ( ! isset( $widget_options[ $widget_id ] ) ) {
1084          $widget_options[ $widget_id ] = array();
1085      }
1086  
1087      $number                                 = 1; // Hack to use wp_widget_rss_form()
1088      $widget_options[ $widget_id ]['number'] = $number;
1089  
1090      if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) {
1091          $_POST['widget-rss'][ $number ]         = wp_unslash( $_POST['widget-rss'][ $number ] );
1092          $widget_options[ $widget_id ]           = wp_widget_rss_process( $_POST['widget-rss'][ $number ] );
1093          $widget_options[ $widget_id ]['number'] = $number;
1094  
1095          // Title is optional. If black, fill it if possible.
1096          if ( ! $widget_options[ $widget_id ]['title'] && isset( $_POST['widget-rss'][ $number ]['title'] ) ) {
1097              $rss = fetch_feed( $widget_options[ $widget_id ]['url'] );
1098              if ( is_wp_error( $rss ) ) {
1099                  $widget_options[ $widget_id ]['title'] = htmlentities( __( 'Unknown Feed' ) );
1100              } else {
1101                  $widget_options[ $widget_id ]['title'] = htmlentities( strip_tags( $rss->get_title() ) );
1102                  $rss->__destruct();
1103                  unset( $rss );
1104              }
1105          }
1106          update_option( 'dashboard_widget_options', $widget_options );
1107          $locale    = get_user_locale();
1108          $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
1109          delete_transient( $cache_key );
1110      }
1111  
1112      wp_widget_rss_form( $widget_options[ $widget_id ], $form_inputs );
1113  }
1114  
1115  
1116  /**
1117   * Renders the Events and News dashboard widget.
1118   *
1119   * @since 4.8.0
1120   */
1121  function wp_dashboard_events_news() {
1122      wp_print_community_events_markup();
1123  
1124      ?>
1125  
1126      <div class="wordpress-news hide-if-no-js">
1127          <?php wp_dashboard_primary(); ?>
1128      </div>
1129  
1130      <p class="community-events-footer">
1131          <?php
1132              printf(
1133                  '<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>',
1134                  'https://make.wordpress.org/community/meetups-landing-page',
1135                  __( 'Meetups' ),
1136                  /* translators: accessibility text */
1137                  __( '(opens in a new tab)' )
1138              );
1139          ?>
1140  
1141          |
1142  
1143          <?php
1144              printf(
1145                  '<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>',
1146                  'https://central.wordcamp.org/schedule/',
1147                  __( 'WordCamps' ),
1148                  /* translators: accessibility text */
1149                  __( '(opens in a new tab)' )
1150              );
1151          ?>
1152  
1153          |
1154  
1155          <?php
1156              printf(
1157                  '<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>',
1158                  /* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
1159                  esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
1160                  __( 'News' ),
1161                  /* translators: accessibility text */
1162                  __( '(opens in a new tab)' )
1163              );
1164          ?>
1165      </p>
1166  
1167      <?php
1168  }
1169  
1170  /**
1171   * Prints the markup for the Community Events section of the Events and News Dashboard widget.
1172   *
1173   * @since 4.8.0
1174   */
1175  function wp_print_community_events_markup() {
1176      ?>
1177  
1178      <div class="community-events-errors notice notice-error inline hide-if-js">
1179          <p class="hide-if-js">
1180              <?php _e( 'This widget requires JavaScript.' ); ?>
1181          </p>
1182  
1183          <p class="community-events-error-occurred" aria-hidden="true">
1184              <?php _e( 'An error occurred. Please try again.' ); ?>
1185          </p>
1186  
1187          <p class="community-events-could-not-locate" aria-hidden="true"></p>
1188      </div>
1189  
1190      <div class="community-events-loading hide-if-no-js">
1191          <?php _e( 'Loading&hellip;' ); ?>
1192      </div>
1193  
1194      <?php
1195      /*
1196       * Hide the main element when the page first loads, because the content
1197       * won't be ready until wp.communityEvents.renderEventsTemplate() has run.
1198       */
1199      ?>
1200      <div id="community-events" class="community-events" aria-hidden="true">
1201          <div class="activity-block">
1202              <p>
1203                  <span id="community-events-location-message"></span>
1204  
1205                  <button class="button-link community-events-toggle-location" aria-label="<?php esc_attr_e( 'Edit city' ); ?>" aria-expanded="false">
1206                      <span class="dashicons dashicons-edit"></span>
1207                  </button>
1208              </p>
1209  
1210              <form class="community-events-form" aria-hidden="true" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post">
1211                  <label for="community-events-location">
1212                      <?php _e( 'City:' ); ?>
1213                  </label>
1214                  <?php
1215                  /* translators: Replace with a city related to your locale.
1216                   * Test that it matches the expected location and has upcoming
1217                   * events before including it. If no cities related to your
1218                   * locale have events, then use a city related to your locale
1219                   * that would be recognizable to most users. Use only the city
1220                   * name itself, without any region or country. Use the endonym
1221                   * (native locale name) instead of the English name if possible.
1222                   */
1223                  ?>
1224                  <input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" />
1225  
1226                  <?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?>
1227  
1228                  <button class="community-events-cancel button-link" type="button" aria-expanded="false">
1229                      <?php _e( 'Cancel' ); ?>
1230                  </button>
1231  
1232                  <span class="spinner"></span>
1233              </form>
1234          </div>
1235  
1236          <ul class="community-events-results activity-block last"></ul>
1237      </div>
1238  
1239      <?php
1240  }
1241  
1242  /**
1243   * Renders the events templates for the Event and News widget.
1244   *
1245   * @since 4.8.0
1246   */
1247  function wp_print_community_events_templates() {
1248      ?>
1249  
1250      <script id="tmpl-community-events-attend-event-near" type="text/template">
1251          <?php
1252          printf(
1253              /* translators: %s: the name of a city */
1254              __( 'Attend an upcoming event near %s.' ),
1255              '<strong>{{ data.location.description }}</strong>'
1256          );
1257          ?>
1258      </script>
1259  
1260      <script id="tmpl-community-events-could-not-locate" type="text/template">
1261          <?php
1262          printf(
1263              /* translators: %s is the name of the city we couldn't locate.
1264               * Replace the examples with cities in your locale, but test
1265               * that they match the expected location before including them.
1266               * Use endonyms (native locale names) whenever possible.
1267               */
1268              __( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
1269              '<em>{{data.unknownCity}}</em>'
1270          );
1271          ?>
1272      </script>
1273  
1274      <script id="tmpl-community-events-event-list" type="text/template">
1275          <# _.each( data.events, function( event ) { #>
1276              <li class="event event-{{ event.type }} wp-clearfix">
1277                  <div class="event-info">
1278                      <div class="dashicons event-icon" aria-hidden="true"></div>
1279                      <div class="event-info-inner">
1280                          <a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
1281                          <span class="event-city">{{ event.location.location }}</span>
1282                      </div>
1283                  </div>
1284  
1285                  <div class="event-date-time">
1286                      <span class="event-date">{{ event.formatted_date }}</span>
1287                      <# if ( 'meetup' === event.type ) { #>
1288                          <span class="event-time">{{ event.formatted_time }}</span>
1289                      <# } #>
1290                  </div>
1291              </li>
1292          <# } ) #>
1293      </script>
1294  
1295      <script id="tmpl-community-events-no-upcoming-events" type="text/template">
1296          <li class="event-none">
1297              <# if ( data.location.description ) { #>
1298                  <?php
1299                  printf(
1300                      /* translators: 1: the city the user searched for, 2: meetup organization documentation URL */
1301                      __( 'There aren&#8217;t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ),
1302                      '{{ data.location.description }}',
1303                      __( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
1304                  );
1305                  ?>
1306  
1307              <# } else { #>
1308                  <?php
1309                  printf(
1310                      /* translators: %s: meetup organization documentation URL */
1311                      __( 'There aren&#8217;t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ),
1312                      __( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
1313                  );
1314                  ?>
1315              <# } #>
1316          </li>
1317      </script>
1318      <?php
1319  }
1320  
1321  /**
1322   * 'WordPress Events and News' dashboard widget.
1323   *
1324   * @since 2.7.0
1325   * @since 4.8.0 Removed popular plugins feed.
1326   */
1327  function wp_dashboard_primary() {
1328      $feeds = array(
1329          'news'   => array(
1330  
1331              /**
1332               * Filters the primary link URL for the 'WordPress Events and News' dashboard widget.
1333               *
1334               * @since 2.5.0
1335               *
1336               * @param string $link The widget's primary link URL.
1337               */
1338              'link'         => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
1339  
1340              /**
1341               * Filters the primary feed URL for the 'WordPress Events and News' dashboard widget.
1342               *
1343               * @since 2.3.0
1344               *
1345               * @param string $url The widget's primary feed URL.
1346               */
1347              'url'          => apply_filters( 'dashboard_primary_feed', __( 'https://wordpress.org/news/feed/' ) ),
1348  
1349              /**
1350               * Filters the primary link title for the 'WordPress Events and News' dashboard widget.
1351               *
1352               * @since 2.3.0
1353               *
1354               * @param string $title Title attribute for the widget's primary link.
1355               */
1356              'title'        => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
1357              'items'        => 1,
1358              'show_summary' => 0,
1359              'show_author'  => 0,
1360              'show_date'    => 0,
1361          ),
1362          'planet' => array(
1363  
1364              /**
1365               * Filters the secondary link URL for the 'WordPress Events and News' dashboard widget.
1366               *
1367               * @since 2.3.0
1368               *
1369               * @param string $link The widget's secondary link URL.
1370               */
1371              'link'         => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
1372  
1373              /**
1374               * Filters the secondary feed URL for the 'WordPress Events and News' dashboard widget.
1375               *
1376               * @since 2.3.0
1377               *
1378               * @param string $url The widget's secondary feed URL.
1379               */
1380              'url'          => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
1381  
1382              /**
1383               * Filters the secondary link title for the 'WordPress Events and News' dashboard widget.
1384               *
1385               * @since 2.3.0
1386               *
1387               * @param string $title Title attribute for the widget's secondary link.
1388               */
1389              'title'        => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
1390  
1391              /**
1392               * Filters the number of secondary link items for the 'WordPress Events and News' dashboard widget.
1393               *
1394               * @since 4.4.0
1395               *
1396               * @param string $items How many items to show in the secondary feed.
1397               */
1398              'items'        => apply_filters( 'dashboard_secondary_items', 3 ),
1399              'show_summary' => 0,
1400              'show_author'  => 0,
1401              'show_date'    => 0,
1402          ),
1403      );
1404  
1405      wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds );
1406  }
1407  
1408  /**
1409   * Display the WordPress events and news feeds.
1410   *
1411   * @since 3.8.0
1412   * @since 4.8.0 Removed popular plugins feed.
1413   *
1414   * @param string $widget_id Widget ID.
1415   * @param array  $feeds     Array of RSS feeds.
1416   */
1417  function wp_dashboard_primary_output( $widget_id, $feeds ) {
1418      foreach ( $feeds as $type => $args ) {
1419          $args['type'] = $type;
1420          echo '<div class="rss-widget">';
1421              wp_widget_rss_output( $args['url'], $args );
1422          echo '</div>';
1423      }
1424  }
1425  
1426  /**
1427   * Display file upload quota on dashboard.
1428   *
1429   * Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now().
1430   *
1431   * @since 3.0.0
1432   *
1433   * @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
1434   */
1435  function wp_dashboard_quota() {
1436      if ( ! is_multisite() || ! current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) {
1437          return true;
1438      }
1439  
1440      $quota = get_space_allowed();
1441      $used  = get_space_used();
1442  
1443      if ( $used > $quota ) {
1444          $percentused = '100';
1445      } else {
1446          $percentused = ( $used / $quota ) * 100;
1447      }
1448      $used_class  = ( $percentused >= 70 ) ? ' warning' : '';
1449      $used        = round( $used, 2 );
1450      $percentused = number_format( $percentused );
1451  
1452      ?>
1453      <h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
1454      <div class="mu-storage">
1455      <ul>
1456          <li class="storage-count">
1457              <?php
1458              $text = sprintf(
1459                  /* translators: %s: number of megabytes */
1460                  __( '%s MB Space Allowed' ),
1461                  number_format_i18n( $quota )
1462              );
1463              printf(
1464                  '<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
1465                  esc_url( admin_url( 'upload.php' ) ),
1466                  $text,
1467                  __( 'Manage Uploads' )
1468              );
1469              ?>
1470          </li><li class="storage-count <?php echo $used_class; ?>">
1471              <?php
1472              $text = sprintf(
1473                  /* translators: 1: number of megabytes, 2: percentage */
1474                  __( '%1$s MB (%2$s%%) Space Used' ),
1475                  number_format_i18n( $used, 2 ),
1476                  $percentused
1477              );
1478              printf(
1479                  '<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
1480                  esc_url( admin_url( 'upload.php' ) ),
1481                  $text,
1482                  __( 'Manage Uploads' )
1483              );
1484              ?>
1485          </li>
1486      </ul>
1487      </div>
1488      <?php
1489  }
1490  
1491  // Display Browser Nag Meta Box
1492  function wp_dashboard_browser_nag() {
1493      $notice   = '';
1494      $response = wp_check_browser_version();
1495  
1496      if ( $response ) {
1497          if ( $response['insecure'] ) {
1498              /* translators: %s: browser name and link */
1499              $msg = sprintf(
1500                  __( "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." ),
1501                  sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
1502              );
1503          } else {
1504              /* translators: %s: browser name and link */
1505              $msg = sprintf(
1506                  __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
1507                  sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
1508              );
1509          }
1510  
1511          $browser_nag_class = '';
1512          if ( ! empty( $response['img_src'] ) ) {
1513              $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) ) ? $response['img_src_ssl'] : $response['img_src'];
1514  
1515              $notice           .= '<div class="alignright browser-icon"><a href="' . esc_attr( $response['update_url'] ) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
1516              $browser_nag_class = ' has-browser-icon';
1517          }
1518          $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
1519  
1520          $browsehappy = 'https://browsehappy.com/';
1521          $locale      = get_user_locale();
1522          if ( 'en_US' !== $locale ) {
1523              $browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
1524          }
1525  
1526          $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>';
1527          $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
1528          $notice .= '<div class="clear"></div>';
1529      }
1530  
1531      /**
1532       * Filters the notice output for the 'Browse Happy' nag meta box.
1533       *
1534       * @since 3.2.0
1535       *
1536       * @param string $notice   The notice content.
1537       * @param array  $response An array containing web browser information. See `wp_check_browser_version()`.
1538       */
1539      echo apply_filters( 'browse-happy-notice', $notice, $response );  // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
1540  }
1541  
1542  /**
1543   * @since 3.2.0
1544   *
1545   * @param array $classes
1546   * @return array
1547   */
1548  function dashboard_browser_nag_class( $classes ) {
1549      $response = wp_check_browser_version();
1550  
1551      if ( $response && $response['insecure'] ) {
1552          $classes[] = 'browser-insecure';
1553      }
1554  
1555      return $classes;
1556  }
1557  
1558  /**
1559   * Check if the user needs a browser update
1560   *
1561   * @since 3.2.0
1562   *
1563   * @return array|bool False on failure, array of browser data on success.
1564   */
1565  function wp_check_browser_version() {
1566      if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1567          return false;
1568      }
1569  
1570      $key = md5( $_SERVER['HTTP_USER_AGENT'] );
1571  
1572      $response = get_site_transient( 'browser_' . $key );
1573      if ( false === $response ) {
1574          // include an unmodified $wp_version
1575          include ( ABSPATH . WPINC . '/version.php' );
1576  
1577          $url     = 'http://api.wordpress.org/core/browse-happy/1.1/';
1578          $options = array(
1579              'body'       => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
1580              'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
1581          );
1582  
1583          if ( wp_http_supports( array( 'ssl' ) ) ) {
1584              $url = set_url_scheme( $url, 'https' );
1585          }
1586  
1587          $response = wp_remote_post( $url, $options );
1588  
1589          if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
1590              return false;
1591          }
1592  
1593          /**
1594           * Response should be an array with:
1595           *  'platform' - string - A user-friendly platform name, if it can be determined
1596           *  'name' - string - A user-friendly browser name
1597           *  'version' - string - The version of the browser the user is using
1598           *  'current_version' - string - The most recent version of the browser
1599           *  'upgrade' - boolean - Whether the browser needs an upgrade
1600           *  'insecure' - boolean - Whether the browser is deemed insecure
1601           *  'update_url' - string - The url to visit to upgrade
1602           *  'img_src' - string - An image representing the browser
1603           *  'img_src_ssl' - string - An image (over SSL) representing the browser
1604           */
1605          $response = json_decode( wp_remote_retrieve_body( $response ), true );
1606  
1607          if ( ! is_array( $response ) ) {
1608              return false;
1609          }
1610  
1611          set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
1612      }
1613  
1614      return $response;
1615  }
1616  
1617  /**
1618   * Displays the PHP update nag.
1619   *
1620   * @since 5.1.0
1621   */
1622  function wp_dashboard_php_nag() {
1623      $response = wp_check_php_version();
1624  
1625      if ( ! $response ) {
1626          return;
1627      }
1628  
1629      if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
1630          $msg = __( 'WordPress has detected that your site is running on an insecure version of PHP.' );
1631      } else {
1632          $msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
1633      }
1634  
1635      ?>
1636      <p><?php echo $msg; ?></p>
1637  
1638      <h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
1639      <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&#8217;s performance.' ); ?></p>
1640  
1641      <p class="button-container">
1642          <?php
1643          printf(
1644              '<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>',
1645              esc_url( wp_get_update_php_url() ),
1646              __( 'Learn more about updating PHP' ),
1647              /* translators: accessibility text */
1648              __( '(opens in a new tab)' )
1649          );
1650          ?>
1651      </p>
1652      <?php
1653  
1654      wp_update_php_annotation();
1655      wp_direct_php_update_button();
1656  }
1657  
1658  /**
1659   * Adds an additional class to the PHP nag if the current version is insecure.
1660   *
1661   * @since 5.1.0
1662   *
1663   * @param array $classes Metabox classes.
1664   * @return array Modified metabox classes.
1665   */
1666  function dashboard_php_nag_class( $classes ) {
1667      $response = wp_check_php_version();
1668  
1669      if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
1670          $classes[] = 'php-insecure';
1671      }
1672  
1673      return $classes;
1674  }
1675  
1676  /**
1677   * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
1678   */
1679  function wp_dashboard_empty() {}
1680  
1681  /**
1682   * Displays a welcome panel to introduce users to WordPress.
1683   *
1684   * @since 3.3.0
1685   */
1686  function wp_welcome_panel() {
1687      ?>
1688      <div class="welcome-panel-content">
1689      <h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
1690      <p class="about-description"><?php _e( 'We&#8217;ve assembled some links to get you started:' ); ?></p>
1691      <div class="welcome-panel-column-container">
1692      <div class="welcome-panel-column">
1693          <?php if ( current_user_can( 'customize' ) ) : ?>
1694              <h3><?php _e( 'Get Started' ); ?></h3>
1695              <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>
1696          <?php endif; ?>
1697          <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
1698          <?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
1699              <?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?>
1700              <p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), $themes_link ); ?></p>
1701          <?php endif; ?>
1702      </div>
1703      <div class="welcome-panel-column">
1704          <h3><?php _e( 'Next Steps' ); ?></h3>
1705          <ul>
1706          <?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
1707              <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>
1708              <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>
1709          <?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
1710              <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>
1711              <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>
1712              <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
1713          <?php else : ?>
1714              <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
1715              <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>
1716              <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>
1717          <?php endif; ?>
1718              <li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
1719          </ul>
1720      </div>
1721      <div class="welcome-panel-column welcome-panel-last">
1722          <h3><?php _e( 'More Actions' ); ?></h3>
1723          <ul>
1724          <?php
1725          if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) :
1726              if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) {
1727                  $widgets_menus_link = sprintf(
1728                      __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ),
1729                      admin_url( 'widgets.php' ),
1730                      admin_url( 'nav-menus.php' )
1731                  );
1732              } elseif ( current_theme_supports( 'widgets' ) ) {
1733                  $widgets_menus_link = '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>';
1734              } else {
1735                  $widgets_menus_link = '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>';
1736              }
1737              ?>
1738              <li><div class="welcome-icon welcome-widgets-menus"><?php echo $widgets_menus_link; ?></div></li>
1739          <?php endif; ?>
1740          <?php if ( current_user_can( 'manage_options' ) ) : ?>
1741              <li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
1742          <?php endif; ?>
1743              <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>
1744          </ul>
1745      </div>
1746      </div>
1747      </div>
1748      <?php
1749  }


Generated: Sun Jul 21 01:00:03 2019 Cross-referenced by PHPXref 0.7.1