/** * Add modal window. * * @since 1.4.0 */ public function add_modal() { $groups = $this->get_groups(); ?> <div id="tb-shortcode-generator" class="tb-hide"> <div class="media-modal wp-core-ui"> <a class="media-modal-close" href="#" title="Close"> <span class="media-modal-icon"></span> </a> <div class="media-modal-content"> <div class="media-frame wp-core-ui"> <div class="media-frame-menu"> <div class="media-menu"> <?php foreach ($groups as $key => $group) { ?> <a href="#" data-id="<?php echo $group['id']; ?> " title="<?php echo $group['name']; ?> " class="media-menu-item <?php if ($key == 0) { echo ' active'; } ?> "> <?php echo $group['name']; ?> </a> <?php } ?> </div> </div><!-- .media-frame-menu (end) --> <div class="media-frame-title"> <h1><?php echo $groups[0]['name']; ?> </h1> </div><!-- .media-frame-title (end) --> <?php foreach ($groups as $key => $group) { ?> <?php if (count($group['sub']) > 0) { ?> <div class="media-frame-router tb-router-<?php echo $group['id']; ?> " data-group="<?php echo $group['id']; ?> "> <div class="media-router"> <?php foreach ($group['sub'] as $id => $name) { ?> <?php $class = 'tb-tab-menu-item'; if (reset($group['sub']) == $name) { $class .= ' active'; } ?> <a href="#" data-sub-group="<?php echo $id; ?> " class="<?php echo $class; ?> "><?php echo $name; ?> </a> <?php } ?> </div><!-- .media-router (end) --> </div><!-- .media-frame-router (end) --> <?php } ?> <?php } ?> <div id="optionsframework" class="media-frame-content"> <div class="attachments-browser"> <?php foreach ($groups as $key => $group) { ?> <?php $class = 'tb-group attachments ui-sortable ui-sortable-disabled'; if ($key == 0) { $class .= ' tb-group-show'; } else { $class .= ' tb-group-hide'; } if (count($group['sub']) > 0) { $class .= ' group-has-subs'; } ?> <div id="tb-group-<?php echo $group['id']; ?> " class="<?php echo $class; ?> "> <?php // Switch by group switch ($group['id']) { /*--------------------------------------------*/ /* Button /*--------------------------------------------*/ case 'button': $options = $this->get_options('button'); $output = themeblvd_option_fields('button', $options, array(), false); echo '<div class="shortcode-options" data-type="button">'; echo '<div class="options-wrap">'; $this->preview($group['id']); $color_browser_ags = array('title' => __('Button Color', 'themeblvd_shortcodes'), 'desc' => __('<p>Select a color for your button.</p><p><em>Note: The "default" color may vary from theme-to-theme.</em></p>', 'themeblvd_shortcodes'), 'std' => 'default'); $this->color_browser($color_browser_ags); echo $output[0]; echo '</div><!-- .options-wrap (end) -->'; echo '</div><!-- .shortcode-options (end) -->'; break; /*--------------------------------------------*/ /* Columns /*--------------------------------------------*/ $options = $this->get_options('column'); $output = themeblvd_option_fields('column', $options, array(), false); echo '<div class="shortcode-options shortcode-options-column" data-type="column">'; $this->preview('column'); echo '<div class="options-wrap">'; echo $output[0]; echo '</div><!-- .options-wrap (end) -->'; echo '</div><!-- .shortcode-options (end) -->'; /*--------------------------------------------*/ /* Icons /*--------------------------------------------*/ /*--------------------------------------------*/ /* Icons /*--------------------------------------------*/ case 'icons': // Image Icons $options = $this->get_options('icon'); $output = themeblvd_option_fields('icon', $options, array(), false); echo '<div class="shortcode-options shortcode-options-icon" data-type="icon">'; echo '<div class="options-wrap">'; $this->preview('icon'); echo $output[0]; echo '</div><!-- .options-wrap (end) -->'; echo '</div><!-- .shortcode-options (end) -->'; // Vector Icons $options = $this->get_options('vector_icon'); $output = themeblvd_option_fields('vector_icon', $options, array(), false); echo '<div class="shortcode-options shortcode-options-vector_icon hide" data-type="vector_icon">'; $this->preview('vector_icon'); $this->icon_browser(); echo '<div class="options-wrap">'; echo $output[0]; echo '</div><!-- .options-wrap (end) -->'; echo '</div><!-- .shortcode-options (end) -->'; break; /*--------------------------------------------*/ /* Default /*--------------------------------------------*/ /*--------------------------------------------*/ /* Default /*--------------------------------------------*/ default: $hide = ''; if (count($group['sub']) > 0) { foreach ($group['sub'] as $id => $name) { $options = $this->get_options($id); $output = themeblvd_option_fields($id, $options, array(), false); printf('<div class="shortcode-options shortcode-options-%s %s" data-type="%s">', $id, $hide, $id); $this->preview($group['id'], $id); echo '<div class="options-wrap">'; echo $output[0]; echo '</div><!-- .options-wrap (end) -->'; echo '</div><!-- .shortcode-options (end) -->'; // Starting with the the second pass, hide clas will be $hide = 'hide'; } } else { $options = $this->get_options($group['id']); $output = themeblvd_option_fields($group['id'], $options, array(), false); printf('<div class="shortcode-options shortcode-options-%1$s" data-type="%1$s">', $group['id']); $this->preview($group['id']); echo '<div class="options-wrap">'; echo $output[0]; echo '</div><!-- .options-wrap (end) -->'; echo '</div><!-- .shortcode-options (end) -->'; } } ?> </div> <?php } ?> </div><!-- .attachments-browser (end) --> </div><!-- .media-frame-content (end) --> <div class="media-frame-toolbar"> <div class="media-toolbar"> <div class="media-toolbar-secondary"> </div> <div class="media-toolbar-primary"> <button href="#" id="tb-shortcode-to-editor" data-insert="button" class="button media-button button-primary button-large">Insert Shortcode</button> </div> </div><!-- .media-toolbar (end) --> </div><!-- .media-frame-toolbar (end) --> </div><!-- .media-frame (end) --> </div><!-- .media-modal-content (end) --> </div><!-- .media-modal (end) --> <div class="media-modal-backdrop"></div> </div> <?php }
/** * Callback to display meta box. * * @since 2.3.0 */ public function display() { global $post; // Make sure options framework exists so we can show // the options form. if (!function_exists('themeblvd_option_fields')) { echo 'Options framework not found.'; return; } $this->args = apply_filters('themeblvd_meta_args_' . $this->id, $this->args); $this->options = apply_filters('themeblvd_meta_options_' . $this->id, $this->options); // Start content echo '<div class="tb-meta-box">'; // Gather any already saved settings or defaults for option types // that need a starting value $settings = array(); foreach ($this->options as $option) { $settings[$option['id']] = get_post_meta($post->ID, $option['id'], true); if (!$settings[$option['id']]) { if ('radio' == $option['type'] || 'images' == $option['type'] || 'select' == $option['type']) { if (isset($option['std'])) { $settings[$option['id']] = $option['std']; } } } } // Use options framework to display form elements $form = themeblvd_option_fields('themeblvd_meta', $this->options, $settings, false); echo $form[0]; // Finish content if (!empty($this->args['desc'])) { printf('<p class="tb-meta-desc">%s</p>', $this->args['desc']); } echo '</div><!-- .tb-meta-box (end) -->'; }
/** * Generates the the interface to edit the layout * when in the metabox interface of editing Pages. * * @since 1.1.0 * * @param $id string ID of layout to edit */ public function mini_edit_layout($id) { $api = Theme_Blvd_Builder_API::get_instance(); // If no layout (i.e. User selected "none" or one hasn't been chosen yet) if (!$id) { echo '<p class="warning">' . __('Select a layout to apply and edit it, or create a new one.', 'themeblvd_builder') . '</p>'; return; } // Get custom layout post $elements = $this->get_elements(); $layout = get_post($id); // Check if valid layout if (!$layout) { echo '<p class="warning">' . __('The layout currently selected no longer exists. Select a different layout to edit, or create a new one.', 'themeblvd_builder') . '</p>'; return; } // Grab elements and settings for the layout we're editing $layout_elements = get_post_meta($id, 'elements', true); $layout_settings = get_post_meta($id, 'settings', true); ?> <input type="hidden" name="tb_layout_id" value="<?php echo $id; ?> " /> <h3><?php _e('Edit Layout', 'themeblvd_builder'); ?> : <?php echo $layout->post_title; ?> </h3> <div id="metabox-builder"> <div class="edit-layout-wrap"> <div id="titlediv"> <div class="ajax-overlay"></div> <h2><?php _e('Manage Elements', 'themeblvd_builder'); ?> </h2> <select> <?php foreach ($elements as $element) { echo '<option value="' . $element['info']['id'] . '=>' . $element['info']['query'] . '">' . $element['info']['name'] . '</option>'; } ?> </select> <a href="#" id="add_new_element" class="button-secondary"><?php _e('Add New Element', 'themeblvd_builder'); ?> </a> <span class="tb-loader ajax-loading"></span> <div class="clear"></div> </div><!-- #titlediv (end) --> <div id="builder"> <div id="featured"> <span class="label"><?php _e('Featured Above', 'themeblvd_builder'); ?> </span> <div class="sortable"> <?php if (!empty($layout_elements) && !empty($layout_elements['featured'])) { foreach ($layout_elements['featured'] as $id => $element) { if ($api->is_element($element['type'])) { $this->edit_element($element['type'], $id, $element['options']); } } } ?> </div><!-- .sortable (end) --> </div><!-- #featured (end) --> <div id="primary"> <input type="hidden" name="tb_elements[divider]" value="" /> <span class="label"><?php _e('Primary Area', 'themeblvd_builder'); ?> </span> <div class="sortable"> <?php if (!empty($layout_elements) && !empty($layout_elements['primary'])) { foreach ($layout_elements['primary'] as $id => $element) { if ($api->is_element($element['type'])) { $this->edit_element($element['type'], $id, $element['options']); } } } ?> </div><!-- .sortable (end) --> </div><!-- #primary (end) --> <div id="featured_below"> <input type="hidden" name="tb_elements[divider_2]" value="" /> <span class="label"><?php _e('Featured Below', 'themeblvd_builder'); ?> </span> <div class="sortable"> <?php if (!empty($layout_elements) && !empty($layout_elements['featured_below'])) { foreach ($layout_elements['featured_below'] as $id => $element) { if ($api->is_element($element['type'])) { $this->edit_element($element['type'], $id, $element['options']); } } } ?> </div><!-- .sortable (end) --> </div><!-- #primary (end) --> </div><!-- #builder (end) --> </div><!-- .edit-layout-wrap (end) --> <div class="sidebar-layout-wrap"> <div class="title"> <h2><?php _e('Sidebar Layout', 'themeblvd_builder'); ?> </h2> <div class="clear"></div> </div><!-- #titlediv (end) --> <div class="sidebar-layout"> <?php // Setup sidebar layouts $imagepath = get_template_directory_uri() . '/framework/admin/assets/images/'; $sidebar_layouts = array('default' => $imagepath . 'layout-default.png'); $layouts = themeblvd_sidebar_layouts(); foreach ($layouts as $layout) { $sidebar_layouts[$layout['id']] = $imagepath . 'layout-' . $layout['id'] . '.png'; } // Now convert it to options form $options = array(array('id' => 'sidebar_layout', 'desc' => __('Select how you\'d like the sidebar(s) arranged in this layout. Your site-wide default sidebar layout can be set from your Theme Options page.<br><br><strong>Note: The sidebar layout is only applied to the "Primary Area" of the custom layout.</strong>', 'themeblvd_builder'), 'type' => 'images', 'options' => $sidebar_layouts)); // Display form element $form = themeblvd_option_fields('tb_layout_options', $options, $layout_settings, false); echo $form[0]; ?> </div> </div><!-- .sidebar-layout-wrap (end) --> <div class="custom-layout-note"> <p><?php _e('Note: For this custom layout to be applied to the current page, you must select the "Custom Layout" page template from your Page Attributes.', 'themeblvd_builder'); ?> </p> </div> </div><!-- #metabox-builder (end) --> <?php }
/** * Generates the the interface to edit slider. * * @since 1.0.0 * * @param $id string ID of slider to edit */ public function edit_slider($id) { $api = Theme_Blvd_Sliders_API::get_instance(); // Get slider custom post $slider = get_post($id); // Check for no post object returned from ID. if (!$slider) { echo '<div class="error"><p>' . __('The slider could not be found.', 'themeblvd_sliders') . '</p></div>'; return; } // Post ID $post_id = $slider->ID; // Meta data for slider post $current_slides = get_post_meta($post_id, 'slides', true); $type = get_post_meta($post_id, 'type', true); $settings = get_post_meta($post_id, 'settings', true); // Check if slider type is valid. if (!$api->is_slider($type)) { echo '<div class="error"><p>' . sprintf(__('The slider type "%s" is not valid.', 'themeblvd_sliders'), $type) . '</p></div>'; return; } $type_info = $types = $api->get_sliders($type); $options = $type_info['options']; ?> <input type="hidden" name="slider_id" value="<?php echo $post_id; ?> " /> <div id="poststuff" class="metabox-holder full-width has-right-sidebar"> <div class="inner-sidebar"> <div id="slider-publish" class="postbox postbox-publish"> <h3 class="hndle" title="<?php echo __('Click to toggle', 'themeblvd_sliders'); ?> "><?php _e('Publish', 'themeblvd_sliders'); ?> <?php echo stripslashes($slider->post_title); ?> </h3> <div class="tb-widget-content submitbox"> <div id="major-publishing-actions"> <div id="delete-action"> <a class="submitdelete delete_slider" href="#<?php echo $post_id; ?> "><?php _e('Delete', 'themeblvd_sliders'); ?> </a> </div> <div id="publishing-action"> <input class="button-primary" value="<?php _e('Update Slider', 'themeblvd_sliders'); ?> " type="submit" /> <img src="<?php echo esc_url(admin_url('images/wpspin_light.gif')); ?> " class="ajax-loading" /> </div> <div class="clear"></div> </div> </div><!-- .tb-widget-content (end) --> </div><!-- .post-box (end) --> <div id="slider-info" class="postbox postbox-slider-info closed"> <div class="handlediv" title="<?php echo __('Click to toggle', 'themeblvd_sliders'); ?> "><br></div> <h3 class="hndle"><?php _e('Slider Information', 'themeblvd_sliders'); ?> </h3> <div class="tb-widget-content hide"> <?php // Current settings $info_settings = array('post_title' => $slider->post_title, 'post_name' => $slider->post_name); // Setup attribute options $info_options = array(array('name' => __('Slider Name', 'themeblvd_sliders'), 'id' => 'post_title', 'desc' => __('This title is just for you. It\'ll never be used outside of your WordPress admin panel.', 'themeblvd_sliders'), 'type' => 'text'), array('name' => __('Slider ID', 'themeblvd_sliders'), 'id' => 'post_name', 'desc' => __('Sliders are assigned based on this ID. So if you change this at any point, make sure to also update any builder elements, pages, or other options in which you\'ve assigned this specific slider.', 'themeblvd_sliders'), 'type' => 'text')); // Display form element $form = themeblvd_option_fields('info', $info_options, $info_settings, false); echo $form[0]; ?> </div><!-- .tb-widget-content (end) --> </div><!-- .post-box (end) --> <?php if ($options) { ?> <div id="slider-options" class="postbox postbox-options closed"> <div class="handlediv" title="<?php echo __('Click to toggle', 'themeblvd_sliders'); ?> "><br></div> <h3 class="hndle"><?php echo $type_info['name'] . ' ' . __('Options', 'themeblvd_sliders'); ?> </h3> <div class="tb-widget-content hide"> <?php // Slider Options $form = themeblvd_option_fields('options', $options, $settings, false); echo $form[0]; ?> </div><!-- .tb-widget-content (end) --> </div><!-- .post-box (end) --> <?php } ?> </div><!-- .inner-sidebar (end) --> <div id="post-body"> <div id="post-body-content"> <div id="titlediv"> <div class="ajax-overlay"></div> <h2><?php printf(__('Manage %s Slides', 'themeblvd_sliders'), ucfirst($type)); ?> </h2> <a href="#<?php echo $post_id; ?> =><?php echo $type; ?> " id="add_new_slide" class="button-secondary"><?php _e('Add New Slide', 'themeblvd_sliders'); ?> </a> <img src="<?php echo esc_url(admin_url('images/wpspin_light.gif')); ?> " class="ajax-loading" id="ajax-loading"> <div class="clear"></div> </div><!-- #titlediv (end) --> <div id="sortable"> <?php if (!empty($current_slides)) { foreach ($current_slides as $slide_id => $slide) { $this->edit_slide($post_id, $type, $slide_id, $slide); } } else { echo '<p class="warning no-item-yet">' . __('You haven\'t added any slides yet. Get started by clicking "Add New Slide" above.', 'themeblvd_sliders') . '</p>'; } ?> </div><!-- .sortable-slides (end) --> </div><!-- #post-body-content (end) --> </div><!-- #post-body (end) --> </div><!-- .metabox-holder (end) --> <?php }
/** * Builds out the options panel. * * If we were using the Settings API as it was likely intended * we would use do_settings_sections here. But as we don't want * the settings wrapped in a table, we'll call our own custom * themeblvd_option_fields. See options-interface.php for * specifics on how each individual field is generated. * * Nonces are provided using the settings_fields() * * @since 2.2.0 */ public function admin_page() { // Get any current settings from the database. $settings = get_option($this->id); // Setup options form $return = themeblvd_option_fields($this->id, $this->options, $settings, $this->args['closer']); // Icon ID $icon_id = !empty($this->args['icon']) ? $this->args['icon'] : str_replace('.php', '', $this->args['parent']); // Display any errors or update messages. settings_errors($this->id); ?> <div class="wrap"> <div class="admin-module-header"> <?php do_action('themeblvd_admin_module_header', 'options'); ?> </div> <?php screen_icon($icon_id); ?> <h2<?php if ($return[1]) { echo ' class="nav-tab-wrapper"'; } ?> > <?php if ($return[1]) { ?> <?php echo $return[1]; ?> <?php } else { ?> <?php echo $this->args['page_title']; ?> <?php } ?> </h2> <div class="metabox-holder"> <div id="optionsframework" class="tb-options-js"> <form id="themeblvd_options_page" action="<?php echo $this->args['form_action']; ?> " method="post"> <?php settings_fields($this->id); ?> <?php echo $return[0]; /* Settings */ ?> <div id="optionsframework-submit"> <input type="submit" class="button-primary" name="update" value="<?php esc_attr_e('Save Options', 'themeblvd'); ?> " /> <input type="submit" class="reset-button button-secondary" value="<?php esc_attr_e('Restore Defaults', 'themeblvd'); ?> " /> <input type="submit" class="clear-button button-secondary" value="<?php esc_attr_e('Clear Options', 'themeblvd'); ?> " /> <div class="clear"></div> </div> </form> <div class="tb-footer-text"> <?php do_action('themeblvd_options_footer_text'); ?> </div><!-- .tb-footer-text (end) --> </div><!-- #optionsframework (end) --> <div class="admin-module-footer"> <?php do_action('themeblvd_admin_module_footer', 'options'); ?> </div><!-- .admin-module-footer (end) --> </div><!-- .metabox-holder (end) --> </div><!-- .wrap (end) --> <?php }
/** * Generates interface to manage sidebar overrides * in meta box. * * @since 1.1.0 * * @param array $settings Optional current selections for generated form */ public function sidebar_overrides($settings = null) { global $post; // If the page is loading, we're going to be pulling // $settings from the meta data, but if this is being // sent from Ajax, we're most likely passing the // $settings in and we can skip this. if (!$settings) { $settings = get_post_meta($post->ID, '_tb_sidebars', true); } // For the meta box, if you want to show ALL widget // area locations, you'd change this to false. Most // people just want to use the fixed sidebars; so we // can save some clutter for the average person by // having this set to true. $fixed_only = apply_filters('themeblvd_sidebar_overrides_fixed_only', true); // Construct <select> of ALL custom widget areas. -- // Because this is our override meta box, we don't care // about the "location" and the user can just override // with whatever custom widget area they want. $custom_sidebars = get_posts('post_type=tb_sidebar&numberposts=-1'); $sidebars_select = array('default' => ' – ' . __('No Override', 'themeblvd_sidebars') . ' – '); foreach ($custom_sidebars as $sidebar) { $sidebars_select[$sidebar->post_name] = $sidebar->post_title; } // Setup options for sidebar locations $options = array(array('type' => 'info', 'desc' => __('Here you can select any custom widget areas you\'d like applied to the sidebars of this specific page. When utilizing this feature, current locations and assignments of your custom widget areas setup under <a href="themes.php?page=themeblvd_widget_areas">Appearance > Widget Areas</a> will be ignored.', 'themeblvd_sidebars'), 'class' => 'section-description')); $locations = themeblvd_get_sidebar_locations(); foreach ($locations as $location) { // If we're only doing fixed sidebars and this // isn't a fixed sidebar, move onto the next location. if ($fixed_only && $location['type'] != 'fixed') { continue; } // Add option for this location $options[] = array('name' => $location['location']['name'], 'desc' => sprintf(__('Select from any of your custom widget areas to override the %s location on this page only.', 'themeblvd_sidebars'), $location['location']['name']), 'id' => $location['location']['id'], 'type' => 'select', 'options' => $sidebars_select); } $options = apply_filters('themeblvd_sidebar_overrides', $options); // Build form $form = themeblvd_option_fields('_tb_sidebars', $options, $settings, false); // And spit it out $nonce = wp_create_nonce('themeblvd_sidebar_overrides'); echo '<input type="hidden" name="_tb_sidebar_overrides_nonce" value="' . $nonce . '" />'; echo $form[0]; }
/** * Display Meta Box * * @since 1.0.0 */ function themeblvd_ltp_display_meta_box() { global $post; // Current Value $value = get_post_meta($post->ID, '_tb_custom_layout', true); $settings = array('_tb_custom_layout' => $value); // Custom Layouts for options array $select = array('' => '-- ' . __('No Custom Templates', 'theme-blvd-layouts-to-posts') . ' --'); $layouts = get_posts('post_type=tb_layout&orderby=title&order=ASC&numberposts=-1'); if ($layouts) { $select = array('' => '-- ' . __('None', 'theme-blvd-layouts-to-posts') . ' --'); foreach ($layouts as $layout) { $select[$layout->post_name] = $layout->post_title; } } $options = array(array('id' => '_tb_placeholder', 'std' => 1, 'type' => 'hidden'), array('id' => '_tb_custom_layout', 'desc' => __('If you\'d like to replace this post with a template from the Layout Builder, you can select one from the dropdown menu.', 'theme-blvd-layouts-to-posts'), 'type' => 'select', 'options' => $select)); if (version_compare(TB_FRAMEWORK_VERSION, '2.5.0', '<')) { unset($options[0]); } // Start output echo '<div id="optionsframework" class="tb-meta-box side">'; // Display options form // @todo - After framework v2.2 is released, we can // clean this up and not to have to check for the // different functions, simply requiring the user // to update their theme. if (function_exists('themeblvd_option_fields')) { // Options form for TB framework v2.2+ $form = themeblvd_option_fields('themeblvd_ltp', $options, $settings, false); echo $form[0]; } else { if (function_exists('optionsframework_fields')) { // Options form for TB framework v2.0 - v2.1 $form = optionsframework_fields('themeblvd_ltp', $options, $settings, false); echo $form[0]; } } // End output echo '</div><!-- .tb-meta-box (end) -->'; }