function init()
 {
     global $wpdb, $pagenow;
     ##Create nonce
     $this->nonce = wp_create_nonce(plugin_basename(__FILE__));
     ##Check version and activate if needed.
     if (get_option("PO_version_num") != "6.0.4" && !in_array($pagenow, array("plugins.php", "update-core.php", "update.php"))) {
         $this->activate();
     }
     ##Check for posts that have been deleted
     if (false === get_site_transient('PO_delete_missing_posts')) {
         $allPostsQuery = "SELECT post_id FROM " . $wpdb->prefix . "PO_plugins";
         $allPosts = $wpdb->get_results($allPostsQuery, ARRAY_A);
         foreach ($allPosts as $post) {
             if (false === get_post_status($post['post_id'])) {
                 $deletePluginQuery = "DELETE FROM " . $wpdb->prefix . "PO_plugins WHERE post_id = %d";
                 $wpdb->query($wpdb->prepare($deletePluginQuery, $post['post_id']));
             }
         }
         set_site_transient('PO_delete_missing_posts', 1, 604800);
     }
     if (is_multisite() && get_option('PO_order_access_net_admin') == 1 && !current_user_can('manage_network')) {
         $this->pluginPageActions = "0";
     }
 }
Example #2
0
 public static function vimeo_master_updater_version_check()
 {
     global $vimeo_master_version;
     //CHECK NEW VERSION
     $vimeo_master_slug = basename(dirname(__FILE__));
     $current = get_site_transient('update_plugins');
     $vimeo_plugin_slug = $vimeo_master_slug . '/' . $vimeo_master_slug . '.php';
     @($r = $current->response[$vimeo_plugin_slug]);
     if (empty($r)) {
         $r = false;
         $vimeo_plugin_slug = false;
         if (is_multisite()) {
             update_site_option('vimeo_master_newest_version', $vimeo_master_version);
         } else {
             update_option('vimeo_master_newest_version', $vimeo_master_version);
         }
     }
     if (!empty($r)) {
         $vimeo_plugin_slug = $vimeo_master_slug . '/' . $vimeo_master_slug . '.php';
         @($r = $current->response[$vimeo_plugin_slug]);
         if (is_multisite()) {
             update_site_option('vimeo_master_newest_version', $r->new_version);
         } else {
             update_option('vimeo_master_newest_version', $r->new_version);
         }
     }
 }
function mu_loader_plugins_files()
{
    if (defined('WP_INSTALLING') && WP_INSTALLING === true) {
        // Do nothing during installation
        return array();
    }
    // Cache plugins
    $plugins = get_site_transient('mu_loader_plugins');
    if ($plugins !== false) {
        // Validate plugins still exist
        // If not, invalidate cache
        foreach ($plugins as $plugin_file) {
            if (!is_readable(WPMU_PLUGIN_DIR . '/' . $plugin_file)) {
                $plugins = false;
                break;
            }
        }
    }
    if ($plugins === false) {
        if (!function_exists('get_plugins')) {
            // get_plugins is not included by default
            require ABSPATH . 'wp-admin/includes/plugin.php';
        }
        // Invalid cache
        $plugins = array();
        foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) {
            if (dirname($plugin_file) != '.' && dirname($plugin_file) != 'mu-loader') {
                // skip files directly at root
                $plugins[] = $plugin_file;
            }
        }
        set_site_transient('mu_loader_plugins', $plugins);
    }
    return $plugins;
}
Example #4
0
 /**
  * Register plugin/theme update.
  *
  * @param string $name
  * @param string $type
  * @param string $remote
  * @param array  $options
  */
 public function register($name, $type, $remote, array $options = array())
 {
     $options = array_merge(compact('name', 'type', 'remote'), $options);
     if (!isset($options['id'])) {
         $options['id'] = $type == 'plugin' ? "{$name}/{$name}.php" : $name;
     }
     if ($type == 'plugin') {
         $this->plugins[$name] = $options;
     } else {
         $this->themes[$name] = $options;
     }
     // check expiration
     if (isset($options['expiration'])) {
         $timeout = $options['expiration'];
         if ($type == 'plugin' and $transient = get_site_transient('update_plugins') and isset($transient->response[$options['id']], $transient->last_checked)) {
             if (time() - $transient->last_checked > $timeout) {
                 delete_site_transient('update_plugins');
             }
         }
         if ($type == 'theme' and $transient = get_site_transient('update_themes') and isset($transient->response[$options['id']], $transient->last_checked)) {
             if (time() - $transient->last_checked > $timeout) {
                 delete_site_transient('update_themes');
             }
         }
     }
 }
 function aiowps_validate_registration_with_captcha($errors, $sanitized_user_login, $user_email)
 {
     global $aio_wp_security;
     $locked = $aio_wp_security->user_login_obj->check_locked_user();
     if ($locked == null) {
         //user is not locked continue
     } else {
         $errors->add('authentication_failed', __('<strong>ERROR</strong>: You are not allowed to register because your IP address is currently locked!', 'all-in-one-wp-security-and-firewall'));
         return $errors;
     }
     if (array_key_exists('aiowps-captcha-answer', $_POST)) {
         isset($_POST['aiowps-captcha-answer']) ? $captcha_answer = strip_tags(trim($_POST['aiowps-captcha-answer'])) : ($captcha_answer = '');
         $captcha_secret_string = $aio_wp_security->configs->get_value('aiowps_captcha_secret_key');
         $submitted_encoded_string = base64_encode($_POST['aiowps-captcha-temp-string'] . $captcha_secret_string . $captcha_answer);
         $trans_handle = sanitize_text_field($_POST['aiowps-captcha-string-info']);
         $captcha_string_info_trans = AIOWPSecurity_Utility::is_multisite_install() ? get_site_transient('aiowps_captcha_string_info_' . $trans_handle) : get_transient('aiowps_captcha_string_info_' . $trans_handle);
         if ($submitted_encoded_string !== $captcha_string_info_trans) {
             //This means a wrong answer was entered
             //return new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Your answer was incorrect - please try again.', 'all-in-one-wp-security-and-firewall'));
             $errors->add('authentication_failed', __('<strong>ERROR</strong>: Your answer was incorrect - please try again.', 'all-in-one-wp-security-and-firewall'));
             return $errors;
         }
     }
     return $errors;
 }
Example #6
0
 /**
  * Plugin update check api request.
  *
  * @since 1.0.0
  * @package GeoDirectory_Review_Rating_Manager
  *
  * @global string $gd_api_url The API url where the plugin can check for update.
  * @global string $plugin_slug The plugin slug to check for update.
  *
  * @param object|bool $def The result object. Default false.
  * @param string $action The type of information being requested from the Plugin Install API.
  * @param object $args Plugin API arguments.
  * @return bool|mixed|WP_Error
  */
 function gd_api_info_call($def, $action, $args)
 {
     global $plugin_slug, $gd_api_url;
     if (isset($args->slug) && strpos($args->slug, 'geodir_') !== false) {
     } else {
         return false;
     }
     // if not a geodir plugin bail
     // Get the current version
     $plugin_info = get_site_transient('update_plugins');
     $current_version = 1;
     $args->version = $current_version;
     $request_string = gd_prepare_request($action, $args);
     $request = wp_remote_post($gd_api_url, $request_string);
     //print_r($request);
     if (is_wp_error($request)) {
         $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message());
     } else {
         $res = unserialize($request['body']);
         if ($res === false) {
             $res = new WP_Error('plugins_api_failed', __('An unknown error occurred'), $request['body']);
         }
     }
     return $res;
 }
 /**
  * Put changelog in plugins_api, return WP.org data as appropriate
  *
  * @since 2.0.0
  */
 public function plugins_api($false, $action, $response)
 {
     if (!('plugin_information' === $action)) {
         return $false;
     }
     $wp_repo_data = get_site_transient('ghu-' . md5($response->slug . 'php'));
     if (!$wp_repo_data) {
         $wp_repo_data = wp_remote_get('http://api.wordpress.org/plugins/info/1.0/' . $response->slug . '.php');
         set_site_transient('ghu-' . md5($response->slug . 'php'), $wp_repo_data, 12 * HOUR_IN_SECONDS);
     }
     if (!empty($wp_repo_data['body'])) {
         $wp_repo_body = unserialize($wp_repo_data['body']);
         if (is_object($wp_repo_body)) {
             $response = $wp_repo_body;
         }
     }
     foreach ((array) $this->config as $plugin) {
         if ($response->slug === $plugin->repo) {
             $response->slug = $plugin->slug;
             $response->plugin_name = $plugin->name;
             $response->author = $plugin->author;
             $response->homepage = $plugin->uri;
             $response->version = $plugin->remote_version;
             $response->sections = $plugin->sections;
             $response->requires = $plugin->requires;
             $response->tested = $plugin->tested;
             $response->downloaded = $plugin->downloaded;
             $response->last_updated = $plugin->last_updated;
             $response->rating = $plugin->rating;
             $response->num_ratings = $plugin->num_ratings;
             //$response->download_link = $plugin->download_link;
         }
     }
     return $response;
 }
Example #8
0
function contact_form_7_modules_get_remote_message()
{
    // The ad is stored locally for 30 days as a transient. See if it exists.
    $cache = function_exists('get_site_transient') ? get_site_transient('contact_form_7_modules_remote_ad') : get_transient('contact_form_7_modules_remote_ad');
    // If it exists, use that (so we save some request time), unless ?cache is set.
    if (!empty($cache) && !isset($_REQUEST['cache'])) {
        return $cache;
    }
    // Get the advertisement remotely. An encrypted site identifier, the language of the site, and the version of the cf7 plugin will be sent to katz.co
    $response = wp_remote_post('http://katz.co/ads/', array('timeout' => 45, 'body' => array('siteid' => sha1(site_url()), 'language' => get_bloginfo('language'), 'plugin' => 'cf7_modules', 'version' => WPCF7_VERSION)));
    // If it was a successful request, process it.
    if (!is_wp_error($response) && !empty($response)) {
        // Basically, remove <script>, <iframe> and <object> tags for security reasons
        $body = strip_tags(trim(rtrim($response['body'])), '<b><strong><em><i><span><u><ul><li><ol><div><attr><cite><a><style><blockquote><q><p><form><br><meta><option><textarea><input><select><pre><code><s><del><small><table><tbody><tr><th><td><tfoot><thead><u><dl><dd><dt><col><colgroup><fieldset><address><button><aside><article><legend><label><source><kbd><tbody><hr><noscript><link><h1><h2><h3><h4><h5><h6><img>');
        // If the result is empty, cache it for 8 hours. Otherwise, cache it for 30 days.
        $cache_time = empty($response['body']) ? floatval(60 * 60 * 8) : floatval(60 * 60 * 30);
        if (function_exists('set_site_transient')) {
            set_site_transient('contact_form_7_modules_remote_ad', $body, $cache_time);
        } else {
            set_transient('contact_form_7_modules_remote_ad', $body, $cache_time);
        }
        // Print the results.
        return $body;
    }
}
 /**
  * {@inheritdoc}
  * @internal
  */
 public function _get_framework_latest_version($force_check)
 {
     $user_slash_repo = fw()->manifest->get($this->manifest_key);
     if (empty($user_slash_repo)) {
         return false;
     }
     if (!preg_match($this->manifest_key_regex, $user_slash_repo)) {
         return new WP_Error('fw_ext_update_github_framework_manifest_invalid', __('Framework manifest has invalid "github_update" parameter. Please use "user/repo" format.', 'fw'));
     }
     $theme_id = preg_replace('[^a-z0-9_]', '_', fw()->theme->manifest->get_id());
     $transient_id = 'fw_ext_update_gh_' . $theme_id . '_fw';
     // this should be 45 characters or less
     if ($force_check) {
         delete_site_transient($transient_id);
     } else {
         $cache = get_site_transient($transient_id);
         if ($cache !== false && isset($cache[$user_slash_repo])) {
             return $cache[$user_slash_repo];
         }
     }
     $latest_version = $this->fetch_latest_version($user_slash_repo);
     if (empty($latest_version)) {
         return new WP_Error(sprintf(__('Failed to fetch framework latest version from github "%s".', 'fw'), $user_slash_repo));
     }
     if (is_wp_error($latest_version)) {
         return $latest_version;
     }
     set_site_transient($transient_id, array($user_slash_repo => $latest_version), $this->transient_expiration);
     return $latest_version;
 }
 /**
  * Retrieve the appropriate EP_HOST
  *
  * Looks at the defined EP_HOST or a backup global should the defined host failed.
  * Priority is given to the EP_HOST constand with the backups only used when needed.
  *
  * @since 1.6
  *
  * @global array $ep_backup_host   array of backup hosts
  *
  * @param bool   $force            Whether to force a new lookup or not
  * @param bool   $use_only_backups Forces the use of only the backup array, no others
  *
  * @return string|WP_Error the host to use or an error
  */
 public function get_ep_host($force = false, $use_only_backups = false)
 {
     global $ep_backup_host;
     // Delete the transient if we want to force a new good host lookup
     if (true === $force) {
         delete_site_transient('ep_last_good_host');
     }
     $last_good_host = get_site_transient('ep_last_good_host');
     if ($last_good_host) {
         return $last_good_host;
     }
     // If nothing is defined just return an error
     if (!defined('EP_HOST') && !$ep_backup_host) {
         return new WP_Error('elasticpress', __('No running host available.', 'elasticpress'));
     }
     $hosts = array();
     if (defined('EP_HOST') && false === $use_only_backups) {
         $hosts[] = EP_HOST;
     }
     // If no backups are defined just return the host
     if ($ep_backup_host && is_array($ep_backup_host)) {
         $hosts = array_merge($hosts, $ep_backup_host);
     }
     foreach ($hosts as $host) {
         if (true === ep_elasticsearch_alive($host)) {
             set_site_transient('ep_last_good_host', $host, apply_filters('ep_last_good_host_timeout', 3600));
             return $host;
         }
     }
     return new WP_Error('elasticpress', __('No running host available.', 'elasticpress'));
 }
Example #11
0
function adrotate_get_updatedetails($def, $action, $args)
{
    global $ajdg_solutions_domain;
    if (!isset($args->slug) || $args->slug != 'adrotate-pro') {
        return $def;
    }
    $license = get_option('adrotate_activate');
    $license_database = substr($license['key'], 0, 3);
    // Get the current version
    $plugin_info = get_site_transient('update_plugins');
    $args->version = $plugin_info->checked['adrotate-pro/adrotate-pro.php'];
    // Plugin version
    $args->instance = $license['instance'];
    // Instance ID
    $args->email = $license['email'];
    // License details
    $args->platform = get_option('siteurl');
    // Who's asking
    $args->database = $license_database;
    // Which database to use (101 || 102)
    $request = wp_remote_post($ajdg_solutions_domain . 'api/updates/4/', adrotate_license_prepare_request($action, $args));
    if (is_wp_error($request)) {
        $response = new WP_Error('plugins_api_failed', 'An Unexpected HTTP Error occurred during the API request. <a href="#" onclick="document.location.reload(); return false;">Try again</a>');
    } else {
        $response = unserialize($request['body']);
        if ($response === false) {
            $response = new WP_Error('plugins_api_failed', 'An unknown error occurred');
        }
    }
    return $response;
}
Example #12
0
/**
 * Get/Set transient.
 *
 * @param  string $key        Transient name. Should be 172 (40 on site) characters or less since WordPress will prefix the name.
 * @param  mixed  $value      Transient value. Expected to not be SQL-escaped. Can be callable value. Optional.
 * @param  int    $expiration Time until expiration in seconds from now, or 0 for never expires. Default 0.
 * @param  bool   $site       Set to true if site transient. Default false.
 *
 * @return mixed
 */
function xu_get_transient($key, $value = null, $expiration = 0, $site = false)
{
    if (!is_string($key)) {
        return false;
    }
    $transient_value = $site ? get_site_transient($key) : get_transient($key);
    // Return transient value if it exists or the return value if given value is null.
    if ($transient_value || is_null($value)) {
        return $transient_value;
    }
    // Support callable values.
    if (is_callable($value)) {
        $value = call_user_func($value);
        // Return false if null value.
        if (is_null($value)) {
            return false;
        }
    }
    if ($site) {
        set_site_transient($key, $value, $expiration);
    } else {
        set_transient($key, $value, $expiration);
    }
    return $value;
}
/**
 * Return an array of installed themes
 *
 * @return array
 */
function _wprp_get_themes()
{
    require_once ABSPATH . '/wp-admin/includes/theme.php';
    // Get all themes
    $themes = get_themes();
    // Get the list of active themes
    $active = get_option('current_theme');
    // Force a theme update check
    wp_update_themes();
    // Different versions of wp store the updates in different places
    // TODO can we depreciate
    if (function_exists('get_site_transient') && ($transient = get_site_transient('update_themes'))) {
        $current = $transient;
    } elseif ($transient = get_transient('update_themes')) {
        $current = $transient;
    } else {
        $current = get_option('update_themes');
    }
    foreach ((array) $themes as $theme) {
        $new_version = isset($current->response[$theme['Template']]) ? $current->response[$theme['Template']]['new_version'] : null;
        if ($active == $theme['Name']) {
            $themes[$theme['Name']]['active'] = true;
        } else {
            $themes[$theme['Name']]['active'] = false;
        }
        if ($new_version) {
            $themes[$theme['Name']]['latest_version'] = $new_version;
            $themes[$theme['Name']]['latest_package'] = $current->response[$theme['Template']]['package'];
        } else {
            $themes[$theme['Name']]['latest_version'] = $theme['Version'];
        }
    }
    return $themes;
}
Example #14
0
 /**
  * Provided a URL, will return an array representing the feed item for that
  * URL.  A feed item contains the content, url, simplepie object, and failure
  * status for the URL passed.  Handles caching of content requests.
  *
  * @return array
  * @author Jared Lang
  * */
 protected static function __new_feed($url)
 {
     require_once ABSPATH . '/wp-includes/class-simplepie.php';
     $simplepie = null;
     $failed = False;
     $cache_key = 'feedmanager-' . md5($url);
     $content = get_site_transient($cache_key);
     if ($content === False) {
         $content = @file_get_contents($url);
         if ($content === False) {
             $failed = True;
             $content = null;
             error_log('FeedManager failed to fetch data using url of ' . $url);
         } else {
             set_site_transient($cache_key, $content, self::$cache_length);
         }
     }
     if ($content) {
         $simplepie = new SimplePie();
         $simplepie->set_raw_data($content);
         $simplepie->init();
         $simplepie->handle_content_type();
         if ($simplepie->error) {
             error_log($simplepie->error);
             $simplepie = null;
             $failed = True;
         }
     } else {
         $failed = True;
     }
     return array('content' => $content, 'url' => $url, 'simplepie' => $simplepie, 'failed' => $failed);
 }
Example #15
0
 public function update_warning()
 {
     if (!is_admin()) {
         return;
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!(is_multisite() && current_user_can('manage_network') || current_user_can('update_plugins'))) {
         return;
     }
     if (!function_exists('get_plugin_data')) {
         include_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     $current = get_site_transient('update_plugins');
     foreach (self::$plugins as $plugin) {
         if (isset($current->response[$plugin])) {
             $data = self::get_plugin_data($plugin);
             if (version_compare($current->response[$plugin]->new_version, $data->info->Version, '<=')) {
                 continue;
             }
             $this->notice(sprintf(__('Hey! %1$s has an update (version %2$s), <a href="%3$s">click here to update</a>.', WYSIJA), '<strong>' . esc_attr($data->info->Name) . '</strong>', $current->response[$plugin]->new_version, wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=') . $plugin, 'upgrade-plugin_' . $plugin)), true, true);
         }
     }
 }
Example #16
0
/**
 * Retrieve the contributor credits.
 *
 * @global string $wp_version The current WordPress version.
 *
 * @since 3.2.0
 *
 * @return array|false A list of all of the contributors, or false on error.
*/
function wp_credits() {
	global $wp_version;
	$locale = get_locale();

	$results = get_site_transient( 'wordpress_credits_' . $locale );

	if ( ! is_array( $results )
		|| false !== strpos( $wp_version, '-' )
		|| ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 )
	) {
		$response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale" );

		if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
			return false;

		$results = json_decode( wp_remote_retrieve_body( $response ), true );

		if ( ! is_array( $results ) )
			return false;

		set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
	}

	return $results;
}
 public function checkForUpdates()
 {
     // This errors out when creating Shortcake UIs
     if (!is_array($this->extensions)) {
         return;
     }
     foreach ($this->extensions as $extension) {
         // Only check for updates every 3 hours
         if (!is_multisite()) {
             $updateChecker = get_transient(self::UPDATE_CHECKER_TRANSIENT . $extension['slug']);
         } else {
             $updateChecker = get_site_transient(self::UPDATE_CHECKER_TRANSIENT . $extension['slug']);
         }
         if (false !== $updateChecker && !self::DEBUG) {
             continue;
         }
         // retrieve our license key from the DB
         $licenseKey = get_site_option('sandwich_license_' . $extension['slug']);
         if (empty($licenseKey)) {
             continue;
         }
         // setup the updater
         $eddUpdater = new PBS_EDD_SL_Plugin_Updater($extension['store_url'], $extension['file'], array('version' => $extension['version'], 'license' => $licenseKey, 'item_name' => $extension['name'], 'author' => $extension['author']));
         if (!is_multisite()) {
             set_transient(self::UPDATE_CHECKER_TRANSIENT . $extension['slug'], '1', 3 * HOUR_IN_SECONDS);
         } else {
             set_site_transient(self::UPDATE_CHECKER_TRANSIENT . $extension['slug'], '1', 3 * HOUR_IN_SECONDS);
         }
     }
 }
Example #18
0
 /**
  * Return parsed XML data
  * 
  * @return SimpleXMLElement|false
  */
 private function get_xml()
 {
     // handle empty xml property
     if (null === $this->packages) {
         // try to get cached data
         $data = get_site_transient($this->cache_key);
         // get any data?
         if (empty($data)) {
             // nope, need to fetch
             $data = $this->fetch_xml();
             // get anything?
             if (empty($data)) {
                 // prevent further fetches
                 $this->packages = false;
                 // nothing, not good
                 return false;
             } else {
                 // got some data, cache it
                 set_site_transient($this->cache_key, $data, $this->lifetime);
             }
         }
         // parse the xml
         $xml = simplexml_load_string($data);
         // update local cache
         if ($xml instanceof SimpleXMLElement) {
             $this->packages = $xml;
         } else {
             $this->packages = false;
         }
     }
     // return the data
     return $this->packages;
 }
 function prepare_items()
 {
     //First, lets decide how many records per page to show
     $per_page = 20;
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     //$this->process_bulk_action();
     global $wpdb;
     global $aio_wp_security;
     /* -- Ordering parameters -- */
     //Parameters that are going to be used to order the result
     $orderby = !empty($_GET["orderby"]) ? mysql_real_escape_string($_GET["orderby"]) : 'user_id';
     $order = !empty($_GET["order"]) ? mysql_real_escape_string($_GET["order"]) : 'DESC';
     $logged_in_users = AIOWPSecurity_Utility::is_multisite_install() ? get_site_transient('users_online') : get_transient('users_online');
     foreach ($logged_in_users as $key => $val) {
         $userdata = get_userdata($val['user_id']);
         $username = $userdata->user_login;
         $val['username'] = $username;
         $logged_in_users[$key] = $val;
     }
     $data = $logged_in_users;
     $current_page = $this->get_pagenum();
     $total_items = count($data);
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     $this->items = $data;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
 /**
  * @param array $args
  * @param array $instance
  */
 function widget($args, $instance)
 {
     extract($args);
     $user = esc_attr($instance['user']);
     $title = esc_attr($instance['title']);
     $number = (int) esc_attr($instance['number']) > 0 ? esc_attr($instance['number']) : 5;
     $before_widget = str_replace('class="', 'class="widget_twitter_tweets ', $before_widget);
     $title = str_replace('class="', 'class="widget_twitter_tweets ', $before_title) . $title . $after_title;
     $title = $before_title . $title . $after_title;
     //		wp_enqueue_script(
     //			'fw-theme-twitter-widget',
     //			get_template_directory_uri() . '/inc/widgets/twitter/static/js/scripts.js',
     //			array( 'jquery' ),
     //			'1.0'
     //		);
     $tweets = get_site_transient('scratch_tweets_' . $user . '_' . $number);
     if (empty($tweets)) {
         /* @var $connection TwitterOAuth */
         $connection = fw_ext_social_twitter_get_connection();
         $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $user . "&count=" . $number);
         set_site_transient('scratch_tweets_' . $user . '_' . $number, $tweets, 12 * HOUR_IN_SECONDS);
     }
     $view_path = dirname(__FILE__) . '/views/widget.php';
     echo fw_render_view($view_path, compact('before_widget', 'title', 'tweets', 'number', 'after_widget'));
 }
 /**
  * Plugins update check & send notification.
  *
  * @since   1.0.0
  */
 public function pluginUpdateNotif()
 {
     // Force version check.
     do_action('wp_update_plugins');
     $versionCheck = get_site_transient('update_plugins');
     $activePlugins = get_option('active_plugins');
     $needsUpdate = array_intersect_key($versionCheck->response, array_flip($activePlugins));
     if (count($needsUpdate) > 0) {
         $notifiedPlugins = get_option('slack_notif_plugins_version');
         $theMessage = '';
         foreach ($needsUpdate as $plugin => $updateData) {
             $pluginMeta = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin, true, false);
             // Did we already notified the admin?
             if (!array_key_exists($plugin, $notifiedPlugins) && $notifiedPlugins[$plugin] != $updateData->new_version) {
                 $notifiedPlugins[$plugin] = $updateData->new_version;
                 $theMessage .= sprintf(__('• *%s* - v%s (current version is v%s)', 'dorzki-slack') . "\n", $pluginMeta['Name'], $updateData->new_version, $pluginMeta['Version']);
             }
         }
         update_option('slack_notif_plugins_version', $notifiedPlugins);
         // Do we still need to notify?
         if ($theMessage != '') {
             $theMessage = __(':information_source: The following plugins have a new version:', 'dorzki-slack') . "\n" . $theMessage;
             $this->slack->sendMessage($theMessage);
         }
     }
 }
Example #22
0
 function queue_old_update($transient, $force = false)
 {
     if (method_exists('FrmUpdate', 'queue_addon_update')) {
         global $frm_update;
         $plugin = $this;
         return $frm_update->queue_addon_update($transient, $plugin, $force);
     }
     if (!is_object($transient) or empty($transient->checked)) {
         return $transient;
     }
     global $frmpro_is_installed;
     if ($frmpro_is_installed) {
         $expired = true;
         if (!$force) {
             $update = get_site_transient($this->pro_last_checked_store);
             if ($update) {
                 $expired = false;
             }
         }
         if (!$update) {
             $update = $this->get_current_info($transient->checked[$this->plugin_name], $force, $this->plugin_nicename);
         }
         if ($update and !empty($update)) {
             $update = (object) $update;
             $transient->response[$this->plugin_name] = $update;
             //only check periodically
             if ($expired) {
                 set_site_transient($this->pro_last_checked_store, $update, $this->pro_check_interval);
             }
         }
     }
     return $transient;
 }
Example #23
0
/**
 * Retrieve product data from Beans REST API.
 *
 * Data are cached in a 24 hours transients and will be returned if found to avoid long loading time.
 *
 * @ignore
 */
function beans_updater($value)
{
    $data = get_site_transient('beans_updater');
    $theme = wp_get_theme('tm-beans');
    if (!$theme->exists()) {
        return $value;
    }
    $current_version = $theme->get('Version');
    // Query Beans REST API if the transient is expired.
    if (empty($data)) {
        $args = array('timeout' => 15, 'sslverify' => false);
        $response = wp_remote_get('http://www.getbeans.io/rest-api/', $args);
        if (is_wp_error($response)) {
            return $value;
        }
        // Retrieve data from the body and decode json format.
        $data = json_decode(wp_remote_retrieve_body($response), true);
        // Stop here if the is an error.
        if (isset($data['error'])) {
            // Set temporary transient.
            set_site_transient('beans_updater', array('version' => $current_version), 30 * MINUTE_IN_SECONDS);
            return $value;
        }
        set_site_transient('beans_updater', $data, 24 * HOUR_IN_SECONDS);
    }
    // Return data if Beans is not up to date.
    if (version_compare($current_version, beans_get('version', $data), '<')) {
        $value->response[$data['path']] = array('slug' => $data['slug'], 'name' => $data['name'], 'url' => $data['changelog_url'], 'package' => $data['download_url'], 'new_version' => $data['version'], 'tested' => $data['tested'], 'requires' => $data['requires']);
        return $value;
    }
    return $value;
}
Example #24
0
 public static function check_currentVersion()
 {
     global $wpsPluginAlertsArray;
     $actionName = $wpsPluginAlertsArray['check_wp_current_version']['name'];
     $alertType = $wpsPluginAlertsArray['check_wp_current_version']['type'];
     $c = get_site_transient('update_core');
     if (is_object($c)) {
         if (empty($c->updates)) {
             self::alert($actionName, $alertType, WpsSettings::ALERT_INFO, __('You have the latest version of WordPress installed', WpsSettings::TEXT_DOMAIN), __('<p>The latest WordPress version is usually more stable and secure, and is only released to include new features or fix technical and WordPress security bugs;
                         making it an important part of your website administration to keep up to date since some fixes might resolve security issues.<p>
                     <p>Running an older WordPress version could put your blog security at risk, allowing a hacker to exploit known vulnerabilities for your specific version and take full control over your web server.</p>', WpsSettings::TEXT_DOMAIN));
         } else {
             if (!empty($c->updates[0])) {
                 $c = $c->updates[0];
                 if (!isset($c->response) || 'latest' == $c->response) {
                     self::alert($actionName, $alertType, WpsSettings::ALERT_INFO, __('You have the latest version of WordPress installed', WpsSettings::TEXT_DOMAIN), __('<p>The latest WordPress version is usually more stable and secure, and is only released to include new features or fix technical and WordPress security bugs;
                         making it an important part of your website administration to keep up to date since some fixes might resolve security issues.<p>
                     <p>Running an older WordPress version could put your blog security at risk, allowing a hacker to exploit known vulnerabilities for your specific version and take full control over your web server.</p>', WpsSettings::TEXT_DOMAIN));
                 } elseif ('upgrade' == $c->response) {
                     self::alert($actionName, $alertType, WpsSettings::ALERT_CRITICAL, sprintf(__('An updated version of WordPress is available: <strong>%s</strong>', WpsSettings::TEXT_DOMAIN), $c->current), __('<p>The latest WordPress version is usually more stable and secure, and is only released to include new features or fix technical and WordPress security bugs;
                                 making it an important part of your website administration to keep up to date since some fixes might resolve security issues.<p>
                             <p>Running an older WordPress version could put your blog security at risk, allowing a hacker to exploit known vulnerabilities for your specific version and take full control over your web server.</p>', WpsSettings::TEXT_DOMAIN), sprintf(__('<p>It is recommended to update your WordPress installation as soon as possible. More information on updating WordPress manually and automatically
                                 can be found on the official <a href="%s" target="%s">WordPress site</a>.</p>', WpsSettings::TEXT_DOMAIN), 'http://codex.wordpress.org/Updating_WordPress', '_blank'));
                 }
             }
         }
     }
 }
Example #25
0
 /**
  * Provided a URL, will return an array representing the feed item for that
  * URL.  A feed item contains the content, url, simplepie object, and failure
  * status for the URL passed.  Handles caching of content requests.
  *
  * @return array
  * @author Jared Lang
  **/
 protected static function __new_feed($url)
 {
     $timer = Timer::start();
     require_once THEME_DIR . '/third-party/simplepie.php';
     $simplepie = null;
     $failed = False;
     $cache_key = 'feedmanager-' . md5($url);
     $content = get_site_transient($cache_key);
     if ($content === False) {
         $content = @file_get_contents($url);
         if ($content === False) {
             $failed = True;
             $content = null;
             error_log('FeedManager failed to fetch data using url of ' . $url);
         } else {
             set_site_transient($cache_key, $content, self::$cache_length);
         }
     }
     if ($content) {
         $simplepie = new SimplePie();
         $simplepie->set_raw_data($content);
         $simplepie->init();
         $simplepie->handle_content_type();
         if ($simplepie->error) {
             error_log($simplepie->error);
             $simplepie = null;
             $failed = True;
         }
     } else {
         $failed = True;
     }
     $elapsed = round($timer->elapsed() * 1000);
     debug("__new_feed: {$elapsed} milliseconds");
     return array('content' => $content, 'url' => $url, 'simplepie' => $simplepie, 'failed' => $failed);
 }
 /**
  * Get the data from the transient and/or schedule new data to be retrieved.
  *
  * @param	string	$transient	The name of the transient. Must be 43 characters or less including $this->transient_prefix.
  * @param	string	$hook		The name of the hook to retrieve new data.
  * @param	array	$args		An array of arguments to pass to the function.
  *
  * @return	mixed	Either false or the data from the transient.
  */
 public function get_transient($transient, $hook, $args)
 {
     // Build the transient names.
     $transient = $this->prefix . $transient;
     $fallback_transient = $transient . '_';
     if (is_multisite()) {
         if (false === ($data = get_site_transient($transient))) {
             $data = get_site_transient($fallback_transient);
             if (!wp_get_schedule($hook, $args)) {
                 wp_clear_scheduled_hook($hook, $args);
                 wp_schedule_single_event(time(), $hook, $args);
             }
             return $data;
         } else {
             return $data;
         }
     } else {
         if (false === ($data = get_transient($transient))) {
             $data = get_transient($fallback_transient);
             if (!wp_get_schedule($hook, $args)) {
                 wp_clear_scheduled_hook($hook, $args);
                 wp_schedule_single_event(time(), $hook, $args);
             }
             return $data;
         } else {
             return $data;
         }
     }
 }
 function prepare_items()
 {
     //First, lets decide how many records per page to show
     $per_page = 20;
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     //$this->process_bulk_action();
     global $wpdb;
     global $aio_wp_security;
     $logged_in_users = AIOWPSecurity_Utility::is_multisite_install() ? get_site_transient('users_online') : get_transient('users_online');
     if ($logged_in_users !== FALSE) {
         foreach ($logged_in_users as $key => $val) {
             $userdata = get_userdata($val['user_id']);
             $username = $userdata->user_login;
             $val['username'] = $username;
             $logged_in_users[$key] = $val;
         }
     } else {
         $logged_in_users = array();
         //If no transient found set to empty array
     }
     $data = $logged_in_users;
     $current_page = $this->get_pagenum();
     $total_items = count($data);
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     $this->items = $data;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
 public function myPluginApiCall($def, $action, $args)
 {
     if ($args->slug != $this->_plugSlug) {
         return $def;
     }
     // For old versions of our addons
     if (empty($this->_plugSlug)) {
         return $def;
     }
     // Get the current version
     $plugin_info = get_site_transient('update_plugins');
     $current_version = $plugin_info->checked[$this->_plugDir . '/' . $this->_plugFile];
     $args->version = $current_version;
     $request_string = $this->prepareRequest($action, $args);
     $request = wp_remote_post($this->_getApiUrl(), $request_string);
     if (is_wp_error($request)) {
         $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message());
     } else {
         $res = unserialize($request['body']);
         if ($res === false) {
             $res = new WP_Error('plugins_api_failed', __('An unknown error occurred'), $request['body']);
         }
     }
     return $res;
 }
 public static function check_update($plugin_path, $plugin_slug, $plugin_url, $offering, $key, $version, $option)
 {
     $version_info = function_exists('get_site_transient') ? get_site_transient("gforms_userregistration_version") : get_transient("gforms_userregistration_version");
     //making the remote request for version information
     if (!$version_info) {
         //Getting version number
         $version_info = self::get_version_info($offering, $key, $version);
         self::set_version_info($version_info);
     }
     if ($version_info == -1) {
         return $option;
     }
     if (empty($option->response[$plugin_path])) {
         $option->response[$plugin_path] = new stdClass();
     }
     //Empty response means that the key is invalid. Do not queue for upgrade
     if (!$version_info["is_valid_key"] || version_compare($version, $version_info["version"], '>=')) {
         unset($option->response[$plugin_path]);
     } else {
         $option->response[$plugin_path]->url = $plugin_url;
         $option->response[$plugin_path]->slug = $plugin_slug;
         $option->response[$plugin_path]->package = str_replace("{KEY}", $key, $version_info["url"]);
         $option->response[$plugin_path]->new_version = $version_info["version"];
         $option->response[$plugin_path]->id = "0";
     }
     return $option;
 }
Example #30
0
function github_theme_update_row($theme_key, $theme)
{
    $current = get_site_transient('update_themes');
    if (!isset($current->response[$theme_key]) and !isset($current->up_to_date[$theme_key])) {
        return false;
    }
    $r = $current->response[$theme_key];
    $wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
    // custom additions
    if (isset($r['error'])) {
        echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message-gtu update-error">';
        printf('Error with Github Theme Updater. %1$s', $r['error']);
    } else {
        if (isset($current->up_to_date[$theme_key])) {
        } else {
            $themes_allowedtags = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'em' => array(), 'strong' => array());
            $theme_name = wp_kses($theme['Name'], $themes_allowedtags);
            $github_url = esc_url($r['url']);
            $diff_url = esc_url($r['url'] . '/compare/' . $theme['Version'] . '...' . $r['new_version']);
            echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message-gtu">';
            printf('Github has as a new version of <a href="%s" target="blank">%s</a>. ', $github_url, $theme_name);
            printf('View <a href="%s" target="blank">version diff</a> with %s. ', $diff_url, $r['new_version']);
            if (current_user_can('update_themes')) {
                if (empty($r['package'])) {
                    echo '<em>Automatic update is unavailable for this plugin.</em>';
                } else {
                    printf('<a href="%s">Update automatically</a>.', wp_nonce_url(self_admin_url('update.php?action=upgrade-github-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key));
                }
            }
        }
    }
    do_action("in_theme_update_message-{$theme_key}", $theme, $r);
    echo '</div></td></tr>';
}