public function register_scripts() { if (!$this->pointers) { return; } $pointers = []; foreach ($this->pointers as $pointer) { if ($this->is_viewable($pointer)) { // Add ajax url in case we don't have access to ajaxurl var $pointer['ajaxurl'] = admin_url('admin-ajax.php', 'relative'); $pointers[] = $pointer; } } $suffix = SCRIPT_DEBUG ? '' : '.min'; wp_register_script('wpem-pointers', wpem()->assets_url . "js/pointers{$suffix}.js", ['jquery', 'wp-pointer'], wpem()->version, true); wp_localize_script('wpem-pointers', 'wpem_pointers', $pointers); }
/** * Set log defaults if not yet present * * @action init */ public function maybe_set_defaults() { $defaults = ['datetime', 'fqdn', 'site_url', 'account_id', 'user_email', 'locale', 'wp_version']; if (!array_diff_key($defaults, static::$log)) { return; } $defaults = ['datetime' => gmdate('c'), 'fqdn' => gethostname(), 'site_url' => get_option('siteurl'), 'account_id' => exec('whoami'), 'user_email' => get_userdata(1)->user_email, 'locale' => ($locale = get_option('WPLANG')) ? $locale : 'en_US', 'wp_version' => get_bloginfo('version'), 'wpem_version' => wpem()->version]; static::$log = $defaults; $this->save(); new Geodata($this); // Saves to log }
/** * Use Contact step data in Social widget */ private function widget_social() { $social_profiles = array_filter((array) get_option('wpem_social_profiles', [])); if (!$social_profiles) { delete_option('widget_wpcw_social'); return; } $widget = (array) get_option('widget_wpcw_social', []); unset($widget['_multiwidget']); if (!$widget) { return; } $keys = array_keys($widget); $key = array_shift($keys); include_once wpem()->base_dir . 'includes/social-networks.php'; // Remove all default social networks from the widget foreach ($social_networks as $network => $data) { if (isset($social_networks[$network])) { unset($widget[$key][$network]); } } $fields = []; if (isset($widget[$key]['title'])) { // Add the title field to the new list $fields['title'] = $widget[$key]['title']; // Remove the title from the original widget unset($widget[$key]['title']); } // Prepend new social networks to the fields list foreach (wpem_get_social_profiles() as $network) { $fields[$network] = ['value' => wpem_get_social_profile_url($network), 'order' => '']; } // Merge updated fields with the original widget $widget[$key] = $fields + $widget[$key]; // Refresh field order $widget[$key] = $this->refresh_widget_field_order($widget[$key]); $widget['_multiwidget'] = 1; update_option('widget_wpcw_social', $widget); }
if (!(bool) apply_filters('wpem_self_destruct', true) || defined('WPEM_DOING_TESTS') && WPEM_DOING_TESTS) { return; } if (!class_exists('WP_Filesystem')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); global $wp_filesystem; $wp_filesystem->rmdir($this->base_dir, true); } /** * Deactivate the plugin silently */ public function deactivate() { if (!$this->is_standalone_plugin()) { return; } /** * Filter to deactivate when done * * @var bool */ if (!(bool) apply_filters('wpem_deactivate', true) || defined('WPEM_DOING_TESTS') && WPEM_DOING_TESTS) { return; } deactivate_plugins($this->basename, true); } } wpem();
/** * Register admin menu screen * * @action admin_init */ public function screen() { $template = wpem()->base_dir . 'templates/fullscreen.php'; if (is_readable($template)) { require_once $template; exit; } }
/** * Step content */ public function content() { printf('<p class="lead-text align-center">%s</p>', __('Please provide the contact details for your website', 'wp-easy-mode')); $this->fields->display(); // Save fields now on first load in case this step is skipped if (!get_option('wpem_contact_info') && !get_option('wpem_social_profiles')) { $this->fields->save(); } include_once wpem()->base_dir . 'includes/social-networks.php'; if (!empty($social_networks)) { ksort($social_networks); ?> <p> <label><?php _e('Social Profiles', 'wp-easy-mode'); ?> </label> <br> <span class="description"><?php _e('Add links to the social profiles where website vistors can follow and learn more about you.', 'wp-easy-mode'); ?> </span> <br> <span class="wpem-contact-social-grid"> <?php foreach ($social_networks as $network => $data) { ?> <a href="#" title="<?php echo esc_attr($data['label']); ?> " data-key="<?php echo esc_attr($network); ?> " data-url="<?php echo esc_attr($data['url']); ?> " data-select="<?php echo !empty($data['select']) ? esc_attr($data['select']) : null; ?> " data-placeholder="<?php esc_attr_e(sprintf('Enter your %s URL here', $data['label']), 'wp-easy-mode'); ?> " class="<?php echo wpem_get_social_profile_url($network) ? 'active' : ''; ?> "> <i class="fa fa-<?php echo !empty($data['icon']) ? esc_attr($data['icon']) : esc_attr($network); ?> "></i> </a> <?php } ?> </span> </p> <div id="wpem-contact-social-fields"></div> <script type="text/html" id="wpem-social-link-template"> <p> <label><i></i></label> <input type="text" required> </p> </script> <?php } /** * Fires after the Contact content */ do_action('wpem_step_contact_after_content'); }