function render_box($post) { $layout_data = apply_filters('it_storage_load_layout_settings', array()); $layouts = array('' => ''); foreach ((array) $layout_data['layouts'] as $layout => $layout_data) { $layouts[$layout] = $layout_data['description']; } if (!empty($GLOBALS['post_type']) && is_callable('get_post_type_object')) { $post_type = get_post_type_object($GLOBALS['post_type']); $type = $post_type->labels->singular_name; } else { $type = preg_match('|page[^/]+$|', $_SERVER['REQUEST_URI']) ? 'page' : 'post'; } $data = array(); if (isset($post->ID)) { $data['custom_layout'] = get_post_meta($post->ID, '_custom_layout', true); } $form = new ITForm($data, array('prefix' => $this->_var)); ?> <p><strong><?php _e('Select a Layout:', 'it-l10n-Builder-Paige'); ?> </strong></p> <p><?php $form->add_drop_down('custom_layout', $layouts); ?> </p> <p><?php printf(__('Choosing a Custom Builder Layout causes the chosen Layout to be used when viewing this %1$s. It will override any custom Views you have configured in the <a href="%2$s">Views Editor</a>.', 'it-l10n-Builder-Paige'), $type, admin_url('admin.php?page=layout-editor&editor_tab=views')); ?> </p> <?php $form->add_hidden('nonce', wp_create_nonce($this->_var)); }
function form($instance) { $instance = wp_parse_args((array) $instance, array('sidebar' => '')); $form = new ITForm($instance, array('widget_instance' => $this)); if (empty($this->_registered_sidebars)) { $this->_registered_sidebars = get_transient('it-cached-registered-sidebars'); } if (!is_array($this->_registered_sidebars)) { $this->_registered_sidebars = array(); } unset($this->_registered_sidebars['wp_inactive_widgets']); ?> <p> <label for="<?php echo $this->get_field_id('sidebar'); ?> "><?php _e('Sidebar to Duplicate:', 'it-l10n-Builder-Madison'); ?> </label><br /> <?php $form->add_drop_down('sidebar', $this->_registered_sidebars); ?> </p> <?php }
function add_widget_style_dropdown($args) { $styles = builder_get_widget_styles(); echo "<pre>Args: " . print_r($args, true) . "</pre>\n"; it_classes_load('it-form.php'); $form = new ITForm(); $description = apply_filters('builder_filter_widget_style_input_description', __('Your Builder child theme offers different widget styles. Select one from the drop down for a different look for this widget.', 'it-l10n-Builder-Madison') . '<br />'); ?> <p> <label><?php echo $description; ?> <?php $form->add_drop_down('it-style', $styles); ?> <br /></label> </p> <?php }
function run_import($settings = array(), $use_post_data = true, $return_data = false, $db_data = false) { $default_settings = array('data_sources' => array('layouts-views' => array('method' => 'add'), 'theme-settings' => array('method' => 'skip'))); $settings = ITUtility::merge_defaults($settings, $default_settings); if ($use_post_data) { $post_data = ITForm::get_post_data(true); $settings = ITUtility::merge_defaults($post_data, $settings); } it_classes_load('it-file-utility.php'); $info = $this->get_info(); $errors = array(); $results = array(); $attachments = $this->get_attachments(); $new_attachments = array(); foreach ((array) $attachments as $id => $file) { $attachment = ITFileUtility::add_to_media_library($file); $new_attachments[$id] = $attachment; } foreach ((array) $info['data_sources'] as $var => $data_source) { if (isset($this->_data_sources[$var])) { if (is_callable(array($this->_data_sources[$var], 'run_import'))) { if (!isset($settings['data_sources'][$var])) { $settings['data_sources'][$var] = array(); } else { if (isset($settings['data_sources'][$var]['method']) && 'skip' == $settings['data_sources'][$var]['method']) { continue; } } $db_settings = isset($db_data[$var]) ? $db_data[$var] : false; $result = $this->_data_sources[$var]->run_import($info['data_sources'][$var], $this->get_data($var), $settings['data_sources'][$var], $new_attachments, $return_data, $db_settings); if ($return_data) { $results[$var] = $result; } if (false === $result) { $errors[] = "{$var}:failed_run_import"; } } else { $errors[] = "{$var}:missing_run_import"; } } } if ($return_data) { return $results; } if (!empty($errors)) { return $errors; } return true; }
function _show_layouts_and_views_options() { $options = array('child_theme_type' => 'parent', 'theme_layouts' => 'ignore', 'theme_activation' => !empty($_REQUEST['theme_activation']) ? 1 : '', 'fresh_install' => !empty($_REQUEST['fresh_install']) ? 1 : '', 'step' => 'finish'); $logo_url = ITUtility::get_url_from_file(dirname(__FILE__) . '/images/builder-logo.png'); $old_theme = isset($GLOBALS['builder_old_theme']) ? $GLOBALS['builder_old_theme'] : false; $current_theme = wp_get_theme(); if ($old_theme && $old_theme->get_template() != $current_theme->get_template()) { $template_switch = true; } else { $template_switch = false; } $form = new ITForm($options); $this->_form =& $form; ?> <div class="wrap"> <?php $form->start_form(array('id' => 'it-builder-setup')); ?> <?php if (empty($_REQUEST['theme_activation'])) { ?> <?php ITUtility::screen_icon(); ?> <?php $this->_print_editor_tabs(); ?> <?php } ?> <div class="it-brochure-box"> <img class="it-logo" src="<?php echo $logo_url; ?> " alt="Builder Logo" /> <h1>Builder Setup</h1> <?php if ($template_switch) { ?> <p><?php _e('You are switching from a different Builder theme. Would you like to continue to use your current Layouts and Views? Or do you want to use the Layouts and Views included with this new theme?', 'it-l10n-Builder-Paige'); ?> </p> <div class="it-shrink-wrap-box"> <label><?php printf(__('%1$s Keep the site\'s current Layouts and Views', 'it-l10n-Builder-Paige'), $form->add_radio('theme_layouts', array('value' => 'ignore', 'class' => 'show-hide-toggle'))); ?> </label> <br /> <label><?php printf(__('%1$s Use the Layouts and Views included with the new theme', 'it-l10n-Builder-Paige'), $form->add_radio('theme_layouts', array('value' => 'use', 'class' => 'show-hide-toggle'))); ?> </label> <div class="it-options-theme_layouts it-options-theme_layouts-use"> <p class="description"><?php _e('Important: This option will replace your current Layouts and Views with the Layouts and Views provided by the theme.', 'it-l10n-Builder-Paige'); ?> </p> </div> <!-- <div class="it-indent-box it-options-theme_layouts it-options-theme_layouts-use"> <label><?php printf(__('%1$s Keep current Layouts', 'it-l10n-Builder-Paige'), $form->add_radio('layouts_import_method', 'add')); ?> </label> <br /> <label><?php printf(__('%1$s Remove current Layouts', 'it-l10n-Builder-Paige'), $form->add_radio('layouts_import_method', 'replace')); ?> </label> </div>--> </div> <?php } else { ?> <p><?php _e('Your theme provides a set of default Layouts and Views. You can update your site to match these provided Layouts and Views.', 'it-l10n-Builder-Paige'); ?> </p> <div class="it-shrink-wrap-box"> <label><?php printf(__('%1$s Keep the site\'s current Layouts and Views', 'it-l10n-Builder-Paige'), $form->add_radio('theme_layouts', array('value' => 'ignore', 'class' => 'show-hide-toggle'))); ?> </label> <br /> <label><?php printf(__('%1$s Use the Layouts and Views included with the theme', 'it-l10n-Builder-Paige'), $form->add_radio('theme_layouts', array('value' => 'use', 'class' => 'show-hide-toggle'))); ?> </label> <div class="it-options-theme_layouts it-options-theme_layouts-use"> <p class="description"><?php _e('Important: This option will replace your current Layouts and Views with the Layouts and Views provided by the theme.', 'it-l10n-Builder-Paige'); ?> </p> </div> <!-- <div class="it-indent-box it-options-theme_layouts it-options-theme_layouts-use"> <label><?php printf(__('%1$s Keep current Layouts', 'it-l10n-Builder-Paige'), $form->add_radio('layouts_import_method', 'add')); ?> </label> <br /> <label><?php printf(__('%1$s Remove current Layouts', 'it-l10n-Builder-Paige'), $form->add_radio('layouts_import_method', 'replace')); ?> </label> </div>--> </div> <?php } ?> <div class="it-input-set"> <div class="it-options-theme_layouts it-options-theme_layouts-ignore"> <?php $form->add_submit('update_layouts_and_views', array('value' => 'Keep current Layouts and Views')); ?> </div> <div class="it-options-theme_layouts it-options-theme_layouts-use"> <?php $form->add_submit('update_layouts_and_views', array('value' => 'Update Layouts and Views')); ?> </div> <p><a class="it-skip" href="<?php echo admin_url('admin.php?page=ithemes-builder-theme'); ?> "><?php _e('Skip'); ?> </a></p> </div> </div> <?php $form->add_hidden('theme_activation'); ?> <?php $form->add_hidden('fresh_install'); ?> <?php $form->add_hidden('step'); ?> <?php $form->add_hidden_no_save('editor_tab', $this->_parent->_active_tab); ?> <?php $form->end_form(); ?> </div> <?php }
function run_import() { ITForm::check_nonce("import_run_guid_{$_REQUEST['guid']}"); require_once dirname(__FILE__) . '/class.builder-import-export.php'; $import = new BuilderImportExport($_REQUEST['guid']); $result = $import->run_import(); $errors = ''; if (is_array($result)) { $errors = '&errors=' . implode(',', $result); } $redirect = "{$this->_parent->_self_link}&imported={$_REQUEST['guid']}{$errors}"; // echo "<p>Redirect: $redirect</p>\n"; wp_redirect($redirect); exit; }
function _get_simple_input($var, $options, $override_value) { if (empty($options['type'])) { return "<!-- _get_simple_input called without a type option set. -->\n"; } $scrublist['textarea']['value'] = true; $scrublist['file']['value'] = true; $scrublist['dropdown']['value'] = true; $scrublist['dropdown']['type'] = true; $defaults = array(); if (isset($this->_args['widget_instance']) && @method_exists($this->_args['widget_instance'], 'get_field_name')) { $defaults['name'] = $this->_args['widget_instance']->get_field_name($var); } else { if (empty($this->_args['prefix'])) { $defaults['name'] = $var; } else { $defaults['name'] = "{$this->_args['prefix']}-{$var}"; } } $input_group_name = $defaults['name']; $var = str_replace('[]', '', $var); $clean_var = trim(preg_replace('/[^a-z0-9_]+/i', '-', $var), '-'); if (!empty($this->_input_group)) { if (false === strpos($defaults['name'], '[')) { $defaults['name'] = "[{$defaults['name']}]"; } else { $defaults['name'] = preg_replace('/^([^\\[]+)\\[/', '[$1][', $defaults['name']); } $input_group_name = $defaults['name']; $defaults['name'] = "{$this->_input_group}{$defaults['name']}"; $clean_var = trim(preg_replace('/[^a-z0-9_]+/i', '-', $defaults['name']), '-'); } if (isset($this->_args['widget_instance']) && @method_exists($this->_args['widget_instance'], 'get_field_id')) { $defaults['id'] = $this->_args['widget_instance']->get_field_id($var); } else { $defaults['id'] = $clean_var; } if (!empty($options['append_val_to_id']) && true === $options['append_val_to_id'] && !empty($options['value'])) { unset($options['append_val_to_id']); $defaults['id'] .= '-' . trim(preg_replace('/[^a-z0-9_]+/i', '-', $options['value']), '-'); } $options = ITUtility::merge_defaults($options, $defaults); if (false === $override_value && isset($this->_options[$var])) { if (in_array($options['type'], array('checkbox', 'radio'))) { if (is_array($this->_options[$var]) && in_array($options['value'], $this->_options[$var]) || !is_array($this->_options[$var]) && (string) $this->_options[$var] === (string) $options['value']) { $options['checked'] = 'checked'; } } else { if ('dropdown' !== $options['type']) { $options['value'] = $this->_options[$var]; } } } if (!empty($this->_args['prefix']) && preg_match("|^{$this->_args['prefix']}-|", $options['name']) || empty($this->_args['prefix'])) { if (!isset($this->_used_inputs[$this->_input_group]) || !in_array($input_group_name, $this->_used_inputs[$this->_input_group])) { $this->_used_inputs[$this->_input_group][] = $input_group_name; } } $attributes = ''; if (false !== $options) { foreach ((array) $options as $name => $val) { if (!is_array($val) && (!isset($scrublist[$options['type']][$name]) || true !== $scrublist[$options['type']][$name])) { if ('value' == $name) { $val = ITForm::esc_value_attr($val); } else { if (!in_array($options['type'], array('submit', 'button'))) { $val = esc_attr($val); } } $attributes .= "{$name}=\"{$val}\" "; } } } $retval = ''; if ('textarea' === $options['type']) { if (!isset($options['value'])) { $options['value'] = ''; } $retval = "<textarea {$attributes} >" . ITForm::esc_value_attr($options['value']) . '</textarea>'; } else { if ('dropdown' === $options['type']) { $retval = "<select {$attributes}>\n"; if (isset($options['value']) && is_array($options['value'])) { foreach ((array) $options['value'] as $val => $name) { if (is_array($name)) { $options = $name; if (preg_match('/^__optgroup_\\d+$/', $val)) { $retval .= "<optgroup class='it-classes-optgroup-separator'>\n"; } else { $retval .= "<optgroup label='" . esc_attr($val) . "'>\n"; } foreach ((array) $options as $val => $name) { $selected = isset($this->_options[$var]) && (string) $this->_options[$var] === (string) $val ? ' selected="selected"' : ''; $retval .= "<option value=\"" . ITForm::esc_value_attr($val) . "\"{$selected}>{$name}</option>\n"; } $retval .= "</optgroup>\n"; } else { $selected = isset($this->_options[$var]) && (string) $this->_options[$var] === (string) $val ? ' selected="selected"' : ''; $retval .= "<option value=\"" . ITForm::esc_value_attr($val) . "\"{$selected}>{$name}</option>\n"; } } } $retval .= "</select>\n"; } else { $retval = '<input ' . $attributes . '/>'; } } return $retval; }
function _add_module_fields($module, $id, $position) { if (!isset($this->_modules[$module['module']])) { return; } $defaults = $this->_modules[$module['module']]->get_defaults(); $data = array_merge($defaults, $module['data']); $form = new ITForm($data, array('prefix' => "module-{$id}")); $layout_option = $this->_modules[$module['module']]->get_layout_option(); $preview_image_url = $this->_modules[$module['module']]->get_preview_image($data); ?> <tr class="module-row" id="module-<?php echo $id; ?> "> <td class="preview-container"> <div id="module-<?php echo $id; ?> -preview" class="module-<?php echo $this->_modules[$module['module']]->_var; ?> "> <?php if (!empty($preview_image_url)) { ?> <img src="<?php echo $preview_image_url; ?> " /> <?php } ?> </div> </td> <td> <h4 class="module-name"> <span class="module-name"> <?php if (isset($module['data']['name'])) { ?> <?php echo $data['name']; ?> <?php } else { ?> <?php echo $this->_modules[$module['module']]->_name; ?> <?php } ?> </span> </h4> <div class="row-actions module-links"></div> <?php foreach ((array) $data as $var => $val) { $value_array = array('value' => $val); if ($var === $layout_option) { $value_array['class'] = 'layout-option'; } $form->add_hidden($var, $value_array); echo "\n"; } unset($form->_args['prefix']); ?> <?php $form->add_hidden("position-{$id}", array('value' => $position, 'class' => 'module-position')); ?> <?php $form->add_hidden("module-{$id}", array('value' => $module['module'], 'class' => 'module-var')); ?> <?php if (isset($module['guid'])) { $form->add_hidden("module-guid-{$id}", $module['guid']); } ?> </td> </tr> <?php return true; }
function _editor() { if (isset($_REQUEST['updated'])) { ITUtility::show_status_message('Theme Settings Updated'); } if (isset($_REQUEST['errors'])) { $error_codes = explode(',', $_REQUEST['errors']); foreach ((array) $error_codes as $code) { $message = get_transient("it_bt_{$code}"); if (false != $message) { ITUtility::show_error_message($message); } } } $this->_set_option_defaults(); $form = new ITForm($this->_options); $this->_form =& $form; ?> <div class="wrap"> <?php $form->start_form(); ?> <?php ITUtility::screen_icon(); ?> <?php $this->_print_editor_tabs(); ?> <p><?php _e('For information about this page, please click the "Help" button at the top right.', 'it-l10n-Builder-Cohen'); ?> </p> <?php $this->_print_meta_boxes($form); ?> <p class="submit"> <?php $form->add_submit('save', array('value' => 'Save Settings', 'class' => 'button-primary')); ?> <?php //$form->add_submit( 'reset', array( 'value' => 'Restore Default Settings', 'class' => 'button-secondary', 'onClick' => "return confirm('Restoring default settings will reset all Builder settings. The layouts and views will not be reset. Are you sure that you want to restore all of Builder\'s settings to default values?');" ) ); ?> </p> <?php $form->add_hidden_no_save('editor_tab', $this->_parent->_active_tab); ?> <?php $form->end_form(); ?> <form style="display:none" method="get" action=""> <p> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> </p> </form> </div> <?php $this->_init_meta_boxes(); }
function form($instance) { $defaults = array('title' => '', 'entry_id' => '', 'style' => ''); $instance = wp_parse_args((array) $instance, $defaults); $form = new ITForm($instance, array('widget_instance' => $this)); $posts = get_posts(array('post_type' => 'widget_content', 'numberposts' => '1000')); $entries = array(); foreach ((array) $posts as $post) { $title = $post->post_title; if (strlen($title) > 80) { $title = substr($title, 0, 80) . '...'; } $entries[$post->ID] = $title; } asort($entries); $styles = builder_get_widget_styles(); if (!empty($styles)) { $styles = array_merge(array('' => 'Default'), $styles); } ?> <?php if (!empty($entries)) { ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'it-l10n-Builder-Madison'); ?> </label> <?php $form->add_text_box('title', array('class' => 'widefat')); ?> </p> <p> <label for="<?php echo $this->get_field_id('entry_id'); ?> "><?php _e('Widget Content Entry:', 'it-l10n-Builder-Madison'); ?> </label><br /> <?php $form->add_drop_down('entry_id', $entries); ?> </p> <?php if (!empty($styles)) { ?> <p> <label for="<?php echo $this->get_field_id('style'); ?> "><?php _e('Widget Style:', 'it-l10n-Builder-Madison'); ?> </label><br /> <?php $form->add_drop_down('style', $styles); ?> </p> <?php } else { ?> <?php $form->add_hidden('style'); ?> <?php } ?> <p> <em>Note: Use the <a href="<?php echo admin_url('edit.php?post_type=widget_content'); ?> ">Widget Content editor</a> to manage content for the Widget Content widgets.</em> </p> <?php } else { ?> <p> This widget allows you to easily add advanced content to a sidebar. </p> <p> Currently, your site doesn't have any Widget Content entries. Use the <a href="<?php echo admin_url('edit.php?post_type=widget_content'); ?> ">Widget Content editor</a> to create new entries. Once you have created one or more new Widget Content entries, edit this widget again to select the desired entry and customize the widget. </p> <?php $form->add_hidden('title'); ?> <?php $form->add_hidden('entry_id'); ?> <?php $form->add_hidden('style'); ?> <?php } }
function save_meta_box_options($post_id) { // Skip if the nonce check fails if (!isset($_POST["{$this->_var}-nonce"]) || !wp_verify_nonce($_POST["{$this->_var}-nonce"], $this->_var)) { return; } // Don't save or update on autosave if (defined('DOING_AUTOSAVE') && true === DOING_AUTOSAVE) { return; } // Only allow those with permissions to modify the type to save/update a layout if (!current_user_can('edit_post', $post_id)) { return; } // Save/update options $options = ITForm::parse_values($_POST, array('prefix' => $this->_var)); unset($options['nonce']); if (method_exists($this, 'validate_meta_box_options')) { $options = $this->validate_meta_box_options($options, $post_id); } update_post_meta($post_id, '_it_options', $options); }
function form($instance) { $defaults = array('show_site_title' => '1', 'custom_site_title' => '', 'site_title_tag' => 'div', 'home_title_tag' => 'h1', 'show_tagline' => '1', 'custom_tagline' => '', 'site_tagline_tag' => 'div', 'home_tagline_tag' => 'div'); $instance = wp_parse_args((array) $instance, $defaults); $form = new ITForm($instance, array('widget_instance' => $this)); $use_default_tag_settings_options = array('1' => __('Yes'), '' => __('No, use custom tag settings', 'it-l10n-Builder-Paige')); $generic_tag_options = array('div' => '<div> (Recommended)', 'h1' => '<h1> (Not Recommended)', 'h2' => '<h2>', 'h3' => '<h3>', 'h4' => '<h4>', 'h5' => '<h5>', 'h6' => '<h6>'); $home_title_tag_options = array('div' => '<div>', 'h1' => '<h1> (Recommended)'); $home_title_tag_options = array_merge($generic_tag_options, $home_title_tag_options); foreach ($generic_tag_options as $tag => $description) { $generic_tag_options[$tag] = htmlentities($description); } foreach ($home_title_tag_options as $tag => $description) { $home_title_tag_options[$tag] = htmlentities($description); } $styles = builder_get_widget_styles(); if (!empty($styles)) { $styles = array_merge(array('' => 'Default'), $styles); } ?> <p> <label for="<?php echo $this->get_field_id('show_site_title'); ?> "><?php printf(__('Show Site Title (configured in <a href="%s">Settings > General</a>):', 'it-l10n-Builder-Paige'), admin_url('options-general.php')); ?> </label><br /> <?php $form->add_yes_no_drop_down('show_site_title'); ?> </p> <p> <label for="<?php echo $this->get_field_id('custom_site_title'); ?> "><?php _e('Customize Site Title (leave blank for default Site Title):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_text_box('custom_site_title'); ?> </p> <p> <label for="<?php echo $this->get_field_id('show_tagline'); ?> "><?php printf(__('Show Tagline (configured in <a href="%s">Settings > General</a>):', 'it-l10n-Builder-Paige'), admin_url('options-general.php')); ?> </label><br /> <?php $form->add_yes_no_drop_down('show_tagline'); ?> </p> <p> <label for="<?php echo $this->get_field_id('custom_tagline'); ?> "><?php _e('Customize Tagline (leave blank for default Tagline):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_text_box('custom_tagline'); ?> </p> <p> <label for="<?php echo $this->get_field_id('home_title_tag'); ?> "><?php _e('Site Title tag (when on the home page):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('home_title_tag', $home_title_tag_options); ?> </p> <p> <label for="<?php echo $this->get_field_id('home_tagline_tag'); ?> "><?php _e('Tagline tag (when on the home page):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('home_tagline_tag', $generic_tag_options); ?> </p> <p> <label for="<?php echo $this->get_field_id('site_title_tag'); ?> "><?php _e('Site Title tag (on other site views):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('site_title_tag', $generic_tag_options); ?> </p> <p> <label for="<?php echo $this->get_field_id('site_tagline_tag'); ?> "><?php _e('Tagline tag (on other site views):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('site_tagline_tag', $generic_tag_options); ?> </p> <?php if (!empty($styles)) { ?> <p> <label for="<?php echo $this->get_field_id('style'); ?> "><?php _e('Widget Style:', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('style', $styles); ?> </p> <?php } else { ?> <?php $form->add_hidden('style'); ?> <?php } }
function post_box_index() { global $post; $form = new ITForm($this->_parse_meta_box_data($post->ID)); $robots = array('' => '', 'index,follow' => 'index, follow', 'noindex,follow' => 'noindex, follow', 'index,nofollow' => 'index, nofollow', 'noindex,nofollow' => 'noindex, nofollow'); ?> <dl> <?php if (!empty($this->_options["enable_custom_titles_{$post->post_type}s"])) { ?> <dt><label for='<?php echo "{$this->_var}_title"; ?> '>Title</label></dt> <dd><?php $form->add_text_box("{$this->_var}_title", array('style' => 'width:350px;')); ?> </dd> <?php } ?> <?php if (!empty($this->_options["enable_custom_descriptions_{$post->post_type}s"])) { ?> <dt><label for='<?php echo "{$this->_var}_description"; ?> '>Description (max 150 characters)</label></dt> <dd><?php $form->add_text_area("{$this->_var}_description", array('style' => 'width:350px;')); ?> </dd> <?php } ?> <?php if (!empty($this->_options["enable_custom_robots_{$post->post_type}s"])) { ?> <dt><label for='<?php echo "{$this->_var}_robots"; ?> '>Robots</label></dt> <dd><?php $form->add_drop_down("{$this->_var}_robots", $robots); ?> </dd> <?php } ?> <?php if (!empty($this->_options["enable_custom_keywords_{$post->post_type}s"])) { ?> <dt><label for='<?php echo "{$this->_var}_keywords"; ?> '>Keywords (comma separated list)</label></dt> <dd><?php $form->add_text_box("{$this->_var}_keywords", array('style' => 'width:350px;')); ?> </dd> <?php } ?> </dl> <?php $form->add_hidden("{$this->_var}_save", '1'); ?> <?php $form->add_hidden("{$this->_var}_nonce", wp_create_nonce(plugin_basename(__FILE__))); }
/** * Save settings. * * @since 1.0 */ function save_settings() { $defaults = it_exchange_get_option('addon_itelic'); $new_values = wp_parse_args(\ITForm::get_post_data(), $defaults); // Check nonce if (!wp_verify_nonce($_POST['_wpnonce'], 'it-exchange-itelic-settings')) { $this->error_message = __('Error. Please try again', Plugin::SLUG); return; } /** * Filter the settings errors before saving. * * @since 1.0 * * @param string[] $errors Errors * @param array $new_values Mixed */ $errors = apply_filters('it_exchange_add_on_itelic_validate_settings', $this->get_form_errors($new_values), $new_values); if (!$errors && it_exchange_save_option('addon_itelic', $new_values)) { $this->status_message = __('Settings saved.', Plugin::SLUG); } else { if ($errors) { $errors = implode('<br />', $errors); $this->error_message = $errors; } else { $this->error_message = __('Settings not saved.', Plugin::SLUG); } } }
function index() { if (!current_user_can($this->_access_level)) { die(__('Cheatin’ uh?')); } // This needs to be modified to not allow an attacker to bypass it. // Possibly do a check to see if $_POST is not empty. if (!empty($_REQUEST['_wpnonce'])) { ITForm::check_nonce(!empty($this->_nonce) ? $this->_nonce : null); } ITUtility::cleanup_request_vars(); }