[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> post-template.php (source)

   1  <?php
   2  /**
   3   * WordPress Post Template Functions.
   4   *
   5   * Gets content for the current post in the loop.
   6   *
   7   * @package WordPress
   8   * @subpackage Template
   9   */
  10  
  11  /**
  12   * Display the ID of the current item in the WordPress Loop.
  13   *
  14   * @since 0.71
  15   */
  16  function the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
  17      echo get_the_ID();
  18  }
  19  
  20  /**
  21   * Retrieve the ID of the current item in the WordPress Loop.
  22   *
  23   * @since 2.1.0
  24   *
  25   * @return int|false The ID of the current item in the WordPress Loop. False if $post is not set.
  26   */
  27  function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
  28      $post = get_post();
  29      return ! empty( $post ) ? $post->ID : false;
  30  }
  31  
  32  /**
  33   * Display or retrieve the current post title with optional markup.
  34   *
  35   * @since 0.71
  36   *
  37   * @param string $before Optional. Markup to prepend to the title. Default empty.
  38   * @param string $after  Optional. Markup to append to the title. Default empty.
  39   * @param bool   $echo   Optional. Whether to echo or return the title. Default true for echo.
  40   * @return string|void Current post title if $echo is false.
  41   */
  42  function the_title( $before = '', $after = '', $echo = true ) {
  43      $title = get_the_title();
  44  
  45      if ( strlen( $title ) == 0 ) {
  46          return;
  47      }
  48  
  49      $title = $before . $title . $after;
  50  
  51      if ( $echo ) {
  52          echo $title;
  53      } else {
  54          return $title;
  55      }
  56  }
  57  
  58  /**
  59   * Sanitize the current title when retrieving or displaying.
  60   *
  61   * Works like the_title(), except the parameters can be in a string or
  62   * an array. See the function for what can be override in the $args parameter.
  63   *
  64   * The title before it is displayed will have the tags stripped and esc_attr()
  65   * before it is passed to the user or displayed. The default as with the_title(),
  66   * is to display the title.
  67   *
  68   * @since 2.3.0
  69   *
  70   * @param string|array $args {
  71   *     Title attribute arguments. Optional.
  72   *
  73   *     @type string  $before Markup to prepend to the title. Default empty.
  74   *     @type string  $after  Markup to append to the title. Default empty.
  75   *     @type bool    $echo   Whether to echo or return the title. Default true for echo.
  76   *     @type WP_Post $post   Current post object to retrieve the title for.
  77   * }
  78   * @return string|void String when echo is false.
  79   */
  80  function the_title_attribute( $args = '' ) {
  81      $defaults = array(
  82          'before' => '',
  83          'after'  => '',
  84          'echo'   => true,
  85          'post'   => get_post(),
  86      );
  87      $r        = wp_parse_args( $args, $defaults );
  88  
  89      $title = get_the_title( $r['post'] );
  90  
  91      if ( strlen( $title ) == 0 ) {
  92          return;
  93      }
  94  
  95      $title = $r['before'] . $title . $r['after'];
  96      $title = esc_attr( strip_tags( $title ) );
  97  
  98      if ( $r['echo'] ) {
  99          echo $title;
 100      } else {
 101          return $title;
 102      }
 103  }
 104  
 105  /**
 106   * Retrieve post title.
 107   *
 108   * If the post is protected and the visitor is not an admin, then "Protected"
 109   * will be displayed before the post title. If the post is private, then
 110   * "Private" will be located before the post title.
 111   *
 112   * @since 0.71
 113   *
 114   * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 115   * @return string
 116   */
 117  function get_the_title( $post = 0 ) {
 118      $post = get_post( $post );
 119  
 120      $title = isset( $post->post_title ) ? $post->post_title : '';
 121      $id    = isset( $post->ID ) ? $post->ID : 0;
 122  
 123      if ( ! is_admin() ) {
 124          if ( ! empty( $post->post_password ) ) {
 125  
 126              /**
 127               * Filters the text prepended to the post title for protected posts.
 128               *
 129               * The filter is only applied on the front end.
 130               *
 131               * @since 2.8.0
 132               *
 133               * @param string  $prepend Text displayed before the post title.
 134               *                         Default 'Protected: %s'.
 135               * @param WP_Post $post    Current post object.
 136               */
 137              $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ), $post );
 138              $title                  = sprintf( $protected_title_format, $title );
 139          } elseif ( isset( $post->post_status ) && 'private' == $post->post_status ) {
 140  
 141              /**
 142               * Filters the text prepended to the post title of private posts.
 143               *
 144               * The filter is only applied on the front end.
 145               *
 146               * @since 2.8.0
 147               *
 148               * @param string  $prepend Text displayed before the post title.
 149               *                         Default 'Private: %s'.
 150               * @param WP_Post $post    Current post object.
 151               */
 152              $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ), $post );
 153              $title                = sprintf( $private_title_format, $title );
 154          }
 155      }
 156  
 157      /**
 158       * Filters the post title.
 159       *
 160       * @since 0.71
 161       *
 162       * @param string $title The post title.
 163       * @param int    $id    The post ID.
 164       */
 165      return apply_filters( 'the_title', $title, $id );
 166  }
 167  
 168  /**
 169   * Display the Post Global Unique Identifier (guid).
 170   *
 171   * The guid will appear to be a link, but should not be used as a link to the
 172   * post. The reason you should not use it as a link, is because of moving the
 173   * blog across domains.
 174   *
 175   * URL is escaped to make it XML-safe.
 176   *
 177   * @since 1.5.0
 178   *
 179   * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
 180   */
 181  function the_guid( $post = 0 ) {
 182      $post = get_post( $post );
 183  
 184      $guid = isset( $post->guid ) ? get_the_guid( $post ) : '';
 185      $id   = isset( $post->ID ) ? $post->ID : 0;
 186  
 187      /**
 188       * Filters the escaped Global Unique Identifier (guid) of the post.
 189       *
 190       * @since 4.2.0
 191       *
 192       * @see get_the_guid()
 193       *
 194       * @param string $guid Escaped Global Unique Identifier (guid) of the post.
 195       * @param int    $id   The post ID.
 196       */
 197      echo apply_filters( 'the_guid', $guid, $id );
 198  }
 199  
 200  /**
 201   * Retrieve the Post Global Unique Identifier (guid).
 202   *
 203   * The guid will appear to be a link, but should not be used as an link to the
 204   * post. The reason you should not use it as a link, is because of moving the
 205   * blog across domains.
 206   *
 207   * @since 1.5.0
 208   *
 209   * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
 210   * @return string
 211   */
 212  function get_the_guid( $post = 0 ) {
 213      $post = get_post( $post );
 214  
 215      $guid = isset( $post->guid ) ? $post->guid : '';
 216      $id   = isset( $post->ID ) ? $post->ID : 0;
 217  
 218      /**
 219       * Filters the Global Unique Identifier (guid) of the post.
 220       *
 221       * @since 1.5.0
 222       *
 223       * @param string $guid Global Unique Identifier (guid) of the post.
 224       * @param int    $id   The post ID.
 225       */
 226      return apply_filters( 'get_the_guid', $guid, $id );
 227  }
 228  
 229  /**
 230   * Display the post content.
 231   *
 232   * @since 0.71
 233   *
 234   * @param string $more_link_text Optional. Content for when there is more text.
 235   * @param bool   $strip_teaser   Optional. Strip teaser content before the more text. Default is false.
 236   */
 237  function the_content( $more_link_text = null, $strip_teaser = false ) {
 238      $content = get_the_content( $more_link_text, $strip_teaser );
 239  
 240      /**
 241       * Filters the post content.
 242       *
 243       * @since 0.71
 244       *
 245       * @param string $content Content of the current post.
 246       */
 247      $content = apply_filters( 'the_content', $content );
 248      $content = str_replace( ']]>', ']]&gt;', $content );
 249      echo $content;
 250  }
 251  
 252  /**
 253   * Retrieve the post content.
 254   *
 255   * @since 0.71
 256   * @since 5.2.0 Added the `$post` parameter.
 257   *
 258   * @global int   $page      Page number of a single post/page.
 259   * @global int   $more      Boolean indicator for whether single post/page is being viewed.
 260   * @global bool  $preview   Whether post/page is in preview mode.
 261   * @global array $pages     Array of all pages in post/page. Each array element contains
 262   *                          part of the content separated by the `<!--nextpage-->` tag.
 263   * @global int   $multipage Boolean indicator for whether multiple pages are in play.
 264   *
 265   * @param string             $more_link_text Optional. Content for when there is more text.
 266   * @param bool               $strip_teaser   Optional. Strip teaser content before the more text. Default is false.
 267   * @param WP_Post|object|int $post           Optional. WP_Post instance or Post ID/object. Default is null.
 268   * @return string
 269   */
 270  function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) {
 271      global $page, $more, $preview, $pages, $multipage;
 272  
 273      $_post = get_post( $post );
 274  
 275      if ( ! ( $_post instanceof WP_Post ) ) {
 276          return '';
 277      }
 278  
 279      if ( null === $post ) {
 280          $elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' );
 281      } else {
 282          $elements = generate_postdata( $_post );
 283      }
 284  
 285      if ( null === $more_link_text ) {
 286          $more_link_text = sprintf(
 287              '<span aria-label="%1$s">%2$s</span>',
 288              sprintf(
 289                  /* translators: %s: Name of current post */
 290                  __( 'Continue reading %s' ),
 291                  the_title_attribute(
 292                      array(
 293                          'echo' => false,
 294                          'post' => $_post,
 295                      )
 296                  )
 297              ),
 298              __( '(more&hellip;)' )
 299          );
 300      }
 301  
 302      $output     = '';
 303      $has_teaser = false;
 304  
 305      // If post password required and it doesn't match the cookie.
 306      if ( post_password_required( $_post ) ) {
 307          return get_the_password_form( $_post );
 308      }
 309  
 310      if ( $elements['page'] > count( $elements['pages'] ) ) { // if the requested page doesn't exist
 311          $elements['page'] = count( $elements['pages'] ); // give them the highest numbered page that DOES exist
 312      }
 313  
 314      $page_no = $elements['page'];
 315      $content = $elements['pages'][ $page_no - 1 ];
 316      if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
 317          if ( has_block( 'more', $content ) ) {
 318              // Remove the core/more block delimiters. They will be left over after $content is split up.
 319              $content = preg_replace( '/<!-- \/?wp:more(.*?) -->/', '', $content );
 320          }
 321  
 322          $content = explode( $matches[0], $content, 2 );
 323  
 324          if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) ) {
 325              $more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) );
 326          }
 327  
 328          $has_teaser = true;
 329      } else {
 330          $content = array( $content );
 331      }
 332  
 333      if ( false !== strpos( $_post->post_content, '<!--noteaser-->' ) && ( ! $elements['multipage'] || $elements['page'] == 1 ) ) {
 334          $strip_teaser = true;
 335      }
 336  
 337      $teaser = $content[0];
 338  
 339      if ( $elements['more'] && $strip_teaser && $has_teaser ) {
 340          $teaser = '';
 341      }
 342  
 343      $output .= $teaser;
 344  
 345      if ( count( $content ) > 1 ) {
 346          if ( $elements['more'] ) {
 347              $output .= '<span id="more-' . $_post->ID . '"></span>' . $content[1];
 348          } else {
 349              if ( ! empty( $more_link_text ) ) {
 350  
 351                  /**
 352                   * Filters the Read More link text.
 353                   *
 354                   * @since 2.8.0
 355                   *
 356                   * @param string $more_link_element Read More link element.
 357                   * @param string $more_link_text    Read More text.
 358                   */
 359                  $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( $_post ) . "#more-{$_post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
 360              }
 361              $output = force_balance_tags( $output );
 362          }
 363      }
 364  
 365      if ( $preview ) { // Preview fix for JavaScript bug with foreign languages.
 366          $output = preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output );
 367      }
 368  
 369      return $output;
 370  }
 371  
 372  /**
 373   * Preview fix for JavaScript bug with foreign languages.
 374   *
 375   * @since 3.1.0
 376   * @access private
 377   *
 378   * @param array $match Match array from preg_replace_callback.
 379   * @return string
 380   */
 381  function _convert_urlencoded_to_entities( $match ) {
 382      return '&#' . base_convert( $match[1], 16, 10 ) . ';';
 383  }
 384  
 385  /**
 386   * Display the post excerpt.
 387   *
 388   * @since 0.71
 389   */
 390  function the_excerpt() {
 391  
 392      /**
 393       * Filters the displayed post excerpt.
 394       *
 395       * @since 0.71
 396       *
 397       * @see get_the_excerpt()
 398       *
 399       * @param string $post_excerpt The post excerpt.
 400       */
 401      echo apply_filters( 'the_excerpt', get_the_excerpt() );
 402  }
 403  
 404  /**
 405   * Retrieves the post excerpt.
 406   *
 407   * @since 0.71
 408   * @since 4.5.0 Introduced the `$post` parameter.
 409   *
 410   * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 411   * @return string Post excerpt.
 412   */
 413  function get_the_excerpt( $post = null ) {
 414      if ( is_bool( $post ) ) {
 415          _deprecated_argument( __FUNCTION__, '2.3.0' );
 416      }
 417  
 418      $post = get_post( $post );
 419      if ( empty( $post ) ) {
 420          return '';
 421      }
 422  
 423      if ( post_password_required( $post ) ) {
 424          return __( 'There is no excerpt because this is a protected post.' );
 425      }
 426  
 427      /**
 428       * Filters the retrieved post excerpt.
 429       *
 430       * @since 1.2.0
 431       * @since 4.5.0 Introduced the `$post` parameter.
 432       *
 433       * @param string $post_excerpt The post excerpt.
 434       * @param WP_Post $post Post object.
 435       */
 436      return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post );
 437  }
 438  
 439  /**
 440   * Determines whether the post has a custom excerpt.
 441   *
 442   * For more information on this and similar theme functions, check out
 443   * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 444   * Conditional Tags} article in the Theme Developer Handbook.
 445   *
 446   * @since 2.3.0
 447   *
 448   * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 449   * @return bool True if the post has a custom excerpt, false otherwise.
 450   */
 451  function has_excerpt( $post = 0 ) {
 452      $post = get_post( $post );
 453      return ( ! empty( $post->post_excerpt ) );
 454  }
 455  
 456  /**
 457   * Displays the classes for the post container element.
 458   *
 459   * @since 2.7.0
 460   *
 461   * @param string|array $class   One or more classes to add to the class list.
 462   * @param int|WP_Post  $post_id Optional. Post ID or post object. Defaults to the global `$post`.
 463   */
 464  function post_class( $class = '', $post_id = null ) {
 465      // Separates classes with a single space, collates classes for post DIV
 466      echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"';
 467  }
 468  
 469  /**
 470   * Retrieves an array of the class names for the post container element.
 471   *
 472   * The class names are many. If the post is a sticky, then the 'sticky'
 473   * class name. The class 'hentry' is always added to each post. If the post has a
 474   * post thumbnail, 'has-post-thumbnail' is added as a class. For each taxonomy that
 475   * the post belongs to, a class will be added of the format '{$taxonomy}-{$slug}' -
 476   * eg 'category-foo' or 'my_custom_taxonomy-bar'.
 477   *
 478   * The 'post_tag' taxonomy is a special
 479   * case; the class has the 'tag-' prefix instead of 'post_tag-'. All class names are
 480   * passed through the filter, {@see 'post_class'}, with the list of class names, followed by
 481   * $class parameter value, with the post ID as the last parameter.
 482   *
 483   * @since 2.7.0
 484   * @since 4.2.0 Custom taxonomy class names were added.
 485   *
 486   * @param string|string[] $class   Space-separated string or array of class names to add to the class list.
 487   * @param int|WP_Post     $post_id Optional. Post ID or post object.
 488   * @return string[] Array of class names.
 489   */
 490  function get_post_class( $class = '', $post_id = null ) {
 491      $post = get_post( $post_id );
 492  
 493      $classes = array();
 494  
 495      if ( $class ) {
 496          if ( ! is_array( $class ) ) {
 497              $class = preg_split( '#\s+#', $class );
 498          }
 499          $classes = array_map( 'esc_attr', $class );
 500      } else {
 501          // Ensure that we always coerce class to being an array.
 502          $class = array();
 503      }
 504  
 505      if ( ! $post ) {
 506          return $classes;
 507      }
 508  
 509      $classes[] = 'post-' . $post->ID;
 510      if ( ! is_admin() ) {
 511          $classes[] = $post->post_type;
 512      }
 513      $classes[] = 'type-' . $post->post_type;
 514      $classes[] = 'status-' . $post->post_status;
 515  
 516      // Post Format
 517      if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
 518          $post_format = get_post_format( $post->ID );
 519  
 520          if ( $post_format && ! is_wp_error( $post_format ) ) {
 521              $classes[] = 'format-' . sanitize_html_class( $post_format );
 522          } else {
 523              $classes[] = 'format-standard';
 524          }
 525      }
 526  
 527      $post_password_required = post_password_required( $post->ID );
 528  
 529      // Post requires password.
 530      if ( $post_password_required ) {
 531          $classes[] = 'post-password-required';
 532      } elseif ( ! empty( $post->post_password ) ) {
 533          $classes[] = 'post-password-protected';
 534      }
 535  
 536      // Post thumbnails.
 537      if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ! is_attachment( $post ) && ! $post_password_required ) {
 538          $classes[] = 'has-post-thumbnail';
 539      }
 540  
 541      // sticky for Sticky Posts
 542      if ( is_sticky( $post->ID ) ) {
 543          if ( is_home() && ! is_paged() ) {
 544              $classes[] = 'sticky';
 545          } elseif ( is_admin() ) {
 546              $classes[] = 'status-sticky';
 547          }
 548      }
 549  
 550      // hentry for hAtom compliance
 551      $classes[] = 'hentry';
 552  
 553      // All public taxonomies
 554      $taxonomies = get_taxonomies( array( 'public' => true ) );
 555      foreach ( (array) $taxonomies as $taxonomy ) {
 556          if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
 557              foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) {
 558                  if ( empty( $term->slug ) ) {
 559                      continue;
 560                  }
 561  
 562                  $term_class = sanitize_html_class( $term->slug, $term->term_id );
 563                  if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) {
 564                      $term_class = $term->term_id;
 565                  }
 566  
 567                  // 'post_tag' uses the 'tag' prefix for backward compatibility.
 568                  if ( 'post_tag' == $taxonomy ) {
 569                      $classes[] = 'tag-' . $term_class;
 570                  } else {
 571                      $classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id );
 572                  }
 573              }
 574          }
 575      }
 576  
 577      $classes = array_map( 'esc_attr', $classes );
 578  
 579      /**
 580       * Filters the list of CSS class names for the current post.
 581       *
 582       * @since 2.7.0
 583       *
 584       * @param string[] $classes An array of post class names.
 585       * @param string[] $class   An array of additional class names added to the post.
 586       * @param int      $post_id The post ID.
 587       */
 588      $classes = apply_filters( 'post_class', $classes, $class, $post->ID );
 589  
 590      return array_unique( $classes );
 591  }
 592  
 593  /**
 594   * Displays the class names for the body element.
 595   *
 596   * @since 2.8.0
 597   *
 598   * @param string|string[] $class Space-separated string or array of class names to add to the class list.
 599   */
 600  function body_class( $class = '' ) {
 601      // Separates class names with a single space, collates class names for body element
 602      echo 'class="' . join( ' ', get_body_class( $class ) ) . '"';
 603  }
 604  
 605  /**
 606   * Retrieves an array of the class names for the body element.
 607   *
 608   * @since 2.8.0
 609   *
 610   * @global WP_Query $wp_query
 611   *
 612   * @param string|string[] $class Space-separated string or array of class names to add to the class list.
 613   * @return string[] Array of class names.
 614   */
 615  function get_body_class( $class = '' ) {
 616      global $wp_query;
 617  
 618      $classes = array();
 619  
 620      if ( is_rtl() ) {
 621          $classes[] = 'rtl';
 622      }
 623  
 624      if ( is_front_page() ) {
 625          $classes[] = 'home';
 626      }
 627      if ( is_home() ) {
 628          $classes[] = 'blog';
 629      }
 630      if ( is_privacy_policy() ) {
 631          $classes[] = 'privacy-policy';
 632      }
 633      if ( is_archive() ) {
 634          $classes[] = 'archive';
 635      }
 636      if ( is_date() ) {
 637          $classes[] = 'date';
 638      }
 639      if ( is_search() ) {
 640          $classes[] = 'search';
 641          $classes[] = $wp_query->posts ? 'search-results' : 'search-no-results';
 642      }
 643      if ( is_paged() ) {
 644          $classes[] = 'paged';
 645      }
 646      if ( is_attachment() ) {
 647          $classes[] = 'attachment';
 648      }
 649      if ( is_404() ) {
 650          $classes[] = 'error404';
 651      }
 652  
 653      if ( is_singular() ) {
 654          $post_id   = $wp_query->get_queried_object_id();
 655          $post      = $wp_query->get_queried_object();
 656          $post_type = $post->post_type;
 657  
 658          if ( is_page_template() ) {
 659              $classes[] = "{$post_type}-template";
 660  
 661              $template_slug  = get_page_template_slug( $post_id );
 662              $template_parts = explode( '/', $template_slug );
 663  
 664              foreach ( $template_parts as $part ) {
 665                  $classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( array( '.', '/' ), '-', basename( $part, '.php' ) ) );
 666              }
 667              $classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( '.', '-', $template_slug ) );
 668          } else {
 669              $classes[] = "{$post_type}-template-default";
 670          }
 671  
 672          if ( is_single() ) {
 673              $classes[] = 'single';
 674              if ( isset( $post->post_type ) ) {
 675                  $classes[] = 'single-' . sanitize_html_class( $post->post_type, $post_id );
 676                  $classes[] = 'postid-' . $post_id;
 677  
 678                  // Post Format
 679                  if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
 680                      $post_format = get_post_format( $post->ID );
 681  
 682                      if ( $post_format && ! is_wp_error( $post_format ) ) {
 683                          $classes[] = 'single-format-' . sanitize_html_class( $post_format );
 684                      } else {
 685                          $classes[] = 'single-format-standard';
 686                      }
 687                  }
 688              }
 689          }
 690  
 691          if ( is_attachment() ) {
 692              $mime_type   = get_post_mime_type( $post_id );
 693              $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
 694              $classes[]   = 'attachmentid-' . $post_id;
 695              $classes[]   = 'attachment-' . str_replace( $mime_prefix, '', $mime_type );
 696          } elseif ( is_page() ) {
 697              $classes[] = 'page';
 698  
 699              $page_id = $wp_query->get_queried_object_id();
 700  
 701              $post = get_post( $page_id );
 702  
 703              $classes[] = 'page-id-' . $page_id;
 704  
 705              if ( get_pages(
 706                  array(
 707                      'parent' => $page_id,
 708                      'number' => 1,
 709                  )
 710              ) ) {
 711                  $classes[] = 'page-parent';
 712              }
 713  
 714              if ( $post->post_parent ) {
 715                  $classes[] = 'page-child';
 716                  $classes[] = 'parent-pageid-' . $post->post_parent;
 717              }
 718          }
 719      } elseif ( is_archive() ) {
 720          if ( is_post_type_archive() ) {
 721              $classes[] = 'post-type-archive';
 722              $post_type = get_query_var( 'post_type' );
 723              if ( is_array( $post_type ) ) {
 724                  $post_type = reset( $post_type );
 725              }
 726              $classes[] = 'post-type-archive-' . sanitize_html_class( $post_type );
 727          } elseif ( is_author() ) {
 728              $author    = $wp_query->get_queried_object();
 729              $classes[] = 'author';
 730              if ( isset( $author->user_nicename ) ) {
 731                  $classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID );
 732                  $classes[] = 'author-' . $author->ID;
 733              }
 734          } elseif ( is_category() ) {
 735              $cat       = $wp_query->get_queried_object();
 736              $classes[] = 'category';
 737              if ( isset( $cat->term_id ) ) {
 738                  $cat_class = sanitize_html_class( $cat->slug, $cat->term_id );
 739                  if ( is_numeric( $cat_class ) || ! trim( $cat_class, '-' ) ) {
 740                      $cat_class = $cat->term_id;
 741                  }
 742  
 743                  $classes[] = 'category-' . $cat_class;
 744                  $classes[] = 'category-' . $cat->term_id;
 745              }
 746          } elseif ( is_tag() ) {
 747              $tag       = $wp_query->get_queried_object();
 748              $classes[] = 'tag';
 749              if ( isset( $tag->term_id ) ) {
 750                  $tag_class = sanitize_html_class( $tag->slug, $tag->term_id );
 751                  if ( is_numeric( $tag_class ) || ! trim( $tag_class, '-' ) ) {
 752                      $tag_class = $tag->term_id;
 753                  }
 754  
 755                  $classes[] = 'tag-' . $tag_class;
 756                  $classes[] = 'tag-' . $tag->term_id;
 757              }
 758          } elseif ( is_tax() ) {
 759              $term = $wp_query->get_queried_object();
 760              if ( isset( $term->term_id ) ) {
 761                  $term_class = sanitize_html_class( $term->slug, $term->term_id );
 762                  if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) {
 763                      $term_class = $term->term_id;
 764                  }
 765  
 766                  $classes[] = 'tax-' . sanitize_html_class( $term->taxonomy );
 767                  $classes[] = 'term-' . $term_class;
 768                  $classes[] = 'term-' . $term->term_id;
 769              }
 770          }
 771      }
 772  
 773      if ( is_user_logged_in() ) {
 774          $classes[] = 'logged-in';
 775      }
 776  
 777      if ( is_admin_bar_showing() ) {
 778          $classes[] = 'admin-bar';
 779          $classes[] = 'no-customize-support';
 780      }
 781  
 782      if ( current_theme_supports( 'custom-background' )
 783          && ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() ) ) {
 784          $classes[] = 'custom-background';
 785      }
 786  
 787      if ( has_custom_logo() ) {
 788          $classes[] = 'wp-custom-logo';
 789      }
 790  
 791      if ( current_theme_supports( 'responsive-embeds' ) ) {
 792          $classes[] = 'wp-embed-responsive';
 793      }
 794  
 795      $page = $wp_query->get( 'page' );
 796  
 797      if ( ! $page || $page < 2 ) {
 798          $page = $wp_query->get( 'paged' );
 799      }
 800  
 801      if ( $page && $page > 1 && ! is_404() ) {
 802          $classes[] = 'paged-' . $page;
 803  
 804          if ( is_single() ) {
 805              $classes[] = 'single-paged-' . $page;
 806          } elseif ( is_page() ) {
 807              $classes[] = 'page-paged-' . $page;
 808          } elseif ( is_category() ) {
 809              $classes[] = 'category-paged-' . $page;
 810          } elseif ( is_tag() ) {
 811              $classes[] = 'tag-paged-' . $page;
 812          } elseif ( is_date() ) {
 813              $classes[] = 'date-paged-' . $page;
 814          } elseif ( is_author() ) {
 815              $classes[] = 'author-paged-' . $page;
 816          } elseif ( is_search() ) {
 817              $classes[] = 'search-paged-' . $page;
 818          } elseif ( is_post_type_archive() ) {
 819              $classes[] = 'post-type-paged-' . $page;
 820          }
 821      }
 822  
 823      if ( ! empty( $class ) ) {
 824          if ( ! is_array( $class ) ) {
 825              $class = preg_split( '#\s+#', $class );
 826          }
 827          $classes = array_merge( $classes, $class );
 828      } else {
 829          // Ensure that we always coerce class to being an array.
 830          $class = array();
 831      }
 832  
 833      $classes = array_map( 'esc_attr', $classes );
 834  
 835      /**
 836       * Filters the list of CSS body class names for the current post or page.
 837       *
 838       * @since 2.8.0
 839       *
 840       * @param string[] $classes An array of body class names.
 841       * @param string[] $class   An array of additional class names added to the body.
 842       */
 843      $classes = apply_filters( 'body_class', $classes, $class );
 844  
 845      return array_unique( $classes );
 846  }
 847  
 848  /**
 849   * Whether post requires password and correct password has been provided.
 850   *
 851   * @since 2.7.0
 852   *
 853   * @param int|WP_Post|null $post An optional post. Global $post used if not provided.
 854   * @return bool false if a password is not required or the correct password cookie is present, true otherwise.
 855   */
 856  function post_password_required( $post = null ) {
 857      $post = get_post( $post );
 858  
 859      if ( empty( $post->post_password ) ) {
 860          /** This filter is documented in wp-includes/post-template.php */
 861          return apply_filters( 'post_password_required', false, $post );
 862      }
 863  
 864      if ( ! isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) {
 865          /** This filter is documented in wp-includes/post-template.php */
 866          return apply_filters( 'post_password_required', true, $post );
 867      }
 868  
 869      require_once  ABSPATH . WPINC . '/class-phpass.php';
 870      $hasher = new PasswordHash( 8, true );
 871  
 872      $hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
 873      if ( 0 !== strpos( $hash, '$P$B' ) ) {
 874          $required = true;
 875      } else {
 876          $required = ! $hasher->CheckPassword( $post->post_password, $hash );
 877      }
 878  
 879      /**
 880       * Filters whether a post requires the user to supply a password.
 881       *
 882       * @since 4.7.0
 883       *
 884       * @param bool    $required Whether the user needs to supply a password. True if password has not been
 885       *                          provided or is incorrect, false if password has been supplied or is not required.
 886       * @param WP_Post $post     Post data.
 887       */
 888      return apply_filters( 'post_password_required', $required, $post );
 889  }
 890  
 891  //
 892  // Page Template Functions for usage in Themes
 893  //
 894  
 895  /**
 896   * The formatted output of a list of pages.
 897   *
 898   * Displays page links for paginated posts (i.e. including the `<!--nextpage-->`
 899   * Quicktag one or more times). This tag must be within The Loop.
 900   *
 901   * @since 1.2.0
 902   * @since 5.1.0 Added the `aria_current` argument.
 903   *
 904   * @global int $page
 905   * @global int $numpages
 906   * @global int $multipage
 907   * @global int $more
 908   *
 909   * @param string|array $args {
 910   *     Optional. Array or string of default arguments.
 911   *
 912   *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 913   *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 914   *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 915   *                                          Also prepended to the current item, which is not linked. Default empty.
 916   *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 917   *                                          Also appended to the current item, which is not linked. Default empty.
 918   *     @type string       $aria_current     The value for the aria-current attribute. Possible values are 'page',
 919   *                                          'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
 920   *     @type string       $next_or_number   Indicates whether page numbers should be used. Valid values are number
 921   *                                          and next. Default is 'number'.
 922   *     @type string       $separator        Text between pagination links. Default is ' '.
 923   *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 924   *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 925   *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 926   *                                          replaced with the page number, so 'Page %' generates "Page 1", "Page 2", etc.
 927   *                                          Defaults to '%', just the page number.
 928   *     @type int|bool     $echo             Whether to echo or not. Accepts 1|true or 0|false. Default 1|true.
 929   * }
 930   * @return string Formatted output in HTML.
 931   */
 932  function wp_link_pages( $args = '' ) {
 933      global $page, $numpages, $multipage, $more;
 934  
 935      $defaults = array(
 936          'before'           => '<p class="post-nav-links">' . __( 'Pages:' ),
 937          'after'            => '</p>',
 938          'link_before'      => '',
 939          'link_after'       => '',
 940          'aria_current'     => 'page',
 941          'next_or_number'   => 'number',
 942          'separator'        => ' ',
 943          'nextpagelink'     => __( 'Next page' ),
 944          'previouspagelink' => __( 'Previous page' ),
 945          'pagelink'         => '%',
 946          'echo'             => 1,
 947      );
 948  
 949      $params = wp_parse_args( $args, $defaults );
 950  
 951      /**
 952       * Filters the arguments used in retrieving page links for paginated posts.
 953       *
 954       * @since 3.0.0
 955       *
 956       * @param array $params An array of arguments for page links for paginated posts.
 957       */
 958      $r = apply_filters( 'wp_link_pages_args', $params );
 959  
 960      $output = '';
 961      if ( $multipage ) {
 962          if ( 'number' == $r['next_or_number'] ) {
 963              $output .= $r['before'];
 964              for ( $i = 1; $i <= $numpages; $i++ ) {
 965                  $link = $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after'];
 966                  if ( $i != $page || ! $more && 1 == $page ) {
 967                      $link = _wp_link_page( $i ) . $link . '</a>';
 968                  } elseif ( $i === $page ) {
 969                      $link = '<span class="post-page-numbers current" aria-current="' . esc_attr( $r['aria_current'] ) . '">' . $link . '</span>';
 970                  }
 971                  /**
 972                   * Filters the HTML output of individual page number links.
 973                   *
 974                   * @since 3.6.0
 975                   *
 976                   * @param string $link The page number HTML output.
 977                   * @param int    $i    Page number for paginated posts' page links.
 978                   */
 979                  $link = apply_filters( 'wp_link_pages_link', $link, $i );
 980  
 981                  // Use the custom links separator beginning with the second link.
 982                  $output .= ( 1 === $i ) ? ' ' : $r['separator'];
 983                  $output .= $link;
 984              }
 985              $output .= $r['after'];
 986          } elseif ( $more ) {
 987              $output .= $r['before'];
 988              $prev    = $page - 1;
 989              if ( $prev > 0 ) {
 990                  $link = _wp_link_page( $prev ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
 991  
 992                  /** This filter is documented in wp-includes/post-template.php */
 993                  $output .= apply_filters( 'wp_link_pages_link', $link, $prev );
 994              }
 995              $next = $page + 1;
 996              if ( $next <= $numpages ) {
 997                  if ( $prev ) {
 998                      $output .= $r['separator'];
 999                  }
1000                  $link = _wp_link_page( $next ) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
1001  
1002                  /** This filter is documented in wp-includes/post-template.php */
1003                  $output .= apply_filters( 'wp_link_pages_link', $link, $next );
1004              }
1005              $output .= $r['after'];
1006          }
1007      }
1008  
1009      /**
1010       * Filters the HTML output of page links for paginated posts.
1011       *
1012       * @since 3.6.0
1013       *
1014       * @param string $output HTML output of paginated posts' page links.
1015       * @param array  $args   An array of arguments.
1016       */
1017      $html = apply_filters( 'wp_link_pages', $output, $args );
1018  
1019      if ( $r['echo'] ) {
1020          echo $html;
1021      }
1022      return $html;
1023  }
1024  
1025  /**
1026   * Helper function for wp_link_pages().
1027   *
1028   * @since 3.1.0
1029   * @access private
1030   *
1031   * @global WP_Rewrite $wp_rewrite
1032   *
1033   * @param int $i Page number.
1034   * @return string Link.
1035   */
1036  function _wp_link_page( $i ) {
1037      global $wp_rewrite;
1038      $post       = get_post();
1039      $query_args = array();
1040  
1041      if ( 1 == $i ) {
1042          $url = get_permalink();
1043      } else {
1044          if ( '' == get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ) ) ) {
1045              $url = add_query_arg( 'page', $i, get_permalink() );
1046          } elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) {
1047              $url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' );
1048          } else {
1049              $url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' );
1050          }
1051      }
1052  
1053      if ( is_preview() ) {
1054  
1055          if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
1056              $query_args['preview_id']    = wp_unslash( $_GET['preview_id'] );
1057              $query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
1058          }
1059  
1060          $url = get_preview_post_link( $post, $query_args, $url );
1061      }
1062  
1063      return '<a href="' . esc_url( $url ) . '" class="post-page-numbers">';
1064  }
1065  
1066  //
1067  // Post-meta: Custom per-post fields.
1068  //
1069  
1070  /**
1071   * Retrieve post custom meta data field.
1072   *
1073   * @since 1.5.0
1074   *
1075   * @param string $key Meta data key name.
1076   * @return false|string|array Array of values or single value, if only one element exists. False will be returned if key does not exist.
1077   */
1078  function post_custom( $key = '' ) {
1079      $custom = get_post_custom();
1080  
1081      if ( ! isset( $custom[ $key ] ) ) {
1082          return false;
1083      } elseif ( 1 == count( $custom[ $key ] ) ) {
1084          return $custom[ $key ][0];
1085      } else {
1086          return $custom[ $key ];
1087      }
1088  }
1089  
1090  /**
1091   * Display a list of post custom fields.
1092   *
1093   * @since 1.2.0
1094   *
1095   * @internal This will probably change at some point...
1096   */
1097  function the_meta() {
1098      $keys = get_post_custom_keys();
1099      if ( $keys ) {
1100          $li_html = '';
1101          foreach ( (array) $keys as $key ) {
1102              $keyt = trim( $key );
1103              if ( is_protected_meta( $keyt, 'post' ) ) {
1104                  continue;
1105              }
1106  
1107              $values = array_map( 'trim', get_post_custom_values( $key ) );
1108              $value  = implode( ', ', $values );
1109  
1110              $html = sprintf(
1111                  "<li><span class='post-meta-key'>%s</span> %s</li>\n",
1112                  /* translators: %s: Post custom field name */
1113                  sprintf( _x( '%s:', 'Post custom field name' ), $key ),
1114                  $value
1115              );
1116  
1117              /**
1118               * Filters the HTML output of the li element in the post custom fields list.
1119               *
1120               * @since 2.2.0
1121               *
1122               * @param string $html  The HTML output for the li element.
1123               * @param string $key   Meta key.
1124               * @param string $value Meta value.
1125               */
1126              $li_html .= apply_filters( 'the_meta_key', $html, $key, $value );
1127          }
1128  
1129          if ( $li_html ) {
1130              echo "<ul class='post-meta'>\n{$li_html}</ul>\n";
1131          }
1132      }
1133  }
1134  
1135  //
1136  // Pages
1137  //
1138  
1139  /**
1140   * Retrieve or display a list of pages as a dropdown (select list).
1141   *
1142   * @since 2.1.0
1143   * @since 4.2.0 The `$value_field` argument was added.
1144   * @since 4.3.0 The `$class` argument was added.
1145   *
1146   * @see get_pages()
1147   *
1148   * @param array|string $args {
1149   *     Optional. Array or string of arguments to generate a page dropdown. See `get_pages()` for additional arguments.
1150   *
1151   *     @type int          $depth                 Maximum depth. Default 0.
1152   *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
1153   *     @type int|string   $selected              Value of the option that should be selected. Default 0.
1154   *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
1155   *                                               or their bool equivalents. Default 1.
1156   *     @type string       $name                  Value for the 'name' attribute of the select element.
1157   *                                               Default 'page_id'.
1158   *     @type string       $id                    Value for the 'id' attribute of the select element.
1159   *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
1160   *                                               Defaults to the value of `$name`.
1161   *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
1162   *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
1163   *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
1164   *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
1165   *                                               elements. Accepts any valid post field. Default 'ID'.
1166   * }
1167   * @return string HTML content, if not displaying.
1168   */
1169  function wp_dropdown_pages( $args = '' ) {
1170      $defaults = array(
1171          'depth'                 => 0,
1172          'child_of'              => 0,
1173          'selected'              => 0,
1174          'echo'                  => 1,
1175          'name'                  => 'page_id',
1176          'id'                    => '',
1177          'class'                 => '',
1178          'show_option_none'      => '',
1179          'show_option_no_change' => '',
1180          'option_none_value'     => '',
1181          'value_field'           => 'ID',
1182      );
1183  
1184      $r = wp_parse_args( $args, $defaults );
1185  
1186      $pages  = get_pages( $r );
1187      $output = '';
1188      // Back-compat with old system where both id and name were based on $name argument
1189      if ( empty( $r['id'] ) ) {
1190          $r['id'] = $r['name'];
1191      }
1192  
1193      if ( ! empty( $pages ) ) {
1194          $class = '';
1195          if ( ! empty( $r['class'] ) ) {
1196              $class = " class='" . esc_attr( $r['class'] ) . "'";
1197          }
1198  
1199          $output = "<select name='" . esc_attr( $r['name'] ) . "'" . $class . " id='" . esc_attr( $r['id'] ) . "'>\n";
1200          if ( $r['show_option_no_change'] ) {
1201              $output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n";
1202          }
1203          if ( $r['show_option_none'] ) {
1204              $output .= "\t<option value=\"" . esc_attr( $r['option_none_value'] ) . '">' . $r['show_option_none'] . "</option>\n";
1205          }
1206          $output .= walk_page_dropdown_tree( $pages, $r['depth'], $r );
1207          $output .= "</select>\n";
1208      }
1209  
1210      /**
1211       * Filters the HTML output of a list of pages as a drop down.
1212       *
1213       * @since 2.1.0
1214       * @since 4.4.0 `$r` and `$pages` added as arguments.
1215       *
1216       * @param string $output HTML output for drop down list of pages.
1217       * @param array  $r      The parsed arguments array.
1218       * @param array  $pages  List of WP_Post objects returned by `get_pages()`
1219       */
1220      $html = apply_filters( 'wp_dropdown_pages', $output, $r, $pages );
1221  
1222      if ( $r['echo'] ) {
1223          echo $html;
1224      }
1225      return $html;
1226  }
1227  
1228  /**
1229   * Retrieve or display a list of pages (or hierarchical post type items) in list (li) format.
1230   *
1231   * @since 1.5.0
1232   * @since 4.7.0 Added the `item_spacing` argument.
1233   *
1234   * @see get_pages()
1235   *
1236   * @global WP_Query $wp_query
1237   *
1238   * @param array|string $args {
1239   *     Optional. Array or string of arguments to generate a list of pages. See `get_pages()` for additional arguments.
1240   *
1241   *     @type int          $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
1242   *     @type string       $authors      Comma-separated list of author IDs. Default empty (all authors).
1243   *     @type string       $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
1244   *                                      Default is the value of 'date_format' option.
1245   *     @type int          $depth        Number of levels in the hierarchy of pages to include in the generated list.
1246   *                                      Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
1247   *                                      the given n depth). Default 0.
1248   *     @type bool         $echo         Whether or not to echo the list of pages. Default true.
1249   *     @type string       $exclude      Comma-separated list of page IDs to exclude. Default empty.
1250   *     @type array        $include      Comma-separated list of page IDs to include. Default empty.
1251   *     @type string       $link_after   Text or HTML to follow the page link label. Default null.
1252   *     @type string       $link_before  Text or HTML to precede the page link label. Default null.
1253   *     @type string       $post_type    Post type to query for. Default 'page'.
1254   *     @type string|array $post_status  Comma-separated list or array of post statuses to include. Default 'publish'.
1255   *     @type string       $show_date    Whether to display the page publish or modified date for each page. Accepts
1256   *                                      'modified' or any other value. An empty value hides the date. Default empty.
1257   *     @type string       $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
1258   *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
1259   *                                      'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
1260   *     @type string       $title_li     List heading. Passing a null or empty value will result in no heading, and the list
1261   *                                      will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
1262   *     @type string       $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
1263   *                                      Default 'preserve'.
1264   *     @type Walker       $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
1265   * }
1266   * @return string|void HTML list of pages.
1267   */
1268  function wp_list_pages( $args = '' ) {
1269      $defaults = array(
1270          'depth'        => 0,
1271          'show_date'    => '',
1272          'date_format'  => get_option( 'date_format' ),
1273          'child_of'     => 0,
1274          'exclude'      => '',
1275          'title_li'     => __( 'Pages' ),
1276          'echo'         => 1,
1277          'authors'      => '',
1278          'sort_column'  => 'menu_order, post_title',
1279          'link_before'  => '',
1280          'link_after'   => '',
1281          'item_spacing' => 'preserve',
1282          'walker'       => '',
1283      );
1284  
1285      $r = wp_parse_args( $args, $defaults );
1286  
1287      if ( ! in_array( $r['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
1288          // invalid value, fall back to default.
1289          $r['item_spacing'] = $defaults['item_spacing'];
1290      }
1291  
1292      $output       = '';
1293      $current_page = 0;
1294  
1295      // sanitize, mostly to keep spaces out
1296      $r['exclude'] = preg_replace( '/[^0-9,]/', '', $r['exclude'] );
1297  
1298      // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
1299      $exclude_array = ( $r['exclude'] ) ? explode( ',', $r['exclude'] ) : array();
1300  
1301      /**
1302       * Filters the array of pages to exclude from the pages list.
1303       *
1304       * @since 2.1.0
1305       *
1306       * @param array $exclude_array An array of page IDs to exclude.
1307       */
1308      $r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) );
1309  
1310      // Query pages.
1311      $r['hierarchical'] = 0;
1312      $pages             = get_pages( $r );
1313  
1314      if ( ! empty( $pages ) ) {
1315          if ( $r['title_li'] ) {
1316              $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
1317          }
1318          global $wp_query;
1319          if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
1320              $current_page = get_queried_object_id();
1321          } elseif ( is_singular() ) {
1322              $queried_object = get_queried_object();
1323              if ( is_post_type_hierarchical( $queried_object->post_type ) ) {
1324                  $current_page = $queried_object->ID;
1325              }
1326          }
1327  
1328          $output .= walk_page_tree( $pages, $r['depth'], $current_page, $r );
1329  
1330          if ( $r['title_li'] ) {
1331              $output .= '</ul></li>';
1332          }
1333      }
1334  
1335      /**
1336       * Filters the HTML output of the pages to list.
1337       *
1338       * @since 1.5.1
1339       * @since 4.4.0 `$pages` added as arguments.
1340       *
1341       * @see wp_list_pages()
1342       *
1343       * @param string $output HTML output of the pages list.
1344       * @param array  $r      An array of page-listing arguments.
1345       * @param array  $pages  List of WP_Post objects returned by `get_pages()`
1346       */
1347      $html = apply_filters( 'wp_list_pages', $output, $r, $pages );
1348  
1349      if ( $r['echo'] ) {
1350          echo $html;
1351      } else {
1352          return $html;
1353      }
1354  }
1355  
1356  /**
1357   * Displays or retrieves a list of pages with an optional home link.
1358   *
1359   * The arguments are listed below and part of the arguments are for wp_list_pages() function.
1360   * Check that function for more info on those arguments.
1361   *
1362   * @since 2.7.0
1363   * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
1364   * @since 4.7.0 Added the `item_spacing` argument.
1365   *
1366   * @param array|string $args {
1367   *     Optional. Array or string of arguments to generate a page menu. See `wp_list_pages()` for additional arguments.
1368   *
1369   *     @type string          $sort_column  How to sort the list of pages. Accepts post column names.
1370   *                                         Default 'menu_order, post_title'.
1371   *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
1372   *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
1373   *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
1374   *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
1375   *                                         Default true.
1376   *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
1377   *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
1378   *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
1379   *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
1380   *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
1381   *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
1382   *     @type string          $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve'
1383   *                                         or 'discard'. Default 'discard'.
1384   *     @type Walker          $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
1385   * }
1386   * @return string|void HTML menu
1387   */
1388  function wp_page_menu( $args = array() ) {
1389      $defaults = array(
1390          'sort_column'  => 'menu_order, post_title',
1391          'menu_id'      => '',
1392          'menu_class'   => 'menu',
1393          'container'    => 'div',
1394          'echo'         => true,
1395          'link_before'  => '',
1396          'link_after'   => '',
1397          'before'       => '<ul>',
1398          'after'        => '</ul>',
1399          'item_spacing' => 'discard',
1400          'walker'       => '',
1401      );
1402      $args     = wp_parse_args( $args, $defaults );
1403  
1404      if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ) ) ) {
1405          // invalid value, fall back to default.
1406          $args['item_spacing'] = $defaults['item_spacing'];
1407      }
1408  
1409      if ( 'preserve' === $args['item_spacing'] ) {
1410          $t = "\t";
1411          $n = "\n";
1412      } else {
1413          $t = '';
1414          $n = '';
1415      }
1416  
1417      /**
1418       * Filters the arguments used to generate a page-based menu.
1419       *
1420       * @since 2.7.0
1421       *
1422       * @see wp_page_menu()
1423       *
1424       * @param array $args An array of page menu arguments.
1425       */
1426      $args = apply_filters( 'wp_page_menu_args', $args );
1427  
1428      $menu = '';
1429  
1430      $list_args = $args;
1431  
1432      // Show Home in the menu
1433      if ( ! empty( $args['show_home'] ) ) {
1434          if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) {
1435              $text = __( 'Home' );
1436          } else {
1437              $text = $args['show_home'];
1438          }
1439          $class = '';
1440          if ( is_front_page() && ! is_paged() ) {
1441              $class = 'class="current_page_item"';
1442          }
1443          $menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
1444          // If the front page is a page, add it to the exclude list
1445          if ( get_option( 'show_on_front' ) == 'page' ) {
1446              if ( ! empty( $list_args['exclude'] ) ) {
1447                  $list_args['exclude'] .= ',';
1448              } else {
1449                  $list_args['exclude'] = '';
1450              }
1451              $list_args['exclude'] .= get_option( 'page_on_front' );
1452          }
1453      }
1454  
1455      $list_args['echo']     = false;
1456      $list_args['title_li'] = '';
1457      $menu                 .= wp_list_pages( $list_args );
1458  
1459      $container = sanitize_text_field( $args['container'] );
1460  
1461      // Fallback in case `wp_nav_menu()` was called without a container.
1462      if ( empty( $container ) ) {
1463          $container = 'div';
1464      }
1465  
1466      if ( $menu ) {
1467  
1468          // wp_nav_menu doesn't set before and after
1469          if ( isset( $args['fallback_cb'] ) &&
1470              'wp_page_menu' === $args['fallback_cb'] &&
1471              'ul' !== $container ) {
1472              $args['before'] = "<ul>{$n}";
1473              $args['after']  = '</ul>';
1474          }
1475  
1476          $menu = $args['before'] . $menu . $args['after'];
1477      }
1478  
1479      $attrs = '';
1480      if ( ! empty( $args['menu_id'] ) ) {
1481          $attrs .= ' id="' . esc_attr( $args['menu_id'] ) . '"';
1482      }
1483  
1484      if ( ! empty( $args['menu_class'] ) ) {
1485          $attrs .= ' class="' . esc_attr( $args['menu_class'] ) . '"';
1486      }
1487  
1488      $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
1489  
1490      /**
1491       * Filters the HTML output of a page-based menu.
1492       *
1493       * @since 2.7.0
1494       *
1495       * @see wp_page_menu()
1496       *
1497       * @param string $menu The HTML output.
1498       * @param array  $args An array of arguments.
1499       */
1500      $menu = apply_filters( 'wp_page_menu', $menu, $args );
1501      if ( $args['echo'] ) {
1502          echo $menu;
1503      } else {
1504          return $menu;
1505      }
1506  }
1507  
1508  //
1509  // Page helpers
1510  //
1511  
1512  /**
1513   * Retrieve HTML list content for page list.
1514   *
1515   * @uses Walker_Page to create HTML list content.
1516   * @since 2.1.0
1517   *
1518   * @param array $pages
1519   * @param int   $depth
1520   * @param int   $current_page
1521   * @param array $r
1522   * @return string
1523   */
1524  function walk_page_tree( $pages, $depth, $current_page, $r ) {
1525      if ( empty( $r['walker'] ) ) {
1526          $walker = new Walker_Page;
1527      } else {
1528          $walker = $r['walker'];
1529      }
1530  
1531      foreach ( (array) $pages as $page ) {
1532          if ( $page->post_parent ) {
1533              $r['pages_with_children'][ $page->post_parent ] = true;
1534          }
1535      }
1536  
1537      $args = array( $pages, $depth, $r, $current_page );
1538      return call_user_func_array( array( $walker, 'walk' ), $args );
1539  }
1540  
1541  /**
1542   * Retrieve HTML dropdown (select) content for page list.
1543   *
1544   * @uses Walker_PageDropdown to create HTML dropdown content.
1545   * @since 2.1.0
1546   * @see Walker_PageDropdown::walk() for parameters and return description.
1547   *
1548   * @return string
1549   */
1550  function walk_page_dropdown_tree( ...$args ) {
1551      if ( empty( $args[2]['walker'] ) ) { // the user's options are the third parameter
1552          $walker = new Walker_PageDropdown;
1553      } else {
1554          $walker = $args[2]['walker'];
1555      }
1556  
1557      return $walker->walk( ...$args );
1558  }
1559  
1560  //
1561  // Attachments
1562  //
1563  
1564  /**
1565   * Display an attachment page link using an image or icon.
1566   *
1567   * @since 2.0.0
1568   *
1569   * @param int|WP_Post $id Optional. Post ID or post object.
1570   * @param bool        $fullsize     Optional, default is false. Whether to use full size.
1571   * @param bool        $deprecated   Deprecated. Not used.
1572   * @param bool        $permalink    Optional, default is false. Whether to include permalink.
1573   */
1574  function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
1575      if ( ! empty( $deprecated ) ) {
1576          _deprecated_argument( __FUNCTION__, '2.5.0' );
1577      }
1578  
1579      if ( $fullsize ) {
1580          echo wp_get_attachment_link( $id, 'full', $permalink );
1581      } else {
1582          echo wp_get_attachment_link( $id, 'thumbnail', $permalink );
1583      }
1584  }
1585  
1586  /**
1587   * Retrieve an attachment page link using an image or icon, if possible.
1588   *
1589   * @since 2.5.0
1590   * @since 4.4.0 The `$id` parameter can now accept either a post ID or `WP_Post` object.
1591   *
1592   * @param int|WP_Post  $id        Optional. Post ID or post object.
1593   * @param string|array $size      Optional. Image size. Accepts any valid image size, or an array
1594   *                                of width and height values in pixels (in that order).
1595   *                                Default 'thumbnail'.
1596   * @param bool         $permalink Optional, Whether to add permalink to image. Default false.
1597   * @param bool         $icon      Optional. Whether the attachment is an icon. Default false.
1598   * @param string|false $text      Optional. Link text to use. Activated by passing a string, false otherwise.
1599   *                                Default false.
1600   * @param array|string $attr      Optional. Array or string of attributes. Default empty.
1601   * @return string HTML content.
1602   */
1603  function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
1604      $_post = get_post( $id );
1605  
1606      if ( empty( $_post ) || ( 'attachment' !== $_post->post_type ) || ! wp_get_attachment_url( $_post->ID ) ) {
1607          return __( 'Missing Attachment' );
1608      }
1609  
1610      $url = wp_get_attachment_url( $_post->ID );
1611  
1612      if ( $permalink ) {
1613          $url = get_attachment_link( $_post->ID );
1614      }
1615  
1616      if ( $text ) {
1617          $link_text = $text;
1618      } elseif ( $size && 'none' != $size ) {
1619          $link_text = wp_get_attachment_image( $_post->ID, $size, $icon, $attr );
1620      } else {
1621          $link_text = '';
1622      }
1623  
1624      if ( '' === trim( $link_text ) ) {
1625          $link_text = $_post->post_title;
1626      }
1627  
1628      if ( '' === trim( $link_text ) ) {
1629          $link_text = esc_html( pathinfo( get_attached_file( $_post->ID ), PATHINFO_FILENAME ) );
1630      }
1631      /**
1632       * Filters a retrieved attachment page link.
1633       *
1634       * @since 2.7.0
1635       * @since 5.1.0 Added the $attr parameter.
1636       *
1637       * @param string       $link_html The page link HTML output.
1638       * @param int          $id        Post ID.
1639       * @param string|array $size      Size of the image. Image size or array of width and height values (in that order).
1640       *                                Default 'thumbnail'.
1641       * @param bool         $permalink Whether to add permalink to image. Default false.
1642       * @param bool         $icon      Whether to include an icon. Default false.
1643       * @param string|bool  $text      If string, will be link text. Default false.
1644       * @param array|string $attr      Array or string of attributes. Default empty.
1645       */
1646      return apply_filters( 'wp_get_attachment_link', "<a href='" . esc_url( $url ) . "'>$link_text</a>", $id, $size, $permalink, $icon, $text, $attr );
1647  }
1648  
1649  /**
1650   * Wrap attachment in paragraph tag before content.
1651   *
1652   * @since 2.0.0
1653   *
1654   * @param string $content
1655   * @return string
1656   */
1657  function prepend_attachment( $content ) {
1658      $post = get_post();
1659  
1660      if ( empty( $post->post_type ) || $post->post_type != 'attachment' ) {
1661          return $content;
1662      }
1663  
1664      if ( wp_attachment_is( 'video', $post ) ) {
1665          $meta = wp_get_attachment_metadata( get_the_ID() );
1666          $atts = array( 'src' => wp_get_attachment_url() );
1667          if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
1668              $atts['width']  = (int) $meta['width'];
1669              $atts['height'] = (int) $meta['height'];
1670          }
1671          if ( has_post_thumbnail() ) {
1672              $atts['poster'] = wp_get_attachment_url( get_post_thumbnail_id() );
1673          }
1674          $p = wp_video_shortcode( $atts );
1675      } elseif ( wp_attachment_is( 'audio', $post ) ) {
1676          $p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) );
1677      } else {
1678          $p = '<p class="attachment">';
1679          // show the medium sized image representation of the attachment if available, and link to the raw file
1680          $p .= wp_get_attachment_link( 0, 'medium', false );
1681          $p .= '</p>';
1682      }
1683  
1684      /**
1685       * Filters the attachment markup to be prepended to the post content.
1686       *
1687       * @since 2.0.0
1688       *
1689       * @see prepend_attachment()
1690       *
1691       * @param string $p The attachment HTML output.
1692       */
1693      $p = apply_filters( 'prepend_attachment', $p );
1694  
1695      return "$p\n$content";
1696  }
1697  
1698  //
1699  // Misc
1700  //
1701  
1702  /**
1703   * Retrieve protected post password form content.
1704   *
1705   * @since 1.0.0
1706   *
1707   * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
1708   * @return string HTML content for password form for password protected post.
1709   */
1710  function get_the_password_form( $post = 0 ) {
1711      $post   = get_post( $post );
1712      $label  = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
1713      $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
1714      <p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
1715      <p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
1716      ';
1717  
1718      /**
1719       * Filters the HTML output for the protected post password form.
1720       *
1721       * If modifying the password field, please note that the core database schema
1722       * limits the password field to 20 characters regardless of the value of the
1723       * size attribute in the form input.
1724       *
1725       * @since 2.7.0
1726       *
1727       * @param string $output The password form HTML output.
1728       */
1729      return apply_filters( 'the_password_form', $output );
1730  }
1731  
1732  /**
1733   * Determines whether currently in a page template.
1734   *
1735   * This template tag allows you to determine if you are in a page template.
1736   * You can optionally provide a template name or array of template names
1737   * and then the check will be specific to that template.
1738   *
1739   * For more information on this and similar theme functions, check out
1740   * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
1741   * Conditional Tags} article in the Theme Developer Handbook.
1742   *
1743   * @since 2.5.0
1744   * @since 4.2.0 The `$template` parameter was changed to also accept an array of page templates.
1745   * @since 4.7.0 Now works with any post type, not just pages.
1746   *
1747   * @param string|array $template The specific template name or array of templates to match.
1748   * @return bool True on success, false on failure.
1749   */
1750  function is_page_template( $template = '' ) {
1751      if ( ! is_singular() ) {
1752          return false;
1753      }
1754  
1755      $page_template = get_page_template_slug( get_queried_object_id() );
1756  
1757      if ( empty( $template ) ) {
1758          return (bool) $page_template;
1759      }
1760  
1761      if ( $template == $page_template ) {
1762          return true;
1763      }
1764  
1765      if ( is_array( $template ) ) {
1766          if ( ( in_array( 'default', $template, true ) && ! $page_template )
1767              || in_array( $page_template, $template, true )
1768          ) {
1769              return true;
1770          }
1771      }
1772  
1773      return ( 'default' === $template && ! $page_template );
1774  }
1775  
1776  /**
1777   * Get the specific template name for a given post.
1778   *
1779   * @since 3.4.0
1780   * @since 4.7.0 Now works with any post type, not just pages.
1781   *
1782   * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
1783   * @return string|false Page template filename. Returns an empty string when the default page template
1784   *  is in use. Returns false if the post does not exist.
1785   */
1786  function get_page_template_slug( $post = null ) {
1787      $post = get_post( $post );
1788  
1789      if ( ! $post ) {
1790          return false;
1791      }
1792  
1793      $template = get_post_meta( $post->ID, '_wp_page_template', true );
1794  
1795      if ( ! $template || 'default' == $template ) {
1796          return '';
1797      }
1798  
1799      return $template;
1800  }
1801  
1802  /**
1803   * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
1804   *
1805   * @since 2.6.0
1806   *
1807   * @param int|object $revision Revision ID or revision object.
1808   * @param bool       $link     Optional, default is true. Link to revisions's page?
1809   * @return string|false i18n formatted datetimestamp or localized 'Current Revision'.
1810   */
1811  function wp_post_revision_title( $revision, $link = true ) {
1812      $revision = get_post( $revision );
1813      if ( ! $revision ) {
1814          return $revision;
1815      }
1816  
1817      if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) {
1818          return false;
1819      }
1820  
1821      /* translators: revision date format, see https://secure.php.net/date */
1822      $datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
1823      /* translators: %s: revision date */
1824      $autosavef = __( '%s [Autosave]' );
1825      /* translators: %s: revision date */
1826      $currentf = __( '%s [Current Revision]' );
1827  
1828      $date      = date_i18n( $datef, strtotime( $revision->post_modified ) );
1829      $edit_link = get_edit_post_link( $revision->ID );
1830      if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
1831          $date = "<a href='$edit_link'>$date</a>";
1832      }
1833  
1834      if ( ! wp_is_post_revision( $revision ) ) {
1835          $date = sprintf( $currentf, $date );
1836      } elseif ( wp_is_post_autosave( $revision ) ) {
1837          $date = sprintf( $autosavef, $date );
1838      }
1839  
1840      return $date;
1841  }
1842  
1843  /**
1844   * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
1845   *
1846   * @since 3.6.0
1847   *
1848   * @param int|object $revision Revision ID or revision object.
1849   * @param bool       $link     Optional, default is true. Link to revisions's page?
1850   * @return string|false gravatar, user, i18n formatted datetimestamp or localized 'Current Revision'.
1851   */
1852  function wp_post_revision_title_expanded( $revision, $link = true ) {
1853      $revision = get_post( $revision );
1854      if ( ! $revision ) {
1855          return $revision;
1856      }
1857  
1858      if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) {
1859          return false;
1860      }
1861  
1862      $author = get_the_author_meta( 'display_name', $revision->post_author );
1863      /* translators: revision date format, see https://secure.php.net/date */
1864      $datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
1865  
1866      $gravatar = get_avatar( $revision->post_author, 24 );
1867  
1868      $date      = date_i18n( $datef, strtotime( $revision->post_modified ) );
1869      $edit_link = get_edit_post_link( $revision->ID );
1870      if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
1871          $date = "<a href='$edit_link'>$date</a>";
1872      }
1873  
1874      $revision_date_author = sprintf(
1875          /* translators: post revision title: 1: author avatar, 2: author name, 3: time ago, 4: date */
1876          __( '%1$s %2$s, %3$s ago (%4$s)' ),
1877          $gravatar,
1878          $author,
1879          human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ),
1880          $date
1881      );
1882  
1883      /* translators: %s: revision date with author avatar */
1884      $autosavef = __( '%s [Autosave]' );
1885      /* translators: %s: revision date with author avatar */
1886      $currentf = __( '%s [Current Revision]' );
1887  
1888      if ( ! wp_is_post_revision( $revision ) ) {
1889          $revision_date_author = sprintf( $currentf, $revision_date_author );
1890      } elseif ( wp_is_post_autosave( $revision ) ) {
1891          $revision_date_author = sprintf( $autosavef, $revision_date_author );
1892      }
1893  
1894      /**
1895       * Filters the formatted author and date for a revision.
1896       *
1897       * @since 4.4.0
1898       *
1899       * @param string  $revision_date_author The formatted string.
1900       * @param WP_Post $revision             The revision object.
1901       * @param bool    $link                 Whether to link to the revisions page, as passed into
1902       *                                      wp_post_revision_title_expanded().
1903       */
1904      return apply_filters( 'wp_post_revision_title_expanded', $revision_date_author, $revision, $link );
1905  }
1906  
1907  /**
1908   * Display a list of a post's revisions.
1909   *
1910   * Can output either a UL with edit links or a TABLE with diff interface, and
1911   * restore action links.
1912   *
1913   * @since 2.6.0
1914   *
1915   * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
1916   * @param string      $type    'all' (default), 'revision' or 'autosave'
1917   */
1918  function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
1919      $post = get_post( $post_id );
1920      if ( ! $post ) {
1921          return;
1922      }
1923  
1924      // $args array with (parent, format, right, left, type) deprecated since 3.6
1925      if ( is_array( $type ) ) {
1926          $type = ! empty( $type['type'] ) ? $type['type'] : $type;
1927          _deprecated_argument( __FUNCTION__, '3.6.0' );
1928      }
1929  
1930      $revisions = wp_get_post_revisions( $post->ID );
1931      if ( ! $revisions ) {
1932          return;
1933      }
1934  
1935      $rows = '';
1936      foreach ( $revisions as $revision ) {
1937          if ( ! current_user_can( 'read_post', $revision->ID ) ) {
1938              continue;
1939          }
1940  
1941          $is_autosave = wp_is_post_autosave( $revision );
1942          if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) ) {
1943              continue;
1944          }
1945  
1946          $rows .= "\t<li>" . wp_post_revision_title_expanded( $revision ) . "</li>\n";
1947      }
1948  
1949      echo "<div class='hide-if-js'><p>" . __( 'JavaScript must be enabled to use this feature.' ) . "</p></div>\n";
1950  
1951      echo "<ul class='post-revisions hide-if-no-js'>\n";
1952      echo $rows;
1953      echo '</ul>';
1954  }


Generated: Tue Jul 16 01:00:03 2019 Cross-referenced by PHPXref 0.7.1