PluginProbe
Property Hive / 2.4.0
Property Hive v2.4.0
2.4.0 2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 All 262 releases
← All changes | includes/admin/settings/class-ph-settings-licenses.php +57 -26 2.2.2 → 2.4.0 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +// phpcs:set WordPress.Security.ValidatedSanitizedInput customSanitizingFunctions[] ph_clean
3 +// ph_clean() recursively sanitizes text; presence, shape and unslashing checks remain separate.
4 +
2 5 /**
3 6 * PropertyHive License Settings
4 7 *
5 8 * @author PropertyHive
@@ -16,8 +19,9 @@
16 19
17 20 /**
18 21 * PH_Settings_Licenses.
19 22 */
23 +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy public global class PH_Settings_Licenses; preserving the existing PH_* class name is required for plugin and extension compatibility.
20 24 class PH_Settings_Licenses extends PH_Settings_Page {
21 25
22 26 /**
23 27 * Constructor.
@@ -72,10 +76,10 @@
72 76 if ( isset($license['expires_at']) && $license['expires_at'] != '' )
73 77 {
74 78 if ( (strtotime($license['expires_at']) + 86400) <= time() )
75 79 {
76 - // Expired
77 - $output = '<span style="color:#900">' . __( 'License expired on ' . date("jS F Y", strtotime($license['expires_at'])), 'propertyhive' ) . '. ' . $renew_link . '</span>';
80 + /* translators: %s: License expiry date. */
81 + $output = '<span style="color:#900">' . sprintf( __( 'License expired on %s', 'propertyhive' ), gmdate( 'jS F Y', strtotime( $license['expires_at'] ) ) ) . '. ' . $renew_link . '</span>';
78 82 $input_border_color = '#900';
79 83 }
80 84 else
81 85 {
@@ -86,8 +90,15 @@
86 90 }
87 91 }
88 92 }
89 93
94 + $legacy_error = get_option( 'propertyhive_license_key_error', '' );
95 + if ( 'old' === $license_type && '' !== $legacy_error ) {
96 + $output = '<span style="color:#900">' . esc_html( $legacy_error ) . '</span>';
97 + $input_border_color = '#900';
98 + $valid_license = false;
99 + }
100 +
90 101 // get new license information
91 102 $valid_pro_license = false;
92 103 $pro_input_border_color = '';
93 104 $pro_output = '';
@@ -142,17 +153,13 @@
142 153
143 154 $settings[] = array(
144 155 'type' => 'html',
145 156 'id' => 'pro_license_key_info',
146 - 'html' => __( '<p>With a Pro license subscription you\'ll unlock a wide array of Property Hive functionality. We offer multiple packages to suit your needs. Your Pro subscription details and license key can be found within the \'<a href="https://wp-property-hive.com/my-account/" target="_blank">My Account</a>\' section of our website.</p>
147 - ' . ( (!$valid_pro_license) ?
148 - '<br><p><a href="https://wp-property-hive.com/pricing/?src=plugin-license-settings" class="button button-primary" target="_blank">Get PRO</a></p>' :
149 - '<br><p>
150 - <a href="' . admin_url('admin.php?page=ph-settings&tab=features') . '" class="button button-primary">Activate Features</a>
151 - <a href="https://wp-property-hive.com/my-account/subscriptions/?src=wordpress-license-tab" class="button button" target="_blank">Manage Subscription</a>
152 - </p>'
153 - ), 'propertyhive' ) . '
154 - <input type="hidden" name="pro_license_key_action" value="' . ( $valid_pro_license ? 'deactivate' : 'activate' ) . '">',
157 + 'html' => '<p>' . wp_kses_post( __( 'With a Pro license subscription you unlock a wide array of Property Hive functionality. We offer multiple packages to suit your needs. Your Pro subscription details and license key can be found in the <a href="https://wp-property-hive.com/my-account/" target="_blank">My Account</a> section of our website.', 'propertyhive' ) ) . '</p><br><p>' .
158 + ( ! $valid_pro_license ?
159 + '<a href="https://wp-property-hive.com/pricing/?src=plugin-license-settings" class="button button-primary" target="_blank">' . esc_html__( 'Get PRO', 'propertyhive' ) . '</a>' :
160 + '<a href="' . esc_url( admin_url( 'admin.php?page=ph-settings&tab=features' ) ) . '" class="button button-primary">' . esc_html__( 'Activate Features', 'propertyhive' ) . '</a> <a href="https://wp-property-hive.com/my-account/subscriptions/?src=wordpress-license-tab" class="button button" target="_blank">' . esc_html__( 'Manage Subscription', 'propertyhive' ) . '</a>'
161 + ) . '</p><input type="hidden" name="pro_license_key_action" value="' . ( $valid_pro_license ? 'deactivate' : 'activate' ) . '">',
155 162 );
156 163
157 164 if ( $valid_pro_license )
158 165 {
@@ -159,9 +166,9 @@
159 166 $settings[] = array(
160 167 'type' => 'html',
161 168 'id' => 'pro_license_key_display',
162 169 'title' => __( 'License Key', 'propertyhive' ),
163 - 'html' => '<input type="text" disabled="disabled" value="' . $license_key_to_display . '" style="min-width:350px; border:1px solid ' . $pro_input_border_color . '"> ' . $pro_output
170 + 'html' => '<input type="text" disabled="disabled" value="' . esc_attr( $license_key_to_display ) . '" style="min-width:350px; border:1px solid ' . esc_attr( $pro_input_border_color ) . '"> ' . esc_html( $pro_output )
164 171 );
165 172
166 173 $settings[] = array(
167 174 'title' => __( 'License Key', 'propertyhive' ),
@@ -179,19 +186,34 @@
179 186 'desc' => $pro_output
180 187 );
181 188 }
182 189
190 + $legacy_license_message = '';
191 +
192 + if ( 'old' === $license_type )
193 + {
194 + $legacy_license_message = '<p>' . sprintf(
195 + /* translators: %s: URL to the support page */
196 + __( 'To switch your existing license key over to the new pricing model, please <a href="%s">get in touch</a>.', 'propertyhive' ),
197 + esc_url( 'https://wp-property-hive.com/support' )
198 + ) . '</p>';
199 + }
200 +
183 201 $settings[] = array(
184 - 'type' => 'html',
185 - 'id' => 'license_key_info',
186 - 'html' => sprintf(
187 - __( '<p>If you purchased a license key prior to 16th October 2023, you can enter it here to benefit from updates to any existing add-ons you\'ve purchased.</p>
188 - <p>We\'ve since moved to a new and improved <a href="%1$s" target="_blank">pro pricing model</a> that is more cost effective for you and gives access to more features.</p>
189 - %2$s
190 - <br><p><a href="%1$s" class="button button-primary" target="_blank">Get PRO</a></p>', 'propertyhive' ),
191 - esc_url('https://wp-property-hive.com/pricing/?src=plugin-license-settings'),
192 - $license_type == 'old' ? '<p>' . sprintf( __( 'To switch your existing license key over to the new pricing model, please get in touch at <a href="mailto:%s">%s</a>.', 'propertyhive' ), '[email protected]', '[email protected]' ) . '</p>' : ''
193 - ),
202 + 'type' => 'html',
203 + 'id' => 'license_key_info',
204 + 'html' => sprintf(
205 + /* translators: 1: URL to the pricing page, 2: optional message shown to legacy license holders */
206 + __(
207 + '<p>If you purchased a license key prior to 16th October 2023, you can enter it here to benefit from updates to any existing add-ons you\'ve purchased.</p>
208 + <p>We\'ve since moved to a new and improved <a href="%1$s" target="_blank">pro pricing model</a> that is more cost effective for you and gives access to more features.</p>
209 + %2$s
210 + <br><p><a href="%1$s" class="button button-primary" target="_blank">Get PRO</a></p>',
211 + 'propertyhive'
212 + ),
213 + esc_url( 'https://wp-property-hive.com/pricing/?src=plugin-license-settings' ),
214 + $legacy_license_message
215 + ),
194 216 );
195 217
196 218 $settings[] = array(
197 219 'title' => __( 'License Key', 'propertyhive' ),
@@ -220,9 +242,18 @@
220 242 /**
221 243 * Save settings.
222 244 */
223 245 public function save() {
246 + if ( ! current_user_can( 'manage_options' ) || ! isset( $_REQUEST['_wpnonce'] ) || ! is_string( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'propertyhive-settings' ) ) {
247 + return;
248 + }
224 249
250 +
251 + $license_type = isset( $_POST['propertyhive_license_type'] ) && is_string( $_POST['propertyhive_license_type'] ) ? sanitize_text_field( wp_unslash( $_POST['propertyhive_license_type'] ) ) : '';
252 + $license_key = isset( $_POST['propertyhive_pro_license_key'] ) && is_string( $_POST['propertyhive_pro_license_key'] ) ? ph_clean( wp_unslash( $_POST['propertyhive_pro_license_key'] ) ) : '';
253 + $license_action = isset( $_POST['pro_license_key_action'] ) && is_string( $_POST['pro_license_key_action'] ) ? sanitize_text_field( wp_unslash( $_POST['pro_license_key_action'] ) ) : '';
254 +
255 +
225 256 $settings = $this->get_settings();
226 257
227 258 PH_Admin_Settings::save_fields( $settings );
228 259
@@ -227,9 +258,9 @@
227 258 PH_Admin_Settings::save_fields( $settings );
228 259
229 260 update_option( 'missing_invalid_expired_license_key_notice_dismissed', '' );
230 261
231 - if ( $_POST['propertyhive_license_type'] == 'pro' && isset($_POST['propertyhive_pro_license_key']) && !empty(ph_clean($_POST['propertyhive_pro_license_key'])) && $_POST['pro_license_key_action'] == 'activate' )
262 + if ( 'pro' === $license_type && ! empty( $license_key ) && 'activate' === $license_action )
232 263 {
233 264 $return = PH()->license->activate_pro_license_key();
234 265 if ( $return['success'] === false )
235 266 {
@@ -240,9 +271,9 @@
240 271 PH_Admin_Settings::add_message('License key activated successfully');
241 272 }
242 273 }
243 274
244 - if ( $_POST['propertyhive_license_type'] == 'pro' && isset($_POST['propertyhive_pro_license_key']) && !empty(ph_clean($_POST['propertyhive_pro_license_key'])) && $_POST['pro_license_key_action'] == 'deactivate' )
275 + if ( 'pro' === $license_type && ! empty( $license_key ) && 'deactivate' === $license_action )
245 276 {
246 277 $return = PH()->license->deactivate_pro_license_key();
247 278 if ( $return['success'] === false )
248 279 {
@@ -253,9 +284,9 @@
253 284 PH_Admin_Settings::add_message('License key deactivated successfully');
254 285 }
255 286 }
256 287
257 - if ( $_POST['propertyhive_license_type'] == 'old' )
288 + if ( 'old' === $license_type )
258 289 {
259 290 PH()->license->ph_check_licenses(true);
260 291 }
261 292 }
@@ -262,5 +293,5 @@
262 293 }
263 294
264 295 endif;
265 296
266 -return new PH_Settings_Licenses();
297 +return new PH_Settings_Licenses();