public function action_edit() { global $current_theme; $current_theme = new EModal_Model_Theme($this->check_id()); if ($this->check_post_nonce()) { $new_values = apply_filters('emodal_theme_pre_save', $current_theme->as_array()); $current_theme->set_fields(apply_filters("emodal_model_theme_meta_defaults", $new_values)); $current_theme->save(); do_action('emodal_theme_save', $current_theme); EModal_Admin_Notice::add(__('Theme Updated.', EMCORE_SLUG), 'updated'); $this->redirect_to_edit(); } $view = new EModal_View_Admin_Theme_Form(); $view->set('title', __('Edit Theme', EMCORE_SLUG)); $view->set('tabs', apply_filters('emodal_admin_theme_form_tabs', array())); self::$instance->view = $view; }
function get_all_modal_themes($where = "is_trash != 1") { global $wpdb; $themes = array(); $theme_ids = array(); $EModal_Model_Theme = new EModal_Model_Theme(); $EModal_Model_Theme_Meta = new EModal_Model_Theme_Meta(); foreach ($EModal_Model_Theme->load("SELECT * FROM {$wpdb->prefix}em_themes" . ($where ? " WHERE " . $where : '')) as $theme) { $themes[$theme->id] = $theme; $theme_ids[] = $theme->id; } if (count($themes)) { foreach ($EModal_Model_Theme_Meta->load("SELECT * FROM {$wpdb->prefix}em_theme_metas WHERE theme_id IN (" . implode(',', $theme_ids) . ")") as $meta) { $themes[$meta->theme_id]->meta->process_load($meta->as_array()); } } return $themes; }
public function __construct() { if (emodal_get_option('EasyModal_Version')) { $themes = self::get_themes(); $theme_check = array(); foreach ($themes as $theme) { $new_theme = new EModal_Model_Theme(); $new_theme->set_fields(array('id' => intval($theme['id']), 'name' => $theme['name'], 'is_system' => intval($theme['id']) == 1 ? 1 : 0, 'meta' => array('overlay' => array('background' => array('color' => $theme['overlayColor'], 'opacity' => $theme['overlayOpacity'])), 'container' => array('padding' => $theme['containerPadding'], 'background' => array('color' => $theme['containerBgColor']), 'border' => array('style' => $theme['containerBorderStyle'], 'color' => $theme['containerBorderColor'], 'width' => $theme['containerBorderWidth'], 'radius' => $theme['containerBorderRadius'])), 'title' => array('font' => array('color' => $theme['contentTitleFontColor'], 'size' => $theme['contentTitleFontSize'], 'family' => $theme['contentTitleFontFamily'])), 'content' => array('font' => array('color' => $theme['contentFontColor'])), 'close' => array('padding' => ($theme['closeSize'] - $theme['closeFontSize']) / 2, 'text' => $theme['closeText'], 'location' => $theme['closePosition'], 'background' => array('color' => $theme['closeBgColor']), 'border' => array('radius' => $theme['closeBorderRadius']), 'font' => array('color' => $theme['closeFontColor'], 'size' => $theme['closeFontSize']))))); $new_theme->save(); $theme_check[] = $new_theme->id; } $modals = self::get_modals(); foreach ($modals as $modal) { $new_modal = new EModal_Model_Modal(); $new_modal->set_fields(array('id' => is_int(intval($modal['id'])) ? intval($modal['id']) : NULL, 'theme_id' => in_array(intval($modal['theme']), $theme_check) ? intval($modal['theme']) : 1, 'name' => $modal['name'], 'title' => $modal['title'], 'content' => $modal['content'], 'is_sitewide' => $modal['sitewide'] ? 1 : 0, 'content' => $modal['content'], 'is_system' => in_array($modal['id'], array('Login', 'Register', 'Forgot')) ? 1 : 0, 'meta' => array('display' => array('size' => $modal['size'] == '' ? 'normal' : $modal['size'], 'custom_width' => $modal['userWidth'], 'custom_width_unit' => $modal['userWidthUnit'], 'custom_height' => $modal['userHeight'], 'custom_height_unit' => $modal['userHeightUnit'], 'animation' => array('type' => $modal['animation'], 'speed' => $modal['duration'], 'origin' => $modal['direction'])), 'close' => array('overlay_click' => $modal['overlayClose'] ? 1 : 0, 'esc_press' => $modal['overlayEscClose'] ? 1 : 0, 'disabled' => !empty($modal['closeDisabled']) && $modal['closeDisabled'] ? 1 : 0)))); $new_modal->save(); if ($modal['id'] == 'Login') { $login_modal = $new_modal->id; } elseif ($modal['id'] == 'Register') { $register_modal = $new_modal->id; } elseif ($modal['id'] == 'Forgot') { $forgot_modal = $new_modal->id; } } $license = self::get_license(); if (!empty($license)) { $EModal_License = new EModal_License(); $EModal_License->check_license($license, true); EModal_Admin::check_updates(); } $settings = self::get_settings(); if (array_key_exists('autoOpen_id', $settings)) { $autoopen = array('modal_id' => intval($settings['autoOpen_id']), 'type' => 'page-load', 'pageload' => array('delay' => intval($settings['autoOpen_delay'])), 'cookie' => array('time' => is_float($settings['autoOpen_timer']) || is_int($settings['autoOpen_timer']) ? $settings['autoOpen_timer'] . ' days' : $settings['autoOpen_timer'])); emodal_update_option('easy-modal-pro_autoopen', $autoopen); $autoexit = array('modal_id' => intval($settings['autoExit_id']), 'cookie' => array('time' => is_float($settings['autoExit_timer']) || is_int($settings['autoExit_timer']) ? $settings['autoExit_timer'] . ' days' : $settings['autoExit_timer'])); emodal_update_option('easy-modal-pro-exit-modals_autoexit', $autoexit); } if ($settings['login_modal_enabled']) { if (empty($login_modal)) { $new_login_modal = new EModal_Model_Modal(); $new_login_modal->set_fields(array('name' => 'Login Modal', 'meta' => array('size' => 'small'))); $new_login_modal->save(); $login_modal = $new_login_modal->id; } if (empty($register_modal)) { $new_registration_modal = new EModal_Model_Modal(); $new_registration_modal->set_fields(array('name' => 'Registration Modal', 'meta' => array('size' => 'small'))); $new_registration_modal->save(); $register_modal = $new_registration_modal->id; } if (empty($forgot_modal)) { $new_forgot_modal = new EModal_Model_Modal(); $new_forgot_modal->set_fields(array('name' => 'Forgot Password Modal', 'meta' => array('size' => 'small'))); $new_forgot_modal->save(); $forgot_modal = $new_forgot_modal->id; } $loginmodal = array('enabled' => $settings['login_modal_enabled'] ? 1 : 0, 'force_login' => $settings['force_user_login'] ? 1 : 0, 'login' => array('modal_id' => $login_modal), 'registration' => array('modal_id' => $register_modal, 'enable_password' => $settings['registration_modal']['enable_password'] ? 1 : 0, 'autologin' => $settings['registration_modal']['autologin'] ? 1 : 0), 'forgot' => array('modal_id' => $forgot_modal)); emodal_update_option('easy-modal-pro-login-modals_loginmodal', $loginmodal); } } global $wpdb; $wpdb->query("UPDATE {$wpdb->postmeta} SET meta_key = 'easy-modal_post_modals' WHERE meta_key = 'easy_modal_post_modals'"); $post_meta = $wpdb->get_results("SELECT * FROM {$wpdb->postmeta} WHERE meta_key LIKE 'easy_modal_post_%' ORDER BY post_id ASC"); $new_post_meta = array(); $delete_post_meta = array(); foreach ($post_meta as $meta) { if (empty($new_post_meta[$meta->post_id])) { $new_post_meta[$meta->post_id] = array('autoopen' => array('modal_id' => NULL, 'type' => 'page-load', 'pageload' => array('delay' => NULL), 'cookie' => array('time' => NULL, 'path' => ''), 'scroll' => array('distance' => NULL)), 'autoexit' => array('modal_id' => NULL, 'cookie' => array('time' => NULL, 'path' => '')), 'loginmodal' => array('force_login' => 0)); } switch ($meta->meta_key) { case "easy_modal_post_autoExit_id": $new_post_meta[$meta->post_id]['autoexit']['modal_id'] = intval($meta->meta_value); break; case "easy_modal_post_autoExit_timer": $new_post_meta[$meta->post_id]['autoexit']['cookie']['time'] = is_float($meta->meta_value) || is_int($meta->meta_value) ? $meta->meta_value . ' days' : $meta->meta_value; break; case "easy_modal_post_autoOpen_id": $new_post_meta[$meta->post_id]['autoopen']['modal_id'] = intval($meta->meta_value); break; case "easy_modal_post_autoOpen_timer": $new_post_meta[$meta->post_id]['autoopen']['cookie']['time'] = is_float($meta->meta_value) || is_int($meta->meta_value) ? $meta->meta_value . ' days' : $meta->meta_value; break; case "easy_modal_post_autoOpen_delay": $new_post_meta[$meta->post_id]['autoopen']['pageload']['delay'] = intval($meta->meta_value); break; case "easy_modal_post_force_user_login": $new_post_meta[$meta->post_id]['autoopen']['modal_id'] = $meta->meta_value == 'true' ? 1 : 0; break; } if ($meta->meta_key != 'easy-modal_post_modals') { $delete_post_meta[] = $meta->meta_id; } } foreach ($new_post_meta as $post_id => $meta) { update_post_meta($post_id, 'easy-modal-pro_autoopen', $meta['autoopen']); update_post_meta($post_id, 'easy-modal-pro-exit-modals_autoexit', $meta['autoexit']); update_post_meta($post_id, 'easy-modal-pro-login-modals_loginmodal', $meta['loginmodal']); } emodal_update_option(EMCORE_SLUG . '_migration_approval', true); }
public function install_data() { $theme = new EModal_Model_Theme(); $theme->set_fields(array()); $theme->save(); }