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


Generated: Fri Nov 22 01:00:04 2019 Cross-referenced by PHPXref 0.7.1