Esempio n. 1
0
 /**
  * Registers grouped settings
  * 
  * @return void
  */
 public function __handleSettingsRegistration()
 {
     // Get sections & callable
     $sections = $this->sections->getAll();
     $function = $this->getFunction();
     $names = [];
     // Fetch control elements name attribute from function
     if ($function) {
         $names += Utils::getControlNamesFromCallable($function, array($this->data, $this));
         if ($names) {
             $this->setOptions($names);
         }
     }
     // Fetch control elements name attribute from sections
     if ($sections) {
         $names += Utils::getControlNamesFromCallable([$this, '__collectSectionsFieldNames'], array($this->data, $this));
         if ($names) {
             $this->setOptions($names);
         }
     }
     $options = $this->options->getAll();
     if ($options) {
         foreach ($options as $option) {
             register_setting($this->getId(), $option);
         }
     }
     // Reset sections so that we do not have duplicates
     $this->sections->clear()->pushList($sections);
 }
Esempio n. 2
0
 /**
  * Registers Shortcode and its function
  * 
  * @param  array  $attrs   Attributes from user input
  * @param  string $content Content on shortcodes with opening and closing tags
  * @param  string $tag     Shortcode tag
  * @return void
  */
 public function __registerShortcode($attrs, $content = null, $tag)
 {
     // Clear attributes
     $this->attributes->clear();
     // Set default attributes
     $this->attributes->setList($this->default_attributes->getAll());
     // Remove quotes from attributes
     if ($attrs) {
         if (is_array($attrs)) {
             foreach ($attrs as $key => $attr) {
                 $attrs[$key] = static::__cleanAttrValue($attr);
             }
         } elseif (is_string($attrs)) {
             $attrs = static::__cleanAttrValue($attrs);
         }
         $this->attributes->setList($attrs);
     }
     ob_start();
     // Execute shortcode function
     call_user_func_array($this->function, array($this->attributes, $content, $tag));
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
Esempio n. 3
0
 /**
  * Gets field names from callback function
  * 
  */
 private function __setMetaFields()
 {
     // Only execute if there are no manually defined meta fields
     if (!$this->meta_fields->getAll()) {
         // Set callable arguments
         $args = array($this->data, new \WP_Post(new \stdClass()), $this);
         // Collect current sections
         $sections = $this->sections->getAll();
         if ($callback = $this->getCallback()) {
             // Collect field names from callable
             $names = Utils::getControlNamesFromCallable($callback, $args);
             $this->meta_fields->pushList($names);
         }
         if ($this->getAllSections()) {
             $names = Utils::getControlNamesFromCallable([$this, '__collectSectionsFieldNames'], $args);
             $this->meta_fields->pushList($names);
         }
         // Reset sections so that we do not have duplicates
         $this->sections->clear()->pushList($sections);
     }
 }
Esempio n. 4
0
 /**
  * Replaces taxonomies
  * 
  * @param  array                          $taxonomies Indexed array with taxonomies
  * @return \Ponticlaro\Bebop\Cms\PostType             PostType instance
  */
 public function replaceTaxonomies(array $taxonomies = array())
 {
     $this->taxonomies->clear();
     $this->addTaxonomies($taxonomies);
     return $this;
 }
Esempio n. 5
0
 /**
  * Replaces all existing vars
  * 
  * @param  array  $vars List of vars to be set
  */
 public function replaceVars(array $vars = array())
 {
     $this->vars->clear()->set($vars);
     return $this;
 }
Esempio n. 6
0
 /**
  * Sets post types
  * 
  * @param  array                          $post_types Indexed array with post types
  * @return \Ponticlaro\Bebop\Cms\Taxonomy             Taxonomy instance
  */
 public function setPostTypes(array $post_types = array())
 {
     $this->post_types->clear();
     $this->addPostTypes($post_types);
     return $this;
 }