Skip to content

Commit

Permalink
add options for labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazz-Man committed Mar 11, 2020
1 parent 16326c0 commit 618f3b7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ function cpt_get_human_friendly(string $name = '')

/**
* @param string $post_type
* @param array $options
* @param string $textdomain
*
* @return array
*/
function cpt_get_post_type_labels(string $post_type, $textdomain = 'cpt')
function cpt_get_post_type_labels(string $post_type, $options = [], $textdomain = 'cpt')
{
$human_friendly = cpt_get_human_friendly($post_type);
$singular = Pluralizer::singular($human_friendly);
Expand All @@ -42,16 +43,19 @@ function cpt_get_post_type_labels(string $post_type, $textdomain = 'cpt')
'parent_item_colon' => sprintf(__('Parent %s:', $textdomain), $singular),
];

$labels = wp_parse_args($options, $labels);

return $labels;
}

/**
* @param string $taxonomy_name
* @param array $options
* @param string $textdomain
*
* @return array
*/
function cpt_get_taxonomy_labels(string $taxonomy_name, $textdomain = 'cpt')
function cpt_get_taxonomy_labels(string $taxonomy_name, $options = [], $textdomain = 'cpt')
{
$human_friendly = cpt_get_human_friendly($taxonomy_name);
$singular = Pluralizer::singular($human_friendly);
Expand All @@ -77,6 +81,8 @@ function cpt_get_taxonomy_labels(string $taxonomy_name, $textdomain = 'cpt')
'not_found' => sprintf(__('No %s found', $textdomain), $plural),
];

$labels = wp_parse_args($options, $labels);

return $labels;
}

Expand All @@ -99,12 +105,12 @@ function cpt_get_post_type_archive_post_id(string $post_type)
AND post_name = %s
LIMIT 1
SQL
,'hdptap_cpt_archive',$post_type);
, 'hdptap_cpt_archive', $post_type);


$post_type_archive_id = $wpdb->get_var($query);

if ( $post_type_archive_id !== null) {
if ($post_type_archive_id !== null) {
return (int)$post_type_archive_id;
}

Expand Down

0 comments on commit 618f3b7

Please sign in to comment.