Exemplo n.º 1
0
 /**
  * Set slugs to each section, according the number of sections.
  */
 private function set_section_slugs()
 {
     // For more than 1 sections, set section specific slugs
     if (count($this->sections) > 1) {
         foreach ($this->sections as $section) {
             $section->set_slug(\Amarkal\Common\Tools::strtoslug($section->title));
         }
     } else {
         $this->sections[0]->set_slug(\Amarkal\Common\Tools::strtoslug($this->title));
     }
 }
Exemplo n.º 2
0
 /**
  * Get the array of fields for this section.
  * If this section has subsections, the returning array will consist of
  * all fields from all subsections.
  * 
  * @return array
  */
 public function get_fields()
 {
     if (!isset($this->fields)) {
         if (!$this->has_sub_sections()) {
             $this->fields = $this->model['fields'];
         } else {
             $this->fields = array();
             foreach ($this->model['subsections'] as $subsection) {
                 foreach ($subsection['fields'] as $field) {
                     $field->subsection = \Amarkal\Common\Tools::strtoslug($subsection['title']);
                 }
                 $this->fields = array_merge($this->fields, $subsection['fields']);
             }
         }
     }
     return $this->fields;
 }
Exemplo n.º 3
0
 public function __construct(array $config)
 {
     $defaults = array('name' => 'My Plugin', 'description' => 'My Plugin\'s description', 'version' => '1.0', 'slug' => \Amarkal\Common\Tools::strtoslug($config['name']), 'callback' => function ($args, $instance) {
     }, 'fields' => array());
     $this->config = array_merge($defaults, $config);
 }
Exemplo n.º 4
0
 /**
  * 
  * @global type $submenu
  */
 function add_submenu_pages()
 {
     $slug = $this->config['slug'];
     foreach ($this->config['submenu-pages'] as $page) {
         \add_submenu_page($slug, $page['title'], $page['title'], $page['capability'], $slug . '&section=' . \Amarkal\Common\Tools::strtoslug($page['title']), $page['content']);
         global $submenu;
         unset($submenu[$slug][0]);
     }
 }