Example #1
0
} else {
    yarpp_upgrade_check();
}
// if action=flush, reset the cache
if (isset($_GET['action']) && $_GET['action'] == 'flush') {
    $yarpp_cache->flush();
}
// check to see that templates are in the right place
$yarpp_templateable = count(glob(STYLESHEETPATH . '/yarpp-template-*.php')) > 0;
if (!$yarpp_templateable) {
    yarpp_set_option('use_template', false);
    yarpp_set_option('rss_use_template', false);
}
// 3.3: move version checking here, in PHP:
if (current_user_can('update_plugins')) {
    $yarpp_version_info = yarpp_version_info();
    // these strings are not localizable, as long as the plugin data on wordpress.org
    // cannot be.
    $slug = 'yet-another-related-posts-plugin';
    $plugin_name = 'Yet Another Related Posts Plugin';
    $file = basename(YARPP_DIR) . '/yarpp.php';
    if ($yarpp_version_info['result'] == 'new') {
        // make sure the update system is aware of this version
        $current = get_site_transient('update_plugins');
        if (!isset($current->response[$file])) {
            delete_site_transient('update_plugins');
            wp_update_plugins();
        }
        echo '<div class="updated"><p>';
        $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $slug . '&TB_iframe=true&width=600&height=800');
        printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update automatically</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $yarpp_version_info['current']['version'], wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file));
Example #2
0
function yarpp_upgrade_check()
{
    $last_version = get_option('yarpp_version');
    if (version_compare(YARPP_VERSION, $last_version) === 0) {
        return;
    }
    global $yarpp_value_options, $yarpp_binary_options, $yarpp_cache;
    foreach (array_keys($yarpp_value_options) as $option) {
        if (get_option("yarpp_{$option}") === false) {
            add_option("yarpp_{$option}", $yarpp_value_options[$option] . ' ');
        }
    }
    foreach (array_keys($yarpp_binary_options) as $option) {
        if (get_option("yarpp_{$option}") === false) {
            add_option("yarpp_{$option}", $yarpp_binary_options[$option]);
        }
    }
    $yarpp_cache->upgrade($last_version);
    yarpp_version_info(true);
    update_option('yarpp_version', YARPP_VERSION);
}