public function inject_addons($response, $action, $args) { $addon_list = EModal_License::available_addons(); $addon_slugs = array(); $addons = array(); if (!empty($addon_list)) { foreach ($addon_list as $addon) { $addon_slugs[] = $addon->slug; $addons[$addon->slug] = $addon; } //Does this request concern our plugin? if ($action !== 'plugin_information' || empty($args->slug) || empty($_GET['em']) || !in_array($args->slug, $addon_slugs)) { return $response; } } $addon = $addons[$args->slug]; //This is basically a stripped-down and simplified version of what the update checker library does. $response = new StdClass(); foreach ($addon as $key => $value) { $response->{$key} = $value; } $response->name = $addon->name; $response->version = $addon->version; $response->download_link = $addon->download_url; return $response; }
public function update_transient_plugin_slugs() { $transient = get_option('_transient_plugin_slugs'); if ($transient) { $save = false; $addons = EModal_License::available_addons(); if (!empty($addons)) { foreach ($addons as $addon) { if (!in_array($addon->slug . '/' . $addon->slug . '.php', $transient)) { $transient[] = $addon->slug . '/' . $addon->slug . '.php'; $save = true; } } } if ($save) { update_option('_transient_plugin_slugs', $transient); } } }
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 output() { extract($this->values); ?> <div class="wrap"> <h2><?php esc_html_e(__($title, EMCORE_SLUG)); ?> </h2> <div id="poststuff"> <div id="post-body" class="metabox-holder"> <div id="post-body-content"><?php $addons = EModal_License::available_addons(); ?> <ul class="addons-available"> <?php $plugins = get_plugins(); $installed_plugins = array(); foreach ($plugins as $key => $plugin) { $is_active = is_plugin_active($key); $installed_plugin = array('is_active' => $is_active); $installerUrl = add_query_arg(array('action' => 'activate', 'plugin' => $key, 'em' => 1), network_admin_url('plugins.php')); $installed_plugin["activation_url"] = $is_active ? "" : wp_nonce_url($installerUrl, 'activate-plugin_' . $key); $installerUrl = add_query_arg(array('action' => 'deactivate', 'plugin' => $key, 'em' => 1), network_admin_url('plugins.php')); $installed_plugin["deactivation_url"] = !$is_active ? "" : wp_nonce_url($installerUrl, 'deactivate-plugin_' . $key); $installed_plugins[$key] = $installed_plugin; } $existing_addon_images = apply_filters('emodal_existing_addon_images', array()); if (!empty($addons)) { foreach ($addons as $addon) { ?> <li class="available-addon-inner"> <h3><?php esc_html_e($addon->name); ?> </h3> <?php $image = in_array($addon->slug, $existing_addon_images) ? EMCORE_URL . '/assets/images/addons/' . $addon->slug . '.jpg' : $addon->image; ?> <img class="addon-thumbnail" src="<?php esc_attr_e($image); ?> "> <p><?php esc_html_e($addon->excerpt); ?> </p> <hr/><?php if (!empty($addon->download_link) && !isset($installed_plugins[$addon->slug . '/' . $addon->slug . '.php'])) { $installerUrl = add_query_arg(array('action' => 'install-plugin', 'plugin' => $addon->slug, 'edd_sample_plugin' => 1), network_admin_url('update.php')); $installerUrl = wp_nonce_url($installerUrl, 'install-plugin_' . $addon->slug); ?> <span class="action-links"><?php printf('<a class="button install" href="%s">%s</a>', esc_attr($installerUrl), __('Install')); ?> </span><?php } elseif (isset($installed_plugins[$addon->slug . '/' . $addon->slug . '.php']['is_active'])) { ?> <span class="action-links"><?php if (!$installed_plugins[$addon->slug . '/' . $addon->slug . '.php']['is_active']) { printf('<a class="button install" href="%s">%s</a>', esc_attr($installed_plugins[$addon->slug . '/' . $addon->slug . '.php']["activation_url"]), __('Activate')); } else { printf('<a class="button install" href="%s">%s</a>', esc_attr($installed_plugins[$addon->slug . '/' . $addon->slug . '.php']["deactivation_url"]), __('Deactivate')); } ?> </span><?php } else { ?> <span class="action-links"><a class="button" target="_blank" href="<?php esc_attr_e($addon->homepage); ?> "><?php _e('Get It Now'); ?> </a></span><?php } ?> <a href="<?php echo esc_url($addon->homepage); ?> " target="_blank"><?php _e('View the entire Add On Specs'); ?> </a> </li> <?php } } ?> </ul> </div> </div> <br class="clear"/> </div> </div><?php }