当前位置: 首页>>代码示例>>PHP>>正文


PHP ot_filter_std_value函数代码示例

本文整理汇总了PHP中ot_filter_std_value函数的典型用法代码示例。如果您正苦于以下问题:PHP ot_filter_std_value函数的具体用法?PHP ot_filter_std_value怎么用?PHP ot_filter_std_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ot_filter_std_value函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build_meta_box

 /**
  * Meta box view
  *
  * @return    string
  *
  * @access    public
  * @since     1.0
  */
 function build_meta_box($post, $metabox)
 {
     echo '<div class="ot-metabox-wrapper">';
     /* Use nonce for verification */
     echo '<input type="hidden" name="' . $this->meta_box['id'] . '_nonce" value="' . wp_create_nonce($this->meta_box['id']) . '" />';
     /* meta box description */
     echo isset($this->meta_box['desc']) && !empty($this->meta_box['desc']) ? '<div class="description" style="padding-top:10px;">' . htmlspecialchars_decode($this->meta_box['desc']) . '</div>' : '';
     /* loop through meta box fields */
     foreach ($this->meta_box['fields'] as $field) {
         /* get current post meta data */
         $field_value = get_post_meta($post->ID, $field['id'], true);
         /* set standard value */
         if (isset($field['std'])) {
             $field_value = ot_filter_std_value($field_value, $field['std']);
         }
         /* build the arguments array */
         $_args = array('type' => $field['type'], 'field_id' => $field['id'], 'field_name' => $field['id'], 'field_value' => $field_value, 'field_desc' => isset($field['desc']) ? $field['desc'] : '', 'field_std' => isset($field['std']) ? $field['std'] : '', 'field_rows' => isset($field['rows']) && !empty($field['rows']) ? $field['rows'] : 10, 'field_post_type' => isset($field['post_type']) && !empty($field['post_type']) ? $field['post_type'] : 'post', 'field_taxonomy' => isset($field['taxonomy']) && !empty($field['taxonomy']) ? $field['taxonomy'] : 'category', 'field_min_max_step' => isset($field['min_max_step']) && !empty($field['min_max_step']) ? $field['min_max_step'] : '0,100,1', 'field_class' => isset($field['class']) ? $field['class'] : '', 'field_choices' => isset($field['choices']) ? $field['choices'] : array(), 'field_settings' => isset($field['settings']) && !empty($field['settings']) ? $field['settings'] : array(), 'post_id' => $post->ID, 'meta' => true);
         /* only allow simple textarea due to DOM issues with wp_editor() */
         if ($_args['type'] == 'textarea') {
             $_args['type'] = 'textarea-simple';
         }
         /* option label */
         echo '<div class="format-settings">';
         /* don't show title with textblocks */
         if ($_args['type'] != 'textblock' && !empty($field['label'])) {
             echo '<div class="format-setting-label">';
             echo '<label for="' . $_args['field_id'] . '" class="label">' . $field['label'] . '</label>';
             echo '</div>';
         }
         /* get the option HTML */
         echo ot_display_by_type($_args);
         echo '</div>';
     }
     echo '</div>';
 }
开发者ID:Jwiens92,项目名称:CumberLandSpice,代码行数:43,代码来源:ot-meta-box-api.php

示例2: build_user_meta_box

        /**
         * Meta box view
         *
         * @return    string
         *
         * @access    public
         * @since     1.0
         */
        function build_user_meta_box($user, $metabox, $id = '', $title = '')
        {
            echo '<div class="user_metabox_wrap" id="' . $id . '">
	  <h3>' . $title . '</h3>
	  <div class="ot-metabox-wrapper">';
            /* Use nonce for verification */
            echo '<input type="hidden" name="' . $this->meta_box['id'] . '_nonce" value="' . wp_create_nonce($this->meta_box['id']) . '" />';
            /* meta box description */
            echo isset($this->meta_box['desc']) && !empty($this->meta_box['desc']) ? '<div class="description" style="padding-top:10px;">' . htmlspecialchars_decode($this->meta_box['desc']) . '</div>' : '';
            /* loop through meta box fields */
            foreach ($this->meta_box['fields'] as $field) {
                /* get current post meta data */
                $field_value = get_user_meta($user->ID, $field['id'], true);
                /* set standard value */
                if (isset($field['std'])) {
                    $field_value = ot_filter_std_value($field_value, $field['std']);
                }
                /* build the arguments array */
                $_args = array('type' => $field['type'], 'field_id' => $field['id'], 'field_name' => $field['id'], 'field_value' => $field_value, 'field_desc' => isset($field['desc']) ? $field['desc'] : '', 'field_std' => isset($field['std']) ? $field['std'] : '', 'field_rows' => isset($field['rows']) && !empty($field['rows']) ? $field['rows'] : 10, 'field_post_type' => isset($field['post_type']) && !empty($field['post_type']) ? $field['post_type'] : 'post', 'field_taxonomy' => isset($field['taxonomy']) && !empty($field['taxonomy']) ? $field['taxonomy'] : 'category', 'field_min_max_step' => isset($field['min_max_step']) && !empty($field['min_max_step']) ? $field['min_max_step'] : '0,100,1', 'field_class' => isset($field['class']) ? $field['class'] : '', 'field_condition' => isset($field['condition']) ? $field['condition'] : '', 'field_operator' => isset($field['operator']) ? $field['operator'] : 'and', 'field_choices' => isset($field['choices']) ? $field['choices'] : array(), 'field_settings' => isset($field['settings']) && !empty($field['settings']) ? $field['settings'] : array(), 'post_id' => $user->ID, 'meta' => true);
                $conditions = '';
                /* setup the conditions */
                if (isset($field['condition']) && !empty($field['condition'])) {
                    $conditions = ' data-condition="' . $field['condition'] . '"';
                    $conditions .= isset($field['operator']) && in_array($field['operator'], array('and', 'AND', 'or', 'OR')) ? ' data-operator="' . $field['operator'] . '"' : '';
                }
                /* only allow simple textarea due to DOM issues with wp_editor() */
                if (apply_filters('ot_override_forced_textarea_simple', false, $field['id']) == false && $_args['type'] == 'textarea') {
                    $_args['type'] = 'textarea-simple';
                }
                // Build the setting CSS class
                if (!empty($_args['field_class'])) {
                    $classes = explode(' ', $_args['field_class']);
                    foreach ($classes as $key => $value) {
                        $classes[$key] = $value . '-wrap';
                    }
                    $class = 'format-settings ' . implode(' ', $classes);
                } else {
                    $class = 'format-settings';
                }
                /* option label */
                echo '<div id="setting_' . $field['id'] . '" class="' . $class . '"' . $conditions . '>';
                echo '<div class="format-setting-wrap">';
                /* don't show title with textblocks */
                if ($_args['type'] != 'textblock' && !empty($field['label'])) {
                    echo '<div class="format-setting-label">';
                    echo '<label for="' . $field['id'] . '" class="label">' . $field['label'] . '</label>';
                    echo '</div>';
                }
                /* get the option HTML */
                echo ot_display_by_type($_args);
                echo '</div>';
                echo '</div>';
            }
            echo '<div class="clear"></div>';
            echo '</div></div>';
        }
开发者ID:rajilesh,项目名称:optiontree-metabox-ui,代码行数:64,代码来源:rj-ot-meta-box-api.php

示例3: display_setting

 /**
  * Callback for add_settings_field() to build each setting by type
  *
  * @param     array     Setting object array
  * @return    string
  *
  * @access    public
  * @since     2.0
  */
 public function display_setting($args = array())
 {
     extract($args);
     /* get current saved data */
     $options = get_option($get_option, false);
     // Set field value
     $field_value = isset($options[$id]) ? $options[$id] : '';
     /* set standard value */
     if (isset($std)) {
         $field_value = ot_filter_std_value($field_value, $std);
     }
     /* build the arguments array */
     $_args = array('type' => $type, 'field_id' => $id, 'field_name' => $get_option . '[' . $id . ']', 'field_value' => $field_value, 'field_desc' => isset($desc) ? $desc : '', 'field_std' => isset($std) ? $std : '', 'field_rows' => isset($rows) && !empty($rows) ? $rows : 15, 'field_post_type' => isset($post_type) && !empty($post_type) ? $post_type : 'post', 'field_taxonomy' => isset($taxonomy) && !empty($taxonomy) ? $taxonomy : 'category', 'field_min_max_step' => isset($min_max_step) && !empty($min_max_step) ? $min_max_step : '0,100,1', 'field_class' => isset($class) ? $class : '', 'field_choices' => isset($choices) && !empty($choices) ? $choices : array(), 'field_settings' => isset($settings) && !empty($settings) ? $settings : array(), 'post_id' => ot_get_media_post_ID(), 'get_option' => $get_option);
     /* get the option HTML */
     echo ot_display_by_type($_args);
 }
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:25,代码来源:ot-settings-api.php

示例4: ot_social_links_view

 function ot_social_links_view($name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '')
 {
     /* if no settings array load the filterable social links settings */
     if (empty($settings)) {
         $settings = ot_social_links_settings($name);
     }
     echo '
 <div class="option-tree-setting">
   <div class="open">' . (isset($list_item['name']) ? esc_attr($list_item['name']) : '') . '</div>
   <div class="button-section">
     <a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __('Edit', 'option-tree') . '">
       <span class="icon ot-icon-pencil"></span>' . __('Edit', 'option-tree') . '
     </a>
     <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __('Delete', 'option-tree') . '">
       <span class="icon ot-icon-trash-o"></span>' . __('Delete', 'option-tree') . '
     </a>
   </div>
   <div class="option-tree-setting-body">';
     foreach ($settings as $field) {
         // Set field value
         $field_value = isset($list_item[$field['id']]) ? $list_item[$field['id']] : '';
         /* set default to standard value */
         if (isset($field['std'])) {
             $field_value = ot_filter_std_value($field_value, $field['std']);
         }
         /* make life easier */
         $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
         /* build the arguments array */
         $_args = array('type' => $field['type'], 'field_id' => $name . '_' . $field['id'] . '_' . $key, 'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']', 'field_value' => $field_value, 'field_desc' => isset($field['desc']) ? $field['desc'] : '', 'field_std' => isset($field['std']) ? $field['std'] : '', 'field_rows' => isset($field['rows']) ? $field['rows'] : 10, 'field_post_type' => isset($field['post_type']) && !empty($field['post_type']) ? $field['post_type'] : 'post', 'field_taxonomy' => isset($field['taxonomy']) && !empty($field['taxonomy']) ? $field['taxonomy'] : 'category', 'field_min_max_step' => isset($field['min_max_step']) && !empty($field['min_max_step']) ? $field['min_max_step'] : '0,100,1', 'field_class' => isset($field['class']) ? $field['class'] : '', 'field_condition' => isset($field['condition']) ? $field['condition'] : '', 'field_operator' => isset($field['operator']) ? $field['operator'] : 'and', 'field_choices' => isset($field['choices']) && !empty($field['choices']) ? $field['choices'] : array(), 'field_settings' => isset($field['settings']) && !empty($field['settings']) ? $field['settings'] : array(), 'post_id' => $post_id, 'get_option' => $get_option);
         $conditions = '';
         /* setup the conditions */
         if (isset($field['condition']) && !empty($field['condition'])) {
             /* doing magic on the conditions so they work in a list item */
             $conditionals = explode(',', $field['condition']);
             foreach ($conditionals as $condition) {
                 $parts = explode(':', $condition);
                 if (isset($parts[0])) {
                     $field['condition'] = str_replace($condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition']);
                 }
             }
             $conditions = ' data-condition="' . $field['condition'] . '"';
             $conditions .= isset($field['operator']) && in_array($field['operator'], array('and', 'AND', 'or', 'OR')) ? ' data-operator="' . $field['operator'] . '"' : '';
         }
         /* option label */
         echo '<div id="setting_' . $_args['field_id'] . '" class="format-settings"' . $conditions . '>';
         /* don't show title with textblocks */
         if ($_args['type'] != 'textblock' && !empty($field['label'])) {
             echo '<div class="format-setting-label">';
             echo '<h3 class="label">' . esc_attr($field['label']) . '</h3>';
             echo '</div>';
         }
         /* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
         if ($_args['type'] == 'textarea') {
             $_args['type'] = 'textarea-simple';
         }
         /* option body, list-item is not allowed inside another list-item */
         if ($_args['type'] !== 'list-item' && $_args['type'] !== 'slider' && $_args['type'] !== 'social-links') {
             echo ot_display_by_type($_args);
         }
         echo '</div>';
     }
     echo '</div>';
     echo '</div>';
 }
开发者ID:ElectricEasel,项目名称:reflection,代码行数:64,代码来源:ot-functions-admin.php

示例5: ot_list_item_view

 function ot_list_item_view($name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '')
 {
     /* required title setting */
     $required_setting = array(array('id' => 'title', 'label' => __('Title', 'option-tree'), 'desc' => '', 'std' => '', 'type' => 'text', 'rows' => '', 'class' => 'option-tree-setting-title', 'post_type' => '', 'choices' => array()));
     /* load the old filterable slider settings */
     if ('slider' == $type) {
         $settings = ot_slider_settings($name);
     }
     /* if no settings array load the filterable list item settings */
     if (empty($settings)) {
         $settings = ot_list_item_settings($name);
     }
     /* merge the two settings array */
     $settings = array_merge($required_setting, $settings);
     echo '
 <div class="option-tree-setting">
   <div class="open">' . (isset($list_item['title']) ? esc_attr($list_item['title']) : 'Item ' . ($key + 1)) . '</div>
   <div class="button-section">
     <a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button left-item" title="' . __('Edit', 'option-tree') . '">
       <span class="icon pencil">' . __('Edit', 'option-tree') . '</span>
     </a>
     <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button right-item" title="' . __('Delete', 'option-tree') . '">
       <span class="icon trash-can">' . __('Delete', 'option-tree') . '</span>
     </a>
   </div>
   <div class="option-tree-setting-body">';
     foreach ($settings as $field) {
         // Set field value
         $field_value = isset($list_item[$field['id']]) ? $list_item[$field['id']] : '';
         /* set default to standard value */
         if (isset($field['std'])) {
             $field_value = ot_filter_std_value($field_value, $field['std']);
         }
         /* make life easier */
         $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
         /* build the arguments array */
         $_args = array('type' => $field['type'], 'field_id' => $name . '_' . $field['id'] . '_' . $key, 'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']', 'field_value' => $field_value, 'field_desc' => isset($field['desc']) ? $field['desc'] : '', 'field_std' => isset($field['std']) ? $field['std'] : '', 'field_rows' => isset($field['rows']) ? $field['rows'] : 10, 'field_post_type' => isset($field['post_type']) && !empty($field['post_type']) ? $field['post_type'] : 'post', 'field_taxonomy' => isset($field['taxonomy']) && !empty($field['taxonomy']) ? $field['taxonomy'] : 'category', 'field_class' => isset($field['class']) ? $field['class'] : '', 'field_choices' => isset($field['choices']) && !empty($field['choices']) ? $field['choices'] : array(), 'field_settings' => isset($field['settings']) && !empty($field['settings']) ? $field['settings'] : array(), 'post_id' => $post_id, 'get_option' => $get_option);
         /* option label */
         echo '<div class="format-settings">';
         /* don't show title with textblocks */
         if ($_args['type'] != 'textblock') {
             echo '<div class="format-setting-label">';
             echo '<h3 class="label">' . esc_attr($field['label']) . '</h3>';
             echo '</div>';
         }
         /* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
         if ($_args['type'] == 'textarea') {
             $_args['type'] = 'textarea-simple';
         }
         /* option body, list-item is not allowed inside another list-item */
         if ($_args['type'] !== 'list-item' && $_args['type'] !== 'slider') {
             echo ot_display_by_type($_args);
         }
         echo '</div>';
     }
     echo '</div>
 </div>';
 }
开发者ID:donpapa26,项目名称:bakancslistad,代码行数:58,代码来源:ot-functions-admin.php

示例6: display_setting

 /**
  * Callback for add_settings_field() to build each setting by type
  *
  * @param     array     Setting object array
  * @return    string
  *
  * @access    public
  * @since     2.0
  */
 public function display_setting($args = array())
 {
     extract($args);
     /* get current saved data */
     $options = get_option($get_option, false);
     // Set field value
     $field_value = isset($options[$id]) ? $options[$id] : '';
     /* set standard value */
     if (isset($std)) {
         $field_value = ot_filter_std_value($field_value, $std);
     }
     // Allow the descriptions to be filtered before being displayed
     $desc = apply_filters('ot_filter_description', isset($desc) ? $desc : '', $id);
     /* build the arguments array */
     $_args = array('type' => $type, 'field_id' => $id, 'field_name' => $get_option . '[' . $id . ']', 'field_value' => $field_value, 'field_desc' => $desc, 'field_std' => isset($std) ? $std : '', 'field_rows' => isset($rows) && !empty($rows) ? $rows : 15, 'field_post_type' => isset($post_type) && !empty($post_type) ? $post_type : 'post', 'field_taxonomy' => isset($taxonomy) && !empty($taxonomy) ? $taxonomy : 'category', 'field_min_max_step' => isset($min_max_step) && !empty($min_max_step) ? $min_max_step : '0,100,1', 'field_condition' => isset($condition) && !empty($condition) ? $condition : '', 'field_operator' => isset($operator) && !empty($operator) ? $operator : 'and', 'field_class' => isset($class) ? $class : '', 'field_choices' => isset($choices) && !empty($choices) ? $choices : array(), 'field_settings' => isset($settings) && !empty($settings) ? $settings : array(), 'post_id' => ot_get_media_post_ID(), 'get_option' => $get_option);
     // Limit DB queries for Google Fonts.
     if ($type == 'google-fonts') {
         ot_fetch_google_fonts();
         ot_set_google_fonts($id, $field_value);
     }
     /* get the option HTML */
     echo ot_display_by_type($_args);
 }
开发者ID:Juliaandavid,项目名称:securexa,代码行数:32,代码来源:ot-settings-api.php

示例7: ot_list_item_view

 function ot_list_item_view($name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '')
 {
     /* required title setting */
     $required_setting = array(array('id' => 'title', 'label' => esc_html__('Title', 'uncode'), 'desc' => '', 'std' => '', 'type' => 'text', 'rows' => '', 'class' => 'option-tree-setting-title', 'post_type' => '', 'choices' => array()));
     /* load the old filterable slider settings */
     if ('slider' == $type) {
         $settings = ot_slider_settings($name);
     }
     /* if no settings array load the filterable list item settings */
     if (empty($settings)) {
         $settings = ot_list_item_settings($name);
     }
     /* merge the two settings array */
     $settings = array_merge($required_setting, $settings);
     echo '
 <div class="option-tree-setting">
   <div class="open">' . (isset($list_item['title']) ? esc_attr($list_item['title']) : '') . '</div>
   <div class="button-section">
     <a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__('Edit', 'uncode') . '">
       <span class="icon ot-icon-pencil"></span>' . esc_html__('Edit', 'uncode') . '
     </a>
     <a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__('Delete', 'uncode') . '">
       <span class="icon ot-icon-trash-o"></span>' . esc_html__('Delete', 'uncode') . '
     </a>
   </div>
   <div class="option-tree-setting-body">';
     foreach ($settings as $field) {
         // Set field value
         $field_value = isset($list_item[$field['id']]) ? $list_item[$field['id']] : '';
         /* set default to standard value */
         if (isset($field['std'])) {
             $field_value = ot_filter_std_value($field_value, isset($field['class']) && $field['class'] === 'unique_id' ? $field['std'] . big_rand() : $field['std']);
         }
         // filter the title label and description
         if ($field['id'] == 'title') {
             // filter the label
             $field['label'] = apply_filters('ot_list_item_title_label', $field['label'], $name);
             // filter the description
             $field['desc'] = apply_filters('ot_list_item_title_desc', $field['desc'], $name);
         }
         /* make life easier */
         $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
         /* build the arguments array */
         $_args = array('type' => $field['type'], 'field_id' => $name . '_' . $field['id'] . '_' . $key, 'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']', 'field_value' => $field_value, 'field_desc' => isset($field['desc']) ? $field['desc'] : '', 'field_std' => isset($field['std']) ? $field['std'] : '', 'field_rows' => isset($field['rows']) ? $field['rows'] : 10, 'field_post_type' => isset($field['post_type']) && !empty($field['post_type']) ? $field['post_type'] : 'post', 'field_taxonomy' => isset($field['taxonomy']) && !empty($field['taxonomy']) ? $field['taxonomy'] : 'category', 'field_min_max_step' => isset($field['min_max_step']) && !empty($field['min_max_step']) ? $field['min_max_step'] : '0,100,1', 'field_class' => isset($field['class']) ? $field['class'] : '', 'field_condition' => isset($field['condition']) ? $field['condition'] : '', 'field_operator' => isset($field['operator']) ? $field['operator'] : 'and', 'field_choices' => isset($field['choices']) && !empty($field['choices']) ? $field['choices'] : array(), 'field_settings' => isset($field['settings']) && !empty($field['settings']) ? $field['settings'] : array(), 'post_id' => $post_id, 'get_option' => $get_option);
         $conditions = '';
         /* setup the conditions */
         if (isset($field['condition']) && !empty($field['condition'])) {
             /* doing magic on the conditions so they work in a list item */
             $conditionals = explode(',', $field['condition']);
             foreach ($conditionals as $condition) {
                 $parts = explode(':', $condition);
                 if (isset($parts[0])) {
                     $field['condition'] = str_replace($condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition']);
                 }
             }
             $conditions = ' data-condition="' . $field['condition'] . '"';
             $conditions .= isset($field['operator']) && in_array($field['operator'], array('and', 'AND', 'or', 'OR')) ? ' data-operator="' . $field['operator'] . '"' : '';
         }
         // Build the setting CSS class
         if (!empty($_args['field_class'])) {
             $classes = explode(' ', $_args['field_class']);
             foreach ($classes as $_key => $value) {
                 $classes[$_key] = $value . '-wrap';
             }
             $class = 'format-settings ' . implode(' ', $classes);
         } else {
             $class = 'format-settings';
         }
         /* option label */
         echo '<div id="setting_' . $_args['field_id'] . '" class="' . $class . '"' . $conditions . '>';
         /* don't show title with textblocks */
         if ($_args['type'] != 'textblock' && !empty($field['label'])) {
             echo '<div class="format-setting-label">';
             echo '<h3 class="label">' . esc_attr($field['label']) . '</h3>';
             echo '</div>';
         }
         /* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
         if (apply_filters('ot_override_forced_textarea_simple', false, $field['id']) == false && $_args['type'] == 'textarea') {
             $_args['type'] = 'textarea-simple';
         }
         /* option body, list-item is not allowed inside another list-item */
         if ($_args['type'] !== 'list-item' && $_args['type'] !== 'slider') {
             echo ot_display_by_type($_args);
         }
         echo '</div>';
     }
     echo '</div>';
     echo '</div>';
 }
开发者ID:b0123498765,项目名称:fithealthyandwealthy,代码行数:89,代码来源:functions.php

示例8: build_meta_box

 /**
  * Meta box view
  *
  * @return    string
  *
  * @access    public
  * @since     1.0
  */
 function build_meta_box($post, $metabox)
 {
     echo '<div class="ot-metabox-wrapper">';
     /* Use nonce for verification */
     echo '<input type="hidden" name="' . $this->meta_box['id'] . '_nonce" value="' . wp_create_nonce($this->meta_box['id']) . '" />';
     /* meta box description */
     echo isset($this->meta_box['desc']) && !empty($this->meta_box['desc']) ? '<div class="description" style="padding-top:10px;">' . htmlspecialchars_decode($this->meta_box['desc']) . '</div>' : '';
     /* loop through meta box fields */
     foreach ($this->meta_box['fields'] as $field) {
         /* inject meta panel */
         if (get_post_type($post->ID) == 'portfolio') {
             /* options to skip */
             $option_to_skip = array('ut_page_type');
             if (in_array($field['id'], $option_to_skip)) {
                 continue;
             }
             /* options to inject */
             $option_to_inject = array('ut_page_hero_style' => 'ut_portfolio_hero_style', 'ut_page_hero_align' => 'ut_portfolio_caption_align', 'ut_section_slogan' => 'ut_page_slogan');
             if (array_key_exists($field['id'], $option_to_inject)) {
                 /* overwrite field ID */
                 $field['id'] = $option_to_inject[$field['id']];
             }
         }
         /* get current post meta data */
         $field_value = get_post_meta($post->ID, $field['id'], true);
         /* set standard value */
         if (isset($field['std'])) {
             $field_value = ot_filter_std_value($field_value, $field['std']);
         }
         /* build the arguments array */
         $_args = array('type' => $field['type'], 'field_id' => $field['id'], 'field_name' => $field['id'], 'field_toplevel' => isset($field['toplevel']) && $field['toplevel'] ? $field['toplevel'] : '', 'field_value' => $field_value, 'field_desc' => isset($field['desc']) ? $field['desc'] : '', 'field_htmldesc' => isset($field['htmldesc']) ? $field['htmldesc'] : '', 'field_std' => isset($field['std']) ? $field['std'] : '', 'field_rows' => isset($field['rows']) && !empty($field['rows']) ? $field['rows'] : 10, 'field_post_type' => isset($field['post_type']) && !empty($field['post_type']) ? $field['post_type'] : 'post', 'field_taxonomy' => isset($field['taxonomy']) && !empty($field['taxonomy']) ? $field['taxonomy'] : 'category', 'field_min_max_step' => isset($field['min_max_step']) && !empty($field['min_max_step']) ? $field['min_max_step'] : '0,100,1', 'field_class' => isset($field['class']) ? $field['class'] : '', 'field_choices' => isset($field['choices']) ? $field['choices'] : array(), 'field_settings' => isset($field['settings']) && !empty($field['settings']) ? $field['settings'] : array(), 'post_id' => $post->ID, 'meta' => true);
         /* only allow simple textarea due to DOM issues with wp_editor() 
            if ( $_args['type'] == 'textarea' )
              $_args['type'] = 'textarea-simple';*/
         $section_class = !empty($field["section_class"]) ? $field["section_class"] : '';
         $metapanel = !empty($field["metapanel"]) ? 'data-panel="' . $field["metapanel"] . '"' : '';
         /* option label */
         echo '<div id="setting_' . $_args['field_id'] . '" class="format-settings ' . $section_class . '" ' . $metapanel . '>';
         /* don't show title with textblocks */
         if ($_args['type'] != 'radio_group_button' && $_args['type'] != 'textblock' && !empty($field['label'])) {
             echo '<div class="format-setting-label">';
             if (isset($field['needsprefix']) && $field['needsprefix']) {
                 global $post_ID;
                 if (get_post_type($post_ID) == 'page') {
                     $prefix = __('Page / Section ', 'unitedthemes');
                 } elseif (get_post_type($post_ID) == 'portfolio') {
                     $prefix = __('Portfolio Page ', 'unitedthemes');
                 } elseif (get_post_type($post_ID) == 'post') {
                     $prefix = __('Post Page ', 'unitedthemes');
                 } else {
                     $prefix = __('Page ', 'unitedthemes');
                 }
             } else {
                 $prefix = NULL;
             }
             echo '<h3 class="label">' . $prefix . $field['label'] . '</h3>';
             /* description */
             if (!empty($field['desc']) && $field['type'] != 'textblock' || isset($field['screenshot']) && $field['screenshot']) {
                 echo '<div class="description">';
                 echo htmlspecialchars_decode($field['desc']);
                 if (isset($field['screenshot']) && $field['screenshot']) {
                     echo '<br /><a href="#" class="ut-admin-tooltip"> ' . __('Learn more about:', 'unitedthemes') . ' ' . $field['label'] . ' <span> <img class="callout" src="' . THEME_WEB_ROOT . '/images/iMac-Flat-Mockup.png" /> </span></a>';
                     //echo '<br /><a href="#" class="ut-admin-tooltip"> '.__('Learn more about:','unitedthemes').' '.$field['label'].' <span> <img class="callout" src="'. THEME_WEB_ROOT . '/admin/assets/images/screenshots/setting_' . $field['id'] .'.jpg" /> </span></a>';
                 }
                 echo '</div>';
             }
             echo '</div>';
         }
         /* get the option HTML */
         echo ot_display_by_type($_args);
         echo '</div>';
     }
     echo '</div>';
 }
开发者ID:amptdesign,项目名称:ampt-2016,代码行数:82,代码来源:ot-meta-box-api.php


注:本文中的ot_filter_std_value函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。