Example #1
0
/**
 * Triggers all upgrade functions
 *
 * @since 2.2
 * @return void
*/
function edd_sl_show_upgrade_notice()
{
    if (!function_exists('EDD')) {
        return;
    }
    $edd_sl_version = get_option('edd_sl_version');
    if (!$edd_sl_version) {
        edd_sl_v22_upgrades();
    }
    if (version_compare($edd_sl_version, '2.4', '<') && !isset($_GET['edd_upgrade'])) {
        printf('<div class="updated"><p>' . __('The License Keys in Easy Digital Downloads needs to be upgraded, click <a href="%s">here</a> to start the upgrade.', 'edd_sl') . '</p></div>', esc_url(add_query_arg(array('edd_action' => 'upgrade_site_urls'), admin_url())));
    }
    if (version_compare($edd_sl_version, '2.5', '<') && !isset($_GET['edd_upgrade'])) {
        printf('<div class="updated"><p>' . __('The License Keys in Easy Digital Downloads needs to be upgraded, click <a href="%s">here</a> to start the upgrade.', 'edd_sl') . '</p></div>', esc_url(add_query_arg(array('edd_action' => 'upgrade_license_price_ids'), admin_url())));
    }
    if (version_compare($edd_sl_version, '3.0', '<') && !isset($_GET['edd_upgrade']) && edd_get_option('edd_sl_send_renewal_reminders')) {
        printf('<div class="updated"><p>' . __('The renewal notices in Easy Digital Downloads needs to be upgraded, click <a href="%s">here</a> to start the upgrade.', 'edd_sl') . '</p></div>', esc_url(add_query_arg(array('edd_action' => 'upgrade_renewal_notices'), admin_url())));
    }
    if (function_exists('edd_has_upgrade_completed') && function_exists('edd_maybe_resume_upgrade')) {
        $resume_upgrade = edd_maybe_resume_upgrade();
        if (empty($resume_upgrade)) {
            if (version_compare($edd_sl_version, '3.2', '<') || !edd_has_upgrade_completed('sl_add_bundle_licenses')) {
                $notice = '<div class="notice notice-info"><p>';
                $notice .= __('Easy Digital Downloads - Software Licensing now supports Bundle Licenses. This is an opt-in upgrade, so please choose one of the following:', 'edd_sl');
                $notice .= '<p>';
                $notice .= sprintf(__('If you want to read more on this new feature, <a href="%s" target="_blank">click here</a>.', 'edd_sl'), 'http://docs.easydigitaldownloads.com/article/698-bundle-licensing');
                $notice .= '</p>';
                $notice .= '<ol>';
                $notice .= sprintf(__('<li>Make <a href="%s">no changes</a></li>', 'edd_sl'), esc_url(admin_url('index.php?page=edd-upgrades&edd-upgrade=sl_add_bundle_licenses&custom=0')));
                $notice .= __('<li>After you enable licensing for the bundles of your choice, <a href="#" onClick="jQuery(\'#generate-licenses-button-wrapper\').toggle(); return false;">generate licenses for bundles with Licensing enabled</a>.</li>', 'edd_sl');
                $notice .= '</ol>';
                $notice .= '</p></div>';
                $notice .= '<div class="notice notice-info" style="display:none;" id="generate-licenses-button-wrapper">';
                $notice .= '<p>' . __('Before clicking this button, verify that all bundles you want to generate licenses for have Licensing enabled, and their license length is correct.', 'edd_sl') . '</p>';
                $notice .= sprintf(__('<a href="%s" class="button-primary">', 'edd_sl'), esc_url(admin_url('index.php?page=edd-upgrades&edd-upgrade=sl_add_bundle_licenses&custom=1')));
                $notice .= __('Generate Bundle Licenses', 'edd_sl');
                $notice .= '</a>';
                $notice .= '</p></div>';
                echo $notice;
            }
        }
    }
}
/**
 * Display Upgrade Notices
 *
 * @since 1.3.1
 * @return void
*/
function edd_show_upgrade_notices()
{
    if (isset($_GET['page']) && $_GET['page'] == 'edd-upgrades') {
        return;
    }
    // Don't show notices on the upgrades page
    $edd_version = get_option('edd_version');
    if (!$edd_version) {
        // 1.3 is the first version to use this option so we must add it
        $edd_version = '1.3';
    }
    $edd_version = preg_replace('/[^0-9.].*/', '', $edd_version);
    if (!get_option('edd_payment_totals_upgraded') && !get_option('edd_version')) {
        if (wp_count_posts('edd_payment')->publish < 1) {
            return;
        }
        // No payment exist yet
        // The payment history needs updated for version 1.2
        $url = add_query_arg('edd-action', 'upgrade_payments');
        $upgrade_notice = sprintf(__('The Payment History needs to be updated. %s', 'edd'), '<a href="' . wp_nonce_url($url, 'edd_upgrade_payments_nonce') . '">' . __('Click to Upgrade', 'edd') . '</a>');
        add_settings_error('edd-notices', 'edd-payments-upgrade', $upgrade_notice, 'error');
    }
    if (version_compare($edd_version, '1.3.2', '<') && !get_option('edd_logs_upgraded')) {
        printf('<div class="updated"><p>' . esc_html__('The Purchase and File Download History in Easy Digital Downloads needs to be upgraded, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
    }
    if (version_compare($edd_version, '1.3.4', '<') || version_compare($edd_version, '1.4', '<')) {
        printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the plugin pages, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
    }
    if (version_compare($edd_version, '1.5', '<')) {
        printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the database, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
    }
    if (version_compare($edd_version, '2.0', '<')) {
        printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the database, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('options.php?page=edd-upgrades')) . '">', '</a>');
    }
    // Sequential Orders was the first stepped upgrade, so check if we have a stalled upgrade
    $resume_upgrade = edd_maybe_resume_upgrade();
    if (!empty($resume_upgrade)) {
        $resume_url = add_query_arg($resume_upgrade, admin_url('index.php'));
        printf('<div class="error"><p>' . __('Easy Digital Downloads needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'edd') . '</p></div>', esc_url($resume_url));
    } else {
        // Include all 'Stepped' upgrade process notices in this else statement,
        // to avoid having a pending, and new upgrade suggested at the same time
        if (EDD()->session->get('upgrade_sequential') && edd_get_payments()) {
            printf('<div class="updated"><p>' . __('Easy Digital Downloads needs to upgrade past order numbers to make them sequential, click <a href="%s">here</a> to start the upgrade.', 'edd') . '</p></div>', admin_url('index.php?page=edd-upgrades&edd-upgrade=upgrade_sequential_payment_numbers'));
        }
        if (version_compare($edd_version, '2.1', '<')) {
            printf('<div class="updated"><p>' . esc_html__('Easy Digital Downloads needs to upgrade the customer database, click %shere%s to start the upgrade.', 'edd') . '</p></div>', '<a href="' . esc_url(admin_url('index.php?page=edd-upgrades&edd-upgrade=upgrade_customers_db')) . '">', '</a>');
        }
        if (version_compare($edd_version, '2.2.6', '<')) {
            printf('<div class="updated"><p>' . __('Easy Digital Downloads needs to upgrade the payment database, click <a href="%s">here</a> to start the upgrade.', 'edd') . '</p></div>', esc_url(admin_url('index.php?page=edd-upgrades&edd-upgrade=upgrade_payments_price_logs_db')));
        }
        if (version_compare($edd_version, '2.3', '<') || !edd_has_upgrade_completed('upgrade_customer_payments_association')) {
            printf('<div class="updated"><p>' . __('Easy Digital Downloads needs to upgrade the customer database, click <a href="%s">here</a> to start the upgrade.', 'edd') . '</p></div>', esc_url(admin_url('index.php?page=edd-upgrades&edd-upgrade=upgrade_customer_payments_association')));
        }
        if (version_compare($edd_version, '2.3', '<') || !edd_has_upgrade_completed('upgrade_payment_taxes')) {
            printf('<div class="updated"><p>' . __('Easy Digital Downloads needs to upgrade the payment database, click <a href="%s">here</a> to start the upgrade.', 'edd') . '</p></div>', esc_url(admin_url('index.php?page=edd-upgrades&edd-upgrade=upgrade_payment_taxes')));
        }
        if (version_compare($edd_version, '2.4', '<') || !edd_has_upgrade_completed('upgrade_user_api_keys')) {
            printf('<div class="updated"><p>' . __('Easy Digital Downloads needs to upgrade the API Key database, click <a href="%s">here</a> to start the upgrade.', 'edd') . '</p></div>', esc_url(admin_url('index.php?page=edd-upgrades&edd-upgrade=upgrade_user_api_keys')));
        }
        if (version_compare($edd_version, '2.4.3', '<') || !edd_has_upgrade_completed('remove_refunded_sale_logs')) {
            printf('<div class="updated"><p>' . __('Easy Digital Downloads needs to upgrade the payments database, click <a href="%s">here</a> to start the upgrade.', 'edd') . '</p></div>', esc_url(admin_url('index.php?page=edd-upgrades&edd-upgrade=remove_refunded_sale_logs')));
        }
        /*
         *  NOTICE:
         *
         *  When adding new upgrade notices, please be sure to put the action into the upgrades array during install:
         *  /includes/install.php @ Appox Line 156
         *
         */
        // End 'Stepped' upgrade process notices
    }
}