CPTP_Util::get_date_front PHP Méthode

get_date_front() public static méthode

Get permalink structure front for date archive.
Since: 1.0.0
public static get_date_front ( string $post_type ) : string
$post_type string post type name.
Résultat string
    public static function get_date_front($post_type)
    {
        $structure = CPTP_Util::get_permalink_structure($post_type);
        $front = '';
        preg_match_all('/%.+?%/', $structure, $tokens);
        $tok_index = 1;
        foreach ((array) $tokens[0] as $token) {
            if ('%post_id%' == $token && $tok_index <= 3) {
                $front = '/date';
                break;
            }
            $tok_index++;
        }
        return $front;
    }

Usage Example

 public function test_get_date_front()
 {
     $post_type = rand_str(12);
     register_post_type($post_type, array("public" => true));
     update_option($post_type . "_structure", "/%year%/%monthnum%/%day%/%post_id%/");
     $this->assertEquals(CPTP_Util::get_date_front($post_type), "");
     update_option($post_type . "_structure", "/%post_id%/");
     $this->assertEquals(CPTP_Util::get_date_front($post_type), "/date");
 }
All Usage Examples Of CPTP_Util::get_date_front