コード例 #1
0
/**
 * Plugin activation procedure
 *
 * @since  1.0
 * @return void
 */
function wprss_activate()
{
    /* Prevents activation of plugin if compatible version of WordPress not found */
    if (!wprss_wp_min_version_satisfied()) {
        deactivate_plugins(basename(__FILE__));
        // Deactivate plugin
        wp_die(sprintf(__('This plugin requires WordPress version %1$s or higher.'), WPRSS_WP_MIN_VERSION), 'WP RSS Aggregator', array('back_link' => true));
    }
    wprss_settings_initialize();
    flush_rewrite_rules();
    wprss_schedule_fetch_all_feeds_cron();
    // Get the previous welcome screen version
    $pwsv = get_option('wprss_pwsv', '0.0');
    // If the aggregator version is higher than the previous version ...
    if (version_compare(WPRSS_VERSION, $pwsv, '>')) {
        // Sets a transient to trigger a redirect upon completion of activation procedure
        set_transient('_wprss_activation_redirect', true, 30);
    }
    include_once ABSPATH . 'wp-admin/includes/plugin.php';
    // Check if WordPress SEO is activate, if yes set its options for hiding the metaboxes on the wprss_feed and wprss_feed_item screens
    if (is_plugin_active('wordpress-seo/wp-seo.php')) {
        $wpseo_titles = get_option('wpseo_titles', array());
        if (isset($wpseo_titles['hideeditbox-wprss_feed'])) {
            $wpseo_titles['hideeditbox-wprss_feed'] = TRUE;
            $wpseo_titles['hideeditbox-wprss_feed_item'] = TRUE;
        }
        update_option('wpseo_titles', $wpseo_titles);
    }
}
コード例 #2
0
/**
 * Plugin activation procedure
 *
 * @since  1.0
 * @return void
 */
function wprss_activate()
{
    /* Prevents activation of plugin if compatible version of WordPress not found */
    if (version_compare(get_bloginfo('version'), '3.3', '<')) {
        deactivate_plugins(basename(__FILE__));
        // Deactivate plugin
        wp_die(__('This plugin requires WordPress version 3.3 or higher.'), 'WP RSS Aggregator', array('back_link' => true));
    }
    wprss_settings_initialize();
    flush_rewrite_rules();
    wprss_schedule_fetch_all_feeds_cron();
    // Get the previous welcome screen version
    $pwsv = get_option('wprss_pwsv', '0.0');
    // If the aggregator version is higher than the previous version ...
    if (version_compare(WPRSS_VERSION, $pwsv, '>')) {
        // Sets a transient to trigger a redirect upon completion of activation procedure
        set_transient('_wprss_activation_redirect', true, 30);
    }
}