/** * AJAX utility function for adding a new layout. */ public function add_layout() { echo ot_layout_view($_REQUEST['count']); die; }
function ot_type_modify_layouts() { echo '<form method="post" id="option-tree-settings-form">'; /* form nonce */ wp_nonce_field('option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce'); /* format setting outer wrapper */ echo '<div class="format-setting type-textarea has-desc">'; /* description */ echo '<div class="description">'; echo '<p>' . __('To add a new layout enter a unique lower case alphanumeric string (dashes allowed) in the text field and click "Save Layouts".', 'option-tree') . '</p>'; echo '<p>' . __('As well, you can activate, remove, and drag & drop the order; all situations require you to click "Save Layouts" for the changes to be applied.', 'option-tree') . '</p>'; echo '<p>' . __('When you create a new layout it will become active and any changes made to the Theme Options will be applied to it. If you switch back to a different layout immediately after creating a new layout that new layout will have a snapshot of the current Theme Options data attached to it.', 'option-tree') . '</p>'; if (OT_SHOW_DOCS) { echo '<p>' . __('Visit <code>OptionTree->Documentation->Layouts Overview</code> to see a more in-depth description of what layouts are and how to use them.', 'option-tree') . '</p>'; } echo '</div>'; echo '<div class="format-setting-inner">'; /* get the saved layouts */ $layouts = get_option(ot_layouts_id()); /* set active layout */ $active_layout = isset($layouts['active_layout']) ? $layouts['active_layout'] : ''; echo '<input type="hidden" name="' . ot_layouts_id() . '[active_layout]" value="' . esc_attr($active_layout) . '" class="active-layout-input" />'; /* add new layout */ echo '<input type="text" name="' . ot_layouts_id() . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />'; /* loop through each layout */ echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_layouts">'; if (is_array($layouts) && !empty($layouts)) { foreach ($layouts as $key => $data) { /* skip active layout array */ if ($key == 'active_layout') { continue; } /* content */ echo '<li class="ui-state-default list-layouts">' . ot_layout_view($key, $data, $active_layout) . '</li>'; } } echo '</ul>'; echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __('Save Layouts', 'option-tree') . '</button>'; echo '</div>'; echo '</div>'; echo '</form>'; }