/** * Retrieves the theme selection dialog for changing themes within optins. * * @since 2.0.3 * * @return string HTML markup for the theme selection dialog. */ public function get_theme_selection() { // Load the interface for grabbing optins. if (!class_exists('Optin_Monster_Views_New')) { require plugin_dir_path($this->base->file) . 'includes/admin/views/new.php'; } // Get all the themes for the optin type. $themes_object = Optin_Monster_Views_New::get_instance(); $themes = $themes_object->get_optin_themes($this->meta['type']); $active = array(); if (isset($themes[$this->meta['theme']])) { $active[$this->meta['theme']] = $themes[$this->meta['theme']]; unset($themes[$this->meta['theme']]); $themes = array_merge($active, $themes); } // Now create the interface for selecting optins. $html = '<div class="optin-monster-themes optin-monster-clear">'; foreach ($themes as $id => $data) { $class = $id == $this->meta['theme'] ? ' om-active-theme' : ''; $html .= '<div class="optin-monster-theme optin-monster-theme-' . $id . $class . '" data-om-optin-theme="' . $id . '" data-om-optin-type="' . $this->meta['type'] . '">'; $html .= '<div class="optin-monster-theme-screenshot">'; $html .= '<img src="' . esc_url($data['image']) . '" alt="' . esc_attr($data['name']) . '" />'; $html .= '</div>'; $html .= '<h3 class="optin-monster-theme-name">' . ($id == $this->meta['theme'] ? '<span>' . __('Active: ', 'optin-monster') . '</span>' : '') . $data['name'] . '</h3>'; $html .= '<div class="optin-monster-theme-actions"' . ($id == $this->meta['theme'] ? ' style="display:none;"' : '') . '>'; $html .= '<a class="button button-primary om-theme-select" data-om-optin-theme="' . $id . '" data-om-optin-type="' . $this->meta['type'] . '" title="' . esc_attr__('Select this theme', 'optin-monster') . '">' . __('Select Theme', 'optin-monster') . '</a>'; $html .= '</div>'; $html .= '</div>'; } $html .= '</div>'; // Return the output. return apply_filters('optin_monster_theme_selection_output', $html); }
/** * Loads themes for selection when creating a new optin. * * @since 2.0.0 */ function optin_monster_ajax_load_themes() { // Run a security check first. check_ajax_referer('optin-monster-type', 'nonce'); // Prepare variables. $type = stripslashes($_POST['type']); // If the class isn't loaded, load it now. if (!class_exists('Optin_Monster_Views_New')) { require plugin_dir_path(Optin_Monster::get_instance()->file) . 'includes/admin/views/new.php'; } // Build the theme UI and send it back to the script. die(json_encode(Optin_Monster_Views_New::get_instance()->get_theme_ui($type))); }
/** * Outputs the main UI for handling and managing optins. * * @since 2.0.0 */ public function menu_ui() { // Build out the necessary HTML structure. echo '<div id="optin-monster-ui" class="wrap">'; // Serve the UI based on the page being visited. if ($this->load_view()) { switch ($this->view) { case 'overview': require plugin_dir_path($this->base->file) . 'includes/admin/views/overview.php'; Optin_Monster_Views_Overview::get_instance()->view(); break; case 'new': require plugin_dir_path($this->base->file) . 'includes/admin/views/new.php'; Optin_Monster_Views_New::get_instance()->view(); break; case 'edit': require plugin_dir_path($this->base->file) . 'includes/admin/views/edit.php'; Optin_Monster_Views_Edit::get_instance()->view(); break; case 'split': require plugin_dir_path($this->base->file) . 'includes/admin/views/split.php'; Optin_Monster_Views_Split::get_instance()->view(); break; case 'preview': if ($this->is_admin_preview()) { require plugin_dir_path($this->base->file) . 'includes/admin/views/preview.php'; Optin_Monster_Views_Preview::get_instance()->view(); } else { require plugin_dir_path($this->base->file) . 'includes/admin/views/overview.php'; Optin_Monster_Views_Overview::get_instance()->view(); } break; default: do_action('optin_monster_admin_view', $this->view); break; } } // Wrap up the main UI. echo '</div>'; }
/** * Returns the singleton instance of the class. * * @since 2.0.0 * * @return object The Optin_Monster_Views_New object. */ public static function get_instance() { if (!isset(self::$instance) && !self::$instance instanceof Optin_Monster_Views_New) { self::$instance = new Optin_Monster_Views_New(); } return self::$instance; }