Example #1
0
 protected function __construct()
 {
     if (false !== get_transient('_my-wp-backup-activated')) {
         delete_transient('_my-wp-backup-activated');
         wp_redirect(Admin::get_page_url(''));
     }
     self::$info = get_file_data(__FILE__, array('name' => 'Plugin Name', 'pluginUri' => 'Plugin URI', 'supportUri' => 'Support URI', 'version' => 'Version', 'description' => 'Description', 'author' => 'Author', 'authorUri' => 'Author URI', 'textDomain' => 'Text Domain', 'domainPath' => 'Domain Path', 'slug' => 'Slug', 'license' => 'License', 'licenseUri' => 'License URI'));
     Admin::get_instance();
     $options = get_site_option('my-wp-backup-options', Admin::$options);
     self::$info['baseDir'] = plugin_dir_path(__FILE__);
     self::$info['baseDirUrl'] = plugin_dir_url(__FILE__);
     self::$info['backup_dir'] = trailingslashit(ABSPATH) . trailingslashit(ltrim($options['backup_dir'], '/'));
     self::$info['root_dir'] = trailingslashit(ABSPATH);
     if (defined('WP_CLI') && WP_CLI) {
         \WP_CLI::add_command('job', new Cli\Job());
         \WP_CLI::add_command('backup', new Cli\Backup());
     }
     add_action('wp_backup_run_job', array(Job::get_instance(), 'cron_run'));
     add_action('wp_backup_restore_backup', array(Backup::get_instance(), 'cron_run'));
     $version = get_site_option(self::KEY_VERSION);
     if (!$version || self::$info['version'] !== $version) {
         if ($this->update_options()) {
             update_site_option(self::KEY_VERSION, self::$info['version']);
         }
     }
 }
Example #2
0
 function __construct()
 {
     $this->username = $this->get_license() ? base64_decode(file_get_contents($this->get_license())) : NULL;
     if (isset($_GET['updated']) && $_GET['updated'] === 'retry_auth') {
         delete_transient('security_api_result');
     }
 }
function wc_crm_delete_group_transient()
{
    $transient = array('wc_crm_static_group_taxonomies', 'wc_crm_group_taxonomies', 'wc_crm_dynamic_group_taxonomies');
    foreach ($transient as $name) {
        delete_transient($name);
    }
}
 public function w3tc_ajax_extension_cloudflare_zones_done()
 {
     $email = $_REQUEST['email'];
     $key = $_REQUEST['key'];
     $zone_id = Util_Request::get('zone_id');
     if (empty($zone_id)) {
         return $this->_render_extension_cloudflare_zones(array('email' => $email, 'key' => $key, 'error_message' => 'Please select zone'));
     }
     $zone_name = '';
     // get zone name
     try {
         $api = new Extension_CloudFlare_Api(array('email' => $email, 'key' => $key));
         $zone = $api->zone($zone_id);
         $zone_name = $zone['name'];
     } catch (\Exception $ex) {
         $details['error_message'] = 'Can\'t authenticate: ' . $ex->getMessage();
         include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Intro.php';
         exit;
     }
     $c = Dispatcher::config();
     $c->set(array('cloudflare', 'email'), $email);
     $c->set(array('cloudflare', 'key'), $key);
     $c->set(array('cloudflare', 'zone_id'), $zone_id);
     $c->set(array('cloudflare', 'zone_name'), $zone_name);
     $c->save();
     delete_transient('w3tc_cloudflare_stats');
     $postfix = Util_Admin::custom_message_id(array(), array('extension_cloudflare_configuration_saved' => 'CloudFlare credentials are saved successfully'));
     echo 'Location admin.php?page=w3tc_extensions&extension=cloudflare&' . 'action=view&' . $postfix;
     exit;
 }
Example #5
0
 /**
  * @param W3_Config $config
  * @param W3_Config $old_config
  */
 function possible_state_change($config, $old_config)
 {
     if ($old_config->get_string('plugin.license_key') != '' && $config->get_string('plugin.license_key') == '') {
         $result = edd_w3edge_w3tc_deactivate_license($old_config->get_string('plugin.license_key'));
         if ($result) {
             $this->site_inactivated = true;
         }
         delete_transient('w3tc_license_status');
     } else {
         if ($old_config->get_string('plugin.license_key') == '' && $config->get_string('plugin.license_key') != '') {
             $result = edd_w3edge_w3tc_activate_license($config->get_string('plugin.license_key'));
             if ($result) {
                 $this->site_activated = true;
             }
             delete_transient('w3tc_license_status');
         } else {
             if ($old_config->get_string('plugin.license_key') != $config->get_string('plugin.license_key')) {
                 $result = edd_w3edge_w3tc_activate_license($config->get_string('plugin.license_key'));
                 if ($result) {
                     $this->site_activated = true;
                 }
                 delete_transient('w3tc_license_status');
             }
         }
     }
 }
Example #6
0
 private static function apiRequest($act, $post_data = null, $use_ssl = true)
 {
     global $wp_version;
     $site = rawurlencode(base64_encode(get_option('siteurl')));
     $url = "http" . ($use_ssl ? "s://ssl-account.com" : ":/") . "/interface.fabi.me/wpfilebase-pro/{$act}.php";
     $get_args = array('version' => WPFB_VERSION, 'pl_slug' => 'wp-filebase', 'pl_ver' => WPFB_VERSION, 'wp_ver' => $wp_version, 'site' => $site);
     // try to get from cache
     $cache_key = 'wpfb_apireq_' . md5($act . '||' . serialize($get_args) . '||' . serialize($post_data) . '||' . __FILE__);
     if (isset($_REQUEST['no_api_cache'])) {
         delete_transient($cache_key);
     }
     $res = get_transient($cache_key);
     if ($res !== false) {
         return $res;
     }
     //trigger_error ( "WP-Filebase apiRequest (ssl=$use_ssl): $act ".json_encode($post_data), E_USER_NOTICE );
     if (empty($post_data)) {
         $res = wp_remote_get($url, $get_args);
     } else {
         $res = wp_remote_post(add_query_arg($get_args, $url), array('body' => $post_data));
     }
     if (is_wp_error($res)) {
         if ($use_ssl) {
             // retry without ssl
             return self::apiRequest($act, $post_data, false);
         }
         echo "<b>WP-Filebase API request error:</b>";
         print_r($res);
         return false;
     }
     $res = empty($res['body']) ? false : json_decode($res['body']);
     set_transient($cache_key, $res, 0 + 6 * HOUR_IN_SECONDS);
     return $res;
 }
 /**
  * Empty the Lists cache
  */
 public function empty_cache()
 {
     delete_transient($this->transient_name);
     delete_transient($this->transient_name . '_fallback');
     delete_transient('mc4wp_list_counts');
     delete_transient('mc4wp_list_counts_fallback');
 }
Example #8
0
/**
 * Disables the product price cache. This function looks for the cache key
 * that is about to be retrieved by WooCommerce, and deletes the cached data
 * associated to it.
 *
 * IMPORTANT
 * This function can have an impact on WooCommerce's performance, and it
 * should not be used unless necessary.
 * 
 * @param array cache_key_args The arguments that form the cache key.
 * @param WC_Product product The product for which the key is being generated.
 * @param bool display Indicates if the prices are being retrieved for display
 * purposes.
 * @return array
 * @since WooCommerce 2.4
 * @author Aelia <*****@*****.**>
 * @link http://aelia.co/2015/08/11/wc-2-4-workaround-for-price-cache
 */
function disable_variation_prices_cache($cache_key_args, $product, $display)
{
    // Delete the cached data, if it exists
    $cache_key = 'wc_var_prices' . md5(json_encode($cache_key_args));
    delete_transient($cache_key);
    return $cache_key_args;
}
function wps_requirements_check($force_check = false)
{
    $check_okay = get_transient('wps_requirements_check');
    if (empty($force_check) && false !== $check_okay) {
        return $check_okay;
    }
    $deactivate_reason = false;
    if (!function_exists('aihr_check_aihrus_framework')) {
        $deactivate_reason = esc_html__('Missing Aihrus Framework');
        add_action('admin_notices', 'wps_notice_aihrus');
    } elseif (!aihr_check_aihrus_framework(WPS_BASE, WPS_NAME, WPS_AIHR_VERSION)) {
        $deactivate_reason = esc_html__('Old Aihrus Framework version detected');
    }
    if (!aihr_check_php(WPS_BASE, WPS_NAME)) {
        $deactivate_reason = esc_html__('Old PHP version detected');
    }
    if (!aihr_check_wp(WPS_BASE, WPS_NAME)) {
        $deactivate_reason = esc_html__('Old WordPress version detected');
    }
    if (!empty($deactivate_reason)) {
        aihr_deactivate_plugin(WPS_BASE, WPS_NAME, $deactivate_reason);
    }
    $check_okay = empty($deactivate_reason);
    if ($check_okay) {
        delete_transient('wps_requirements_check');
        set_transient('wps_requirements_check', $check_okay, HOUR_IN_SECONDS);
    }
    return $check_okay;
}
Example #10
0
 public function erase_transient_data()
 {
     delete_transient(self::CATALOG_SITE_TYPES);
     delete_transient(self::CATALOG_THEMES);
     delete_transient(self::CATALOG_PLUGINS);
     delete_transient(self::TRANSIENT_CHECK_FLAG);
 }
Example #11
0
 function delete_cache_transition($new_status, $old_status, $post)
 {
     global $wpdb;
     $cache_duration = vibe_get_option('cache_duration');
     if (!isset($cache_duration)) {
         $cache_duration = 0;
     }
     if ($cache_duration) {
         $key = 'kposts_' . $post->post_type;
         $instructor_content_privacy = vibe_get_option('instructor_content_privacy');
         if ($instructor_content_privacy) {
             $user_id = get_current_user_id();
             $key .= '_' . $user_id;
         }
         $linkage = vibe_get_option('linkage');
         if (isset($linkage) && $linkage) {
             $linkage_terms = get_the_terms($post_id, 'linkage');
             if (isset($linkage_terms) && is_array($linkage_terms)) {
                 foreach ($linkage_terms as $term) {
                     $key .= '_' . $term->name;
                 }
             }
         }
         delete_transient($key);
         if ($post->post_type == 'course') {
             global $wpdb;
             $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '%wplms_%_course%'");
         }
     }
 }
        /**
         * Admin notices
         */
        function admin_notices()
        {
            if ('removed_ht_kb_data' == get_transient('_removed_ht_kb_data')) {
                delete_transient('_removed_ht_kb_data');
                ?>
                    <div class="updated">
                        <p><?php 
                _e('Knowldge Base Data Removed', 'ht-knowledge-base');
                ?>
</p>
                    </div>
                <?php 
            }
            if ('install_sample_ht_kb_data' == get_transient('_install_sample_ht_kb_data')) {
                delete_transient('_install_sample_ht_kb_data');
                ?>
                    <div class="updated">
                        <p><?php 
                _e('Knowldge Base Sample Data Added', 'ht-knowledge-base');
                ?>
</p>
                    </div>
                <?php 
            }
        }
Example #13
0
function wp_dlm_clear_cached_stuff()
{
    delete_transient('dlm_categories');
    delete_transient('dlm_tags');
    delete_transient('dlm_used_tags');
    wp_cache_flush();
}
 static function uninstall()
 {
     global $wpdb;
     if (is_multisite()) {
         // Cleanup Network install
         foreach (wp_get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) {
             switch_to_blog($blog['blog_id']);
             $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_gadash%%'");
             $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_gadash%%'");
             $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_ga_dash%%'");
             $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_ga_dash%%'");
             delete_option('gadash_options');
             delete_transient('ga_dash_lasterror');
             delete_transient('ga_dash_refresh_token');
             delete_transient('ga_dash_gapi_errors');
             restore_current_blog();
         }
         delete_site_option('gadash_network_options');
         delete_site_transient('ga_dash_refresh_token');
     } else {
         // Cleanup Single install
         $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_gadash%%'");
         $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_gadash%%'");
         $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_ga_dash%%'");
         $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_ga_dash%%'");
         delete_option('gadash_options');
         delete_transient('ga_dash_lasterror');
         delete_transient('ga_dash_refresh_token');
         delete_transient('ga_dash_gapi_errors');
     }
 }
function bqw_sliderpro_delete_all_data()
{
    global $wpdb;
    $prefix = $wpdb->prefix;
    $sliders_table = $prefix . 'slider_pro_sliders';
    $slides_table = $prefix . 'slider_pro_slides';
    $layers_table = $prefix . 'slider_pro_layers';
    $wpdb->query("DROP TABLE {$sliders_table}, {$slides_table}, {$layers_table}");
    delete_option('sliderpro_custom_css');
    delete_option('sliderpro_custom_js');
    delete_option('sliderpro_is_custom_css');
    delete_option('sliderpro_is_custom_js');
    delete_option('sliderpro_load_stylesheets');
    delete_option('sliderpro_load_custom_css_js');
    delete_option('sliderpro_load_unminified_scripts');
    delete_option('sliderpro_purchase_code');
    delete_option('sliderpro_purchase_code_message');
    delete_option('sliderpro_purchase_code_status');
    delete_option('sliderpro_hide_inline_info');
    delete_option('sliderpro_hide_getting_started_info');
    delete_option('sliderpro_access');
    delete_option('sliderpro_version');
    delete_transient('sliderpro_post_names');
    delete_transient('sliderpro_posts_data');
    delete_transient('sliderpro_update_notification_message');
    $wpdb->query("DELETE FROM " . $prefix . "options WHERE option_name LIKE '%sliderpro_cache%'");
}
Example #16
0
 private function reset_state()
 {
     delete_transient('wpsc_settings_tab_import_file');
     $this->file = false;
     $this->completed = false;
     $this->display_data = array();
 }
function pmpro_notifications()
{
    if (current_user_can("manage_options")) {
        delete_transient("pmpro_notification_" . PMPRO_VERSION);
        $pmpro_notification = get_transient("pmpro_notification_" . PMPRO_VERSION);
        if (empty($pmpro_notification)) {
            if (is_ssl()) {
                $pmpro_notification = wp_remote_retrieve_body(wp_remote_get("https://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION));
            } else {
                $pmpro_notification = wp_remote_retrieve_body(wp_remote_get("http://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION));
            }
            set_transient("pmpro_notification_" . PMPRO_VERSION, $pmpro_notification, 86400);
        }
        if ($pmpro_notification && $pmpro_notification != "NULL") {
            ?>
		<div id="pmpro_notifications">
			<?php 
            echo $pmpro_notification;
            ?>
		</div>
		<?php 
        }
    }
    //exit so we just show this content
    exit;
}
Example #18
0
 function store()
 {
     // Save the posted value in the database
     update_option($this->option_name, $this);
     delete_transient($this->option_name);
     set_transient($this->option_name, $this);
 }
Example #19
0
 function aioseop_activate()
 {
     global $aiosp_activation, $aioseop_update_checker;
     $aiosp_activation = true;
     delete_transient("aioseop_oauth_current");
     $aioseop_update_checker->checkForUpdates();
 }
Example #20
0
/**
Plugin Name: SSO
Author: Garth Mortensen, Mike Hansen
Version: 0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
function sso_check()
{
    if (!isset($_GET['salt']) || !isset($_GET['nonce']) || !isset($_GET['user'])) {
        sso_req_login();
    }
    if (sso_check_blocked()) {
        sso_req_login();
    }
    $nonce = esc_attr($_GET['nonce']);
    $salt = esc_attr($_GET['salt']);
    $user = esc_attr($_GET['user']);
    $hash = base64_encode(hash('sha256', $nonce . $salt, false));
    $hash = substr($hash, 0, 64);
    if (get_transient('sso_token') == $hash) {
        if (is_email($user)) {
            $user = get_user_by('email', $user);
        } else {
            $user = get_user_by('id', (int) $user);
        }
        if (is_a($user, 'WP_User')) {
            wp_set_current_user($user->ID, $user->user_login);
            wp_set_auth_cookie($user->ID);
            do_action('wp_login', $user->user_login);
            delete_transient('sso_token');
            wp_safe_redirect(admin_url());
        } else {
            sso_req_login();
        }
    } else {
        sso_add_failed_attempt();
        sso_req_login();
    }
    die;
}
Example #21
0
 public static function do_deactivation_actions()
 {
     delete_transient(self::SETTING_KEY_DISPLAY);
     delete_transient(self::SETTING_KEY_STYLE);
     delete_transient(self::SETTING_KEY_ADVANCED);
     delete_transient(self::SETTING_KEY_NUM_STYLE_SAVED);
 }
Example #22
0
 function admin_init()
 {
     global $wp_theatre;
     /*
      * Flush rewrite rules after option's values have been updated.
      * @see sanitize_option_values()
      */
     if (delete_transient('wpt_listing_page_flush_rules')) {
         flush_rewrite_rules();
     }
     /*
      * Create a new tab on the settings page.
      */
     register_setting('wpt_listing_page', 'wpt_listing_page', array($this, 'sanitize_option_values'));
     if ($wp_theatre->admin->tab == 'wpt_listing_page') {
         add_settings_section('wpt_listing_page_page', __('Upcoming events', 'wp_theatre'), '', 'wpt_listing_page');
         add_settings_field('wpt_listing_page_post_id', __('Page to show upcoming events on', 'wp_theatre'), array($this, 'settings_field_wpt_listing_page_post_id'), 'wpt_listing_page', 'wpt_listing_page_page');
         add_settings_field('wpt_listing_page_position', __('Position on page', 'wp_theatre'), array($this, 'settings_field_wpt_listing_page_position'), 'wpt_listing_page', 'wpt_listing_page_page');
         add_settings_field('wpt_listing_page_nav_events', __('Arrange the events', 'wp_theatre'), array($this, 'settings_field_wpt_listing_page_nav_events'), 'wpt_listing_page', 'wpt_listing_page_page');
         add_settings_field('wpt_listing_page_template', __('Template', 'wp_theatre'), array($this, 'settings_field_wpt_listing_template'), 'wpt_listing_page', 'wpt_listing_page_page');
         add_settings_section('wpt_listing_production_page', __('Events on production pages', 'wp_theatre'), '', 'wpt_listing_page');
         add_settings_field('wpt_listing_page_position_on_production_page', __('Position on page', 'wp_theatre'), array($this, 'settings_field_wpt_listing_page_position_on_production_page'), 'wpt_listing_page', 'wpt_listing_production_page');
         add_settings_field('wpt_listing_page_template_on_production_page', __('Template', 'wp_theatre'), array($this, 'settings_field_wpt_listing_template_on_production_page'), 'wpt_listing_page', 'wpt_listing_production_page');
     }
 }
 /**
  * @since 1.4
  * @return array
  */
 public function &upgrade()
 {
     $major_version = (double) $this->options['version'];
     if ($major_version < 1.3) {
         $this->upgradeOptionsUpTo_1_2_2();
         // Here the backup() method must be called after upgradeOptionsUpTo_1_2_2()
         // to let the latter merge the two arrays of options.
         $this->backup();
         delete_transient('sitetree');
         delete_option('sitetree_content');
     } elseif ($major_version < 1.4) {
         $this->backup();
         $this->upgrade_1_3_Options();
         delete_transient('sitetree');
         delete_transient('sitetree_xml');
         wp_clear_scheduled_hook('sitetree_rebuild');
         wp_clear_scheduled_hook('sitetree_rebuild', array('xml'));
     } elseif ($major_version < 1.5) {
         $this->backup();
         $this->upgrade_1_4_Data();
     } elseif ($this->options['version'] === '1.5') {
         $this->restoreAndUpgradeExceptionsLostWith_1_5();
     } else {
         return $this->options;
     }
     return $this->newOptions;
 }
 /**
  * Uses the Brightcove oAuth API to retrieve and store an access key for use with requests. The token is stored as a transient
  * with an expiration time matching that which is returned from Brightcove. The call to the API is only performed if that transient
  * is invalid or expired. Return a WP_Error object for use in WordPress in the case of failure.
  *
  * @since  1.0.0
  *
  * @see    get_transient()
  * @see    set_transient()
  * @see    delete_transient()
  * @see    wp_remote_post()
  *
  * @param bool $force_new_token whether or not to obtain a new OAuth token
  * @param bool $retry           true to retry on failure or false
  *
  * @return string|WP_Error
  */
 public function _request_access_token($force_new_token = false, $retry = true)
 {
     $transient_name = $this->transient_name;
     $token = $force_new_token ? false : get_transient($transient_name);
     if (!$token) {
         $endpoint = esc_url_raw(self::ENDPOINT_BASE . '/access_token?grant_type=client_credentials');
         $request = wp_remote_post($endpoint, $this->_http_headers);
         if ('400' == wp_remote_retrieve_response_code($request)) {
             // Just in case
             delete_transient($transient_name);
             $oauth_error = new WP_Error('oauth_access_token_failure', sprintf(__('There is a problem with your Brightcove %1$s or %2$s', 'brightcove'), '<code>client_id</code>', '<code>client_secret</code>'));
             BC_Logging::log(sprintf('BC OAUTH ERROR: %s', $oauth_error->get_error_message()));
             return $oauth_error;
         }
         $body = wp_remote_retrieve_body($request);
         $data = json_decode($body);
         if (isset($data->access_token)) {
             $token = $data->access_token;
             set_transient($transient_name, $token, $data->expires_in);
         } else {
             if (!$retry) {
                 return new WP_Error('oauth_access_token_response_failure', sprintf(esc_html__('oAuth API did not return us an access token', 'brightcove')));
             }
             return $this->_request_access_token($force_new_token, false);
         }
     }
     return $token;
 }
function wr2x_admin_init()
{
    if (isset($_POST) && isset($_POST['wr2x_pro'])) {
        wr2x_validate_pro($_POST['wr2x_pro']['subscr_id']);
    }
    $pro_status = get_option('wr2x_pro_status', "Not Pro.");
    require 'wr2x_class.settings-api.php';
    if (delete_transient('wr2x_flush_rules')) {
        global $wp_rewrite;
        wr2x_generate_rewrite_rules($wp_rewrite, true);
    }
    $sections = array(array('id' => 'wr2x_basics', 'title' => __('Basics', 'wp-retina-2x')), array('id' => 'wr2x_advanced', 'title' => __('Advanced', 'wp-retina-2x')), array('id' => 'wr2x_pro', 'title' => __('Pro', 'wp-retina-2x')));
    // Default Auto-Generate
    $auto_generate = wr2x_getoption('auto_generate', 'wr2x_basics', null);
    if ($auto_generate === null) {
        wr2x_setoption('auto_generate', 'wr2x_basics', 'on');
    }
    $wpsizes = wr2x_get_image_sizes();
    $sizes = array();
    foreach ($wpsizes as $name => $attr) {
        $sizes["{$name}"] = sprintf("%s (%dx%d)", $name, $attr['width'], $attr['height']);
    }
    $fields = array('wr2x_basics' => array(array('name' => 'ignore_sizes', 'label' => __('Disabled Sizes', 'wp-retina-2x'), 'desc' => __('<br />The selected sizes will not have their retina equivalent generated.', 'wp-retina-2x'), 'type' => 'multicheck', 'options' => $sizes), array('name' => 'auto_generate', 'label' => __('Auto Generate', 'wp-retina-2x'), 'desc' => __('Generate retina images automatically when images are uploaded or re-generated.<br />The \'Disabled Sizes\' will be skipped.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => true), array('name' => 'full_size', 'label' => __('Full Size Retina (Pro)', 'wp-retina-2x'), 'desc' => __('Retina for the full-size image will be considered required.<br />Checks and upload feature are available.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)), 'wr2x_advanced' => array(array('name' => 'method', 'label' => __('Method', 'wp-retina-2x'), 'desc' => __('<br />Check the <a href="http://apps.meow.fr/wp-retina-2x/">plugin official page</a> if you want to know more about the methods to deliver the retina images.', 'wp-retina-2x'), 'type' => 'radio', 'default' => 'Picturefill', 'options' => array('Picturefill' => __("Picturefill (Recommended)", 'wp-retina-2x'), 'retina.js' => __("Retina.js", 'wp-retina-2x'), 'HTML Rewrite' => __("IMG Rewrite", 'wp-retina-2x'), 'Retina-Images' => __("Retina-Images", 'wp-retina-2x'), 'none' => __("None", 'wp-retina-2x'))), array('name' => 'image_quality', 'label' => __('Quality', 'wp-retina-2x'), 'desc' => __('<br />Image Compression quality (between 0 and 100).<br />That doesn\'t always actually work depending on your hosting service.', 'wp-retina-2x'), 'type' => 'text', 'default' => 90), array('name' => 'debug', 'label' => __('Debug Mode', 'wp-retina-2x'), 'desc' => __('If checked, the client will be always served Retina images. <br />Please use it for testing purposes. It creates a <a href="' . plugins_url("wp-retina-2x") . '/wp-retina-2x.log">log file</a> in the plugin folder.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'cdn_domain', 'label' => __('Custom CDN Domain (Pro)', 'wp-retina-2x'), 'desc' => __('<br />If not empty, your site domain will be replaced with this CDN domain (PictureFill and HTML Rewrite only).', 'wp-retina-2x'), 'type' => 'text', 'default' => ""), array('name' => 'picture_fill', 'label' => '', 'desc' => __('<h2>For PictureFill</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'picturefill_keep_src', 'label' => __('Keep IMG SRC (Pro)', 'wp-retina-2x'), 'desc' => __('With PictureFill, <b>src</b> tags are replaced by <b>src-set</b> tags and consequently search engines might not be able to find and reference those images. Keeping it will load images twice for retina devices on old browsers.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'picturefill_lazysizes', 'label' => __('Use Lazysizes (Pro)', 'wp-retina-2x'), 'desc' => __('HTML will be rewritten to support the lazysizes and the script will be also loaded. The images will be loaded in a lazy way (when the visitor is getting close to them).', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'picturefill_noscript', 'label' => __('No Picturefill Script', 'wp-retina-2x'), 'desc' => __('The script for Picturefill will not be loaded. Only the browsers with src-set support (e.g. Chrome) will display images. You can also load the Picturefill script manually.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'admin_screens', 'label' => '', 'desc' => __('<h2>Admin Screens</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'hide_retina_column', 'label' => __('Hide \'Retina\' column', 'wp-retina-2x'), 'desc' => __('Will hide the \'Retina Column\' from the Media Library.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'hide_retina_dashboard', 'label' => __('Hide Retina Dashboard', 'wp-retina-2x'), 'desc' => __('Doesn\'t show the Retina Dashboard menu and tools.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'retina_admin', 'label' => __('Admin in Retina', 'wp-retina-2x'), 'desc' => __('If checked, the WordPress Admin will also be Retina. Some plugins (like NextGen) do not like Retina enabled in the admin.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'mobile', 'label' => '', 'desc' => __('<h2>Mobiles</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'ignore_mobile', 'label' => __('Ignore Mobile', 'wp-retina-2x'), 'desc' => __('Doesn\'t deliver Retina images to mobiles.<br />PictureFill doesn\'t support it and cache will also prevent it from working.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)), 'wr2x_pro' => array(array('name' => 'pro', 'label' => '', 'desc' => __(sprintf('Status: %s<br /><br />With the Pro version, full support for the <b>Full Size Retina</b> will be added. You will also get a new and nice pop-up window with more <b>Details</b> in the Retina dashboard.', $pro_status), 'wp-retina-2x'), 'type' => 'html'), array('name' => 'subscr_id', 'label' => __('Serial', 'wp-retina-2x'), 'desc' => __('<br />Enter your serial or subscription ID here. If you don\'t have one yet, get one <a target="_blank" href="http://apps.meow.fr/wp-retina-2x/">right here</a>.', 'wp-retina-2x'), 'type' => 'text', 'default' => "")));
    global $wr2x_settings_api;
    $wr2x_settings_api = new WeDevs_Settings_API();
    $wr2x_settings_api->set_sections($sections);
    $wr2x_settings_api->set_fields($fields);
    $wr2x_settings_api->admin_init();
}
function wr2x_admin_init()
{
    if (isset($_POST) && isset($_POST['wr2x_pro'])) {
        wr2x_validate_pro($_POST['wr2x_pro']['subscr_id']);
    }
    $pro_status = get_option('wr2x_pro_status', "Not Pro.");
    require 'wr2x_class.settings-api.php';
    if (delete_transient('wr2x_flush_rules')) {
        global $wp_rewrite;
        wr2x_generate_rewrite_rules($wp_rewrite, true);
    }
    $sections = array(array('id' => 'wr2x_basics', 'title' => __('Basics', 'wp-retina-2x')), array('id' => 'wr2x_advanced', 'title' => __('Advanced', 'wp-retina-2x')), array('id' => 'wr2x_pro', 'title' => __('Pro', 'wp-retina-2x')));
    // Default Auto-Generate
    $auto_generate = wr2x_getoption('auto_generate', 'wr2x_basics', null);
    if ($auto_generate === null) {
        wr2x_setoption('auto_generate', 'wr2x_basics', 'on');
    }
    $wpsizes = wr2x_get_image_sizes();
    $sizes = array();
    foreach ($wpsizes as $name => $attr) {
        $sizes["{$name}"] = sprintf("<div style='float: left; text-align: right; margin-right: 5px; width: 20px;'>%s</div> <b>%s</b> <small>(Normal: %dx%d, Retina: %dx%d)</small>", wr2x_size_shortname($name), $name, $attr['width'], $attr['height'], $attr['width'] * 2, $attr['height'] * 2);
    }
    $fields = array('wr2x_basics' => array(array('name' => 'ignore_sizes', 'label' => __('Disabled Sizes', 'wp-retina-2x'), 'desc' => __('<br />The selected sizes will not have their retina equivalent generated.', 'wp-retina-2x'), 'type' => 'multicheck', 'options' => $sizes), array('name' => 'auto_generate', 'label' => __('Auto Generate', 'wp-retina-2x'), 'desc' => __('Generate retina images automatically when images are uploaded or re-generated.<br /><small>The \'Disabled Sizes\' will be skipped.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => true), array('name' => 'disable_responsive', 'label' => __('Disable Responsive<br/>(WP 4.4+)', 'wp-retina-2x'), 'desc' => __('Disable the Responsive Images feature of WordPress 4.4+.<br /><small>This feature can be quite messy for many websites as it creates a src-set automatically with all your image sizes in it. You can disable it completely here and get back control over your HTML as it is in the editor (while keeping the plugin adding Retina support, of course).</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'disable_medium_large', 'label' => __('Disable Medium Large<br/>(WP 4.4+)', 'wp-retina-2x'), 'desc' => __('Disable the image size called "Medium Large" created by in WordPress 4.4+.<br /><small>You probably don\'t need this and it creates additional images. Be careful however, future themes might use it.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'full_size', 'label' => __('Full Size Retina (Pro)', 'wp-retina-2x'), 'desc' => __('Retina for the full-size image will be considered required.<br /><small>Checks for Full-Size retina will be enabled and upload features made available.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)), 'wr2x_advanced' => array(array('name' => 'method', 'label' => __('Method', 'wp-retina-2x'), 'desc' => __('<br />In all cases (including "None"), Retina support will be added to the Responsive Images created by WP 4.4.<br />Check the <a href="http://apps.meow.fr/wp-retina-2x/retina-methods/">Retina Methods</a> page if you want to know more about those methods.', 'wp-retina-2x'), 'type' => 'radio', 'default' => 'Picturefill', 'options' => array('Picturefill' => __("Picturefill (Recommended)", 'wp-retina-2x'), 'retina.js' => __("Retina.js", 'wp-retina-2x'), 'HTML Rewrite' => __("IMG Rewrite", 'wp-retina-2x'), 'Retina-Images' => __("Retina-Images", 'wp-retina-2x'), 'none' => __("None", 'wp-retina-2x'))), array('name' => 'image_quality', 'label' => __('Quality', 'wp-retina-2x'), 'desc' => __('<br />Image Compression quality (between 0 and 100).<br />That doesn\'t always actually work depending on your hosting service.', 'wp-retina-2x'), 'type' => 'text', 'default' => 90), array('name' => 'debug', 'label' => __('Debug Mode', 'wp-retina-2x'), 'desc' => __('Retina images will be always displayed and a log file will be created. <br /><small>Please use it for testing purposes. It creates a <a href="' . plugins_url("wp-retina-2x") . '/wp-retina-2x.log">log file</a> in the plugin folder.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'cdn_domain', 'label' => __('Custom CDN Domain (Pro)', 'wp-retina-2x'), 'desc' => __('<br />If not empty, your site domain will be replaced with this CDN domain (PictureFill and HTML Rewrite only).', 'wp-retina-2x'), 'type' => 'text', 'default' => ""), array('name' => 'picture_fill', 'label' => '', 'desc' => __('<h2>For PictureFill</h2><small>Using "Keep IMG SRC" and "Use Lazysizes" is the perfect middle between SEO and Performance.<br />Since WP 4.4, the src-set is already created for post content. Those options will therefore only affect the images which are <u>not</u> in the post content.</small>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'picturefill_keep_src', 'label' => __('Keep IMG SRC (Pro)', 'wp-retina-2x'), 'desc' => __('Excellent for SEO. But Retina devices will get both normal and retina images.<br /><small>With PictureFill, <b>src</b> tags are replaced by <b>src-set</b> tags and consequently search engines might not be able to find and reference those images.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'picturefill_lazysizes', 'label' => __('Use Lazysizes (Pro)', 'wp-retina-2x'), 'desc' => __('Retina images will be loaded in a lazy way, when the visitor is getting close to them.<br /><small>HTML will be rewritten to support the lazysizes and the script will be also loaded. </small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'picturefill_noscript', 'label' => __('No Picturefill Script', 'wp-retina-2x'), 'desc' => __('The script for Picturefill will not be loaded.<br /><small>Only the browsers with src-set support (e.g. Chrome) will display images. You can also load the Picturefill script manually.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'admin_screens', 'label' => '', 'desc' => __('<h2>Admin Screens</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'hide_retina_column', 'label' => __('Hide \'Retina\' column', 'wp-retina-2x'), 'desc' => __('Will hide the \'Retina Column\' from the Media Library.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'hide_retina_dashboard', 'label' => __('Hide Retina Dashboard', 'wp-retina-2x'), 'desc' => __('Doesn\'t show the Retina Dashboard menu and tools.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'retina_admin', 'label' => __('Admin in Retina', 'wp-retina-2x'), 'desc' => __('WordPress Admin will also be Retina.<br /><small>Some plugins (like NextGen) do not like Retina enabled in the admin.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'mobile', 'label' => '', 'desc' => __('<h2>Mobiles</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'ignore_mobile', 'label' => __('Ignore Mobile', 'wp-retina-2x'), 'desc' => __('Doesn\'t deliver Retina images to mobiles.<br /><small>PictureFill doesn\'t support it and cache will also prevent it from working.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)), 'wr2x_pro' => array(array('name' => 'pro', 'label' => '', 'desc' => __(sprintf('Status: %s<br /><br />With the Pro version, full support for the <b>Full Size Retina</b> will be added. You will also get a new and nice pop-up window with more <b>Details</b> in the Retina dashboard.', $pro_status), 'wp-retina-2x'), 'type' => 'html'), array('name' => 'subscr_id', 'label' => __('Serial', 'wp-retina-2x'), 'desc' => __('<br />Enter your serial or subscription ID here. If you don\'t have one yet, get one <a target="_blank" href="http://apps.meow.fr/wp-retina-2x/">right here</a>.', 'wp-retina-2x'), 'type' => 'text', 'default' => "")));
    global $wr2x_settings_api;
    $wr2x_settings_api = new WeDevs_Settings_API();
    $wr2x_settings_api->set_sections($sections);
    $wr2x_settings_api->set_fields($fields);
    $wr2x_settings_api->admin_init();
}
 /**
  * pre-defined validation callback method
  * @param $sInput
  * @param $sOldInput
  * @return mixed
  */
 public function validation_HW_Conditions_Metabox($sInput, $sOldInput)
 {
     //  delete transient when add new one or modify exists post
     delete_transient('hw_dynamic_conditions_settings');
     //if(!isset($_SESSION['skin_options']) && isset($sInput['skin_options'])) unset($sInput['skin_options']);
     return $sInput;
 }
Example #28
0
 public function render()
 {
     delete_transient($this->transient_notices);
     $loader = new \Twig_Loader_Filesystem($this->paths);
     $twig = new \Twig_Environment($loader);
     // Add the admin_url() function.
     $twig->addFunction('admin_url', new \Twig_SimpleFunction('admin_url', 'admin_url'));
     // Add titlecase filter.
     $titlecase_filter = new \Twig_SimpleFilter('titlecase', '\\WordPress\\Tabulate\\Text::titlecase');
     $twig->addFilter($titlecase_filter);
     // Add date and time filters.
     $date_filter = new \Twig_SimpleFilter('wp_date_format', '\\WordPress\\Tabulate\\Text::wp_date_format');
     $twig->addFilter($date_filter);
     $time_filter = new \Twig_SimpleFilter('wp_time_format', '\\WordPress\\Tabulate\\Text::wp_time_format');
     $twig->addFilter($time_filter);
     // Add strtolower filter.
     $strtolower_filter = new \Twig_SimpleFilter('strtolower', function ($str) {
         if (is_array($str)) {
             return array_map('strtolower', $str);
         } else {
             return strtolower($str);
         }
     });
     $twig->addFilter($strtolower_filter);
     // Enable debugging.
     if (WP_DEBUG) {
         $twig->enableDebug();
         $twig->addExtension(new \Twig_Extension_Debug());
     }
     // Render the template.
     $template = $twig->loadTemplate($this->templateName);
     return $template->render($this->data);
 }
Example #29
0
 /**
  * Install actions such as installing pages when a button is clicked.
  */
 public function install_actions()
 {
     // Install - Add pages button
     if (!empty($_GET['install_woocommerce_pages'])) {
         self::create_pages();
         // We no longer need to install pages
         delete_option('_wc_needs_pages');
         delete_transient('_wc_activation_redirect');
         // What's new redirect
         wp_redirect(admin_url('index.php?page=wc-about&wc-installed=true'));
         exit;
         // Skip button
     } elseif (!empty($_GET['skip_install_woocommerce_pages'])) {
         // We no longer need to install pages
         delete_option('_wc_needs_pages');
         delete_transient('_wc_activation_redirect');
         // What's new redirect
         wp_redirect(admin_url('index.php?page=wc-about'));
         exit;
         // Update button
     } elseif (!empty($_GET['do_update_woocommerce'])) {
         $this->update();
         // Update complete
         delete_option('_wc_needs_pages');
         delete_option('_wc_needs_update');
         delete_transient('_wc_activation_redirect');
         // What's new redirect
         wp_redirect(admin_url('index.php?page=wc-about&wc-updated=true'));
         exit;
     }
 }
 /**
  * Directories of sub sites on a network should not count against the same spaced used total for
  * the main site.
  */
 function test_get_space_used_main_site()
 {
     $space_used = get_space_used();
     $blog_id = $this->factory->blog->create();
     switch_to_blog($blog_id);
     // We don't rely on an initial value of 0 for space used, but should have a clean space available
     // so that we can remove any uploaded files and directories without concern of a conflict with
     // existing content directories in src.
     while (0 != get_space_used()) {
         restore_current_blog();
         $blog_id = $this->factory->blog->create();
         switch_to_blog($blog_id);
     }
     // Upload a file to the new site.
     $filename = rand_str() . '.jpg';
     $contents = rand_str();
     wp_upload_bits($filename, null, $contents);
     restore_current_blog();
     delete_transient('dirsize_cache');
     $this->assertEquals($space_used, get_space_used());
     // Switch back to the new site to remove the uploaded file.
     switch_to_blog($blog_id);
     $upload_dir = wp_upload_dir();
     $this->remove_added_uploads();
     $this->delete_folders($upload_dir['basedir']);
     restore_current_blog();
 }