Parsed: 117437

  public function get_date_permastruct() {
    if ( isset( $this->date_structure ) ) {
      return $this->date_structure;
    }

    if ( empty( $this->permalink_structure ) ) {
      $this->date_structure = '';
      return false;
    }

    // The date permalink must have year, month, and day separated by slashes.
    $endians = array( '%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%' );

    $this->date_structure = '';
    $date_endian          = '';

    foreach ( $endians as $endian ) {
      if ( str_contains( $this->permalink_structure, $endian ) ) {
        $date_endian = $endian;
        break;
      }
    }

    if ( empty( $date_endian ) ) {
      $date_endian = '%year%/%monthnum%/%day%';
    }

    /*
		 * Do not allow the date tags and %post_id% to overlap in the permalink
		 * structure. If they do, move the date tags to $front/date/.
		 */
    $front = $this->front;
    preg_match_all( '/%.+?%/', $this->permalink_structure, $tokens );
    $tok_index = 1;
    foreach ( (array) $tokens[0] as $token ) {
      if ( '%post_id%' === $token && ( $tok_index <= 3 ) ) {
        $front = $front . 'date/';
        break;
      }
      ++$tok_index;
    }

    $this->date_structure = $front . $date_endian;

    return $this->date_structure;
  }