PluginProbe ʕ •ᴥ•ʔ
Checkout Field Editor (Checkout Manager) for WooCommerce / 2.0.5
Checkout Field Editor (Checkout Manager) for WooCommerce v2.0.5
1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.0.9 1.2.0 1.2.5 1.2.8 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8
woo-checkout-field-editor-pro / admin / class-thwcfd-admin-settings-themehigh-plugins.php
woo-checkout-field-editor-pro / admin Last commit date
assets 1 year ago class-thwcfd-admin-form-field.php 1 year ago class-thwcfd-admin-form.php 1 year ago class-thwcfd-admin-settings-advanced.php 1 year ago class-thwcfd-admin-settings-general.php 1 year ago class-thwcfd-admin-settings-pro.php 1 year ago class-thwcfd-admin-settings-themehigh-plugins.php 1 year ago class-thwcfd-admin-settings.php 1 year ago class-thwcfd-admin.php 1 year ago
class-thwcfd-admin-settings-themehigh-plugins.php
339 lines
1 <?php
2 /**
3 * The admin advanced settings page functionality of the plugin.
4 *
5 * @link https://themehigh.com
6 * @since 1.4.4
7 *
8 * @package woo-checkout-field-editor-pro
9 * @subpackage woo-checkout-field-editor-pro/admin
10 */
11
12 if(!defined('WPINC')){ die; }
13
14 if(!class_exists('THWCFD_Admin_Settings_Themehigh_Plugins')):
15
16 class THWCFD_Admin_Settings_Themehigh_Plugins extends THWCFD_Admin_Settings{
17 protected static $_instance = null;
18 protected $tabs = '';
19
20 private $settings_fields = NULL;
21 private $cell_props = array();
22 private $cell_props_CB = array();
23
24 public function __construct() {
25 parent::__construct();
26 $this->page_id = 'themehigh_plugins';
27 }
28
29 public static function instance() {
30 if(is_null(self::$_instance)){
31 self::$_instance = new self();
32 }
33 return self::$_instance;
34 }
35
36 public function render_page(){
37 $this->render_tabs();
38 $this->render_content();
39 }
40
41 private function plugins(){
42 return array(
43 array(
44 'title' => 'Checkout Field Editor (Checkout Manager) for WooCommerce',
45 'image' => 'checkout-field-editor.png',
46 'content' => 'Checkout Field Editor plugin lets you add and manage the fields of your WooCommerce checkout page and allows you to choose the field display areas.',
47 'slug' => 'woo-checkout-field-editor-pro',
48 'file' => 'checkout-form-designer.php',
49 'featured' => true,
50 'skip' => true,
51 ),
52 array(
53 'title' => 'Extra Product Options (Product Addons) for WooCommerce',
54 'image' => 'extra-product-options.png',
55 'content' => 'The Extra Product Options plugin allows you to create additional fields on your product page and helps you to manage them efficiently.',
56 'slug' => 'woo-extra-product-options',
57 'file' => 'woo-extra-product-options.php',
58 ),
59 array(
60 'title' => 'MultiStep Checkout for WooCommerce',
61 'image' => 'multistep-checkout.png',
62 'content' => 'Using the compatibility feature of the Multi-step checkout plugin, you can create additional fields to your checkout page and split the default WooCommerce checkout page into simpler steps.',
63 'slug' => 'woo-multistep-checkout',
64 'file' => 'woo-multistep-checkout.php',
65 'featured' => true,
66 ),
67 array(
68 'title' => 'Email Customizer for WooCommerce',
69 'image' => 'email-customizer.png',
70 'content' => 'As the Checkout Field editor plugin is compatible with the Email customizer, you can edit the WooCommerce transactional emails with the checkout fields at your desired position in the email.',
71 'slug' => 'email-customizer-for-woocommerce',
72 'file' => 'email-customizer-for-woocommerce.php',
73 'featured' => true,
74 ),
75 array(
76 'title' => 'Multiple Addresses for WooCommerce',
77 'image' => 'multiple-addresses.png',
78 'content' => 'The plugin compatibility helps the shoppers to add custom checkout field data to their customer addresses and lets them choose the desired address while placing the order.',
79 'slug' => 'themehigh-multiple-addresses',
80 'file' => 'themehigh-multiple-addresses.php',
81 'featured' => true,
82 ),
83 array(
84 'title' => 'Order Delivery Date And Time',
85 'image' => 'order-delivery.gif',
86 'content' => "Order Delivery | Pickup Date and Time Planner allows you to plan your store's delivery and pickup, as well as pre-set specific days and holidays.",
87 'slug' => 'order-delivery-date-and-time',
88 'file' => 'order-delivery-date-and-time.php',
89 'featured' => true,
90 ),
91 array(
92 'title' => 'Variation Swatches for WooCommerce',
93 'image' => 'variation-swatches.png',
94 'content' => 'Variation Swatches for Woocommerce plugin lets you display the variable product attributes as attractive swatches of different types.',
95 'slug' => 'product-variation-swatches-for-woocommerce',
96 'file' => 'product-variation-swatches-for-woocommerce.php',
97 ),
98 array(
99 'title' => 'Job Manager & Career',
100 'image' => 'job-manager.png',
101 'content' => 'Job Manager & Career is a lightweight WordPress plugin to add and manage job posts on your career page.',
102 'slug' => 'job-manager-career',
103 'file' => 'job-manager-career.php',
104 ),
105 array(
106 'title' => 'WooCommerce Wishlist and Comparison',
107 'image' => 'wishlist-compare.png',
108 'content' => 'The plugin helps your customers to move products to the wishlist for future purchases and lets them compare between different products.',
109 'slug' => 'wishlist-and-compare',
110 'file' => 'wishlist-and-compare.php',
111 ),
112 array(
113 'title' => 'Dynamic Pricing and Discount Rules',
114 'image' => 'discount-and-dynamic-pricing.png',
115 'content' => 'Dynamic Pricing and Discount Rules plugin helps you to define special discount rules for both the product and cart details.',
116 'slug' => 'discount-and-dynamic-pricing',
117 'file' => 'discount-and-dynamic-pricing.php',
118 ),
119 array(
120 'title' => 'Advanced FAQ Manager',
121 'image' => 'advanced-faq-manager.png',
122 'content' => 'Advanced FAQ Manager plugin lets you easily add and manage the Frequently Asked Questions on your WordPress pages.',
123 'slug' => 'advanced-faq-manager',
124 'file' => 'advanced-faq-manager.php',
125 ),
126
127 array(
128 'title' => 'Product Feature Request',
129 'image' => 'product-feature-request.png',
130 'content' => 'Using the Product Feature Request plugin, you can collect suggestions or ideas from the customers and improve your WooCommerce products.',
131 'slug' => 'product-feature-request',
132 'file' => 'product-feature-request.php',
133 ),
134
135 );
136 }
137
138 private function render_content(){
139 ?>
140 <?php
141 $plugins = $this->plugins();
142 $featured_plugins = array_filter($plugins, function ($var) {
143 return (isset($var['featured']) && $var['featured'] == true && !(isset($var['skip'])));
144 });
145 if(!empty($featured_plugins)){ ?>
146 <h2><?php esc_html_e('Compatible Plugins', 'woo-checkout-field-editor-pro'); ?></h2>
147 <div class="th-plugins-wrapper featured">
148 <?php
149 foreach($featured_plugins as $plugin){
150 $title = isset($plugin['title']) ? $plugin['title'] : '';
151 $img = isset($plugin['image']) ? $plugin['image'] : '';
152 $content = isset($plugin['content']) ? $plugin['content'] : '';
153 $link = isset($plugin['download_link']) ? $plugin['download_link'] : '';
154 $slug = isset($plugin['slug']) ? $plugin['slug'] : '';
155 $file = isset($plugin['file']) ? $plugin['file'] : '';
156 ?>
157 <div class="th-plugins-child">
158 <div class="th-title-box">
159 <?php if($img){ ?>
160 <img src="<?php echo esc_url( THWCFD_URL . 'admin/assets/images/wp-plugins/' . $img ); ?>" alt="<?php echo esc_attr( $title ); ?>">
161 <?php } ?>
162 <h3><a href="https://wordpress.org/plugins/<?php echo esc_attr( $slug ); ?>" target="_blank"><?php echo esc_html($title); ?></a></h3>
163 </div>
164 <?php echo wp_kses_post(wpautop($content)); ?>
165
166 <?php if($slug && $file){
167 $this->install_plugin_button($slug, $file, $title);
168 } ?>
169
170 </div>
171 <?php } ?>
172 </div>
173 <?php } ?>
174
175
176
177
178 <?php
179 $plugin = array();
180 $regular_plugins = array_filter($plugins, function ($var) {
181 return (!isset($var['featured']) && !isset($var['skip']));
182 });
183 if(!empty($regular_plugins)){ ?>
184 <h2><?php esc_html_e('Other Plugins', 'woo-checkout-field-editor-pro'); ?></h2>
185 <div class="th-plugins-wrapper">
186 <?php
187 foreach($regular_plugins as $plugin){
188 $title = isset($plugin['title']) ? $plugin['title'] : '';
189 $img = isset($plugin['image']) ? $plugin['image'] : '';
190 $content = isset($plugin['content']) ? $plugin['content'] : '';
191 $link = isset($plugin['download_link']) ? $plugin['download_link'] : '';
192 $slug = isset($plugin['slug']) ? $plugin['slug'] : '';
193 $file = isset($plugin['file']) ? $plugin['file'] : '';
194 ?>
195 <div class="th-plugins-child">
196 <div class="th-title-box">
197 <?php if($img){ ?>
198 <img src="<?php echo esc_url( THWCFD_URL . 'admin/assets/images/wp-plugins/' . $img ); ?>" alt="<?php echo esc_attr( $title ); ?>">
199 <?php } ?>
200 <h3><a href="https://wordpress.org/plugins/<?php echo esc_attr( $slug ); ?>" target="_blank"><?php echo esc_html($title); ?></a></h3>
201 </div>
202 <?php echo wp_kses_post((wpautop($content))); ?>
203
204 <?php if($slug && $file){
205 $this->install_plugin_button($slug, $file, $title);
206 } ?>
207
208 </div>
209 <?php } ?>
210 </div>
211 <?php } ?>
212 <?php
213 }
214
215
216 /**
217 * Output a button that will install or activate a plugin if it doesn't exist, or display a disabled button if the
218 * plugin is already activated.
219 *
220 * @param string $plugin_slug The plugin slug.
221 * @param string $plugin_file The plugin file.
222 * @param string $plugin_name The plugin name.
223 * @param string $classes CSS classes.
224 * @param string $activated Button activated text.
225 * @param string $activate Button activate text.
226 * @param string $install Button install text.
227 */
228 public static function install_plugin_button( $plugin_slug, $plugin_file, $plugin_name, $classes = array(), $activated = '', $activate = '', $install = '' ) {
229 if ( current_user_can( 'install_plugins' ) && current_user_can( 'activate_plugins' ) ) {
230 if ( is_plugin_active( $plugin_slug . '/' . $plugin_file ) ) {
231 // The plugin is already active.
232 $button = array(
233 'message' => esc_attr__( 'Activated', 'storefront' ),
234 'url' => '#',
235 'classes' => array('button', 'disabled' ),
236 );
237
238 if ( '' !== $activated ) {
239 $button['message'] = esc_attr( $activated );
240 }
241 } elseif ( self::is_plugin_installed( $plugin_slug ) ) {
242 $url = self::is_plugin_installed( $plugin_slug );
243
244 // The plugin exists but isn't activated yet.
245 $button = array(
246 'message' => esc_attr__( 'Activate', 'storefront' ),
247 'url' => $url,
248 'classes' => array( 'activate-now', 'button' ),
249 );
250
251 if ( '' !== $activate ) {
252 $button['message'] = esc_attr( $activate );
253 }
254 } else {
255 // The plugin doesn't exist.
256 $url = wp_nonce_url(
257 add_query_arg(
258 array(
259 'action' => 'install-plugin',
260 'plugin' => $plugin_slug,
261 ),
262 self_admin_url( 'update.php' )
263 ),
264 'install-plugin_' . $plugin_slug
265 );
266 $button = array(
267 'message' => esc_attr__( 'Install now', 'storefront' ),
268 'url' => $url,
269 'classes' => array('button-primary', 'install-now', 'install-' . $plugin_slug ),
270 );
271
272 if ( '' !== $install ) {
273 $button['message'] = esc_attr( $install );
274 }
275 }
276
277 if ( ! empty( $classes ) ) {
278 $button['classes'] = array_merge( $button['classes'], $classes );
279 }
280
281 $button['classes'] = implode( ' ', $button['classes'] );
282
283 ?>
284 <span class="plugin-card-<?php echo esc_attr( $plugin_slug ); ?>">
285 <a href="<?php echo esc_url( $button['url'] ); ?>" class="<?php echo esc_attr( $button['classes'] ); ?> th-plugin-action" data-originaltext="<?php echo esc_attr( $button['message'] ); ?>" data-name="<?php echo esc_attr( $plugin_name ); ?>" data-slug="<?php echo esc_attr( $plugin_slug ); ?>" aria-label="<?php echo esc_attr( $button['message'] ); ?>"><?php echo esc_html( $button['message'] ); ?></a>
286 </span>
287 <?php
288 }
289 }
290
291 /**
292 * Check if a plugin is installed and return the url to activate it if so.
293 *
294 * @param string $plugin_slug The plugin slug.
295 */
296 public static function is_plugin_installed( $plugin_slug ) {
297 if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) {
298 $plugins = get_plugins( '/' . $plugin_slug );
299 if ( ! empty( $plugins ) ) {
300 $keys = array_keys( $plugins );
301 $plugin_file = $plugin_slug . '/' . $keys[0];
302 $url = wp_nonce_url(
303 add_query_arg(
304 array(
305 'action' => 'activate',
306 'plugin' => $plugin_file,
307 ),
308 admin_url( 'plugins.php' )
309 ),
310 'activate-plugin_' . $plugin_file
311 );
312 return $url;
313 }
314 }
315 return false;
316 }
317
318 function activate_themehigh_plugins(){
319 $plugin_file = isset($_REQUEST['file']) ? sanitize_text_field(wp_unslash($_REQUEST['file'])) : '';
320 if( $plugin_file && check_ajax_referer( 'activate-plugin_' . $plugin_file ) ){
321 if ( current_user_can( 'install_plugins' ) && current_user_can( 'activate_plugins' ) ) {
322 if (!is_plugin_active($plugin_file) ) {
323
324 $result = activate_plugin($plugin_file);
325
326 if( is_wp_error( $result ) ) {
327 wp_send_json(false);
328 }else{
329 wp_send_json(true);
330 }
331 }
332 }
333 }
334 wp_send_json(false);
335 }
336
337 }
338
339 endif;