コード例 #1
0
ファイル: backend.php プロジェクト: isatrio/Unyson
 /**
  * Render option enclosed in backend design
  *
  * @param string $id
  * @param array $option
  * @param array $data
  * @param string $design default or taxonomy
  *
  * @return string
  */
 public function render_option($id, $option, $data = array(), $design = null)
 {
     if (empty($design)) {
         $design = $this->default_render_design;
     }
     if (!doing_action('admin_enqueue_scripts') && !did_action('admin_enqueue_scripts')) {
         /**
          * Do not wp_enqueue/register_...() because at this point not all handles has been registered
          * and maybe they are used in dependencies in handles that are going to be enqueued.
          * So as a result some handles will not be equeued because of not registered dependecies.
          */
     } else {
         $this->register_static();
     }
     if (!in_array($design, $this->available_render_designs)) {
         trigger_error('Invalid render design specified: ' . $design, E_USER_WARNING);
         $design = 'post';
     }
     if (!isset($data['id_prefix'])) {
         $data['id_prefix'] = FW_Option_Type::get_default_id_prefix();
     }
     if (isset($option['option_handler']) && $option['option_handler'] instanceof FW_Option_Handler) {
         /*
          * if the option has a custom option_handler
          * then the handler provides the option's value
          */
         $data['value'] = $option['option_handler']->get_option_value($id, $option, $data);
     }
     return fw_render_view(fw_get_framework_directory('/views/backend-option-design-' . $design . '.php'), array('id' => $id, 'option' => $option, 'data' => $data));
 }
コード例 #2
0
ファイル: backend.php プロジェクト: joelgarciajr84/Unyson
 /**
  * Render option enclosed in backend design
  *
  * @param string $id
  * @param array $option
  * @param array $data
  * @param string $design default or taxonomy
  *
  * @return string
  */
 public function render_option($id, $option, $data = array(), $design = null)
 {
     if (empty($design)) {
         $design = $this->default_render_design;
     }
     /**
      * register scripts and styles
      * in case if this method is called before enqueue_scripts action
      * and option types has some of these in their dependencies
      */
     $this->register_static();
     if (!in_array($design, $this->available_render_designs)) {
         trigger_error('Invalid render design specified: ' . $design, E_USER_WARNING);
         $design = 'post';
     }
     if (!isset($data['id_prefix'])) {
         $data['id_prefix'] = FW_Option_Type::get_default_id_prefix();
     }
     if (isset($option['option_handler']) && $option['option_handler'] instanceof FW_Option_Handler) {
         /*
          * if the option has a custom option_handler
          * then the handler provides the option's value
          */
         $data['value'] = $option['option_handler']->get_option_value($id, $option, $data);
     }
     return fw_render_view(fw_get_framework_directory('/views/backend-option-design-' . $design . '.php'), array('id' => $id, 'option' => $option, 'data' => $data));
 }
コード例 #3
0
ファイル: backend.php プロジェクト: halkibsi/Unyson
 /**
  * Render option enclosed in backend design
  */
 public function render_option($id, $option, $data = array(), $design = 'default')
 {
     /**
      * register scripts and styles
      * in case if this method is called before enqueue_scripts action
      * and option types has some of these in their dependencies
      */
     $this->register_static();
     if (!in_array($design, $this->available_render_designs)) {
         trigger_error('Invalid render design specified: ' . $design, E_USER_WARNING);
         $design = 'post';
     }
     if (!isset($data['id_prefix'])) {
         $data['id_prefix'] = FW_Option_Type::get_default_id_prefix();
     }
     return fw_render_view(FW_DIR . '/views/backend-option-design-' . $design . '.php', array('id' => $id, 'option' => $option, 'data' => $data));
 }
コード例 #4
0
 /**
  * Fixes and prepare defaults
  *
  * @param string $id
  * @param array  $option
  * @param array  $data
  * @return array
  */
 private function prepare($id, &$option, &$data)
 {
     $data = array_merge(array('id_prefix' => FW_Option_Type::get_default_id_prefix(), 'name_prefix' => FW_Option_Type::get_default_name_prefix()), $data);
     $option = array_merge($this->get_defaults(), $option, array('type' => $this->get_type()));
     if (!isset($option['attr'])) {
         $option['attr'] = array();
     }
     if (!isset($option['title'])) {
         $option['title'] = fw_id_to_title($id);
     }
     $option['attr']['class'] = 'fw-container fw-container-type-' . $option['type'] . (isset($option['attr']['class']) ? ' ' . $option['attr']['class'] : '');
 }