PluginProbe
Property Hive / 1.4.6
Property Hive v1.4.6
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 1.4.61 All 261 releases
propertyhive / includes / admin / settings / class-ph-settings-licenses.php

class-ph-settings-licenses.php in Property Hive 1.4.6, at includes/admin/settings/class-ph-settings-licenses.php

144 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PropertyHive License Settings
4 *
5 * @author PropertyHive
6 * @category Admin
7 * @package PropertyHive/Admin
8 * @version 1.0.0
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly
13 }
14
15 if ( ! class_exists( 'PH_Settings_Licenses' ) ) :
16
17 /**
18 * PH_Settings_Licenses.
19 */
20 class PH_Settings_Licenses extends PH_Settings_Page {
21
22 /**
23 * Constructor.
24 */
25 public function __construct() {
26 $this->id = 'licensekey';
27 $this->label = __( 'License Key', 'propertyhive' );
28
29 add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
30 add_action( 'propertyhive_settings_' . $this->id, array( $this, 'output' ) );
31 add_action( 'propertyhive_settings_save_' . $this->id, array( $this, 'save' ) );
32 }
33
34 /**
35 * Get sections.
36 *
37 * @return array
38 */
39 public function get_sections() {
40 $sections = array(
41 '' => __( 'License Key', 'propertyhive' ),
42 );
43 return apply_filters( 'propertyhive_get_sections_' . $this->id, $sections );
44 }
45
46 /**
47 * Get settings array.
48 *
49 * @return array
50 */
51 public function get_settings() {
52
53 $license = PH()->license->get_current_license();
54
55 $output = '';
56 $input_border_color = '';
57 $renew_link = '<a href=https://wp-property-hive.com/product/12-month-license-key/"" target="_blank">' . __( 'Renew License', 'propertyhive' ) . '</a>';
58 $valid_license = false;
59
60 if ( isset($license['active']) && $license['active'] != '1' )
61 {
62 $output = '<span style="color:#900">' . __( 'License inactive.', 'propertyhive' ) . '</span>';
63 $input_border_color = '#900';
64 }
65 else
66 {
67 if ( isset($license['expires_at']) && $license['expires_at'] != '' )
68 {
69 if ( strtotime($license['expires_at']) <= time() )
70 {
71 // Expired
72 $output = '<span style="color:#900">' . __( 'License expired on ' . date("jS F Y", strtotime($license['expires_at'])), 'propertyhive' ) . '. ' . $renew_link . '</span>';
73 $input_border_color = '#900';
74 }
75 elseif (
76 strtotime($license['expires_at']) > time() &&
77 strtotime($license['expires_at']) < (time() + 30 * 24 * 60 * 60)
78 )
79 {
80 // Expires in less than 30 days
81 $output = '<span style="color:#F90">' . __( 'License expires on ' . date("jS F Y", strtotime($license['expires_at'])), 'propertyhive' ) . '. ' . $renew_link . '</span>';
82 $input_border_color = '#F90';
83 }
84 elseif (strtotime($license['expires_at']) > time())
85 {
86 // Valid
87 $output = '<span style="color:#090">' . __( 'License valid. Expires on ' . date("jS F Y", strtotime($license['expires_at'])), 'propertyhive' ) . '.</span>';
88 $input_border_color = '#090';
89 $valid_license = true;
90 }
91 }
92 }
93
94 $settings = apply_filters( 'propertyhive_licenses_settings', array(
95
96 array( 'title' => __( 'License Key', 'propertyhive' ), 'type' => 'title', 'id' => 'license_options' ),
97
98 array(
99 'type' => 'html',
100 'html' => __( '<p>By having a license key you will benefit from priority one-to-one email support, setup assistance, troubleshooting, and updates to purchased add ons containing new functionality and fixes.</p>
101
102 <p>Licenses are valid for 12 months from the date of purchase and exist on a per-site-basis. Should a license key not exist, your website will still function as it does now. However support will be limited and potentially slower than usual and you won’t receive updates to any purchased add ons.</p>
103
104 ' . ( (!$valid_license) ? '<br><p><a href="https://wp-property-hive.com/product/12-month-license-key/" class="button button-primary" target="_blank">Purchase License Key</a></p>' : '' ), 'propertyhive' ),
105 ),
106
107 array(
108 'title' => __( 'License Key', 'propertyhive' ),
109 'id' => 'propertyhive_license_key',
110 'type' => 'text',
111 'css' => 'min-width:300px; border:1px solid ' . $input_border_color,
112 'desc' => $output,
113 ),
114
115 array( 'type' => 'sectionend', 'id' => 'license_options' ),
116
117 ) );
118
119 return apply_filters( 'propertyhive_get_settings_' . $this->id, $settings );
120 }
121
122 /**
123 * Output the settings.
124 */
125 public function output() {
126 global $current_section;
127
128 $settings = $this->get_settings();
129 PH_Admin_Settings::output_fields( $settings );
130 }
131
132 /**
133 * Save settings.
134 */
135 public function save() {
136 PH_Admin_Settings::save_fields( $this->get_settings() );
137
138 PH()->license->ph_check_licenses(true);
139 }
140 }
141
142 endif;
143
144 return new PH_Settings_Licenses();