本文整理汇总了PHP中get_site_transient函数的典型用法代码示例。如果您正苦于以下问题:PHP get_site_transient函数的具体用法?PHP get_site_transient怎么用?PHP get_site_transient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_site_transient函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: init
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";
}
}
开发者ID:WP-Panda,项目名称:allergenics,代码行数:25,代码来源:PluginOrganizer.class.php
示例2: vimeo_master_updater_version_check
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);
}
}
}
开发者ID:Twohedz,项目名称:vimeo-master,代码行数:27,代码来源:vimeo-master.php
示例3: mu_loader_plugins_files
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;
}
开发者ID:UPMediaDesign,项目名称:vidaestudiantilip,代码行数:35,代码来源:mu-loader.php
示例4: register
/**
* 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');
}
}
}
}
开发者ID:oakcms,项目名称:oakcms,代码行数:34,代码来源:Update.php
示例5: aiowps_validate_registration_with_captcha
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;
}
开发者ID:crazyyy,项目名称:bessarabia,代码行数:25,代码来源:wp-security-user-registration.php
示例6: gd_api_info_call
/**
* 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;
}
开发者ID:poweronio,项目名称:mbsite,代码行数:39,代码来源:gd_update.php
示例7: plugins_api
/**
* 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;
}
开发者ID:vondervick,项目名称:veuse-uikit,代码行数:40,代码来源:class-plugin-updater.php
示例8: contact_form_7_modules_get_remote_message
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;
}
}
开发者ID:Allan019,项目名称:grupometa,代码行数:25,代码来源:functions.php
示例9: _get_framework_latest_version
/**
* {@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;
}
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:34,代码来源:class-fw-extension-github-update.php
示例10: get_ep_host
/**
* 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'));
}
开发者ID:cliebler,项目名称:elasticsearch-wp-plugin,代码行数:46,代码来源:class-ep-config.php
示例11: adrotate_get_updatedetails
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;
}
开发者ID:OneTimeUser,项目名称:retailwire,代码行数:31,代码来源:update-api.php
示例12: xu_get_transient
/**
* 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;
}
开发者ID:wp-xu,项目名称:framework,代码行数:35,代码来源:transient.php
示例13: _wprp_get_themes
/**
* 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;
}
开发者ID:redferriswheel,项目名称:ZachFonville,代码行数:39,代码来源:wprp.themes.php
示例14: __new_feed
/**
* 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);
}
开发者ID:UCF,项目名称:Students-Theme,代码行数:40,代码来源:feeds.php
示例15: update_warning
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);
}
}
}
开发者ID:duboisGeof,项目名称:deliciousMeals,代码行数:25,代码来源:WJ_Upgrade.php
示例16: wp_credits
/**
* 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;
}
开发者ID:ShankarVellal,项目名称:WordPress,代码行数:34,代码来源:credits.php
示例17: checkForUpdates
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);
}
}
}
开发者ID:JohnStafford,项目名称:Page-Builder-Sandwich,代码行数:30,代码来源:updater.php
示例18: get_xml
/**
* 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;
}
开发者ID:nathan929,项目名称:infinity,代码行数:38,代码来源:nicepkg.php
示例19: prepare_items
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)));
}
开发者ID:CarterNelms,项目名称:www.engineeredcomfort.net,代码行数:29,代码来源:wp-security-list-logged-in-users.php
示例20: widget
/**
* @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'));
}
开发者ID:Umeeshh,项目名称:Scratch-Theme,代码行数:29,代码来源:class-widget-twitter.php
注:本文中的get_site_transient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论