Beispiel #1
0
 /**
  * Fake the gallery shortcode
  *
  * The JS takes over and creates the actual shortcode with 
  * the real attachment IDs on the fly. Here we just need to 
  * pass in the post ID to get the ball rolling.
  *
  * @param     array     The current settings
  * @param     object    The post object
  * @return    array
  *
  * @access    public
  * @since     2.2.0
  */
 public function shortcode($settings, $post)
 {
     // Set the OptionTree post ID
     if (!is_object($post)) {
         $settings['post']['id'] = ot_get_media_post_ID();
     }
     // No ID return settings
     if ($settings['post']['id'] == 0) {
         return $settings;
     }
     // Set the fake shortcode
     $settings['ot_gallery'] = array('shortcode' => "[gallery id='{$settings['post']['id']}']");
     // Return settings
     return $settings;
 }
 /**
  * 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 default to standard value */
     if (!isset($options[$id]) && isset($std)) {
         $options[$id] = trim($std);
     }
     /* build the arguments array */
     $_args = array('type' => $type, 'field_id' => $id, 'field_name' => 'option_tree[' . $id . ']', 'field_value' => isset($options[$id]) ? $options[$id] : '', '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_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);
 }
 /**
  * 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);
 }
 function ot_create_media_post()
 {
     register_post_type('option-tree', array('labels' => array('name' => __('Option Tree', 'option-tree')), 'public' => false, 'show_ui' => false, 'capability_type' => 'post', 'exclude_from_search' => true, 'hierarchical' => false, 'rewrite' => false, 'supports' => array('title', 'editor'), 'can_export' => false, 'show_in_nav_menus' => false));
     /* look for custom page */
     $post_id = ot_get_media_post_ID();
     /* no post exists */
     if ($post_id == 0) {
         /* create post object */
         $_p = array();
         $_p['post_title'] = 'Media';
         $_p['post_name'] = 'media';
         $_p['post_status'] = 'private';
         $_p['post_type'] = 'option-tree';
         $_p['comment_status'] = 'closed';
         $_p['ping_status'] = 'closed';
         /* insert the post into the database */
         wp_insert_post($_p);
     }
 }
 /**
  * Fake the gallery shortcode
  *
  * The JS takes over and creates the actual shortcode with
  * the real attachment IDs on the fly. Here we just need to
  * pass in the post ID to get the ball rolling.
  *
  * @param     array     The current settings
  * @param     object    The post object
  * @return    array
  *
  * @access    public
  * @since     2.2.0
  */
 public function shortcode($settings, $post)
 {
     // Set the OptionTree post ID
     if (!is_object($post)) {
         $post_id = isset($_GET['post']) ? $_GET['post'] : (isset($_GET['post_ID']) ? $_GET['post_ID'] : 0);
         if ($post_id == 0 && function_exists('ot_get_media_post_ID')) {
             $post_id = ot_get_media_post_ID();
         }
         $settings['post']['id'] = $post_id;
     }
     // No ID return settings
     if ($settings['post']['id'] == 0) {
         return $settings;
     }
     // Set the fake shortcode
     $settings['ot_gallery'] = array('shortcode' => "[gallery id='{$settings['post']['id']}']");
     // Return settings
     return $settings;
 }
 /**
  * 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);
 }
 function ot_type_import_xml()
 {
     echo '<form method="post" id="import-xml-form">';
     /* form nonce */
     wp_nonce_field('import_xml_form', 'import_xml_nonce');
     /* format setting outer wrapper */
     echo '<div class="format-setting type-textblock has-desc">';
     /* description */
     echo '<div class="description">';
     echo '<p class="deprecated">' . __('This import method has been deprecated. That means it has been replaced by a new method and is no longer supported, and may be removed from future versions. All themes that use this import method should be converted to use its replacement below.', 'option-tree') . '</p>';
     echo '<p>' . sprintf(__('If you were given a Theme Options XML file with a premium or free theme, locate it on your hard drive and upload that file by clicking the upload button. A popup window will appear, upload the XML file and click "%s". The file URL should be in the upload input, if it is click "Import XML".', 'option-tree'), apply_filters('ot_upload_text', __('Send to OptionTree', 'option-tree'))) . '</p>';
     /* button */
     echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __('Import XML', 'option-tree') . '</button>';
     echo '</div>';
     echo '<div class="format-setting-inner">';
     /* build upload */
     echo '<div class="option-tree-ui-upload-parent">';
     /* input */
     echo '<input type="text" name="import_xml" id="import_xml" value="" class="widefat option-tree-ui-upload-input" />';
     /* get media post_id */
     $post_id = ($id = ot_get_media_post_ID()) ? (int) $id : 0;
     /* add xml button */
     echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button button button-primary light" rel="' . $post_id . '" title="' . __('Add XML', 'option-tree') . '"><span class="icon ot-icon-plus-circle"></span>' . __('Add XML', 'option-tree') . '</a>';
     echo '</div>';
     echo '</div>';
     echo '</div>';
     echo '</form>';
 }