public static get_date_front ( string $post_type ) : string | ||
$post_type | string | post type name. |
return | 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;
}
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"); }