本文整理汇总了PHP中cssJSToolbox::premiumUpgradeTransient方法的典型用法代码示例。如果您正苦于以下问题:PHP cssJSToolbox::premiumUpgradeTransient方法的具体用法?PHP cssJSToolbox::premiumUpgradeTransient怎么用?PHP cssJSToolbox::premiumUpgradeTransient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cssJSToolbox
的用法示例。
在下文中一共展示了cssJSToolbox::premiumUpgradeTransient方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Run once everyday at the time the Plugin activated.
* Callback for wp_schedule_event.
*/
public static function check()
{
// Ask the server for updates.
$response = wp_remote_get(cssJSToolbox::CHECK_UPDATE_URL);
// If check success, store the response.
if (is_array($response)) {
// response = WP_Error on failure.
// We need only response array.
$response = @unserialize($response['body']);
// Make sure that we got array from the server.
if (is_array($response['response'])) {
$response = $response['response'];
$currentVersion = is_array(cssJSToolbox::$premiumUpgradeTransient) ? cssJSToolbox::$premiumUpgradeTransient['version'] : '';
$newVersion = $response['version'];
// Upload and update image URL only if current transient version
// is different from the new version.
if ($currentVersion != $newVersion) {
// Get image from URL.
$image = wp_remote_get($response['imageURL']);
// $image = WP_Error on failure.
if (is_array($image)) {
$imagesUploadPath = CJTOOLBOX_PATH . '/public/media/' . cssJSToolbox::IMAGES_UPLOAD_DIR;
$imageStream = $image['body'];
$imageName = basename($response['imageURL']);
$imageFile = "{$imagesUploadPath}/{$imageName}";
$localImageLength = @file_put_contents($imageFile, $imageStream);
// If file is created change the URL of the image to the local image.
if ($localImageLength == strlen($imageStream)) {
$response['imageURL'] = CJTOOLBOX_MEDIA_URL . '/' . cssJSToolbox::IMAGES_UPLOAD_DIR . "/{$imageName}";
// Store the response/transient with the new ImageURL, make sense!
}
}
}
// Update current transient.
set_site_transient('cjt_premium_upgrade', $response);
cssJSToolbox::$premiumUpgradeTransient = $response;
}
}
}
示例2: array
/**
* Bind Wordpress hooks.
*
* Callback for plugins_loaded.
*/
function start_plugin()
{
if (is_admin()) {
// New installation or check for upgrade.
// Plugin activation hook is not fired when the Plugin updated since Wordpress 3.1.
// No worries the code inside will not executed twice.
$this->checkInstallation();
// Load Plugin translation.
load_plugin_textdomain(CJTOOLBOX_TEXT_DOMAIN, null, 'css-javascript-toolbox/langs');
// Load for admin panel
add_action('admin_menu', array(&self::$instance, 'add_plugin_menu'));
// register ajax save function
add_action('wp_ajax_cjtoolbox_save', array(&self::$instance, 'ajax_save_changes'));
add_action('wp_ajax_cjtoolbox_save_newcode', array(&self::$instance, 'ajax_save_newcode'));
add_action('wp_ajax_cjtoolbox_form', array(&self::$instance, 'ajax_show_form'));
add_action('wp_ajax_cjtoolbox_get_code', array(&self::$instance, 'ajax_get_code'));
add_action('wp_ajax_cjtoolbox_delete_code', array(&self::$instance, 'ajax_delete_code'));
add_action('wp_ajax_cjtoolbox_add_block', array(&self::$instance, 'ajax_add_block'));
add_action('wp_ajax_cjtoolbox_request_template', array(&self::$instance, 'ajax_request_template'));
// Get latest update data.
self::$premiumUpgradeTransient = get_site_transient('cjt_premium_upgrade');
} else {
// Add the script and style files to header/footer
add_action('wp_head', array(&self::$instance, 'cjtoolbox_insert_header_code'));
add_action('wp_print_scripts', array(&self::$instance, 'cjtoolbox_embedded_scripts'), 11);
add_action('wp_footer', array(&self::$instance, 'cjtoolbox_insert_footer_code'));
// Premium update check cron hook.
add_action('cjt_premium_update_checker', array(&self::$instance, 'checkPremiumUpdate'));
}
}