array(
'client_id' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_client_id'],
'secret' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_client_secret'],
'webhook_id' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_webhook_id'],
),
'sandbox' => array(
'client_id' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_sandbox_client_id'],
'secret' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_sandbox_client_secret'],
'webhook_id' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_sandbox_webhook_id'],
),
);
foreach($ppco_webhook_envs as $ppco_webhook_env => $ppco_webhook_config)
if($ppco_webhook_config['client_id'] && $ppco_webhook_config['secret'] && $ppco_webhook_config['webhook_id'])
if(!c_ws_plugin__s2member_paypal_utilities::paypal_checkout_webhook_upsert($ppco_webhook_env, TRUE))
{
$ppco_webhook_env_label = ($ppco_webhook_env === 'sandbox') ? 'Sandbox' : 'Live';
$ppco_webhook_settings_url = add_query_arg('s2member-open-panel', 'paypal-checkout', admin_url('/admin.php?page=ws-plugin--s2member-paypal-ops')).'#ws-plugin--s2member-paypal-checkout';
//260824.0507 Mark this persistent warning so a later successful reconciliation can remove it automatically.
$notice = 's2Member PayPal Checkout: Your '.esc_html($ppco_webhook_env_label).' webhook could not be updated automatically with the latest required events. Please go to s2Member → PayPal Options → PayPal Checkout and click Create/Update Webhook for '.esc_html($ppco_webhook_env_label).'.';
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array(), TRUE, 0, TRUE);
}
}
if(!$v || !version_compare($v, '3.2', '>=')) // Needs to be upgraded?
// Version 3.2 is where `meta_key` names were changed. They're prefixed now.
{
$like = "`meta_key` LIKE 's2member\\_%' AND `meta_key` NOT LIKE '%s2member\\_originating\\_blog%'";
$wpdb->query("UPDATE `".$wpdb->usermeta."` SET `meta_key` = CONCAT('".$wpdb->prefix."', `meta_key`) WHERE ".$like);
}
if(!$v || !version_compare($v, '3.2.5', '>=')) // Needs to be upgraded?
// Version 3.2.5 is where transient names were changed. They're prefixed now.
{
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '\\_transient\\_%'");
}
if(!$v || !version_compare($v, '3.2.6', '>=')) // Needs to be upgraded?
// Version 3.2.6 fixed `s2member_ccaps_req` being stored empty and/or w/ one empty element in the array.
{
$wpdb->query("DELETE FROM `".$wpdb->postmeta."` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` IN('','a:0:{}','a:1:{i:0;s:0:\"\";}')");
}
if((!$v || !version_compare($v, '110912', '>=')) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['filter_wp_query'] === array('all'))
// s2Member v110912 changed the way the 'all' option for Alternative Views was handled.
{
$notice = 'IMPORTANT: This version of s2Member changes the way your Alternative View Protections work. Please review your options under: s2Member → Restriction Options → Alternative View Protections.';
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
}
if($v && version_compare($v, '130316', '<=')) // This version disables logging by default.
{
c_ws_plugin__s2member_menu_pages::update_all_options(array('ws_plugin__s2member_gateway_debug_logs' => '0', 'ws_plugin__s2member_gateway_debug_logs_extensive' => '0'), TRUE, FALSE, FALSE, FALSE, FALSE);
$notice = 'IMPORTANT: This version of s2Member disables s2Member\'s debug logging by default (for added security). Please see: s2Member → Log Files (Debug) → Configuration for further details.';
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
$notice = 'IMPORTANT / Regarding s2Member Security Badges: If debug logging is enabled, your site will no longer qualify for an s2Member Security Badge until you disable logging (and you must also download, and then delete any existing log files from the past). Please see KB Article: s2Member Security Badges for further details. If you have existing s2Member log files, you will need to delete those files from the server before your s2Member Security Badge can be re-enabled. s2Member stores log files here: '.esc_html(c_ws_plugin__s2member_utils_dirs::doc_root_path($GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir'])).'. See also: s2Member → Log Files (Debug) → Configuration for further details.';
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
}
if($v && version_compare($v, '140128', '<=')) // This version introduces support for partial refunds.
{
if($GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds,reversals') // `refunds,reversals` => `refunds,partial_refunds,reversals`
c_ws_plugin__s2member_menu_pages::update_all_options(array('ws_plugin__s2member_triggers_immediate_eot' => 'refunds,partial_refunds,reversals'), TRUE, FALSE, FALSE, FALSE, FALSE);
}
$notice = 's2Member has been reactivated, with '.(($reactivation_reason === 'levels') ? ''.esc_html($GLOBALS['WS_PLUGIN__']['s2member']['c']['levels']).' Membership Levels' : 'the latest version').'.
';
$notice .= 'You now have version '.esc_html(WS_PLUGIN__S2MEMBER_VERSION).'. Your existing configuration remains.';
if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) // No Changelog on a Multisite Blog Farm.
$notice .= '
Have fun, read the Changelog, and make some money! :-)';
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
}
else // Otherwise (initial activation); we'll help the Site Owner out by giving them a link to the Getting Started section.
{
$notice = 'Note: s2Member adds some new data columns to your list of Users/Members. If your list gets overcrowded, please use the Screen Options tab (upper right-hand corner). With WordPress Screen Options, you can add/remove specific data columns; thereby making the most important data easier to read. For example, if you create Custom Registration/Profile Fields with s2Member, those Custom Fields will result in new data columns; which can cause your list of Users/Members to become nearly unreadable. So just use the Screen Options tab to clean things up.';
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, 'blog:users.php', FALSE, FALSE, TRUE);
$notice = 's2Member v'.esc_html(WS_PLUGIN__S2MEMBER_VERSION).' has been activated. Nice work!
';
$notice .= 'We suggest a review of the "Getting Started" page to familiarize yourself with s2Member terminology and basic configuration.
↳ Would you like to review now? Yes (explain)';
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
}
if(is_multisite() && is_main_site()) // Network activation routines.
{
$wpdb->query("INSERT INTO `".$wpdb->usermeta."` (`user_id`, `meta_key`, `meta_value`) SELECT `ID`, 's2member_originating_blog', '".esc_sql($current_site->blog_id)."' FROM `".$wpdb->users."` WHERE `ID` NOT IN (SELECT `user_id` FROM `".$wpdb->usermeta."` WHERE `meta_key` = 's2member_originating_blog')");
$notice = 'Multisite Network updated automatically by s2Member v'.esc_html(WS_PLUGIN__S2MEMBER_VERSION).'.
';
$notice .= 'You\'ll want to configure s2Member\'s Multisite options now.
';
$notice .= 'In the Dashboard for your Main Site, see:
';
$notice .= 's2Member → Multisite (Config).';
c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array('blog|network:plugins.php', 'blog|network:ws-plugin--s2member-start', 'blog|network:ws-plugin--s2member-mms-ops', 'blog|network:ws-plugin--s2member-gen-ops', 'blog|network:ws-plugin--s2member-res-ops'));
update_site_option('ws_plugin__s2member_options', (array)get_option('ws_plugin__s2member_options'));
update_option('ws_plugin__s2member_activated_mms_version', WS_PLUGIN__S2MEMBER_VERSION);
}
update_option('ws_plugin__s2member_activated_version', WS_PLUGIN__S2MEMBER_VERSION);
do_action('ws_plugin__s2member_after_activation', get_defined_vars());
}
/**
* Deactivation routines for s2Member.
*
* @package s2Member\Installation
* @since 3.5
*/
public static function deactivate()
{
global $wpdb;
/** @var $wpdb wpdb */
global $current_site, $current_blog; // Multisite.
do_action('ws_plugin__s2member_before_deactivation', get_defined_vars());
do_action('ws_plugin__s2member_after_deactivation', get_defined_vars());
}
/**
* Uninstall routines for s2Member.
*
* @package s2Member\Installation
* @since 3.5
*/
public static function uninstall()
{
global $wpdb;
/** @var $wpdb wpdb */
global $current_site, $current_blog; // Multisite.
do_action('ws_plugin__s2member_before_uninstall', get_defined_vars());
if($GLOBALS['WS_PLUGIN__']['s2member']['o']['run_uninstall_routines'])
{
c_ws_plugin__s2member_roles_caps::unlink_roles();
c_ws_plugin__s2member_files::remove_no_gzip_from_root_htaccess();
if(is_dir($files_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['files_dir']))
{
if(file_exists($htaccess = $files_dir.'/.htaccess'))
if(is_writable($htaccess))
unlink($htaccess);
@rmdir($files_dir).@rmdir(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($files_dir));
}
if(is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir']))
{
foreach(scandir($logs_dir) as $log_file)
if(is_file($log_file = $logs_dir.'/'.$log_file))
if(is_writable($log_file))
unlink($log_file);
@rmdir($logs_dir).@rmdir(c_ws_plugin__s2member_utils_dirs::strip_dir_app_data($logs_dir));
}
delete_option('ws_plugin__s2member_cache');
delete_option('ws_plugin__s2member_notices');
delete_option('ws_plugin__s2member_options');
delete_option('ws_plugin__s2member_configured');
delete_option('ws_plugin__s2member_activated_levels');
delete_option('ws_plugin__s2member_activated_version');
delete_option('ws_plugin__s2member_activated_mms_version');
if(is_multisite() && is_main_site() /* Site options? */)
delete_site_option('ws_plugin__s2member_options');
$wpdb->query("DELETE FROM `".$wpdb->postmeta."` WHERE `meta_key` LIKE '".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2m_'))."%'");
$wpdb->query("DELETE FROM `".$wpdb->postmeta."` WHERE `meta_key` LIKE '%".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('_s2m_'))."%'");
$wpdb->query("DELETE FROM `".$wpdb->postmeta."` WHERE `meta_key` LIKE '%".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2member_'))."%'");
$wpdb->query("DELETE FROM `".$wpdb->usermeta."` WHERE `meta_key` LIKE '".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2m_'))."%'");
$wpdb->query("DELETE FROM `".$wpdb->usermeta."` WHERE `meta_key` LIKE '%".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('_s2m_'))."%'");
$wpdb->query("DELETE FROM `".$wpdb->usermeta."` WHERE `meta_key` LIKE '%".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2member_'))."%'");
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2m_'))."%'");
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '%".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('_s2m_'))."%'");
$wpdb->query("DELETE FROM `".$wpdb->options."` WHERE `option_name` LIKE '%".esc_sql(c_ws_plugin__s2member_utils_strings::like_escape('s2member_'))."%'");
do_action('ws_plugin__s2member_during_uninstall', get_defined_vars());
}
do_action('ws_plugin__s2member_after_uninstall', get_defined_vars());
}
/**
* Disallow automatic updates of s2Member w/ Pro is installed.
*
* @package s2Member\Installation
* @since 150717
*
* @attaches-to `auto_update_plugin` filter.
*/
public static function auto_update_filter($update = NULL, $item = NULL)
{
if(is_object($item) && !empty($item->slug) && $item->slug === 's2member')
if(c_ws_plugin__s2member_utils_conds::pro_is_installed())
$update = FALSE; // Disallow.
return $update; // Filter through.
}
}
}