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


PHP ot_social_links_settings函数代码示例

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


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

示例1: sanitize_callback

 /**
  * Sanitize callback for register_setting()
  *
  * @return    string
  *
  * @access    public
  * @since     2.0
  */
 public function sanitize_callback($input)
 {
     /* loop through options */
     foreach ((array) $this->options as $option) {
         /* loop through pages */
         foreach ((array) $this->get_pages($option) as $page) {
             /* loop through page settings */
             foreach ((array) $this->get_the_settings($page) as $setting) {
                 /* verify setting has a type & value */
                 if (isset($setting['type']) && isset($input[$setting['id']])) {
                     /* get the defaults */
                     $current_settings = get_option(ot_settings_id());
                     $current_options = get_option($option['id']);
                     /* validate setting */
                     if (is_array($input[$setting['id']]) && in_array($setting['type'], array('list-item', 'slider'))) {
                         /* 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()));
                         /* get the settings array */
                         $settings = isset($_POST[$setting['id'] . '_settings_array']) ? unserialize(ot_decode($_POST[$setting['id'] . '_settings_array'])) : array();
                         /* settings are empty for some odd ass reason get the defaults */
                         if (empty($settings)) {
                             $settings = 'slider' == $setting['type'] ? ot_slider_settings($setting['id']) : ot_list_item_settings($setting['id']);
                         }
                         /* merge the two settings array */
                         $settings = array_merge($required_setting, $settings);
                         /* create an empty WPML id array */
                         $wpml_ids = array();
                         foreach ($input[$setting['id']] as $k => $setting_array) {
                             foreach ($settings as $sub_setting) {
                                 /* setup the WPML ID */
                                 $wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
                                 /* add id to array */
                                 $wpml_ids[] = $wpml_id;
                                 /* verify sub setting has a type & value */
                                 if (isset($sub_setting['type']) && isset($input[$setting['id']][$k][$sub_setting['id']])) {
                                     /* validate setting */
                                     $input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting($input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'], $wpml_id);
                                 }
                             }
                         }
                     } else {
                         if (is_array($input[$setting['id']]) && $setting['type'] == 'social-links') {
                             /* get the settings array */
                             $settings = isset($_POST[$setting['id'] . '_settings_array']) ? unserialize(ot_decode($_POST[$setting['id'] . '_settings_array'])) : array();
                             /* settings are empty get the defaults */
                             if (empty($settings)) {
                                 $settings = ot_social_links_settings($setting['id']);
                             }
                             /* create an empty WPML id array */
                             $wpml_ids = array();
                             foreach ($input[$setting['id']] as $k => $setting_array) {
                                 foreach ($settings as $sub_setting) {
                                     /* setup the WPML ID */
                                     $wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
                                     /* add id to array */
                                     $wpml_ids[] = $wpml_id;
                                     /* verify sub setting has a type & value */
                                     if (isset($sub_setting['type']) && isset($input[$setting['id']][$k][$sub_setting['id']])) {
                                         /* validate setting */
                                         $input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting($input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'], $wpml_id);
                                     }
                                 }
                             }
                         } else {
                             $input[$setting['id']] = ot_validate_setting($input[$setting['id']], $setting['type'], $setting['id'], $setting['id']);
                         }
                     }
                 }
                 /* unregister WPML strings that were deleted from lists and sliders */
                 if (isset($current_settings['settings']) && isset($setting['type']) && in_array($setting['type'], array('list-item', 'slider'))) {
                     if (!isset($wpml_ids)) {
                         $wpml_ids = array();
                     }
                     foreach ($current_settings['settings'] as $check_setting) {
                         if ($setting['id'] == $check_setting['id'] && !empty($current_options[$setting['id']])) {
                             foreach ($current_options[$setting['id']] as $key => $value) {
                                 foreach ($value as $ckey => $cvalue) {
                                     $id = $setting['id'] . '_' . $ckey . '_' . $key;
                                     if (!in_array($id, $wpml_ids)) {
                                         ot_wpml_unregister_string($id);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 /* unregister WPML strings that were deleted from social links */
                 if (isset($current_settings['settings']) && isset($setting['type']) && $setting['type'] == 'social-links') {
                     if (!isset($wpml_ids)) {
                         $wpml_ids = array();
                     }
                     foreach ($current_settings['settings'] as $check_setting) {
//.........这里部分代码省略.........
开发者ID:Juliaandavid,项目名称:securexa,代码行数:101,代码来源:ot-settings-api.php

示例2: 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

示例3: save_meta_box

 /**
  * Saves the meta box values
  *
  * @return    void
  *
  * @access    public
  * @since     1.0
  */
 function save_meta_box($post_id, $post_object)
 {
     global $pagenow;
     /* don't save if $_POST is empty */
     if (empty($_POST)) {
         return $post_id;
     }
     /* don't save during quick edit */
     if ($pagenow == 'admin-ajax.php') {
         return $post_id;
     }
     /* don't save during autosave */
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     /* don't save if viewing a revision */
     if ($post_object->post_type == 'revision' || $pagenow == 'revision.php') {
         return $post_id;
     }
     /* verify nonce */
     if (isset($_POST[$this->meta_box['id'] . '_nonce']) && !wp_verify_nonce($_POST[$this->meta_box['id'] . '_nonce'], $this->meta_box['id'])) {
         return $post_id;
     }
     /* check permissions */
     if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return $post_id;
         }
     }
     foreach ($this->meta_box['fields'] as $field) {
         $old = get_post_meta($post_id, $field['id'], true);
         $new = '';
         /* there is data to validate */
         if (isset($_POST[$field['id']])) {
             /* slider and list item */
             if (in_array($field['type'], array('list-item', 'slider'))) {
                 /* 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()));
                 /* get the settings array */
                 $settings = isset($_POST[$field['id'] . '_settings_array']) ? unserialize(ot_decode($_POST[$field['id'] . '_settings_array'])) : array();
                 /* settings are empty for some odd ass reason get the defaults */
                 if (empty($settings)) {
                     $settings = 'slider' == $field['type'] ? ot_slider_settings($field['id']) : ot_list_item_settings($field['id']);
                 }
                 /* merge the two settings array */
                 $settings = array_merge($required_setting, $settings);
                 foreach ($_POST[$field['id']] as $k => $setting_array) {
                     foreach ($settings as $sub_setting) {
                         /* verify sub setting has a type & value */
                         if (isset($sub_setting['type']) && isset($_POST[$field['id']][$k][$sub_setting['id']])) {
                             $_POST[$field['id']][$k][$sub_setting['id']] = ot_validate_setting($_POST[$field['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id']);
                         }
                     }
                 }
                 /* set up new data with validated data */
                 $new = $_POST[$field['id']];
             } else {
                 if ($field['type'] == 'social-links') {
                     /* get the settings array */
                     $settings = isset($_POST[$field['id'] . '_settings_array']) ? unserialize(ot_decode($_POST[$field['id'] . '_settings_array'])) : array();
                     /* settings are empty get the defaults */
                     if (empty($settings)) {
                         $settings = ot_social_links_settings($field['id']);
                     }
                     foreach ($_POST[$field['id']] as $k => $setting_array) {
                         foreach ($settings as $sub_setting) {
                             /* verify sub setting has a type & value */
                             if (isset($sub_setting['type']) && isset($_POST[$field['id']][$k][$sub_setting['id']])) {
                                 $_POST[$field['id']][$k][$sub_setting['id']] = ot_validate_setting($_POST[$field['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id']);
                             }
                         }
                     }
                     /* set up new data with validated data */
                     $new = $_POST[$field['id']];
                 } else {
                     /* run through validattion */
                     $new = ot_validate_setting($_POST[$field['id']], $field['type'], $field['id']);
                 }
             }
             /* insert CSS */
             if ($field['type'] == 'css') {
                 /* insert CSS into dynamic.css */
                 if ('' !== $new) {
                     ot_insert_css_with_markers($field['id'], $new, true);
                     /* remove old CSS from dynamic.css */
                 } else {
                     ot_remove_old_css($field['id']);
                 }
//.........这里部分代码省略.........
开发者ID:ariefsetya,项目名称:setya.me,代码行数:101,代码来源:ot-meta-box-api.php


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