I would like to know how to access an array using a method. I would like to know that you guys think my code is right what I'm trying to do?
class RegisterPostType
{
public $name;
public $singleName;
public $addNew;
public $addNewItem;
public $editNewItem;
public $newItem;
public $viewItem;
public $searchItem;
public $notFound;
public $notFoundinTrash;
private function labels()
{
$label = array(
'name' => $this->name,
'singular_name' => $this->singleName,
'add_new' => $this->addNew,
'add_new_item' => $this->addNewItem,
'edit_item' => $this->editNewItem,
'new_item' => $this->newItem,
'view_item' => $this->viewItem,
'search_items' => $this->searchItem,
'not_found' => $this->notFound,
'not_found_in_trash' => $this->notFoundinTrash,
'parent_item_colon' => ''
);
}
public function registerPostType()
{
$args = array(
'labels' => $this->labels()->label,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail')
);
}
}
And I'm calling the array this way:
add_action('init', 'postTypes');
function postTypes()
{
$header = new RegisterPostType;
$header->name = 'Titulo';
$header->singleName = 'Titulo';
$header->addNew = 'Titulo';
$header->addNewItem = 'Titulo';
$header->editNewItem = 'Titulo';
$header->newItem = 'Titulo';
$header->viewItem = 'Titulo';
$header->searchItem = 'Titulo';
$header->notFound = 'Titulo';
$header->notFoundinTrash = 'Titulo';
register_post_type('header', $header->registerPostType()->args);
}
I took it and gave it a var_dump in ARRAY and it is returning me NULL. Could you help me?