PluginProbe
Envo Extra / trunk
Envo Extra vtrunk
1.9.22 1.9.21 trunk 1.1.0 1.4.0 1.4.1 1.4.2 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 All 75 releases
envo-extra / envo-extra.php

envo-extra.php in Envo Extra trunk, at envo-extra.php

712 lines 25.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Plugin Name: Envo Extra
4 * Plugin URI: https://envothemes.com/
5 * Description: Extra addon for EnvoThemes Themes
6 * Version: 1.9.22
7 * Author: EnvoThemes
8 * Author URI: https://envothemes.com/
9 * License: GPL-2.0+
10 * Text Domain: envo-extra
11 * Domain Path: /languages
12 */
13 // Exit if accessed directly.
14 if ( !defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( !function_exists( 'add_action' ) ) {
19 die( 'Nothing to do...' );
20 }
21 //define( 'KIRKI_TEST', true );
22 $plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ), false );
23 $plugin_version = $plugin_data[ 'Version' ];
24 // Define WC_PLUGIN_FILE.
25 if ( !defined( 'ENVO_EXTRA_CURRENT_VERSION' ) ) {
26 define( 'ENVO_EXTRA_CURRENT_VERSION', $plugin_version );
27 }
28
29 //plugin constants
30 define( 'ENVO_EXTRA_PATH', plugin_dir_path( __FILE__ ) );
31 define( 'ENVO_EXTRA_PLUGIN_BASE', plugin_basename( __FILE__ ) );
32 define( 'ENVO_EXTRA_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
33
34 add_action( 'init', 'envo_extra_load_textdomain' );
35
36 function envo_extra_load_textdomain() {
37 load_plugin_textdomain( 'envo-extra', false, basename( dirname( __FILE__ ) ) . '/languages/' );
38 }
39
40 function envo_extra_is_gutenberg() {
41
42 if ( function_exists( 'has_blocks' ) && has_blocks( get_the_ID() ) ) {
43 return true;
44 } else {
45 return false;
46 }
47 }
48
49 function envo_extra_scripts() {
50 if ( envo_extra_is_gutenberg() ) {
51 wp_enqueue_style( 'envo-extra-gutenberg', plugin_dir_url( __FILE__ ) . 'css/gutenberg.css', array(), ENVO_EXTRA_CURRENT_VERSION );
52 }
53 wp_enqueue_style( 'envo-extra', plugin_dir_url( __FILE__ ) . 'css/style.css', array(), ENVO_EXTRA_CURRENT_VERSION );
54 wp_enqueue_script( 'envo-extra-js', plugin_dir_url( __FILE__ ) . 'js/envo.js', array( 'jquery' ), ENVO_EXTRA_CURRENT_VERSION, true );
55 }
56
57 add_action( 'wp_enqueue_scripts', 'envo_extra_scripts' );
58
59 function envo_extra_admin_scripts() {
60 wp_enqueue_script( 'preview-script-elmn', ENVO_EXTRA_PLUGIN_URL . 'lib/elementor/assets/js/elementor.js', [ ], ENVO_EXTRA_CURRENT_VERSION, true );
61 }
62 //Dequeue Styles
63 function envo_extra_dequeue_unnecessary_styles() {
64 $value = get_theme_mod( 'main_typographydesktop', array() );
65 if ( isset( $value[ 'font-family' ] ) && !empty( $value[ 'font-family' ] ) ) {
66 wp_dequeue_style( 'enwoo-fonts' );
67 wp_deregister_style( 'enwoo-fonts' );
68 }
69 }
70
71 add_action( 'wp_print_styles', 'envo_extra_dequeue_unnecessary_styles' );
72
73 /**
74 * Return theme slug
75 */
76 function envo_extra_theme() {
77 $theme = get_template();
78 $slug = str_replace( '-', '_', $theme );
79 return $slug;
80 }
81
82 /**
83 * Footer copyright function
84 */
85 if ( !function_exists( 'envo_extra_text' ) ) {
86
87 function envo_extra_text( $rewritetexts ) {
88
89 $currentyear = date( 'Y' );
90 $copy = '&copy;';
91
92 return str_replace(
93 array( '%current_year%', '%copy%' ), array( $currentyear, $copy ), $rewritetexts
94 );
95 }
96
97 }
98
99 add_filter( 'envo_extra_footer_text', 'envo_extra_text' );
100
101 /**
102 * Back to top
103 */
104 function envo_extra_back_to_top() {
105 if ( get_theme_mod( 'back_to_top_on_off', 'block' ) == 'block' ) {
106 ?>
107 <!-- Return to Top -->
108 <a href="javascript:" id="return-to-top"><i class="las la-chevron-up"></i></a>
109 <?php
110 }
111 }
112
113 /**
114 * Footer extra actions - footer text and back to top
115 */
116 function envo_extra_action() {
117 remove_action( envo_extra_theme() . '_generate_footer', envo_extra_theme() . '_generate_construct_footer', 20 );
118 add_action( envo_extra_theme() . '_generate_footer', 'envo_extra_generate_construct_footer' );
119 add_action( 'wp_footer', 'envo_extra_back_to_top' );
120 remove_theme_support( 'widgets-block-editor' );
121 }
122
123 /**
124 * Footer footer text
125 */
126 function envo_extra_generate_construct_footer() {
127 if ( get_theme_mod( 'enwoo_custom_footer_on_off', '' ) == 'elementor' && get_theme_mod( 'enwoo_custom_footer', '' ) != '' && envo_extra_check_for_elementor() ) {
128 $elementor_section_ID = get_theme_mod( 'enwoo_custom_footer', '' );
129 ?>
130 <footer id="colophon" class="elementor-footer-credits">
131 <?php echo do_shortcode( '[elementor-template id="' . $elementor_section_ID . '"]' ); ?>
132 </footer>
133 <?php } elseif ( get_theme_mod( 'footer-credits', '' ) != '' ) { ?>
134 <footer id="colophon" class="footer-credits container-fluid">
135 <div class="container">
136 <div class="footer-credits-text text-center">
137 <div class="envo-credits-text">
138 <?php echo apply_filters( 'envo_extra_footer_text', get_theme_mod( 'footer-credits', '' ) ); ?>
139 </div>
140 <?php if ( get_theme_mod( 'enwoo_footer_credits_on_off', 1 ) == 1 ) { ?>
141 <?php printf( get_site_option( 'et_fc' ) ); ?>
142 <?php } ?>
143 </div>
144 </div>
145 </footer>
146 <?php } else { ?>
147 <?php if ( get_theme_mod( 'enwoo_footer_credits_on_off', 1 ) == 1 ) { ?>
148 <footer id="colophon" class="footer-credits container-fluid">
149 <div class="container">
150 <div class="footer-credits-text text-center">
151 <?php printf( get_site_option( 'et_fc' ) ); ?>
152 </div>
153 </div>
154 </footer>
155 <?php } ?>
156 <?php
157 }
158 }
159
160 function envo_extra_recommended_plugins() {
161 add_theme_support( 'recommend-plugins', array(
162 'woocommerce' => array(
163 'name' => 'WooCommerce',
164 'active_filename' => 'woocommerce/woocommerce.php',
165 /* translators: %s plugin name string */
166 'description' => sprintf( esc_attr__( 'To enable shop features, please install and activate the %s plugin.', 'envo-extra' ), '<strong>WooCommerce</strong>' ),
167 ),
168 'elementor' => array(
169 'name' => 'Elementor',
170 'active_filename' => 'elementor/elementor.php',
171 /* translators: %s plugin name string */
172 'description' => sprintf( esc_attr__( 'The most advanced frontend drag & drop page builder.', 'envo-extra' ), '<strong>Elementor</strong>' ),
173 ),
174 ) );
175 }
176
177 if ( !class_exists( 'Kirki' ) ) {
178 include_once( plugin_dir_path( __FILE__ ) . 'include/kirki.php' );
179 }
180
181 /**
182 * Remove Kirki telemetry
183 */
184 function envo_extra_remove_kirki_module( $modules ) {
185 unset( $modules[ 'telemetry' ] );
186 unset( $modules[ 'gutenberg' ] );
187 return $modules;
188 }
189
190 add_filter( 'kirki_modules', 'envo_extra_remove_kirki_module' );
191
192 /**
193 * Add Kirki CSS into a file
194 */
195 add_filter( 'kirki_output_inline_styles', function() {
196 return true;
197 } );
198
199 /* Register the config */
200 Kirki::add_config( 'envo_extra', array(
201 'capability' => 'edit_theme_options',
202 'option_type' => 'theme_mod',
203 ) );
204
205
206 /* Make the CSS of kirki tabs available after switch */
207 //add_filter('kirki_envo_extra_webfonts_skip_hidden', '__return_false', 99);
208 //add_filter('kirki_envo_extra_css_skip_hidden', '__return_false', 99);
209 //add_filter( 'kirki_dynamic_css_method', function() {
210 // return 'file';
211 //} );
212 // Check if needed functions exists - if not, require them
213 if ( !function_exists( 'is_plugin_active' ) ) {
214 require_once ABSPATH . 'wp-admin/includes/plugin.php';
215 }
216
217 function envo_extra_check_plugin_active( $plugin_slug ) {
218 if ( is_plugin_active( $plugin_slug ) ) {
219 return true;
220 }
221
222 return false;
223 }
224
225 /**
226 * Add Kirki custom controls.
227 *
228 * @param WP_Customize_Manager $wp_customize Instance of WP_Customize_Manager.
229 */
230 function envo_extra_custom_customizer_control( $wp_customize ) {
231
232 // Custom controls.
233
234 require ENVO_EXTRA_PATH . '/controls/responsive-devices/control-responsive-devices.php';
235 require ENVO_EXTRA_PATH . '/controls/responsive-devices/control-responsive-devices-typography.php';
236 }
237
238 if ( !function_exists( 'envo_extra_dashboard' ) ) {
239
240 function envo_extra_dashboard() {
241
242 require_once( plugin_dir_path( __FILE__ ) . 'lib/admin/dashboard.php' );
243 }
244
245 }
246
247 function envo_extra_functions() {
248 require_once( plugin_dir_path( __FILE__ ) . 'options/extra.php' );
249 }
250 add_action( 'after_setup_theme', 'envo_extra_functions' );
251
252 $theme = wp_get_theme();
253 if ( 'Enwoo' == $theme->name || 'enwoo' == $theme->template ) {
254
255 add_action( 'customize_register', 'envo_extra_custom_customizer_control' );
256
257 function envo_extra_check_for_woocommerce() {
258 require_once( plugin_dir_path( __FILE__ ) . 'lib/admin/metabox.php' );
259 if ( !envo_extra_check_for_pro( 'enwoo' ) ) {
260 Kirki::add_section( 'pro', array(
261 'title' => esc_html__( 'Unlock More Options', 'kirki' ),
262 'type' => 'link',
263 'button_text' => esc_html__( 'Enwoo PRO', 'envo-extra' ),
264 'button_url' => 'https://enwoo-wp.com/enwoo-pro/',
265 'priority' => 1,
266 ) );
267 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/pro.php' );
268 require_once( plugin_dir_path( __FILE__ ) . 'lib/envothemes-demo-import/includes/panel/pro-demos.php' );
269 }
270
271 Kirki::add_panel( 'envo_theme_panel', array(
272 'title' => esc_attr__( 'Theme Options', 'envo-extra' ),
273 'priority' => 5,
274 ) );
275 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/site-width.php' );
276 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/top-bar.php' );
277 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/header.php' );
278 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/main-menu.php' );
279 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/footer-credits.php' );
280 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/footer-widgets.php' );
281 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/main-colors.php' );
282 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/posts-pages.php' );
283 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/sidebar.php' );
284 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/back-to-top.php' );
285 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/custom-codes.php' );
286 if ( !defined( 'WC_VERSION' ) ) {
287 // no woocommerce :(
288 } else {
289 require_once( plugin_dir_path( __FILE__ ) . 'options/enwoo/woocommerce.php' );
290 require_once( plugin_dir_path( __FILE__ ) . 'lib/woocommerce.php' );
291 }
292 }
293
294 add_action( 'after_setup_theme', 'envo_extra_check_for_woocommerce' );
295
296
297 add_action( 'init', 'envo_extra_dashboard' );
298 add_action( 'init', 'envo_extra_recommended_plugins' );
299
300 add_filter( 'use_widgets_block_editor', '__return_false' );
301
302 add_action( 'after_setup_theme', 'envo_extra_action', 0 );
303 }
304
305 if ( 'Envo Royal' == $theme->name || 'envo-royal' == $theme->template ) {
306
307 add_action( 'customize_register', 'envo_extra_custom_customizer_control' );
308
309 function envo_extra_check_for_woocommerce() {
310
311 require_once( plugin_dir_path( __FILE__ ) . 'lib/admin/metabox.php' );
312 if ( !envo_extra_check_for_pro( 'envo-royal' ) ) {
313 Kirki::add_section( 'pro', array(
314 'title' => esc_html__( 'Unlock More Options', 'kirki' ),
315 'type' => 'link',
316 'button_text' => esc_html__( 'Envo Royal PRO', 'envo-extra' ),
317 'button_url' => 'https://envothemes.com/product/envo-royal-pro/',
318 'priority' => 1,
319 ) );
320 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/pro.php' );
321 require_once( plugin_dir_path( __FILE__ ) . 'lib/envothemes-demo-import/includes/panel/envo-royal-pro-demos.php' );
322 }
323
324 Kirki::add_panel( 'envo_theme_panel', array(
325 'title' => esc_attr__( 'Theme Options', 'envo-extra' ),
326 'priority' => 5,
327 ) );
328
329
330 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/color-preset.php' );
331 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/top-bar.php' );
332 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/header.php' );
333 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/main-menu.php' );
334 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/footer-credits.php' );
335 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/footer-widgets.php' );
336 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/main-colors.php' );
337 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/posts-pages.php' );
338 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/sidebar.php' );
339 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/back-to-top.php' );
340 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/custom-codes.php' );
341 if ( !defined( 'WC_VERSION' ) ) {
342 // no woocommerce :(
343 } else {
344 require_once( plugin_dir_path( __FILE__ ) . 'options/envo-royal/woocommerce.php' );
345 require_once( plugin_dir_path( __FILE__ ) . 'lib/woocommerce.php' );
346 }
347 }
348
349 add_action( 'after_setup_theme', 'envo_extra_check_for_woocommerce' );
350
351 add_action( 'init', 'envo_extra_dashboard' );
352 add_action( 'init', 'envo_extra_recommended_plugins' );
353
354 add_filter( 'use_widgets_block_editor', '__return_false' );
355
356 add_action( 'after_setup_theme', 'envo_extra_action', 0 );
357 }
358
359 // Deactivate 3rd party plugin
360 if ( in_array( 'envothemes-demo-import/envothemes-demo-import.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
361 deactivate_plugins( 'envothemes-demo-import/envothemes-demo-import.php' );
362 }
363
364 add_action( 'plugins_loaded', 'envo_extra_plugin_load' );
365
366 function envo_extra_plugin_load() {
367 if ( !in_array( 'envothemes-demo-import/envothemes-demo-import.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
368 require_once( plugin_dir_path( __FILE__ ) . 'lib/envothemes-demo-import/envothemes-demo-import.php' );
369 }
370 }
371
372 add_action( 'customize_register', 'envo_extra_theme_customize_register', 99 );
373
374 function envo_extra_fonts() {
375 if (envo_extra_check_for_pro('enwoo') || envo_extra_check_for_pro('envo-royal')) {
376 $fonts = array();
377 } else {
378 $fonts = array(
379 'google' => array(
380 'Roboto',
381 'Open Sans',
382 'Lato',
383 'Roboto Condensed',
384 'Slabo 27px',
385 'Montserrat',
386 'Oswald',
387 'Source Sans Pro',
388 'Raleway',
389 'Merriweather',
390 ),
391 );
392 }
393 return $fonts;
394 }
395 add_action( 'admin_init', 'envo_extra_fonts' );
396
397 function envo_extra_theme_customize_register( $wp_customize ) {
398
399 $wp_customize->remove_control( 'header_textcolor' );
400
401 // relocating default background color
402 $wp_customize->get_control( 'background_color' )->section = 'background_image';
403 }
404
405 function envo_extra_get_meta( $name = '', $output = '' ) {
406 if ( is_singular( array( 'post', 'page' ) ) || ( function_exists( 'is_shop' ) && is_shop() ) ) {
407 global $post;
408 if ( ( function_exists( 'is_shop' ) && is_shop() ) ) {
409 $post_id = get_option( 'woocommerce_shop_page_id' );
410 ;
411 } else {
412 $post_id = $post->ID;
413 }
414 $meta = get_post_meta( $post_id, 'envo_extra_meta_' . $name, true );
415 if ( isset( $meta ) && $meta != '' ) {
416 if ( $output == 'echo' ) {
417 echo esc_html( $meta );
418 } else {
419 return $meta;
420 }
421 } else {
422 return;
423 }
424 }
425 }
426
427 if ( !function_exists( 'envo_extra_widget_date_comments' ) ) :
428
429 /**
430 * Returns date for widgets.
431 */
432 function envo_extra_widget_date_comments() {
433 ?>
434 <span class="extra-posted-date">
435 <?php echo esc_html( get_the_date() ); ?>
436 </span>
437 <span class="extra-comments-meta">
438 <?php
439 if ( !comments_open() ) {
440 esc_html_e( 'Off', 'envo-extra' );
441 } else {
442 ?>
443 <a href="<?php echo esc_url( get_comments_link() ); ?>" rel="nofollow" title="<?php esc_html_e( 'Comment on ', 'envo-extra' ) . the_title_attribute(); ?>">
444 <?php echo absint( get_comments_number() ); ?>
445 </a>
446 <?php } ?>
447 <i class="fa fa-comments-o"></i>
448 </span>
449 <?php
450 }
451
452 endif;
453
454 /**
455 * Check Elementor plugin
456 */
457 function envo_extra_check_for_elementor() {
458 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
459 return is_plugin_active( 'elementor/elementor.php' );
460 }
461
462 /**
463 * Check Elementor PRO plugin
464 */
465 function envo_extra_check_for_elementor_pro() {
466 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
467 return is_plugin_active( 'elementor-pro/elementor-pro.php' );
468 }
469
470 /**
471 * Register Elementor features
472 */
473 if ( envo_extra_check_for_elementor() ) {
474 if ( !envo_extra_check_for_elementor_pro() ) {
475 include_once( plugin_dir_path( __FILE__ ) . 'lib/elementor/shortcode.php' );
476 add_action( 'admin_enqueue_scripts', 'envo_extra_admin_scripts' );
477 }
478 }
479
480 include_once( plugin_dir_path( __FILE__ ) . 'lib/elementor/widgets.php' );
481
482 function envo_extra_activate_fc() {
483 $arr = array( '' );
484 $theme = wp_get_theme();
485 if ( 'Enwoo' == $theme->name || 'enwoo' == $theme->template ) {
486 $arr = array(
487 'Created with <a href="https://enwoo-wp.com/free-woocommerce-theme/" title="Free WooCommerce WordPress Theme">Enwoo</a> WordPress theme',
488 'Created with <a href="https://enwoo-wp.com/free-business-wp-theme/" title="Free Business WordPress Theme">Enwoo</a> WordPress theme',
489 'Created with <a href="https://enwoo-wp.com/" title="Free Multipurpose WordPress Theme">Enwoo</a> WordPress theme',
490 );
491 } elseif ( 'Envo Royal' == $theme->name || 'envo-royal' == $theme->template ) {
492 $arr = array(
493 'Created with <a href="https://envothemes.com/envo-royal-free-wp-theme/" title="Free Multipurpose WordPress Theme">Envo Royal</a> WordPress theme',
494 );
495 }
496
497 $key = array_rand( $arr );
498
499 update_site_option( 'et_fc', $arr[ $key ] );
500 }
501
502 add_action( 'after_switch_theme', 'envo_extra_activate_fc' );
503 register_activation_hook( __FILE__, 'envo_extra_activate_fc' );
504
505
506
507 register_activation_hook( __FILE__, 'envo_extra_plugin_activate' );
508 add_action( 'admin_init', 'envo_extra_plugin_redirect' );
509 add_action( 'after_switch_theme', 'envo_extra_theme_redirect' );
510
511 function envo_extra_plugin_activate() {
512 add_option( 'envo_plugin_do_activation_redirect', true );
513 }
514
515 /**
516 * Check PRO plugin
517 */
518 function envo_extra_check_for_pro( $plugin ) {
519 if ( in_array( $plugin . '-pro/' . $plugin . '-pro.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
520 return true;
521 }
522 return;
523 }
524
525 /**
526 * Redirect after plugin activation
527 */
528 function envo_extra_plugin_redirect() {
529 if ( get_option( 'envo_plugin_do_activation_redirect', false ) ) {
530 delete_option( 'envo_plugin_do_activation_redirect' );
531 if ( !is_network_admin() || !isset( $_GET[ 'activate-multi' ] ) ) {
532 wp_redirect( 'themes.php?page=envothemes-panel-install-demos' );
533 }
534 }
535 }
536
537 /**
538 * Redirect after plugin activation
539 */
540 function envo_extra_theme_redirect() {
541 if ( !is_network_admin() || !isset( $_GET[ 'activate-multi' ] ) ) {
542 wp_redirect( 'themes.php?page=envothemes-panel-install-demos' );
543 }
544 }
545
546 /**
547 * Adjust customizer preview.
548 */
549 function envo_extra_customizer_responsive_sizes() {
550
551 $medium_breakpoint = 990;
552 $mobile_breakpoint = 480;
553
554 $tablet_margin_left = -$medium_breakpoint / 2 . 'px';
555 $tablet_width = $medium_breakpoint . 'px';
556
557 $mobile_margin_left = -$mobile_breakpoint / 2 . 'px';
558 $mobile_width = $mobile_breakpoint . 'px';
559 ?>
560
561 <style>
562 .wp-customizer .preview-tablet .wp-full-overlay-main {
563 margin-left: <?php echo esc_attr( $tablet_margin_left ); ?>;
564 width: <?php echo esc_attr( $tablet_width ); ?>;
565 }
566 .wp-customizer .preview-mobile .wp-full-overlay-main {
567 margin-left: <?php echo esc_attr( $mobile_margin_left ); ?>;
568 width: <?php echo esc_attr( $mobile_width ); ?>;
569 height: 680px;
570 }
571 </style>
572
573 <?php
574 }
575
576 add_action( 'customize_controls_print_styles', 'envo_extra_customizer_responsive_sizes' );
577
578 /**
579 * Enqueue customizer scripts & styles.
580 */
581 function envo_extra_customizer_scripts_styles() {
582
583 wp_enqueue_style( 'responsive-controls', ENVO_EXTRA_PLUGIN_URL . 'css/responsive-controls.css', '', ENVO_EXTRA_CURRENT_VERSION );
584 wp_enqueue_script( 'responsive-controls', ENVO_EXTRA_PLUGIN_URL . 'js/responsive-controls.js', array( 'jquery' ), ENVO_EXTRA_CURRENT_VERSION, true );
585 }
586
587 add_action( 'customize_controls_print_styles', 'envo_extra_customizer_scripts_styles' );
588
589 add_filter( 'body_class', 'envo_extra_body_classes' );
590
591 function envo_extra_body_classes( $classes ) {
592
593 $theme = wp_get_theme();
594 if ( 'Enwoo' == $theme->name || 'enwoo' == $theme->template ) {
595 $header = get_theme_mod( 'header_layout', envo_extra_check_plugin_active( 'woocommerce/woocommerce.php' ) ? 'woonav' : 'busnav' );
596 } else {
597 $header = get_theme_mod( 'header_layout', 'busnav' );
598 }
599 if ( $header != '' ) {
600 $classes[] = 'header-' . $header;
601 }
602
603 $woo_check = envo_extra_check_plugin_active( 'woocommerce/woocommerce.php' ) ? 'woo-on' : '';
604 if ( $header != '' ) {
605 $classes[] = $woo_check;
606 }
607
608 if ( is_archive() || is_home() )
609 return $classes;
610
611 if ( envo_extra_is_gutenberg() ) {
612 $classes[] = 'gutenberg-on';
613 }
614 $title = get_post_meta( get_the_ID(), 'envo_extra_hide_title', true );
615 if ( $title == 'on' ) {
616 $classes[] = 'title-off';
617 }
618 $sidebar = get_post_meta( get_the_ID(), 'envo_extra_hide_sidebar', true );
619 if ( $sidebar == 'on' ) {
620 $classes[] = 'sidebar-off';
621 }
622 $transparent_header = get_post_meta( get_the_ID(), 'envo_extra_transparent_header', true ) !== '' ? get_post_meta( get_the_ID(), 'envo_extra_transparent_header', true ) : '';
623 if ( $transparent_header == 'on' ) {
624 $classes[] = 'transparent-header';
625 }
626
627 return $classes;
628 }
629
630 /**
631 * Add custom CSS styles
632 */
633 function envo_extra_enqueue_header_css() {
634
635 $css = '';
636
637 $transparent_header = get_post_meta( get_the_ID(), 'envo_extra_transparent_header', true );
638 $transparent_header_color = get_post_meta( get_the_ID(), 'envo_extra_header_text_color', true );
639 $theme = wp_get_theme();
640 if ( 'Enwoo' == $theme->name || 'enwoo' == $theme->template ) {
641 $header = get_theme_mod( 'header_layout', envo_extra_check_plugin_active( 'woocommerce/woocommerce.php' ) ? 'woonav' : 'busnav' );
642 } else {
643 $header = get_theme_mod( 'header_layout', 'busnav' );
644 }
645 if ( $transparent_header == 'on' ) {
646 if ( $header == 'busnav' ) {
647 $css .= '.transparent-header .site-header.business-heading:not(.shrink), .transparent-header .site-header.business-heading:not(.shrink) .navbar-default .navbar-nav > li > a, .transparent-header .site-header.business-heading:not(.shrink) a.cart-contents i, .transparent-header .site-header.business-heading:not(.shrink) .header-my-account a, .transparent-header .site-header.business-heading:not(.shrink) .header-wishlist a, .transparent-header .site-header.business-heading:not(.shrink) .header-compare a, .transparent-header .site-header.business-heading:not(.shrink) .header-search a, .transparent-header .site-header.business-heading:not(.shrink) .site-branding-text h1.site-title a, .transparent-header .site-header.business-heading:not(.shrink) .site-branding-text .site-title a, .transparent-header .site-header.business-heading:not(.shrink) #site-navigation .navbar-nav > li > a, .transparent-header .site-header.business-heading:not(.shrink) p.site-description {color: ' . $transparent_header_color . ';}';
648 $css .= '.transparent-header .site-header.business-heading:not(.shrink) .hc-nav-trigger span,.transparent-header .site-header.business-heading:not(.shrink) .hc-nav-trigger span:before,.transparent-header .site-header.business-heading:not(.shrink) .hc-nav-trigger span:after {background-color: ' . $transparent_header_color . ';}';
649 } elseif ( $header == 'woonav' ) {
650 $css .= '.transparent-header #second-site-navigation, .transparent-header #second-site-navigation .navbar-default .navbar-nav > li > a, .transparent-header #second-site-navigation a.cart-contents i, .transparent-header #second-site-navigation .header-my-account a, .transparent-header #second-site-navigation .header-wishlist a, .transparent-header #second-site-navigation .header-compare a, .transparent-header #second-site-navigation .header-search a, .transparent-header #second-site-navigation .site-branding-text h1.site-title a, .transparent-header #second-site-navigation .site-branding-text .site-title a, .transparent-header #second-site-navigation #site-navigation .navbar-nav > li > a, .transparent-header #second-site-navigation p.site-description {color: ' . $transparent_header_color . ';}';
651 $css .= '.transparent-header #second-site-navigation .hc-nav-trigger span,.transparent-header #second-site-navigation .hc-nav-trigger span:before,.transparent-header #second-site-navigation .hc-nav-trigger span:after {color: ' . $transparent_header_color . ';}';
652 }
653 }
654
655 wp_add_inline_style( 'envo-extra', $css, 9999 );
656 }
657
658 add_action( 'wp_enqueue_scripts', 'envo_extra_enqueue_header_css', 9999 );
659
660 function envo_extra_is_gutenberg_active() {
661 $gutenberg = false;
662 $block_editor = false;
663
664 if ( has_filter( 'replace_editor', 'gutenberg_init' ) ) {
665 // Gutenberg is installed and activated.
666 $gutenberg = true;
667 }
668
669 if ( version_compare( $GLOBALS[ 'wp_version' ], '5.0-beta', '>' ) ) {
670 // Block editor.
671 $block_editor = true;
672 }
673
674 if ( !$gutenberg && !$block_editor ) {
675 return false;
676 }
677
678 include_once ABSPATH . 'wp-admin/includes/plugin.php';
679
680 if ( !is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
681 return true;
682 }
683
684 if ( is_plugin_active( 'classic-editor/classic-editor.php' ) && get_option( 'classic-editor-replace' ) === 'block' ) {
685 return true;
686 }
687 }
688
689 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'envo_action_links' );
690
691 function envo_action_links( $links ) {
692 $links[ 'install_demos' ] = sprintf( '<a href="%1$s" class="install-demos">%2$s</a>', esc_url( admin_url( 'themes.php?page=envothemes-panel-install-demos' ) ), esc_html__( 'Install Demos', 'envo-extra' ) );
693 $theme = wp_get_theme();
694 if ( 'Enwoo' == $theme->name || 'enwoo' == $theme->template ) {
695 $url = 'https://enwoo-wp.com/enwoo-pro/';
696 } elseif ( 'Entr' == $theme->name || 'entr' == $theme->template ) {
697 $url = 'https://envothemes.com/product/envo-pro/';
698 } else {
699 $url = 'https://envothemes.com/';
700 }
701 if ( !envo_extra_check_for_pro( 'enwoo' ) ) {
702 $links[ 'go_pro' ] = sprintf( '<a href="%1$s" target="_blank" class="elementor-plugins-gopro">%2$s</a>', esc_url( $url ), esc_html__( 'Go Pro', 'envo-extra' ) );
703 }
704 return $links;
705 }
706
707 add_action( 'before_woocommerce_init', function() {
708 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
709 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
710 }
711 } );
712