Papi_Page_Type::get_labels PHP Method

get_labels() public method

Get labels that should be changed when using fill_labels option.
public get_labels ( ) : array
return array
    public function get_labels()
    {
        if (!$this->fill_labels) {
            return $this->labels;
        }
        return array_merge($this->labels, ['add_new_item' => sprintf('%s %s', __('Add New', 'papi'), $this->name), 'edit_item' => sprintf('%s %s', __('Edit', 'papi'), $this->name), 'view_item' => sprintf('%s %s', __('View', 'papi'), $this->name)]);
    }

Usage Example

コード例 #1
0
 /**
  * Override labels with labels from the page type.
  *
  * @param Papi_Page_Type $page_type
  */
 private function override_labels(Papi_Page_Type $page_type)
 {
     global $wp_post_types;
     $post_type = papi_get_post_type();
     if (empty($post_type) || !isset($wp_post_types[$post_type])) {
         return;
     }
     foreach ($page_type->get_labels() as $key => $value) {
         if (!isset($wp_post_types[$post_type]->labels->{$key}) || empty($value)) {
             continue;
         }
         $wp_post_types[$post_type]->labels->{$key} = $value;
     }
 }