id = 'licensekey'; $this->label = __( 'License', 'propertyhive' ); add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_action( 'propertyhive_settings_' . $this->id, array( $this, 'output' ) ); add_action( 'propertyhive_settings_save_' . $this->id, array( $this, 'save' ) ); } /** * Get settings array. * * @return array */ public function get_settings() { $license_type = PH()->license->get_license_type(); if ( $license_type == '' ) { $license_type = 'pro'; } // get old license information $license = PH()->license->get_current_license(); $output = ''; $input_border_color = ''; $renew_link = '' . __( 'Renew License', 'propertyhive' ) . ''; $valid_license = false; if ( is_array($license) && empty($license) && get_option( 'propertyhive_license_key', '' ) != '' ) { $output = '' . __( 'Invalid license key entered. If you\'re seeing this message and the license key is correct please contact Property Hive support.', 'propertyhive' ) . ''; $input_border_color = '#900'; if ( get_option( 'propertyhive_license_key_error', '' ) != '' ) { $output .= ' ' . esc_html(get_option( 'propertyhive_license_key_error', '' )) . ''; } } elseif ( isset($license['active']) && $license['active'] != '1' ) { $output = '' . __( 'License inactive.', 'propertyhive' ) . ''; $input_border_color = '#900'; } else { if ( isset($license['expires_at']) && $license['expires_at'] != '' ) { if ( (strtotime($license['expires_at']) + 86400) <= time() ) { /* translators: %s: License expiry date. */ $output = '' . sprintf( __( 'License expired on %s', 'propertyhive' ), gmdate( 'jS F Y', strtotime( $license['expires_at'] ) ) ) . '. ' . $renew_link . ''; $input_border_color = '#900'; } else { // Valid $output = '' . __( 'License valid', 'propertyhive') . '.'; $input_border_color = '#090'; $valid_license = true; } } } $legacy_error = get_option( 'propertyhive_license_key_error', '' ); if ( 'old' === $license_type && '' !== $legacy_error ) { $output = '' . esc_html( $legacy_error ) . ''; $input_border_color = '#900'; $valid_license = false; } // get new license information $valid_pro_license = false; $pro_input_border_color = ''; $pro_output = ''; $license_key_to_display = ''; if (get_option('propertyhive_pro_license_key', '') != '') { $length = strlen(get_option('propertyhive_pro_license_key', '')); $license_key_to_display = get_option('propertyhive_pro_license_key', ''); if ( $length >= 6 ) { $license_key_to_display = get_option('propertyhive_pro_license_key', '')[0] . get_option('propertyhive_pro_license_key', '')[1] . get_option('propertyhive_pro_license_key', '')[2] . str_repeat('*', $length - 4) . get_option('propertyhive_pro_license_key', '')[$length-3] . get_option('propertyhive_pro_license_key', '')[$length-2] . get_option('propertyhive_pro_license_key', '')[$length-1]; } if ( PH()->license->is_valid_pro_license_key(true) ) { $valid_pro_license = true; // to be used for displaying subscription level in future //$product_id_and_package = PH()->license->get_pro_license_product_id_and_package(); $pro_input_border_color = '#090'; } else { $pro_license = PH()->license->get_current_pro_license(); $pro_input_border_color = '#900'; $pro_output = ( isset($pro_license['error']) ? $pro_license['error'] : '' ); } } $settings = array( array( 'title' => __( 'License Key', 'propertyhive' ), 'type' => 'title', 'id' => 'license_options' ), ); $settings[] = array( 'title' => __( 'License Type', 'propertyhive' ), 'id' => 'propertyhive_license_type', 'type' => 'radio', 'default' => $license_type, 'options' => array( 'pro' => 'Pro', 'old' => 'Old-Style (license keys purchased before October 2023)' ) ); $settings[] = array( 'type' => 'html', 'id' => 'pro_license_key_info', 'html' => '
' . 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 My Account section of our website.', 'propertyhive' ) ) . '
' . ( ! $valid_pro_license ? '' . esc_html__( 'Get PRO', 'propertyhive' ) . '' : '' . esc_html__( 'Activate Features', 'propertyhive' ) . ' ' . esc_html__( 'Manage Subscription', 'propertyhive' ) . '' ) . '
', ); if ( $valid_pro_license ) { $settings[] = array( 'type' => 'html', 'id' => 'pro_license_key_display', 'title' => __( 'License Key', 'propertyhive' ), 'html' => ' ' . esc_html( $pro_output ) ); $settings[] = array( 'title' => __( 'License Key', 'propertyhive' ), 'id' => 'propertyhive_pro_license_key', 'type' => 'hidden' ); } else { $settings[] = array( 'title' => __( 'License Key', 'propertyhive' ), 'id' => 'propertyhive_pro_license_key', 'type' => 'text', 'css' => 'min-width:350px; border:1px solid ' . $pro_input_border_color, 'desc' => $pro_output ); } $legacy_license_message = ''; if ( 'old' === $license_type ) { $legacy_license_message = '' . sprintf( /* translators: %s: URL to the support page */ __( 'To switch your existing license key over to the new pricing model, please get in touch.', 'propertyhive' ), esc_url( 'https://wp-property-hive.com/support' ) ) . '
'; } $settings[] = array( 'type' => 'html', 'id' => 'license_key_info', 'html' => sprintf( /* translators: 1: URL to the pricing page, 2: optional message shown to legacy license holders */ __( '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.
We\'ve since moved to a new and improved pro pricing model that is more cost effective for you and gives access to more features.
%2$s