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 +32 -16 2.2.6 → 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' ),
@@ -235,9 +242,18 @@
235 242 /**
236 243 * Save settings.
237 244 */
238 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 + }
239 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 +
240 256 $settings = $this->get_settings();
241 257
242 258 PH_Admin_Settings::save_fields( $settings );
243 259
@@ -242,9 +258,9 @@
242 258 PH_Admin_Settings::save_fields( $settings );
243 259
244 260 update_option( 'missing_invalid_expired_license_key_notice_dismissed', '' );
245 261
246 - 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 )
247 263 {
248 264 $return = PH()->license->activate_pro_license_key();
249 265 if ( $return['success'] === false )
250 266 {
@@ -255,9 +271,9 @@
255 271 PH_Admin_Settings::add_message('License key activated successfully');
256 272 }
257 273 }
258 274
259 - 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 )
260 276 {
261 277 $return = PH()->license->deactivate_pro_license_key();
262 278 if ( $return['success'] === false )
263 279 {
@@ -268,9 +284,9 @@
268 284 PH_Admin_Settings::add_message('License key deactivated successfully');
269 285 }
270 286 }
271 287
272 - if ( $_POST['propertyhive_license_type'] == 'old' )
288 + if ( 'old' === $license_type )
273 289 {
274 290 PH()->license->ph_check_licenses(true);
275 291 }
276 292 }
@@ -277,5 +293,5 @@
277 293 }
278 294
279 295 endif;
280 296
281 -return new PH_Settings_Licenses();
297 +return new PH_Settings_Licenses();