[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

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          if ( $the_content = wp_trim_words( $draft->post_content, $draft_length ) ) {
 599              echo '<p>' . $the_content . '</p>';
 600          }
 601          echo "</li>\n";
 602      }
 603      echo "</ul>\n</div>";
 604  }
 605  
 606  /**
 607   * Outputs a row for the Recent Comments widget.
 608   *
 609   * @access private
 610   * @since 2.7.0
 611   *
 612   * @global WP_Comment $comment
 613   *
 614   * @param WP_Comment $comment   The current comment.
 615   * @param bool       $show_date Optional. Whether to display the date.
 616   */
 617  function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
 618      $GLOBALS['comment'] = clone $comment;
 619  
 620      if ( $comment->comment_post_ID > 0 ) {
 621  
 622          $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
 623          $comment_post_url   = get_the_permalink( $comment->comment_post_ID );
 624          $comment_post_link  = "<a href='$comment_post_url'>$comment_post_title</a>";
 625      } else {
 626          $comment_post_link = '';
 627      }
 628  
 629      $actions_string = '';
 630      if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
 631          // Pre-order it: Approve | Reply | Edit | Spam | Trash.
 632          $actions = array(
 633              'approve'   => '',
 634              'unapprove' => '',
 635              'reply'     => '',
 636              'edit'      => '',
 637              'spam'      => '',
 638              'trash'     => '',
 639              'delete'    => '',
 640              'view'      => '',
 641          );
 642  
 643          $del_nonce     = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
 644          $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
 645  
 646          $approve_url   = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
 647          $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
 648          $spam_url      = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 649          $trash_url     = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 650          $delete_url    = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 651  
 652          $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>';
 653          $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>';
 654          $actions['edit']      = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>';
 655          $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>';
 656          $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>';
 657  
 658          if ( ! EMPTY_TRASH_DAYS ) {
 659              $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>';
 660          } else {
 661              $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>';
 662          }
 663  
 664          $actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>';
 665  
 666          /**
 667           * Filters the action links displayed for each comment in the 'Recent Comments'
 668           * dashboard widget.
 669           *
 670           * @since 2.6.0
 671           *
 672           * @param string[]   $actions An array of comment actions. Default actions include:
 673           *                            'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
 674           *                            'Delete', and 'Trash'.
 675           * @param WP_Comment $comment The comment object.
 676           */
 677          $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
 678  
 679          $i = 0;
 680          foreach ( $actions as $action => $link ) {
 681              ++$i;
 682              ( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
 683  
 684              // Reply and quickedit need a hide-if-no-js span
 685              if ( 'reply' == $action || 'quickedit' == $action ) {
 686                  $action .= ' hide-if-no-js';
 687              }
 688  
 689              if ( 'view' === $action && '1' !== $comment->comment_approved ) {
 690                  $action .= ' hidden';
 691              }
 692              $actions_string .= "<span class='$action'>$sep$link</span>";
 693          }
 694      }
 695      ?>
 696  
 697          <li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
 698  
 699              <?php echo get_avatar( $comment, 50, 'mystery' ); ?>
 700  
 701              <?php if ( ! $comment->comment_type || 'comment' == $comment->comment_type ) : ?>
 702  
 703              <div class="dashboard-comment-wrap has-row-actions">
 704              <p class="comment-meta">
 705                  <?php
 706                  // Comments might not have a post they relate to, e.g. programmatically created ones.
 707                  if ( $comment_post_link ) {
 708                      printf(
 709                          /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
 710                          __( 'From %1$s on %2$s %3$s' ),
 711                          '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
 712                          $comment_post_link,
 713                          '<span class="approve">' . __( '[Pending]' ) . '</span>'
 714                      );
 715                  } else {
 716                      printf(
 717                          /* translators: 1: comment author, 2: notification if the comment is pending */
 718                          __( 'From %1$s %2$s' ),
 719                          '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
 720                          '<span class="approve">' . __( '[Pending]' ) . '</span>'
 721                      );
 722                  }
 723                  ?>
 724              </p>
 725  
 726                  <?php
 727              else :
 728                  switch ( $comment->comment_type ) {
 729                      case 'pingback':
 730                          $type = __( 'Pingback' );
 731                          break;
 732                      case 'trackback':
 733                          $type = __( 'Trackback' );
 734                          break;
 735                      default:
 736                          $type = ucwords( $comment->comment_type );
 737                  }
 738                  $type = esc_html( $type );
 739                  ?>
 740              <div class="dashboard-comment-wrap has-row-actions">
 741              <p class="comment-meta">
 742                  <?php
 743                  // Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
 744                  if ( $comment_post_link ) {
 745                      printf(
 746                          /* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
 747                          _x( '%1$s on %2$s %3$s', 'dashboard' ),
 748                          "<strong>$type</strong>",
 749                          $comment_post_link,
 750                          '<span class="approve">' . __( '[Pending]' ) . '</span>'
 751                      );
 752                  } else {
 753                      printf(
 754                          /* translators: 1: type of comment, 2: notification if the comment is pending */
 755                          _x( '%1$s %2$s', 'dashboard' ),
 756                          "<strong>$type</strong>",
 757                          '<span class="approve">' . __( '[Pending]' ) . '</span>'
 758                      );
 759                  }
 760                  ?>
 761              </p>
 762              <p class="comment-author"><?php comment_author_link( $comment ); ?></p>
 763  
 764              <?php endif; // comment_type ?>
 765              <blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
 766              <?php if ( $actions_string ) : ?>
 767              <p class="row-actions"><?php echo $actions_string; ?></p>
 768              <?php endif; ?>
 769              </div>
 770          </li>
 771      <?php
 772      $GLOBALS['comment'] = null;
 773  }
 774  
 775  /**
 776   * Callback function for Activity widget.
 777   *
 778   * @since 3.8.0
 779   */
 780  function wp_dashboard_site_activity() {
 781  
 782      echo '<div id="activity-widget">';
 783  
 784      $future_posts = wp_dashboard_recent_posts(
 785          array(
 786              'max'    => 5,
 787              'status' => 'future',
 788              'order'  => 'ASC',
 789              'title'  => __( 'Publishing Soon' ),
 790              'id'     => 'future-posts',
 791          )
 792      );
 793      $recent_posts = wp_dashboard_recent_posts(
 794          array(
 795              'max'    => 5,
 796              'status' => 'publish',
 797              'order'  => 'DESC',
 798              'title'  => __( 'Recently Published' ),
 799              'id'     => 'published-posts',
 800          )
 801      );
 802  
 803      $recent_comments = wp_dashboard_recent_comments();
 804  
 805      if ( ! $future_posts && ! $recent_posts && ! $recent_comments ) {
 806          echo '<div class="no-activity">';
 807          echo '<p class="smiley" aria-hidden="true"></p>';
 808          echo '<p>' . __( 'No activity yet!' ) . '</p>';
 809          echo '</div>';
 810      }
 811  
 812      echo '</div>';
 813  }
 814  
 815  /**
 816   * Generates Publishing Soon and Recently Published sections.
 817   *
 818   * @since 3.8.0
 819   *
 820   * @param array $args {
 821   *     An array of query and display arguments.
 822   *
 823   *     @type int    $max     Number of posts to display.
 824   *     @type string $status  Post status.
 825   *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 826   *     @type string $title   Section title.
 827   *     @type string $id      The container id.
 828   * }
 829   * @return bool False if no posts were found. True otherwise.
 830   */
 831  function wp_dashboard_recent_posts( $args ) {
 832      $query_args = array(
 833          'post_type'      => 'post',
 834          'post_status'    => $args['status'],
 835          'orderby'        => 'date',
 836          'order'          => $args['order'],
 837          'posts_per_page' => intval( $args['max'] ),
 838          'no_found_rows'  => true,
 839          'cache_results'  => false,
 840          'perm'           => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
 841      );
 842  
 843      /**
 844       * Filters the query arguments used for the Recent Posts widget.
 845       *
 846       * @since 4.2.0
 847       *
 848       * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
 849       */
 850      $query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
 851      $posts      = new WP_Query( $query_args );
 852  
 853      if ( $posts->have_posts() ) {
 854  
 855          echo '<div id="' . $args['id'] . '" class="activity-block">';
 856  
 857          echo '<h3>' . $args['title'] . '</h3>';
 858  
 859          echo '<ul>';
 860  
 861          $today    = current_time( 'Y-m-d' );
 862          $tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
 863          $year     = current_time( 'Y' );
 864  
 865          while ( $posts->have_posts() ) {
 866              $posts->the_post();
 867  
 868              $time = get_the_time( 'U' );
 869              if ( gmdate( 'Y-m-d', $time ) == $today ) {
 870                  $relative = __( 'Today' );
 871              } elseif ( gmdate( 'Y-m-d', $time ) == $tomorrow ) {
 872                  $relative = __( 'Tomorrow' );
 873              } elseif ( gmdate( 'Y', $time ) !== $year ) {
 874                  /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
 875                  $relative = date_i18n( __( 'M jS Y' ), $time );
 876              } else {
 877                  /* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */
 878                  $relative = date_i18n( __( 'M jS' ), $time );
 879              }
 880  
 881              // Use the post edit link for those who can edit, the permalink otherwise.
 882              $recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();
 883  
 884              $draft_or_post_title = _draft_or_post_title();
 885              printf(
 886                  '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
 887                  /* translators: 1: relative date, 2: time */
 888                  sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ),
 889                  $recent_post_link,
 890                  /* translators: %s: post title */
 891                  esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $draft_or_post_title ) ),
 892                  $draft_or_post_title
 893              );
 894          }
 895  
 896          echo '</ul>';
 897          echo '</div>';
 898  
 899      } else {
 900          return false;
 901      }
 902  
 903      wp_reset_postdata();
 904  
 905      return true;
 906  }
 907  
 908  /**
 909   * Show Comments section.
 910   *
 911   * @since 3.8.0
 912   *
 913   * @param int $total_items Optional. Number of comments to query. Default 5.
 914   * @return bool False if no comments were found. True otherwise.
 915   */
 916  function wp_dashboard_recent_comments( $total_items = 5 ) {
 917      // Select all comment types and filter out spam later for better query performance.
 918      $comments = array();
 919  
 920      $comments_query = array(
 921          'number' => $total_items * 5,
 922          'offset' => 0,
 923      );
 924      if ( ! current_user_can( 'edit_posts' ) ) {
 925          $comments_query['status'] = 'approve';
 926      }
 927  
 928      while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
 929          if ( ! is_array( $possible ) ) {
 930              break;
 931          }
 932          foreach ( $possible as $comment ) {
 933              if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) {
 934                  continue;
 935              }
 936              $comments[] = $comment;
 937              if ( count( $comments ) == $total_items ) {
 938                  break 2;
 939              }
 940          }
 941          $comments_query['offset'] += $comments_query['number'];
 942          $comments_query['number']  = $total_items * 10;
 943      }
 944  
 945      if ( $comments ) {
 946          echo '<div id="latest-comments" class="activity-block">';
 947          echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
 948  
 949          echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
 950          foreach ( $comments as $comment ) {
 951              _wp_dashboard_recent_comments_row( $comment );
 952          }
 953          echo '</ul>';
 954  
 955          if ( current_user_can( 'edit_posts' ) ) {
 956              echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>';
 957              _get_list_table( 'WP_Comments_List_Table' )->views();
 958          }
 959  
 960          wp_comment_reply( -1, false, 'dashboard', false );
 961          wp_comment_trashnotice();
 962  
 963          echo '</div>';
 964      } else {
 965          return false;
 966      }
 967      return true;
 968  }
 969  
 970  /**
 971   * Display generic dashboard RSS widget feed.
 972   *
 973   * @since 2.5.0
 974   *
 975   * @param string $widget_id
 976   */
 977  function wp_dashboard_rss_output( $widget_id ) {
 978      $widgets = get_option( 'dashboard_widget_options' );
 979      echo '<div class="rss-widget">';
 980      wp_widget_rss_output( $widgets[ $widget_id ] );
 981      echo '</div>';
 982  }
 983  
 984  /**
 985   * Checks to see if all of the feed url in $check_urls are cached.
 986   *
 987   * If $check_urls is empty, look for the rss feed url found in the dashboard
 988   * widget options of $widget_id. If cached, call $callback, a function that
 989   * echoes out output for this widget. If not cache, echo a "Loading..." stub
 990   * which is later replaced by Ajax call (see top of /wp-admin/index.php)
 991   *
 992   * @since 2.5.0
 993   *
 994   * @param string   $widget_id  The widget ID.
 995   * @param callable $callback   The callback funtion used to display each feed.
 996   * @param array    $check_urls RSS feeds
 997   * @param mixed    ...$args    Optional additional parameters to pass to the callback function when it's called.
 998   * @return bool False on failure. True on success.
 999   */
1000  function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
1001      $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>';
1002      $doing_ajax = wp_doing_ajax();
1003  
1004      if ( empty( $check_urls ) ) {
1005          $widgets = get_option( 'dashboard_widget_options' );
1006          if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) {
1007              echo $loading;
1008              return false;
1009          }
1010          $check_urls = array( $widgets[ $widget_id ]['url'] );
1011      }
1012  
1013      $locale    = get_user_locale();
1014      $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
1015      if ( false !== ( $output = get_transient( $cache_key ) ) ) {
1016          echo $output;
1017          return true;
1018      }
1019  
1020      if ( ! $doing_ajax ) {
1021          echo $loading;
1022          return false;
1023      }
1024  
1025      if ( $callback && is_callable( $callback ) ) {
1026          $args = array_slice( func_get_args(), 3 );
1027          array_unshift( $args, $widget_id, $check_urls );
1028          ob_start();
1029          call_user_func_array( $callback, $args );
1030          set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
1031      }
1032  
1033      return true;
1034  }
1035  
1036  //
1037  // Dashboard Widgets Controls
1038  //
1039  
1040  /**
1041   * Calls widget control callback.
1042   *
1043   * @since 2.5.0
1044   *
1045   * @global array $wp_dashboard_control_callbacks
1046   *
1047   * @param int $widget_control_id Registered Widget ID.
1048   */
1049  function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
1050      global $wp_dashboard_control_callbacks;
1051  
1052      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 ] ) ) {
1053          call_user_func(
1054              $wp_dashboard_control_callbacks[ $widget_control_id ],
1055              '',
1056              array(
1057                  'id'       => $widget_control_id,
1058                  'callback' => $wp_dashboard_control_callbacks[ $widget_control_id ],
1059              )
1060          );
1061      }
1062  }
1063  
1064  /**
1065   * The RSS dashboard widget control.
1066   *
1067   * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
1068   * from RSS-type widgets.
1069   *
1070   * @since 2.5.0
1071   *
1072   * @param string $widget_id
1073   * @param array $form_inputs
1074   */
1075  function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
1076      if ( ! $widget_options = get_option( 'dashboard_widget_options' ) ) {
1077          $widget_options = array();
1078      }
1079  
1080      if ( ! isset( $widget_options[ $widget_id ] ) ) {
1081          $widget_options[ $widget_id ] = array();
1082      }
1083  
1084      $number                                 = 1; // Hack to use wp_widget_rss_form()
1085      $widget_options[ $widget_id ]['number'] = $number;
1086  
1087      if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) {
1088          $_POST['widget-rss'][ $number ]         = wp_unslash( $_POST['widget-rss'][ $number ] );
1089          $widget_options[ $widget_id ]           = wp_widget_rss_process( $_POST['widget-rss'][ $number ] );
1090          $widget_options[ $widget_id ]['number'] = $number;
1091  
1092          // Title is optional. If black, fill it if possible.
1093          if ( ! $widget_options[ $widget_id ]['title'] && isset( $_POST['widget-rss'][ $number ]['title'] ) ) {
1094              $rss = fetch_feed( $widget_options[ $widget_id ]['url'] );
1095              if ( is_wp_error( $rss ) ) {
1096                  $widget_options[ $widget_id ]['title'] = htmlentities( __( 'Unknown Feed' ) );
1097              } else {
1098                  $widget_options[ $widget_id ]['title'] = htmlentities( strip_tags( $rss->get_title() ) );
1099                  $rss->__destruct();
1100                  unset( $rss );
1101              }
1102          }
1103          update_option( 'dashboard_widget_options', $widget_options );
1104          $locale    = get_user_locale();
1105          $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
1106          delete_transient( $cache_key );
1107      }
1108  
1109      wp_widget_rss_form( $widget_options[ $widget_id ], $form_inputs );
1110  }
1111  
1112  
1113  /**
1114   * Renders the Events and News dashboard widget.
1115   *
1116   * @since 4.8.0
1117   */
1118  function wp_dashboard_events_news() {
1119      wp_print_community_events_markup();
1120  
1121      ?>
1122  
1123      <div class="wordpress-news hide-if-no-js">
1124          <?php wp_dashboard_primary(); ?>
1125      </div>
1126  
1127      <p class="community-events-footer">
1128          <?php
1129              printf(
1130                  '<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>',
1131                  'https://make.wordpress.org/community/meetups-landing-page',
1132                  __( 'Meetups' ),
1133                  /* translators: accessibility text */
1134                  __( '(opens in a new tab)' )
1135              );
1136          ?>
1137  
1138          |
1139  
1140          <?php
1141              printf(
1142                  '<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>',
1143                  'https://central.wordcamp.org/schedule/',
1144                  __( 'WordCamps' ),
1145                  /* translators: accessibility text */
1146                  __( '(opens in a new tab)' )
1147              );
1148          ?>
1149  
1150          |
1151  
1152          <?php
1153              printf(
1154                  '<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>',
1155                  /* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
1156                  esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
1157                  __( 'News' ),
1158                  /* translators: accessibility text */
1159                  __( '(opens in a new tab)' )
1160              );
1161          ?>
1162      </p>
1163  
1164      <?php
1165  }
1166  
1167  /**
1168   * Prints the markup for the Community Events section of the Events and News Dashboard widget.
1169   *
1170   * @since 4.8.0
1171   */
1172  function wp_print_community_events_markup() {
1173      ?>
1174  
1175      <div class="community-events-errors notice notice-error inline hide-if-js">
1176          <p class="hide-if-js">
1177              <?php _e( 'This widget requires JavaScript.' ); ?>
1178          </p>
1179  
1180          <p class="community-events-error-occurred" aria-hidden="true">
1181              <?php _e( 'An error occurred. Please try again.' ); ?>
1182          </p>
1183  
1184          <p class="community-events-could-not-locate" aria-hidden="true"></p>
1185      </div>
1186  
1187      <div class="community-events-loading hide-if-no-js">
1188          <?php _e( 'Loading&hellip;' ); ?>
1189      </div>
1190  
1191      <?php
1192      /*
1193       * Hide the main element when the page first loads, because the content
1194       * won't be ready until wp.communityEvents.renderEventsTemplate() has run.
1195       */
1196      ?>
1197      <div id="community-events" class="community-events" aria-hidden="true">
1198          <div class="activity-block">
1199              <p>
1200                  <span id="community-events-location-message"></span>
1201  
1202                  <button class="button-link community-events-toggle-location" aria-label="<?php esc_attr_e( 'Edit city' ); ?>" aria-expanded="false">
1203                      <span class="dashicons dashicons-edit"></span>
1204                  </button>
1205              </p>
1206  
1207              <form class="community-events-form" aria-hidden="true" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post">
1208                  <label for="community-events-location">
1209                      <?php _e( 'City:' ); ?>
1210                  </label>
1211                  <?php
1212                  /* translators: Replace with a city related to your locale.
1213                   * Test that it matches the expected location and has upcoming
1214                   * events before including it. If no cities related to your
1215                   * locale have events, then use a city related to your locale
1216                   * that would be recognizable to most users. Use only the city
1217                   * name itself, without any region or country. Use the endonym
1218                   * (native locale name) instead of the English name if possible.
1219                   */
1220                  ?>
1221                  <input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" />
1222  
1223                  <?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?>
1224  
1225                  <button class="community-events-cancel button-link" type="button" aria-expanded="false">
1226                      <?php _e( 'Cancel' ); ?>
1227                  </button>
1228  
1229                  <span class="spinner"></span>
1230              </form>
1231          </div>
1232  
1233          <ul class="community-events-results activity-block last"></ul>
1234      </div>
1235  
1236      <?php
1237  }
1238  
1239  /**
1240   * Renders the events templates for the Event and News widget.
1241   *
1242   * @since 4.8.0
1243   */
1244  function wp_print_community_events_templates() {
1245      ?>
1246  
1247      <script id="tmpl-community-events-attend-event-near" type="text/template">
1248          <?php
1249          printf(
1250              /* translators: %s: the name of a city */
1251              __( 'Attend an upcoming event near %s.' ),
1252              '<strong>{{ data.location.description }}</strong>'
1253          );
1254          ?>
1255      </script>
1256  
1257      <script id="tmpl-community-events-could-not-locate" type="text/template">
1258          <?php
1259          printf(
1260              /* translators: %s is the name of the city we couldn't locate.
1261               * Replace the examples with cities in your locale, but test
1262               * that they match the expected location before including them.
1263               * Use endonyms (native locale names) whenever possible.
1264               */
1265              __( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
1266              '<em>{{data.unknownCity}}</em>'
1267          );
1268          ?>
1269      </script>
1270  
1271      <script id="tmpl-community-events-event-list" type="text/template">
1272          <# _.each( data.events, function( event ) { #>
1273              <li class="event event-{{ event.type }} wp-clearfix">
1274                  <div class="event-info">
1275                      <div class="dashicons event-icon" aria-hidden="true"></div>
1276                      <div class="event-info-inner">
1277                          <a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
1278                          <span class="event-city">{{ event.location.location }}</span>
1279                      </div>
1280                  </div>
1281  
1282                  <div class="event-date-time">
1283                      <span class="event-date">{{ event.formatted_date }}</span>
1284                      <# if ( 'meetup' === event.type ) { #>
1285                          <span class="event-time">{{ event.formatted_time }}</span>
1286                      <# } #>
1287                  </div>
1288              </li>
1289          <# } ) #>
1290      </script>
1291  
1292      <script id="tmpl-community-events-no-upcoming-events" type="text/template">
1293          <li class="event-none">
1294              <# if ( data.location.description ) { #>
1295                  <?php
1296                  printf(
1297                      /* translators: 1: the city the user searched for, 2: meetup organization documentation URL */
1298                      __( 'There aren&#8217;t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ),
1299                      '{{ data.location.description }}',
1300                      __( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
1301                  );
1302                  ?>
1303  
1304              <# } else { #>
1305                  <?php
1306                  printf(
1307                      /* translators: %s: meetup organization documentation URL */
1308                      __( 'There aren&#8217;t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ),
1309                      __( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
1310                  );
1311                  ?>
1312              <# } #>
1313          </li>
1314      </script>
1315      <?php
1316  }
1317  
1318  /**
1319   * 'WordPress Events and News' dashboard widget.
1320   *
1321   * @since 2.7.0
1322   * @since 4.8.0 Removed popular plugins feed.
1323   */
1324  function wp_dashboard_primary() {
1325      $feeds = array(
1326          'news'   => array(
1327  
1328              /**
1329               * Filters the primary link URL for the 'WordPress Events and News' dashboard widget.
1330               *
1331               * @since 2.5.0
1332               *
1333               * @param string $link The widget's primary link URL.
1334               */
1335              'link'         => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
1336  
1337              /**
1338               * Filters the primary feed URL for the 'WordPress Events and News' dashboard widget.
1339               *
1340               * @since 2.3.0
1341               *
1342               * @param string $url The widget's primary feed URL.
1343               */
1344              'url'          => apply_filters( 'dashboard_primary_feed', __( 'https://wordpress.org/news/feed/' ) ),
1345  
1346              /**
1347               * Filters the primary link title for the 'WordPress Events and News' dashboard widget.
1348               *
1349               * @since 2.3.0
1350               *
1351               * @param string $title Title attribute for the widget's primary link.
1352               */
1353              'title'        => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
1354              'items'        => 1,
1355              'show_summary' => 0,
1356              'show_author'  => 0,
1357              'show_date'    => 0,
1358          ),
1359          'planet' => array(
1360  
1361              /**
1362               * Filters the secondary link URL for the 'WordPress Events and News' dashboard widget.
1363               *
1364               * @since 2.3.0
1365               *
1366               * @param string $link The widget's secondary link URL.
1367               */
1368              'link'         => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
1369  
1370              /**
1371               * Filters the secondary feed URL for the 'WordPress Events and News' dashboard widget.
1372               *
1373               * @since 2.3.0
1374               *
1375               * @param string $url The widget's secondary feed URL.
1376               */
1377              'url'          => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
1378  
1379              /**
1380               * Filters the secondary link title for the 'WordPress Events and News' dashboard widget.
1381               *
1382               * @since 2.3.0
1383               *
1384               * @param string $title Title attribute for the widget's secondary link.
1385               */
1386              'title'        => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
1387  
1388              /**
1389               * Filters the number of secondary link items for the 'WordPress Events and News' dashboard widget.
1390               *
1391               * @since 4.4.0
1392               *
1393               * @param string $items How many items to show in the secondary feed.
1394               */
1395              'items'        => apply_filters( 'dashboard_secondary_items', 3 ),
1396              'show_summary' => 0,
1397              'show_author'  => 0,
1398              'show_date'    => 0,
1399          ),
1400      );
1401  
1402      wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds );
1403  }
1404  
1405  /**
1406   * Display the WordPress events and news feeds.
1407   *
1408   * @since 3.8.0
1409   * @since 4.8.0 Removed popular plugins feed.
1410   *
1411   * @param string $widget_id Widget ID.
1412   * @param array  $feeds     Array of RSS feeds.
1413   */
1414  function wp_dashboard_primary_output( $widget_id, $feeds ) {
1415      foreach ( $feeds as $type => $args ) {
1416          $args['type'] = $type;
1417          echo '<div class="rss-widget">';
1418              wp_widget_rss_output( $args['url'], $args );
1419          echo '</div>';
1420      }
1421  }
1422  
1423  /**
1424   * Display file upload quota on dashboard.
1425   *
1426   * Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now().
1427   *
1428   * @since 3.0.0
1429   *
1430   * @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
1431   */
1432  function wp_dashboard_quota() {
1433      if ( ! is_multisite() || ! current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) {
1434          return true;
1435      }
1436  
1437      $quota = get_space_allowed();
1438      $used  = get_space_used();
1439  
1440      if ( $used > $quota ) {
1441          $percentused = '100';
1442      } else {
1443          $percentused = ( $used / $quota ) * 100;
1444      }
1445      $used_class  = ( $percentused >= 70 ) ? ' warning' : '';
1446      $used        = round( $used, 2 );
1447      $percentused = number_format( $percentused );
1448  
1449      ?>
1450      <h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
1451      <div class="mu-storage">
1452      <ul>
1453          <li class="storage-count">
1454              <?php
1455              $text = sprintf(
1456                  /* translators: %s: number of megabytes */
1457                  __( '%s MB Space Allowed' ),
1458                  number_format_i18n( $quota )
1459              );
1460              printf(
1461                  '<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
1462                  esc_url( admin_url( 'upload.php' ) ),
1463                  $text,
1464                  __( 'Manage Uploads' )
1465              );
1466              ?>
1467          </li><li class="storage-count <?php echo $used_class; ?>">
1468              <?php
1469              $text = sprintf(
1470                  /* translators: 1: number of megabytes, 2: percentage */
1471                  __( '%1$s MB (%2$s%%) Space Used' ),
1472                  number_format_i18n( $used, 2 ),
1473                  $percentused
1474              );
1475              printf(
1476                  '<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
1477                  esc_url( admin_url( 'upload.php' ) ),
1478                  $text,
1479                  __( 'Manage Uploads' )
1480              );
1481              ?>
1482          </li>
1483      </ul>
1484      </div>
1485      <?php
1486  }
1487  
1488  // Display Browser Nag Meta Box
1489  function wp_dashboard_browser_nag() {
1490      $notice   = '';
1491      $response = wp_check_browser_version();
1492  
1493      if ( $response ) {
1494          if ( $response['insecure'] ) {
1495              /* translators: %s: browser name and link */
1496              $msg = sprintf(
1497                  __( "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." ),
1498                  sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
1499              );
1500          } else {
1501              /* translators: %s: browser name and link */
1502              $msg = sprintf(
1503                  __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
1504                  sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
1505              );
1506          }
1507  
1508          $browser_nag_class = '';
1509          if ( ! empty( $response['img_src'] ) ) {
1510              $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) ) ? $response['img_src_ssl'] : $response['img_src'];
1511  
1512              $notice           .= '<div class="alignright browser-icon"><a href="' . esc_attr( $response['update_url'] ) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
1513              $browser_nag_class = ' has-browser-icon';
1514          }
1515          $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
1516  
1517          $browsehappy = 'https://browsehappy.com/';
1518          $locale      = get_user_locale();
1519          if ( 'en_US' !== $locale ) {
1520              $browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
1521          }
1522  
1523          $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>';
1524          $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
1525          $notice .= '<div class="clear"></div>';
1526      }
1527  
1528      /**
1529       * Filters the notice output for the 'Browse Happy' nag meta box.
1530       *
1531       * @since 3.2.0
1532       *
1533       * @param string $notice   The notice content.
1534       * @param array  $response An array containing web browser information. See `wp_check_browser_version()`.
1535       */
1536      echo apply_filters( 'browse-happy-notice', $notice, $response );
1537  }
1538  
1539  /**
1540   * @since 3.2.0
1541   *
1542   * @param array $classes
1543   * @return array
1544   */
1545  function dashboard_browser_nag_class( $classes ) {
1546      $response = wp_check_browser_version();
1547  
1548      if ( $response && $response['insecure'] ) {
1549          $classes[] = 'browser-insecure';
1550      }
1551  
1552      return $classes;
1553  }
1554  
1555  /**
1556   * Check if the user needs a browser update
1557   *
1558   * @since 3.2.0
1559   *
1560   * @return array|bool False on failure, array of browser data on success.
1561   */
1562  function wp_check_browser_version() {
1563      if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1564          return false;
1565      }
1566  
1567      $key = md5( $_SERVER['HTTP_USER_AGENT'] );
1568  
1569      if ( false === ( $response = get_site_transient( 'browser_' . $key ) ) ) {
1570          // include an unmodified $wp_version
1571          include ( ABSPATH . WPINC . '/version.php' );
1572  
1573          $url     = 'http://api.wordpress.org/core/browse-happy/1.1/';
1574          $options = array(
1575              'body'       => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
1576              'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
1577          );
1578  
1579          if ( wp_http_supports( array( 'ssl' ) ) ) {
1580              $url = set_url_scheme( $url, 'https' );
1581          }
1582  
1583          $response = wp_remote_post( $url, $options );
1584  
1585          if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
1586              return false;
1587          }
1588  
1589          /**
1590           * Response should be an array with:
1591           *  'platform' - string - A user-friendly platform name, if it can be determined
1592           *  'name' - string - A user-friendly browser name
1593           *  'version' - string - The version of the browser the user is using
1594           *  'current_version' - string - The most recent version of the browser
1595           *  'upgrade' - boolean - Whether the browser needs an upgrade
1596           *  'insecure' - boolean - Whether the browser is deemed insecure
1597           *  'update_url' - string - The url to visit to upgrade
1598           *  'img_src' - string - An image representing the browser
1599           *  'img_src_ssl' - string - An image (over SSL) representing the browser
1600           */
1601          $response = json_decode( wp_remote_retrieve_body( $response ), true );
1602  
1603          if ( ! is_array( $response ) ) {
1604              return false;
1605          }
1606  
1607          set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
1608      }
1609  
1610      return $response;
1611  }
1612  
1613  /**
1614   * Displays the PHP update nag.
1615   *
1616   * @since 5.1.0
1617   */
1618  function wp_dashboard_php_nag() {
1619      $response = wp_check_php_version();
1620  
1621      if ( ! $response ) {
1622          return;
1623      }
1624  
1625      if ( isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
1626          $msg = __( 'WordPress has detected that your site is running on an insecure version of PHP.' );
1627      } else {
1628          $msg = __( 'WordPress has detected that your site is running on an outdated version of PHP.' );
1629      }
1630  
1631      ?>
1632      <p><?php echo $msg; ?></p>
1633  
1634      <h3><?php _e( 'What is PHP and how does it affect my site?' ); ?></h3>
1635      <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>
1636  
1637      <p class="button-container">
1638          <?php
1639          printf(
1640              '<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>',
1641              esc_url( wp_get_update_php_url() ),
1642              __( 'Learn more about updating PHP' ),
1643              /* translators: accessibility text */
1644              __( '(opens in a new tab)' )
1645          );
1646          ?>
1647      </p>
1648      <?php
1649  
1650      wp_update_php_annotation();
1651      wp_direct_php_update_button();
1652  }
1653  
1654  /**
1655   * Adds an additional class to the PHP nag if the current version is insecure.
1656   *
1657   * @since 5.1.0
1658   *
1659   * @param array $classes Metabox classes.
1660   * @return array Modified metabox classes.
1661   */
1662  function dashboard_php_nag_class( $classes ) {
1663      $response = wp_check_php_version();
1664  
1665      if ( $response && isset( $response['is_secure'] ) && ! $response['is_secure'] ) {
1666          $classes[] = 'php-insecure';
1667      }
1668  
1669      return $classes;
1670  }
1671  
1672  /**
1673   * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
1674   */
1675  function wp_dashboard_empty() {}
1676  
1677  /**
1678   * Displays a welcome panel to introduce users to WordPress.
1679   *
1680   * @since 3.3.0
1681   */
1682  function wp_welcome_panel() {
1683      ?>
1684      <div class="welcome-panel-content">
1685      <h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
1686      <p class="about-description"><?php _e( 'We&#8217;ve assembled some links to get you started:' ); ?></p>
1687      <div class="welcome-panel-column-container">
1688      <div class="welcome-panel-column">
1689          <?php if ( current_user_can( 'customize' ) ) : ?>
1690              <h3><?php _e( 'Get Started' ); ?></h3>
1691              <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>
1692          <?php endif; ?>
1693          <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
1694          <?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?>
1695              <?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?>
1696              <p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), $themes_link ); ?></p>
1697          <?php endif; ?>
1698      </div>
1699      <div class="welcome-panel-column">
1700          <h3><?php _e( 'Next Steps' ); ?></h3>
1701          <ul>
1702          <?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
1703              <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>
1704              <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>
1705          <?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
1706              <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>
1707              <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>
1708              <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
1709          <?php else : ?>
1710              <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
1711              <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>
1712              <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>
1713          <?php endif; ?>
1714              <li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li>
1715          </ul>
1716      </div>
1717      <div class="welcome-panel-column welcome-panel-last">
1718          <h3><?php _e( 'More Actions' ); ?></h3>
1719          <ul>
1720          <?php
1721          if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) :
1722              if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) {
1723                  $widgets_menus_link = sprintf(
1724                      __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ),
1725                      admin_url( 'widgets.php' ),
1726                      admin_url( 'nav-menus.php' )
1727                  );
1728              } elseif ( current_theme_supports( 'widgets' ) ) {
1729                  $widgets_menus_link = '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>';
1730              } else {
1731                  $widgets_menus_link = '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>';
1732              }
1733              ?>
1734              <li><div class="welcome-icon welcome-widgets-menus"><?php echo $widgets_menus_link; ?></div></li>
1735          <?php endif; ?>
1736          <?php if ( current_user_can( 'manage_options' ) ) : ?>
1737              <li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
1738          <?php endif; ?>
1739              <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>
1740          </ul>
1741      </div>
1742      </div>
1743      </div>
1744      <?php
1745  }


Generated: Mon Jun 17 08:20:02 2019 Cross-referenced by PHPXref 0.7