PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 261001
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v261001
261001 260927 260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 All 191 releases
← All changes | src/includes/classes/installation.inc.php +60 -16 260814 → 261001 View file →
@@ -64,13 +64,41 @@
64 64 if(is_dir($logs_dir) && is_writable($logs_dir))
65 65 if(!is_file($htaccess = $logs_dir.'/.htaccess') || !apply_filters('ws_plugin__s2member_preserve_logs_dir_htaccess', !is_writable($logs_dir.'/.htaccess'), get_defined_vars()))
66 66 file_put_contents($htaccess, trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($GLOBALS['WS_PLUGIN__']['s2member']['c']['logs_dir_htaccess']))));
67 67
68 + //260916.2137 Detect a genuinely fresh activation before creating the options row; missing options on any prior installation must retain legacy EOT demotion behavior.
69 + $fresh_install = !get_option('ws_plugin__s2member_activated_version') && !is_array(get_option('ws_plugin__s2member_options'));
70 +
68 71 (!is_array(get_option('ws_plugin__s2member_cache'))) ? update_option('ws_plugin__s2member_cache', array()) : NULL;
69 72 (!is_array(get_option('ws_plugin__s2member_notices'))) ? update_option('ws_plugin__s2member_notices', array()) : NULL;
70 73 (!is_array(get_option('ws_plugin__s2member_options'))) ? update_option('ws_plugin__s2member_options', array()) : NULL;
71 74 (!is_numeric(get_option('ws_plugin__s2member_configured'))) ? update_option('ws_plugin__s2member_configured', '0') : NULL;
72 75
76 + $options = (array)get_option('ws_plugin__s2member_options');
77 + if(!array_key_exists('eot_demotion_from', $options))
78 + {
79 + $options['eot_demotion_from'] = $fresh_install ? 's2member_level' : 'all';
80 + update_option('ws_plugin__s2member_options', $options);
81 + if(is_multisite() && is_main_site())
82 + update_site_option('ws_plugin__s2member_options', $options);
83 + }
84 + unset($fresh_install, $options);
85 +
86 + //260902.0420 A Framework activation/update invalidates cached Pro update availability; the next admin request will refresh it in the background.
87 + if($reactivation_reason === '' || $reactivation_reason === 'version')
88 + {
89 + $options = (array)get_option('ws_plugin__s2member_options');
90 + if(isset($options['pro_latest_version']))
91 + {
92 + unset($options['pro_latest_version']);
93 + $options = ws_plugin__s2member_configure_options_and_their_defaults($options);
94 + update_option('ws_plugin__s2member_options', $options);
95 + if(is_multisite() && is_main_site())
96 + update_site_option('ws_plugin__s2member_options', $options);
97 + }
98 + unset($options);
99 + }
100 +
73 101 //260809 Seed hashed Defuse key mappings on activation after installation or updates; migration is idempotent.
74 102 c_ws_plugin__s2member_utils_defuse::migrate_legacy_defuse_key_mappings();
75 103
76 104 if($GLOBALS['WS_PLUGIN__']['s2member']['c']['configured']) // If we are re-activating.
@@ -76,8 +104,40 @@
76 104 if($GLOBALS['WS_PLUGIN__']['s2member']['c']['configured']) // If we are re-activating.
77 105 {
78 106 $v = get_option('ws_plugin__s2member_activated_version'); // Currently.
79 107
108 + //260822.2048 Older EOT demotions recorded their processing time only in Administrative Notes; recover that history asynchronously where the legacy note is still available.
109 + if(!$v || version_compare($v, '260822.2048', '<'))
110 + c_ws_plugin__s2member_auto_eots::start_eot_processed_time_backfill();
111 +
112 + //260824.1727 Refresh existing Checkout webhooks once more to add dispute-created notifications.
113 + if(!$v || version_compare($v, '260824.1727', '<'))
114 + {
115 + $ppco_webhook_envs = array(
116 + 'live' => array(
117 + 'client_id' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_client_id'],
118 + 'secret' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_client_secret'],
119 + 'webhook_id' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_webhook_id'],
120 + ),
121 + 'sandbox' => array(
122 + 'client_id' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_sandbox_client_id'],
123 + 'secret' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_sandbox_client_secret'],
124 + 'webhook_id' => (string)$GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_checkout_sandbox_webhook_id'],
125 + ),
126 + );
127 + foreach($ppco_webhook_envs as $ppco_webhook_env => $ppco_webhook_config)
128 + if($ppco_webhook_config['client_id'] && $ppco_webhook_config['secret'] && $ppco_webhook_config['webhook_id'])
129 + if(!c_ws_plugin__s2member_paypal_utilities::paypal_checkout_webhook_upsert($ppco_webhook_env, TRUE))
130 + {
131 + $ppco_webhook_env_label = ($ppco_webhook_env === 'sandbox') ? 'Sandbox' : 'Live';
132 + $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';
133 +
134 + //260824.0507 Mark this persistent warning so a later successful reconciliation can remove it automatically.
135 + $notice = '<span class="s2member-ppco-webhook-upgrade-notice-'.esc_attr($ppco_webhook_env).'"><strong>s2Member PayPal Checkout:</strong> Your '.esc_html($ppco_webhook_env_label).' webhook could not be updated automatically with the latest required events. Please go to <a href="'.esc_url($ppco_webhook_settings_url).'"><strong>s2Member → PayPal Options → PayPal Checkout</strong></a> and click <strong>Create/Update Webhook</strong> for '.esc_html($ppco_webhook_env_label).'.</span>';
136 + c_ws_plugin__s2member_admin_notices::enqueue_admin_notice($notice, array(), TRUE, 0, TRUE);
137 + }
138 + }
139 +
80 140 if(!$v || !version_compare($v, '3.2', '>=')) // Needs to be upgraded?
81 141 // Version 3.2 is where `meta_key` names were changed. They're prefixed now.
82 142 {
83 143 $like = "`meta_key` LIKE 's2member\\_%' AND `meta_key` NOT LIKE '%s2member\\_originating\\_blog%'";
@@ -232,22 +292,6 @@
232 292 }
233 293 do_action('ws_plugin__s2member_after_uninstall', get_defined_vars());
234 294 }
235 295
236 - /**
237 - * Disallow automatic updates of s2Member w/ Pro is installed.
238 - *
239 - * @package s2Member\Installation
240 - * @since 150717
241 - *
242 - * @attaches-to `auto_update_plugin` filter.
243 - */
244 - public static function auto_update_filter($update = NULL, $item = NULL)
245 - {
246 - if(is_object($item) && !empty($item->slug) && $item->slug === 's2member')
247 - if(c_ws_plugin__s2member_utils_conds::pro_is_installed())
248 - $update = FALSE; // Disallow.
249 -
250 - return $update; // Filter through.
251 - }
252 296 }
253 297 }