PluginProbe
Property Hive / 2.2.6
Property Hive v2.2.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-features.php

class-ph-settings-features.php in Property Hive 2.2.6, at includes/admin/settings/class-ph-settings-features.php

293 lines 11.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PropertyHive Features 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_Features' ) ) :
16
17 /**
18 * PH_Settings_Features
19 */
20 class PH_Settings_Features extends PH_Settings_Page {
21
22 /**
23 * Constructor.
24 */
25 public function __construct() {
26 $this->id = 'features';
27 $this->label = __( 'Features', '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_admin_field_pro_features', array( $this, 'pro_features_setting' ) );
32 }
33
34 public function get_settings() {
35
36 $settings = array(
37
38 array( 'title' => __( 'Active Features', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'pro_active_features_settings' )
39
40 );
41
42 $settings[] = array(
43 'type' => 'pro_features',
44 );
45
46 $settings[] = array( 'type' => 'sectionend', 'id' => 'pro_active_features_settings');
47
48 return $settings;
49 }
50
51 public function pro_features_setting()
52 {
53 $features = get_ph_pro_features();
54
55 echo '<div class="pro-feature-settings">';
56
57 // filters
58 $categories = array(
59 '' => 'All',
60 'import' => 'Property Import',
61 'export' => 'Portal Feeds',
62 'website' => 'Website Tools',
63 'crm' => 'CRM Tools',
64 'data-bridges' => 'Data Bridges',
65 'free' => 'Free',
66 );
67
68 $selected_category = '';
69 if ( isset($_GET['profilter']) && array_key_exists(sanitize_text_field($_GET['profilter']), $categories) )
70 {
71 $selected_category = sanitize_text_field($_GET['profilter']);
72 }
73
74 echo '<div class="pro-filters">';
75 echo '<ul>';
76 $i = 0;
77 foreach ( $categories as $key => $value )
78 {
79 echo '<li ' . ( $selected_category == $key ? ' class="active"' : '' ) . '><a href="" data-filter="' . esc_attr($key) . '">' . esc_html($value) . '</a></li>';
80 ++$i;
81 }
82 echo '</ul>';
83 echo '</div>';
84
85 // Check if AI Property Search is in list. If not, it can't have been launched yet and to show promo instead
86 /*$ai_property_search_found = false;
87 foreach ( $features as $feature )
88 {
89 $slug = explode("/", $feature['wordpress_plugin_file']);
90 $slug = $slug[0];
91
92 if ( strpos($slug, 'propertyhive-ai-property-search') !== false )
93 {
94 $ai_property_search_found = true;
95 break;
96 }
97 }*/
98
99 // list of features
100 echo '<div class="pro-features">';
101 echo '<ul>';
102 $i = 0;
103 foreach ( $features as $feature )
104 {
105 /*if ( $i == 0 && $ai_property_search_found === false )
106 {
107 // Show ad
108 $feature_status = false;
109
110 if ( is_dir( WP_PLUGIN_DIR . '/' . $slug ) )
111 {
112 $feature_status = 'installed';
113 }
114 if ( is_plugin_active( $feature['wordpress_plugin_file'] ) )
115 {
116 $feature_status = 'active';
117 }
118
119 echo '<li style="visibility:hidden" class="website">
120 <div class="inner" style="background:#0c2442; color:#FFF">
121 <h3><img src="' . esc_url(PH()->plugin_url() . '/assets/images/admin/settings/ai-property-search.png') . '" style="height:28px;" alt="AI Property Search - Coming Soon"></h3>';
122
123 $links = array();
124
125 $links[] = '<span style="color:#999;" class="help_tip" data-tip="' . esc_attr( __('Integrate with ai-property-search.com and add natural language search to your website.', 'propertyhive') ) . '"><span class="dashicons dashicons-info-outline"></span></span>';
126
127 $links[] = '<a href="https://ai-property-search.com/?src=plugin-feature-settings" target="_blank" style="text-decoration:none; color:#FFF;">' . esc_html(__( 'Coming Soon', 'propertyhive' )) . '</a>';
128
129 $links[] = '<a href="https://ai-property-search.com/?src=plugin-feature-settings" target="_blank" style="text-decoration:none; color:#FFF;">' . esc_html(__( 'More Info', 'propertyhive' )) . '</a>';
130
131
132 echo '<div style="float:right; padding-top:6px;">';
133 echo implode("&nbsp;&nbsp;|&nbsp;&nbsp;", $links);
134 echo '</div>';
135
136 echo '<label class="switch">
137 <input type="checkbox" name="" disabled value="">
138 <span class="slider round" style="pointer-events:none; opacity:0.5"></span>
139 </label>';
140
141 echo '</div>';
142 echo '</li>';
143
144 ++$i;
145 }*/
146
147 $slug = explode("/", $feature['wordpress_plugin_file']);
148 $slug = $slug[0];
149
150 if ( $slug == 'propertyhive-template-assistant' )
151 {
152 echo '<li style="visibility:hidden" class="';
153 if ( isset($feature['categories']) && is_array($feature['categories']) && !empty($feature['categories']) )
154 {
155 echo esc_attr(implode(" ", $feature['categories']));
156 }
157
158 $pro = false;
159
160 echo '">
161 <div class="inner"' . ( !$can_use ? ' style="border:1px solid #900"' : '' ) . '>
162 <h3>' . ( ( isset($feature['dashicon']) && !empty($feature['dashicon']) ) ? '<span class="dashicons ' . esc_attr($feature['dashicon']) . '"></span> ' : '' ) . esc_html($feature['name']) . '</h3>
163 <span class="free"><span>FREE</span></span>
164 ';
165
166 $links = array();
167 $links[] = 'This feature has moved. <a href="https://wp-property-hive.com/template-assistant-is-now-part-of-property-hive-core-plugin?src=plugin-feature-settings" target="_blank" style="text-decoration:none">' . esc_html(__( 'Read More', 'propertyhive' )) . '</a>';
168
169 echo '<div style="float:right; padding-top:6px;">';
170 echo implode("&nbsp;&nbsp;|&nbsp;&nbsp;", $links);
171 echo '</div>';
172
173 echo '<label class="switch">
174 <input type="checkbox" name="" disabled value="">
175 <span class="slider round" style="pointer-events:none; opacity:0.5"></span>
176 </label>';
177
178 echo '<div class="loading"><img src="' . esc_url(PH()->plugin_url() . '/assets/images/admin/loading.gif') . '" alt=""></div>';
179
180 echo '</div>';
181 echo '</li>';
182
183 continue;
184 }
185
186 $feature_status = false;
187
188 if ( is_dir( WP_PLUGIN_DIR . '/' . $slug ) )
189 {
190 $feature_status = 'installed';
191 }
192 if ( is_plugin_active( $feature['wordpress_plugin_file'] ) )
193 {
194 $feature_status = 'active';
195 }
196
197 echo '<li style="visibility:hidden" class="';
198 if ( isset($feature['categories']) && is_array($feature['categories']) && !empty($feature['categories']) )
199 {
200 echo esc_attr(implode(" ", $feature['categories']));
201 }
202
203 $pro = false;
204 $plans = (isset($feature['plans']) & is_array($feature['plans'])) ? $feature['plans'] : array();
205 if ( !in_array('free', $plans) )
206 {
207 $pro = true;
208 }
209
210 $can_use = true;
211 if ( $pro && $feature_status == 'active' && apply_filters( 'propertyhive_add_on_can_be_used', true, $slug ) === FALSE )
212 {
213 $can_use = false;
214 }
215
216 echo '">
217 <div class="inner"' . ( !$can_use ? ' style="border:1px solid #900"' : '' ) . '>
218 <h3>' . ( ( isset($feature['dashicon']) && !empty($feature['dashicon']) ) ? '<span class="dashicons ' . esc_attr($feature['dashicon']) . '"></span> ' : '' ) . esc_html($feature['name']) . '</h3>' .
219 ( $pro ? '<span class="pro"><span><a href="https://wp-property-hive.com/pricing/?src=plugin-feature-settings" target="_blank">PRO</a></span></span>' : '' ) .
220 ( !$pro ? '<span class="free"><span>FREE</span></span>' : '' ) . '
221 ';
222
223 $links = array();
224 if ( isset($feature['description']) && !empty($feature['description']) )
225 {
226 $links[] = '<span style="color:#999;" class="help_tip" data-tip="' . esc_attr($feature['description']) . '"><span class="dashicons dashicons-info-outline"></span></span>';
227 }
228 if ( isset($feature['url']) && !empty($feature['url']) )
229 {
230 $links[] = '<a href="' . esc_url($feature['url']) . '" target="_blank" style="text-decoration:none">' . esc_html(__( 'Details', 'propertyhive' )) . '</a>';
231 }
232 if ( isset($feature['docs_url']) && !empty($feature['docs_url']) )
233 {
234 $links[] = '<a href="' . esc_url($feature['docs_url']) . '" target="_blank" style="text-decoration:none">' . esc_html(__( 'Docs', 'propertyhive' )) . '</a>';
235 }
236 if ( $feature_status == 'active' )
237 {
238 $transient = get_site_transient( 'update_plugins' );
239 if ( isset($transient->response) && is_array($transient->response) && isset($transient->response[$feature['wordpress_plugin_file']]) && isset($transient->response[$feature['wordpress_plugin_file']]->new_version) )
240 {
241 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $feature['wordpress_plugin_file'] );
242
243 if ( version_compare($plugin_data['Version'], $transient->response[$feature['wordpress_plugin_file']]->new_version, '<') )
244 {
245 $links[] = '<a href="' . esc_url(admin_url('plugins.php?plugin_status=upgrade')) . '" style="text-decoration:none"><span class="dashicons dashicons-update"></span> ' . esc_html(__( 'Update', 'propertyhive' )) . '</a>';
246 }
247 }
248 }
249
250 echo '<div style="float:right; padding-top:6px;">';
251 echo implode("&nbsp;&nbsp;|&nbsp;&nbsp;", $links);
252 echo '</div>';
253
254 echo '<label class="switch">
255 <input type="checkbox" name="active_plugins[]" value="' . esc_attr($slug) . '"' . ( $feature_status == 'active' ? ' checked' : '' ) . '>
256 <span class="slider round"></span>
257 </label>';
258
259 echo '<div class="loading"><img src="' . esc_url(PH()->plugin_url() . '/assets/images/admin/loading.gif') . '" alt=""></div>';
260
261 if ( !$can_use )
262 {
263 echo '<div style="color:#900; font-size:0.9; margin-top:10px;">Disabled due to <a href="' . esc_url(admin_url('admin.php?page=ph-settings&tab=licensekey')) . '" style="color:inherit">invalid license</a></div>';
264 }
265
266 echo '</div>';
267 echo '</li>';
268
269 ++$i;
270 }
271 echo '</ul><div style="clear:both"></div></div>';
272
273 echo '</div>';
274 }
275
276 /**
277 * Output the settings
278 */
279 public function output() {
280 global $current_section, $hide_save_button;
281
282 $hide_save_button = true;
283 $settings = $this->get_settings();
284
285 PH_Admin_Settings::output_fields( $settings );
286 }
287
288 }
289
290 endif;
291
292 return new PH_Settings_Features();
293