Example #1
0
function emodal_shortcode_modal($atts, $content = NULL)
{
    $atts = shortcode_atts(apply_filters('emodal_shortcode_modal_default_atts', array('id' => "", 'theme_id' => 1, 'title' => "", 'overlay_disabled' => 0, 'size' => "auto", 'width' => "", 'widthUnit' => "px", 'height' => "", 'heightUnit' => "px", 'location' => "center top", 'positionTop' => 100, 'positionLeft' => 0, 'positionBottom' => 0, 'positionRight' => 0, 'positionFixed' => 0, 'animation' => "slide", 'animationSpeed' => 350, 'animationOrigin' => 'top', 'overlayClose' => 0, 'escClose' => 1, 'theme' => NULL, 'duration' => NULL, 'direction' => NULL, 'overlayEscClose' => NULL)), apply_filters('emodal_shortcode_modal_atts', $atts));
    $modal_fields = array('id' => $atts['id'], 'theme_id' => $atts['theme_id'], 'title' => $atts['title'], 'content' => $content, 'meta' => array('display' => array('size' => $atts['size'], 'overlay_disabled' => $atts['overlay_disabled'], 'custom_width' => $atts['width'], 'custom_width_unit' => $atts['widthUnit'], 'custom_height' => $atts['height'], 'custom_height_unit' => $atts['heightUnit'], 'custom_height_auto' => $atts['width'] > 0 ? 0 : 1, 'location' => $atts['location'], 'position' => array('top' => $atts['positionTop'], 'left' => $atts['positionLeft'], 'bottom' => $atts['positionBottom'], 'right' => $atts['positionRight'], 'fixed' => $atts['positionFixed']), 'animation' => array('type' => $atts['animation'], 'speed' => $atts['animationSpeed'], 'origin' => $atts['animationOrigin'])), 'close' => array('overlay_click' => $atts['overlayClose'], 'esc_press' => $atts['escClose'])));
    $modal_fields = apply_filters('emodal_shortcode_modal_settings', $modal_fields, $atts);
    $Modal = new EModal_Model_Modal();
    $Modal->set_fields($modal_fields);
    $View = new EModal_View_Modal();
    $View->set('modal', $Modal->as_array());
    return $View->output();
}
Example #2
0
 function get_all_modals($where = "is_trash != 1")
 {
     global $wpdb;
     $modals = array();
     $modal_ids = array();
     $EModal_Model_Modal = new EModal_Model_Modal();
     $EModal_Model_Modal_Meta = new EModal_Model_Modal_Meta();
     foreach ($EModal_Model_Modal->load("SELECT * FROM {$wpdb->prefix}em_modals" . ($where ? " WHERE " . $where : '')) as $modal) {
         $modals[$modal->id] = $modal;
         $modal_ids[] = $modal->id;
     }
     if (count($modals)) {
         foreach ($EModal_Model_Modal_Meta->load("SELECT * FROM {$wpdb->prefix}em_modal_metas WHERE modal_id IN (" . implode(',', $modal_ids) . ")") as $meta) {
             $modals[$meta->modal_id]->meta->process_load($meta->as_array());
         }
     }
     return $modals;
 }
Example #3
0
 public function action_clone()
 {
     if ($this->check_get_nonce()) {
         global $current_modal;
         $current_modal = new EModal_Model_Modal($this->check_id());
         $current_modal->id = NULL;
         $current_modal->meta->id = NULL;
         $current_modal->save();
         do_action('emodal_modal_clone', $current_modal);
         EModal_Admin_Notice::add(__('Modal cloned successfully', EMCORE_SLUG), 'updated');
         $this->redirect_to_edit();
     }
     wp_redirect($this->index_url(), 302);
     exit;
 }
 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);
 }