function __construct() { // Don't allow more than one instance of the class if (isset(self::$_this)) { wp_die(sprintf(__('%s is a singleton class and you cannot create a second instance.', 'bloom'), get_class($this))); } self::$_this = $this; $this->protocol = is_ssl() ? 'https' : 'http'; add_action('admin_menu', array($this, 'add_menu_link')); add_action('plugins_loaded', array($this, 'add_localization')); add_filter('et_bloom_import_sub_array', array($this, 'import_settings')); add_filter('et_bloom_import_array', array($this, 'import_filter')); add_filter('et_bloom_export_exclude', array($this, 'filter_export_settings')); add_filter('et_bloom_save_button_class', array($this, 'save_btn_class')); // generate home tab in dashboard add_action('et_bloom_after_header_options', array($this, 'generate_home_tab')); add_action('et_bloom_after_main_options', array($this, 'generate_premade_templates')); add_action('et_bloom_after_save_button', array($this, 'add_next_button')); $plugin_file = plugin_basename(__FILE__); add_filter("plugin_action_links_{$plugin_file}", array($this, 'add_settings_link')); $dashboard_args = array('et_dashboard_options_pagename' => $this->_options_pagename, 'et_dashboard_plugin_name' => 'bloom', 'et_dashboard_save_button_text' => __('Save & Exit', 'bloom'), 'et_dashboard_plugin_class_name' => 'et_bloom', 'et_dashboard_options_path' => ET_BLOOM_PLUGIN_DIR . '/dashboard/includes/options.php', 'et_dashboard_options_page' => 'toplevel_page'); parent::__construct($dashboard_args); // Register save settings function for ajax request add_action('wp_ajax_et_bloom_save_settings', array($this, 'bloom_save_settings')); add_action('admin_enqueue_scripts', array($this, 'register_scripts')); add_action('wp_enqueue_scripts', array($this, 'load_scripts_styles')); add_action('wp_ajax_reset_options_page', array($this, 'reset_options_page')); add_action('wp_ajax_bloom_remove_optin', array($this, 'remove_optin')); add_action('wp_ajax_bloom_duplicate_optin', array($this, 'duplicate_optin')); add_action('wp_ajax_bloom_add_variant', array($this, 'add_variant')); add_action('wp_ajax_bloom_home_tab_tables', array($this, 'home_tab_tables')); add_action('wp_ajax_bloom_toggle_optin_status', array($this, 'toggle_optin_status')); add_action('wp_ajax_bloom_authorize_account', array($this, 'authorize_account')); add_action('wp_ajax_bloom_reset_accounts_table', array($this, 'reset_accounts_table')); add_action('wp_ajax_bloom_generate_mailing_lists', array($this, 'generate_mailing_lists')); add_action('wp_ajax_bloom_generate_new_account_fields', array($this, 'generate_new_account_fields')); add_action('wp_ajax_bloom_generate_accounts_list', array($this, 'generate_accounts_list')); add_action('wp_ajax_bloom_generate_current_lists', array($this, 'generate_current_lists')); add_action('wp_ajax_bloom_generate_edit_account_page', array($this, 'generate_edit_account_page')); add_action('wp_ajax_bloom_save_account_tab', array($this, 'save_account_tab')); add_action('wp_ajax_bloom_ab_test_actions', array($this, 'ab_test_actions')); add_action('wp_ajax_bloom_get_stats_graph_ajax', array($this, 'get_stats_graph_ajax')); add_action('wp_ajax_bloom_refresh_optins_stats_table', array($this, 'refresh_optins_stats_table')); add_action('wp_ajax_bloom_reset_stats', array($this, 'reset_stats')); add_action('wp_ajax_bloom_pick_winner_optin', array($this, 'pick_winner_optin')); add_action('wp_ajax_bloom_clear_stats', array($this, 'clear_stats')); add_action('wp_ajax_bloom_get_premade_values', array($this, 'get_premade_values')); add_action('wp_ajax_bloom_generate_premade_grid', array($this, 'generate_premade_grid')); add_action('wp_ajax_bloom_display_preview', array($this, 'display_preview')); add_action('wp_ajax_bloom_handle_stats_adding', array($this, 'handle_stats_adding')); add_action('wp_ajax_nopriv_bloom_handle_stats_adding', array($this, 'handle_stats_adding')); add_action('wp_ajax_bloom_subscribe', array($this, 'subscribe')); add_action('wp_ajax_nopriv_bloom_subscribe', array($this, 'subscribe')); add_action('widgets_init', array($this, 'register_widget')); add_action('after_setup_theme', array($this, 'register_image_sizes')); add_shortcode('et_bloom_inline', array($this, 'display_inline_shortcode')); add_shortcode('et_bloom_locked', array($this, 'display_locked_shortcode')); add_filter('body_class', array($this, 'add_body_class')); register_activation_hook(__FILE__, array($this, 'activate_plugin')); register_deactivation_hook(__FILE__, array($this, 'deactivate_plugin')); add_action('bloom_lists_auto_refresh', array($this, 'perform_auto_refresh')); add_action('bloom_stats_auto_refresh', array($this, 'perform_stats_refresh')); $this->frontend_register_locations(); foreach (array('post.php', 'post-new.php') as $hook) { add_action("admin_head-{$hook}", array($this, 'tiny_mce_vars')); add_action("admin_head-{$hook}", array($this, 'add_mce_button_filters')); } }
function construct_dashboard() { $dashboard_args = array('et_dashboard_options_pagename' => $this->_options_pagename, 'et_dashboard_plugin_name' => 'bloom', 'et_dashboard_save_button_text' => __('Save & Exit', 'bloom'), 'et_dashboard_plugin_class_name' => 'et_bloom', 'et_dashboard_options_path' => ET_BLOOM_PLUGIN_DIR . '/dashboard/includes/options.php', 'et_dashboard_options_page' => 'toplevel_page'); parent::__construct($dashboard_args); }
/** * Generates dashboard page based on the options from options.php file. * Supports following hooks: * 'et_<plugin_name>_after_main_options' * 'et_<plugin_name>_after_header_options' * 'et_<plugin_name>_after_save_button' * 'et_<plugin_name>_header_start' * 'et_<plugin_name>_header_end' * * @return array */ function generate_options_page($sub_array = '') { $this->dashboard_options = $this->get_options_array(); $dashboard_options = $this->dashboard_options; $dashboard_sections = $this->dashboard_sections; $dashboard_options_assigned = $this->assigned_options; $dashboard_post_types = $this->dashboard_post_types; $dashboard_categories = $this->dashboard_categories; printf('<div id="et_dashboard_wrapper_outer" class="%1$s"> <div id="et_dashboard_wrapper" class="et_dashboard"> <div id="et_dashboard_header"> <div id="et_dashboard_logo" class="et_dashboard_icon_%2$s et_dashboard_icon"></div> <ul>', esc_attr($this->plugin_class_name), esc_attr($this->plugin_name)); if (isset($dashboard_sections['header']['contents'])) { foreach ($dashboard_sections['header']['contents'] as $key => $value) { printf('<li class="et_dashboard_tab_content_header_%1$s"> <a href="#tab_et_dashboard_tab_content_header_%1$s" id="et_dashboard_tab_content_header_%1$s" class="et_dashboard_icon_header_%1$s et_dashboard_icon"> <span></span> </a> </li>', esc_attr($key)); } } echo ' </ul> </div> <div class="clearfix"></div> <div id="et_dashboard_navigation"> <ul>'; $menu_count = 0; if (isset($dashboard_sections)) { foreach ($dashboard_sections as $key => $value) { if ($key !== 'header') { $current_section = $key; foreach ($value as $key => $value) { if ($key == 'title') { printf('<li class="et_dashboard_tab_content_side_%1$s"> <a href="#" class="et_dashboard_icon_%1$s et_dashboard_icon et_dashboard_tab_parent"> <span>%2$s</span> </a>', esc_attr($current_section), esc_html($value)); } else { printf('<ul class="et_dashboard_%1$s_nav">', esc_attr($current_section)); foreach ($value as $key => $value) { printf('<li class="et_dashboard_tab_content_side_%2$s"> <a href="#tab_et_dashboard_tab_content_%1$s_%2$s" id="et_dashboard_tab_content_%1$s_%2$s" class="et_dashboard_icon_%2$s et_dashboard_icon"> <span>%3$s</span> </a> </li>', esc_attr($current_section), esc_attr($key), esc_html($value)); } echo ' </ul> </li>'; } // end else } // end foreach( $value as $key => $value ) } // end if ( $key !== 'header') } //end foreach ( $dashboard_sections as $key => $value ) } // end if ( isset( $dashboard_sections ) ) echo ' </ul> </div> <div id="et_dashboard_content"> <form id="et_dashboard_options" enctype="multipart/form-data">'; settings_fields('et_dashboard_settings_group'); if (isset($dashboard_sections)) { foreach ($dashboard_sections as $key => $value) { $current_section = $key; if ($key !== 'header') { foreach ($value['contents'] as $key => $value) { $current_location = $key; $options_prefix = $current_section . '_' . $key; $options_array = $dashboard_options_assigned[$current_section . '_' . $key . '_options']; $sidebar_section = 'sidebar' == $key ? true : false; printf('<div class="et_dashboard_tab_content et_dashboard_tab_content_%1$s_%2$s">', esc_attr($current_section), esc_attr($key)); foreach ($options_array as $option) { $current_option_name = ''; $hint_output = ''; if (isset($option['name'])) { if ('' !== $sub_array) { $current_option_name = $option['name']; } else { $current_option_name = $options_prefix . '_' . $option['name']; } } if ('' !== $sub_array) { $current_option_value = isset($dashboard_options[$sub_array][$current_option_name]) ? $dashboard_options[$sub_array][$current_option_name] : ''; if (!isset($dashboard_options[$sub_array][$current_option_name]) && isset($option['default'])) { $current_option_value = isset($option['default_' . $current_location]) ? $option['default_' . $current_location] : $option['default']; } } else { $current_option_value = isset($dashboard_options[$current_option_name]) ? $dashboard_options[$current_option_name] : ''; if (!isset($dashboard_options[$current_option_name]) && isset($option['default'])) { $current_option_value = isset($option['default_' . $current_location]) ? $option['default_' . $current_location] : $option['default']; } } if (isset($option['hint_text'])) { $escape = isset($option['hint_text_with_links']) ? (bool) true : (bool) false; $hint_output = $this->generate_hint($option['hint_text'], $escape); } switch ($option['type']) { case 'select_shape': printf('<div class="et_dashboard_row et_dashboard_selection%2$s%4$s"%3$s%5$s> <h2>%1$s</h2> <div style="clear:both;"></div>', esc_html($option['title']), isset($option['display_if']) ? ' et_dashboard_hidden_option' : '', isset($option['display_if']) ? ' data-condition="' . esc_attr($option['display_if']) . '"' : '', isset($option['class']) ? ' ' . esc_attr($option['class']) : '', isset($option['display_if']) ? ' data-triggers_count="0"' : ''); foreach ($option['value'] as $shape) { printf('<div class="et_dashboard_shape et_dashboard_icon et_dashboard_single_selectable %1$s"> <div class="et_dashboard_shape_tile et_dashboard_icon et_dashboard_shape_%2$s"></div> <input type="radio" class="et_dashboard[%3$s]" name="et_dashboard[%3$s]" value="%2$s" %4$s style="position: absolute; z-index: -1; visibility: hidden;"> </div>', $shape === $current_option_value ? 'et_dashboard_selected' : '', esc_attr($shape), esc_attr($current_option_name), checked($current_option_value, $shape, false)); } echo '</div>'; break; case 'select': $current_option_list = isset($option['value_' . $current_location]) ? $option['value_' . $current_location] : $option['value']; if (isset($option['filter'])) { $current_option_list = apply_filters($option['filter'], $current_option_list); } printf('<li class="select%3$s%5$s%7$s"%4$s%6$s%8$s> <p>%1$s</p> <select name="et_dashboard[%2$s]">', isset($option['title_' . $current_location]) ? esc_html($option['title_' . $current_location]) : esc_html($option['title']), esc_attr($current_option_name), isset($option['display_if']) ? ' et_dashboard_hidden_option et_dashboard_triggered_option' : '', isset($option['display_if']) ? ' data-condition="' . esc_attr($option['display_if']) . '"' : '', isset($option['conditional']) ? ' et_dashboard_conditional' : '', isset($option['conditional']) ? sprintf(' data-enables="%1$s"', '' !== $sub_array ? esc_attr($option['conditional']) : esc_attr($options_prefix . '_' . $option['conditional'])) : '', isset($option['class']) ? ' ' . esc_attr($option['class']) : '', isset($option['display_if']) ? ' data-triggers_count="0"' : ''); foreach ($current_option_list as $actual_value => $display_value) { printf('<option value="%1$s" %2$s>%3$s</option>', esc_attr($actual_value), selected($actual_value, $current_option_value, false), esc_html($display_value)); } echo ' </select>'; echo $hint_output; echo ' </li>'; break; case 'checkbox': printf(' <li class="et_dashboard_checkbox clearfix%5$s%6$s%9$s"%4$s%7$s%8$s> <p>%1$s</p> <input type="checkbox" id="et_dashboard[%2$s]" name="et_dashboard[%2$s]" value="1" %3$s> <label for="et_dashboard[%2$s]"></label>', isset($option['title_' . $current_location]) ? esc_html($option['title_' . $current_location]) : esc_html($option['title']), esc_attr($current_option_name), checked($current_option_value, 1, false), isset($option['conditional']) ? sprintf(' data-enables="%1$s"', '' !== $sub_array ? esc_attr($option['conditional']) : esc_attr($options_prefix . '_' . $option['conditional'])) : '', isset($option['conditional']) ? ' et_dashboard_conditional' : '', isset($option['display_if']) ? ' et_dashboard_hidden_option et_dashboard_triggered_option' : '', isset($option['display_if']) ? ' data-condition="' . esc_attr($option['display_if']) . '"' : '', isset($option['display_if']) ? ' data-triggers_count="0"' : '', isset($option['class']) ? ' ' . esc_attr($option['class']) : ''); echo $hint_output; echo ' </li>'; break; case 'checkbox_set': $checkboxes_array = isset($option['value']) ? $option['value'] : array(); $current_option_value = isset($current_option_value) ? $current_option_value : array(); if (!empty($checkboxes_array)) { $i = 0; foreach ($checkboxes_array as $value => $label) { printf(' <li class="et_dashboard_checkbox%6$s%8$s"%7$s> <input type="checkbox" id="et_dashboard[%1$s][%4$s]" name="et_dashboard[%1$s][]" value="%3$s" %2$s> <label for="et_dashboard[%1$s][%4$s]"></label> <p>%5$s</p> </li>', esc_attr($current_option_name), checked(in_array($value, $current_option_value), true, false), esc_attr($value), esc_attr($i), esc_attr($label), isset($option['conditional'][$value]) ? ' et_dashboard_conditional' : '', isset($option['conditional'][$value]) ? sprintf(' data-enables="%1$s"', esc_attr($option['conditional'][$value])) : '', isset($option['class']) ? ' ' . esc_attr($option['class']) . ' ' . esc_attr($option['class']) . '_' . esc_attr($value) : ''); $i++; } } break; case 'input_field': printf('<li class="input clearfix%4$s%7$s"%5$s%10$s> <p>%1$s</p> <input type="%9$s" name="et_dashboard[%2$s]" value="%3$s" placeholder="%6$s"%8$s>', isset($option['title_' . $current_location]) ? esc_html($option['title_' . $current_location]) : esc_html($option['title']), esc_attr($current_option_name), esc_attr($current_option_value), isset($option['display_if']) ? ' et_dashboard_hidden_option' : '', isset($option['display_if']) ? ' data-condition="' . esc_attr($option['display_if']) . '"' : '', 'number' == $option['subtype'] ? '0' : $option['placeholder'], 'text' == $option['subtype'] ? ' et_dashboard_longinput' : '', isset($option['class']) ? sprintf(' class="%1$s"', esc_attr($option['class'])) : '', isset($option['hide_contents']) ? 'password' : 'text', isset($option['display_if']) ? ' data-triggers_count="0"' : ''); echo $hint_output; echo ' </li>'; break; case 'checkbox_posts': echo ' <li> <ul class="inline">'; $i = 0; $current_option_value = '' == $current_option_value ? array() : $current_option_value; $checkbox_array = 'post_types' === $option['subtype'] ? $dashboard_post_types : $dashboard_categories['post']; $post_types = !empty($option['value']) ? $option['value'] : $checkbox_array; $array_of_saved_cats = isset($current_option_value['previously_saved']) ? explode(',', $current_option_value['previously_saved']) : array(); foreach ($post_types as $post_type => $id) { if ('post_cats' === $option['subtype']) { if (!isset($current_option_value['previously_saved'])) { $is_checked = true; } else { if (isset($current_option_value['auto_select']) && '1' === $current_option_value['auto_select']) { $is_checked = !in_array($post_type, $array_of_saved_cats) ? true : in_array($post_type, $current_option_value); } else { $is_checked = in_array($post_type, $current_option_value); } } } $conditional_class = ''; $conditional_data = ''; if ('post_types' === $option['subtype']) { if (isset($option['conditional']['any_post']) && 'page' !== $id) { $conditional_class = ' et_dashboard_conditional'; $conditional_data = sprintf(' data-enables="%1$s"', esc_attr($option['conditional']['any_post'])); } $conditional_class = isset($option['conditional'][$id]) ? ' et_dashboard_conditional' : $conditional_class; $conditional_data = isset($option['conditional'][$id]) ? sprintf(' data-enables="%1$s"', esc_attr($option['conditional'][$id])) : $conditional_data; } printf(' <li class="et_dashboard_checkbox%6$s"%7$s> <input type="checkbox" id="et_dashboard[%1$s][%4$s]" name="et_dashboard[%1$s][]" value="%3$s" %2$s> <label for="et_dashboard[%1$s][%4$s]"></label> <p>%5$s</p> </li>', esc_attr($current_option_name), 'post_types' === $option['subtype'] ? checked(in_array($id, $current_option_value), true, false) : checked($is_checked, true, false), 'post_types' === $option['subtype'] ? esc_attr($id) : esc_attr($post_type), esc_attr($i), 'post_cats' === $option['subtype'] && isset($option['include_custom']) ? esc_attr($id) . __(' ( post )', 'bloom') : esc_attr($id), esc_attr($conditional_class), $conditional_data); $i++; } if (isset($option['include_custom']) && 'post_cats' === $option['subtype']) { foreach ($dashboard_post_types as $post_type) { if ('post' != $post_type && 'page' != $post_type) { if (!empty($dashboard_categories[$post_type])) { foreach ($dashboard_categories[$post_type] as $cat_id => $cat_name) { if (!isset($current_option_value['previously_saved'])) { $is_checked = true; } else { if (isset($current_option_value['auto_select']) && '1' === $current_option_value['auto_select']) { $is_checked = !in_array($cat_id, $array_of_saved_cats) ? true : in_array($cat_id, $current_option_value); } else { $is_checked = in_array($cat_id, $current_option_value); } } printf(' <li class="et_dashboard_checkbox%6$s"%7$s> <input type="checkbox" id="et_dashboard[%1$s][%4$s]" name="et_dashboard[%1$s][]" value="%3$s" %2$s> <label for="et_dashboard[%1$s][%4$s]"></label> <p>%5$s</p> </li>', esc_attr($current_option_name), checked($is_checked, true, false), esc_attr($cat_id), esc_attr($i), esc_html($cat_name) . ' ( ' . $post_type . ' )', esc_attr($conditional_class), $conditional_data); $i++; } } } } } if ('post_cats' === $option['subtype']) { $current_option_value['auto_select'] = isset($current_option_value['auto_select']) ? $current_option_value['auto_select'] : 0; $current_option_value['auto_select'] = !isset($current_option_value['previously_saved']) ? 1 : $current_option_value['auto_select']; $cat_id_array = array(); printf(' <li class="et_dashboard_checkbox et_dashboard_auto_select"> <input type="checkbox" id="et_dashboard[%1$s][auto_select]" name="et_dashboard[%1$s][auto_select]" value="1" %2$s> <label for="et_dashboard[%1$s][auto_select]"></label> <p>%3$s</p> </li>', esc_attr($current_option_name), checked($current_option_value['auto_select'], 1, false), __('Automatically check categories created in future', 'et_dashboard')); foreach ($checkbox_array as $id => $name) { $cat_id_array[] = $id; } if (isset($option['include_custom'])) { foreach ($dashboard_post_types as $post_type) { if ('post' != $post_type && 'page' != $post_type) { if (!empty($dashboard_categories[$post_type])) { foreach ($dashboard_categories[$post_type] as $cat_id => $cat_name) { $cat_id_array[] = $cat_id; } } } } } $current_option_value['previously_saved'] = implode(',', $cat_id_array); printf(' <li> <input type="hidden" id="et_dashboard[%1$s][previously_saved]" name="et_dashboard[%1$s][previously_saved]" value="%2$s" /> </li>', esc_attr($current_option_name), $current_option_value['previously_saved']); } echo ' </ul> <div style="clear:both;"></div> </li>'; break; case 'section_start': printf('%5$s<div class="et_dashboard_form et_dashboard_row%2$s%7$s"%3$s%4$s%8$s> %1$s %6$s <div style="clear:both;"></div> <ul>', isset($option['title']) ? sprintf('<h2>%1$s</h2>', esc_html($option['title'])) : '', isset($option['display_if']) ? ' et_dashboard_hidden_option' : '', isset($option['display_if']) ? ' data-condition="' . esc_attr($option['display_if']) . '"' : '', isset($current_option_name) && '' != $current_option_name ? sprintf(' data-name="et_dashboard[%1$s]"', esc_attr($current_option_name)) : '', isset($option['sub_section']) && true == $option['sub_section'] ? '<li class="et_dashboard_auto_height">' : '', isset($option['subtitle']) ? sprintf('<p class="et_dashboard_section_subtitle">%1$s</p>', esc_html($option['subtitle'])) : '', isset($option['class']) ? ' ' . esc_attr($option['class']) : '', isset($option['display_if']) ? ' data-triggers_count="0"' : ''); break; case 'section_end': printf(' </ul> </div> %1$s', isset($option['sub_section']) && true == $option['sub_section'] ? '</li>' : ''); break; case 'text': printf('<li class="et_dashboard_auto_height%6$s%10$s"%7$s%8$s> %9$s <textarea placeholder="%1$s" rows="%2$s" id="et_dashboard_%4$s" name="et_dashboard[%4$s]"%5$s>%3$s</textarea> </li>', esc_attr($option['placeholder']), esc_attr($option['rows']), esc_html($current_option_value), esc_attr($current_option_name), isset($option['class']) ? sprintf(' class="%1$s"', esc_attr($option['class'])) : '', isset($option['display_if']) ? ' et_dashboard_hidden_option' : '', isset($option['display_if']) ? ' data-condition="' . esc_attr($option['display_if']) . '"' : '', isset($option['display_if']) ? ' data-triggers_count="0"' : '', !empty($option['title']) ? sprintf('<p>%1$s</p>', esc_html($option['title'])) : '', !empty($option['title']) ? ' et_dashboard_text_with_title' : ''); break; case 'main_title': printf('<div class="et_dashboard_row et_dashboard_selection%3$s"> <h1>%1$s</h1> %2$s </div>', esc_html($option['title']), isset($option['subtitle']) ? sprintf('<p>%1$s</p>', esc_html($option['subtitle'])) : '', isset($option['class']) ? ' ' . esc_attr($option['class']) : ''); break; case 'note': printf('<div class="et_dashboard_row et_dashboard_note"> <h2>%1$s</h2> <p> <span>%2$s</span> </p> </div>', esc_html__('Note:', 'et_dashboard'), esc_html($option['text'])); break; case 'color_picker': printf('<li class="input clearfix et_dashboard_color_picker%5$s%8$s"%6$s%7$s> <p>%4$s</p> <input class="et-dashboard-color-picker" type="text" maxlength="7" placeholder="%1$s" name=et_dashboard[%2$s] value="%3$s" /> </li>', esc_attr($option['placeholder']), esc_attr($current_option_name), esc_attr($current_option_value), esc_html($option['title']), isset($option['display_if']) ? ' et_dashboard_hidden_option' : '', isset($option['display_if']) ? ' data-condition="' . esc_attr($option['display_if']) . '"' : '', isset($option['display_if']) ? ' data-triggers_count="0"' : '', isset($option['class']) ? ' ' . esc_attr($option['class']) : ''); break; case 'live_search': if ('' === $current_option_value) { $current_option_value_array = array(); } else { $current_option_value_array = is_array($current_option_value) ? $current_option_value : explode(',', $current_option_value); } $selected_posts_list = ''; if (!empty($current_option_value_array)) { $selected_posts = get_posts(array('post__in' => $current_option_value_array, 'post_type' => 'any', 'posts_per_page' => -1)); if (!empty($selected_posts)) { foreach ($selected_posts as $single_post) { $selected_posts_list .= sprintf(' <span data-post_id="%3$s">[%1$s] - %2$s<span class="et_dashboard_menu_remove"></span></span>', esc_html($single_post->post_type), esc_html($single_post->post_title), esc_attr($single_post->ID)); } } } printf(' <li class="et_dashboard_selected">%1$s</li> <li class="et_dashboard_live_fields"> <input type="text" class="et_dashboard_search_posts" placeholder="%4$s" data-post_type="%5$s"/><span class="spinner"></span> <input type="hidden" id="et_dashboard[%2$s]" name="et_dashboard[%2$s]" value="%3$s" /> </li> <li class="et_dashboard_live_search_res"> <ul class="et_dashboard_search_results"></ul> </li>', $selected_posts_list, esc_attr($current_option_name), is_array($current_option_value) ? esc_attr(implode(',', $current_option_value)) : esc_attr($current_option_value), esc_attr($option['placeholder']), esc_attr($option['post_type'])); break; case 'image_upload': printf(' <li class="et_dashboard_upload_image%7$s"%8$s%9$s> <p>%6$s</p> <input name="et_dashboard[%1$s][url]" type="text" class="et-dashboard-upload-field" value="%2$s" /> <input type="hidden" class="et-dashboard-upload-id" name="et_dashboard[%1$s][id]" value="%10$s"> <input type="button" class="button button-upload et-dashboard-upload-button" value="%3$s" data-choose="%4$s" data-update="%5$s" data-type="image" /> </li>', esc_attr($current_option_name), isset($current_option_value['url']) ? esc_attr($current_option_value['url']) : '', esc_attr($option['button_text']), esc_attr($option['wp_media_title']), esc_attr($option['wp_media_button']), isset($option['title_' . $current_location]) ? esc_html($option['title_' . $current_location]) : esc_html($option['title']), isset($option['display_if']) ? ' et_dashboard_hidden_option' : '', isset($option['display_if']) ? ' data-condition="' . esc_attr($option['display_if']) . '"' : '', isset($option['display_if']) ? ' data-triggers_count="0"' : '', isset($current_option_value['id']) ? esc_attr($current_option_value['id']) : ''); break; case 'hidden_option': if ('array' == $option['subtype']) { $current_option_value = '' == $current_option_value ? array() : $current_option_value; foreach ($current_option_value as $single_value) { printf('<input name="et_dashboard[%1$s][]" type="hidden" value="%2$s" />', esc_attr($current_option_name), esc_attr($single_value)); } } else { printf('<input name="et_dashboard[%1$s]" id="et_dashboard_%1$s" type="hidden" value="%2$s" />', esc_attr($current_option_name), esc_attr($current_option_value)); } break; case 'button': printf('<li class="et_dashboard_action_button"> <a href="%1$s" class="et_dashboard_icon %2$s">%3$s</a> <span class="spinner"></span> </li>', esc_url($option['link']), esc_html($option['class']), true == $option['authorize'] && $this->api_is_network_authorized($option['action']) ? __('Re-Authorize', 'et_dashboard') : esc_html($option['title'])); break; case 'font_select': $fonts_class = ET_Dashboard::load_fonts_class(); $current_option_list = $fonts_class->et_get_google_fonts(); if (isset($option['filter'])) { $current_option_list = apply_filters($option['filter'], $current_option_list); } printf('<li class="select%3$s%5$s%7$s"%4$s%6$s%8$s> <p>%1$s</p> <select name="et_dashboard[%2$s]">', isset($option['title_' . $current_location]) ? esc_html($option['title_' . $current_location]) : esc_html($option['title']), esc_attr($current_option_name), isset($option['display_if']) ? ' et_dashboard_hidden_option et_dashboard_triggered_option' : '', isset($option['display_if']) ? ' data-condition="' . esc_attr($option['display_if']) . '"' : '', isset($option['conditional']) ? ' et_dashboard_conditional' : '', isset($option['conditional']) ? sprintf(' data-enables="%1$s"', '' !== $sub_array ? esc_attr($option['conditional']) : esc_attr($options_prefix . '_' . $option['conditional'])) : '', isset($option['class']) ? ' ' . esc_attr($option['class']) : '', isset($option['display_if']) ? ' data-triggers_count="0"' : ''); foreach ($current_option_list as $font_name => $font_details) { printf('<option value="%1$s" class="et_dashboard_font_%1$s" %2$s>%3$s</option>', esc_attr($font_name), selected($font_name, $current_option_value, false), esc_html($font_name)); } echo ' </select>'; echo $hint_output; echo '</li>'; break; } // end switch do_action('et_' . $this->plugin_name . '_after_main_options', $option, $current_option_value); } // end foreach( $options_array as $option) echo '</div>'; } // end foreach( $value['contents'] as $key => $value ) } // end if ( $key !== 'header') } // end foreach ( $dashboard_sections as $key => $value ) } // end if ( isset( $dashboard_sections ) ) printf('<div class="et_dashboard_row et_dashboard_save_changes %3$s"> <button class="et_dashboard_icon"%2$s>%1$s</button> <span class="spinner"></span> </div> <input type="hidden" name="action" value="save_dashboard" />', esc_html__($this->save_button_text), '' !== $sub_array ? sprintf('data-subtitle="%1$s"', esc_attr($sub_array)) : '', apply_filters('et_' . $this->plugin_name . '_save_button_class', '')); do_action('et_' . $this->plugin_name . '_after_save_button'); echo '</form>'; if (isset($dashboard_sections['header']['contents'])) { do_action('et_' . $this->plugin_name . '_header_start'); foreach ($dashboard_sections['header']['contents'] as $key => $value) { $options_array = $dashboard_options_assigned['header_' . $key . '_options']; printf('<div class="et_dashboard_tab_content et_dashboard_tab_content_header_%1$s et_dashboard_header_option">', esc_attr($key)); if (isset($options_array)) { foreach ($options_array as $option) { switch ($option['type']) { case 'import_export': printf('<div class="et_dashboard_form et_dashboard_row"> <h1>%1$s</h1> <p>%2$s</p> </div> <div class="et_dashboard_import_form et_dashboard_row"> <h2>%3$s</h2> <p class="et_dashboard_section_subtitle">%4$s</p> <form method="post"> <input type="hidden" name="et_dashboard_action" value="export_settings" /> <p>', esc_html($option['title']), __(sprintf('You can either export your %1$s Settings or import settings from another install of %1$s below.', esc_html(ucfirst($this->plugin_name))), 'et_dashboard'), __(sprintf('Export %1$s Settings', esc_html(ucfirst($this->plugin_name))), 'et_dashboard'), __('Export the plugin settings for this site as a .json file. This allows you to easily import the configuration into another site.', 'et_dashboard')); wp_nonce_field('et_dashboard_export_nonce', 'et_dashboard_export_nonce'); printf(' <button class="et_dashboard_icon et_dashboard_icon_importexport" type="submit" name="submit_export" id="submit_export">' . __('Export', 'et_dashboard') . '</button> </p> </form> </div> <div class="et_dashboard_form et_dashboard_row"> <h2>%1$s</h2> <div class="et_dashboard_import_form et_dashboard_row"> <p class="et_dashboard_section_subtitle">%2$s</p> <form method="post" enctype="multipart/form-data" action="%4$s.php?page=%3$s#tab_et_dashboard_tab_content_header_importexport"> <input type="file" name="import_file"/>', sprintf(__('Import %1$s Settings', 'et_dashboard'), esc_html(ucfirst($this->plugin_name))), __('Import the plugin settings from a .json file. This file can be obtained by exporting the settings on another site using the form above.', 'et_dashboard'), $this->_options_pagename, 'toplevel_page' == $this->top_level_page ? 'admin' : $this->top_level_page); wp_nonce_field('et_dashboard_import_nonce', 'et_dashboard_import_nonce'); echo ' <button class="et_dashboard_icon et_dashboard_icon_importexport" type="submit" name="submit_import" id="submit_import">' . __('Import', 'et_dashboard') . '</button> <input type="hidden" name="et_dashboard_action" value="import_settings" /> </form> </div> </div>'; break; } // end switch do_action('et_' . $this->plugin_name . '_after_header_options', $option, $dashboard_options); } // end foreach( $options_array as $option ) } // end if ( isset( $options_array ) ) echo '</div><!-- .et_dashboard_tab_content_header_ -->'; } // end foreach ( $dashboard_sections[ 'header' ][ 'contents' ] as $key => $value ) do_action('et_' . $this->plugin_name . '_header_end'); } // end if ( isset( $dashboard_sections[ 'header' ][ 'contents' ] ) ) echo ' </div> </div> </div>'; }