/** * Create a new tab array or rendering a template tab file. * * @param string|array $file_or_options * @param array $properties * * @return array */ function papi_tab($file_or_options, $properties = []) { list($options, $properties) = papi_get_options_and_properties($file_or_options, $properties, false); // The tab key is important, it's says that we should render a tab meta box. // This may change in later version of Papi. return (object) ['options' => $options, 'properties' => $properties, 'tab' => true]; }
/** * Add new meta box with properties. * * @param mixed $file_or_options * @param array $properties */ protected function box($file_or_options = [], $properties = []) { if (!is_string($file_or_options) && !is_array($file_or_options) && !is_object($file_or_options)) { return; } list($options, $properties) = papi_get_options_and_properties($file_or_options, $properties, true); $post_type = $this->get_post_type(); // Check so we have a post the to add the box to. // @codeCoverageIgnoreStart if (!$this->load_boxes && (empty($post_type) || !$this->has_post_type($post_type))) { return; } // @codeCoverageIgnoreEnd // Add post type to the options array. $options['_post_type'] = $post_type; if (isset($options['sort_order'])) { $sort_order = intval($options['sort_order']); } else { $sort_order = papi_filter_settings_sort_order(); } if (is_callable($properties)) { $properties = call_user_func($properties); } // Check and convert all non properties objects to properties objects. $properties = $this->convert_properties($properties); $options['title'] = papi_esc_html(isset($options['title']) ? $options['title'] : ''); array_push($this->boxes, [$options, $properties, 'sort_order' => $sort_order, 'title' => $options['title']]); }
/** * Add new meta box with properties. * * @param mixed $file_or_options * @param array $properties */ protected function box($file_or_options = [], $properties = []) { if (!is_string($file_or_options) && !is_array($file_or_options) && !is_object($file_or_options)) { return; } list($options, $properties) = papi_get_options_and_properties($file_or_options, $properties, true); // Check so we have a post the to add the box to. // @codeCoverageIgnoreStart if (!$this->load_boxes) { return; } // @codeCoverageIgnoreEnd if (is_callable($properties)) { $properties = call_user_func($properties); } // Check and convert all non properties objects to properties objects. $properties = $this->convert_properties($properties); // Create a core box instance and add it to the boxes array. array_push($this->boxes, new Papi_Core_Box($options, $properties)); }
/** * Create a new tab array or rendering a template tab file. * * @param string|array $file_or_options * @param array $properties * * @return array */ function papi_tab($file_or_options, $properties = []) { list($options, $properties) = papi_get_options_and_properties($file_or_options, $properties, false); return new Papi_Core_Tab($options, $properties); }