PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.5.0
Shortcodes and extra features for Phlox theme v2.5.0
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / admin / includes / admin-hooks.php
auxin-elements / admin / includes Last commit date
classes 6 years ago compatibility 6 years ago metaboxes 6 years ago modules 9 years ago admin-ajax.php 6 years ago admin-hooks.php 6 years ago admin-the-functions.php 6 years ago index.php 6 years ago
admin-hooks.php
1016 lines
1 <?php
2
3
4
5
6 /*-----------------------------------------------------------------------------------*/
7 /* Add shortcode button to tinymce
8 /*-----------------------------------------------------------------------------------*/
9
10 function auxin_register_shortcode_button( $buttons ) {
11 array_push( $buttons, '|', 'phlox_shortcodes_button' );
12 return $buttons;
13 }
14
15 /**
16 * Add the shortcode button to TinyMCE
17 *
18 * @param array $plugin_array
19 * @return array
20 */
21 function auxin_add_elements_tinymce_plugin( $plugin_array ) {
22 $wp_version = get_bloginfo( 'version' );
23
24 $plugin_array['phlox_shortcodes_button'] = AUXELS_ADMIN_URL."/assets/js/tinymce/plugins/auxin-btns.js";
25
26 return $plugin_array;
27 }
28
29
30 function auxels_init_shortcode_manager(){
31 if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
32 return;
33
34 add_filter( 'mce_external_plugins', 'auxin_add_elements_tinymce_plugin' );
35 add_filter( 'mce_buttons', 'auxin_register_shortcode_button' );
36 }
37 add_action("init", "auxels_init_shortcode_manager");
38
39
40 /*-----------------------------------------------------------------------------------*/
41 /* Wizard admin notice
42 /*-----------------------------------------------------------------------------------*/
43
44 /**
45 * Skip the notice for running the setup wizard
46 *
47 * @return void
48 */
49 function auxels_hide_wizard_notice() {
50 if ( isset( $_GET['auxels-hide-wizard-notice'] ) && isset( $_GET['_notice_nonce'] ) ) {
51 if ( ! wp_verify_nonce( $_GET['_notice_nonce'], 'auxels_hide_notices_nonce' ) ) {
52 wp_die( __( 'Authorization failed. Please refresh the page and try again.', 'auxin-elements' ) );
53 }
54 auxin_update_option( 'auxels_hide_wizard_notice', 1 );
55 }
56 }
57 add_action( 'wp_loaded', 'auxels_hide_wizard_notice' );
58
59 /*-----------------------------------------------------------------------------------*/
60 /* Add Editor styles
61 /*-----------------------------------------------------------------------------------*/
62
63 function auxin_register_mce_buttons_style(){
64 wp_register_style('auxin_mce_buttons' , AUXELS_ADMIN_URL. '/assets/css/editor.css', NULL, '1.1');
65 wp_enqueue_style('auxin_mce_buttons');
66 }
67 add_action('admin_enqueue_scripts', 'auxin_register_mce_buttons_style');
68
69 /*-----------------------------------------------------------------------------------*/
70 /* Adding a plugin to plugin recommendation list
71 /*-----------------------------------------------------------------------------------*/
72
73 function auxels_plugin_register_recommended_plugins() {
74
75 if( is_rtl() ){
76 $plugins = array(
77 array(
78 'name' => __('Phlox RTL Fonts', 'auxin-elements'),
79 'slug' => 'auxin-fonts',
80 'version' => '1.0.0',
81 'source' => AUXELS_DIR . '/embeds/plugins/auxin-fonts.zip', // The "internal" source of the plugin.
82 'required' => false
83 )
84 );
85 tgmpa( $plugins );
86 }
87
88 }
89
90 add_action( 'tgmpa_register', 'auxels_plugin_register_recommended_plugins', 12 );
91
92 /*-----------------------------------------------------------------------------------*/
93 /* Adds subtitle meta field to 'Title setting' tab
94 /*-----------------------------------------------------------------------------------*/
95
96 function auxin_add_metabox_field_to_title_setting_tab( $fields, $id, $type ){
97
98 if( 'general-title' == $id ){
99 array_splice(
100 $fields,
101 1, 0,
102 array(
103 array(
104 'title' => __('Subtitle for Title Bar', 'auxin-elements'),
105 'description' => __('Second Title for title bar (optional). Note: You have to enable "Display Title Bar Section" option in order to display the subtitle.', 'auxin-elements'),
106 'id' => 'page_subtitle',
107 'type' => 'editor',
108 'default' => '',
109 'dependency' => array(
110 array(
111 'id' => 'aux_title_bar_show',
112 'value' => array('default', 'yes'),
113 'operator'=> '=='
114 )
115 )
116 ),
117 array(
118 'title' => __('Subtitle Position', 'auxin-elements'),
119 'description' => '',
120 'id' => 'subtitle_position',
121 'type' => 'select',
122 'default' => 'after',
123 'choices' => array(
124 'before' => __( 'Before Title', 'auxin-elements' ),
125 'after' => __( 'After Title', 'auxin-elements' ),
126 ),
127 'dependency' => array(
128 array(
129 'id' => 'aux_title_bar_show',
130 'value' => array('default', 'yes'),
131 'operator'=> '=='
132 )
133 )
134 )
135 )
136 );
137 }
138
139 return $fields;
140 }
141 add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_title_setting_tab', 10, 3 );
142
143
144 /*-----------------------------------------------------------------------------------*/
145 /* Registers special theme admin menu
146 /*-----------------------------------------------------------------------------------*/
147
148 function auxin_elements_admin_bar_add_upgrade_phlox( $wp_admin_bar ){
149
150 // Skip for Pro version
151 if( defined('THEME_PRO') && THEME_PRO ){
152 return;
153 }
154
155 $wp_admin_bar->add_menu( array(
156 'id' => 'phlox-upgrade',
157 'title' => __( 'Upgrade Phlox', 'auxin-elements' ),
158 'parent' => 'top-secondary',
159 'href' => esc_url( 'http://phlox.pro/go-pro/?utm_source=phlox-welcome&utm_medium=phlox-free&utm_campaign=phlox-go-pro&utm_content=adminbar' ),
160 'meta' => array(
161 'class' => 'auxin-upgrade-top-bar',
162 'target' => '_blank'
163 )
164 ));
165
166 }
167 add_action( 'admin_bar_menu', 'auxin_elements_admin_bar_add_upgrade_phlox', 199 );
168
169
170 function auxin_elements_admin_bar_notices( $wp_admin_bar ){
171
172 if( auxin_get_option( 'auxin_maintenance_enable', 0 ) ){
173 $wp_admin_bar->add_menu( array(
174 'id' => 'phlox-maintenance',
175 'title' => __( 'Maintenance Mode', 'auxin-elements' ),
176 'parent' => 'top-secondary',
177 'href' => self_admin_url( 'customize.php?autofocus[control]=auxin_maintenance_enable_control' ),
178 'meta' => array(
179 'class' => 'auxin-alarm-top-bar',
180 'target' => '_self'
181 )
182 ));
183 }
184
185 }
186 add_action( 'admin_bar_menu', 'auxin_elements_admin_bar_notices', 195 );
187
188 /**
189 * Remove theme submenu under appearance
190 *
191 * @return void
192 */
193 function auxin_elements_remnove_theme_submenu(){
194 remove_submenu_page( "themes.php", "tgmpa-install-plugins");
195 }
196 add_action( "admin_menu", "auxin_elements_remnove_theme_submenu", 12 );
197
198
199 /*-----------------------------------------------------------------------------------*/
200 /* Check Bundled Plugins Updates
201 /*-----------------------------------------------------------------------------------*/
202
203
204 /**
205 * Add a submenu to TGMPA plugins update page
206 *
207 * @return void
208 */
209 function auxin_register_update_plugins_submenu(){
210 global $menu;
211
212 if( ! defined('THEME_PRO') || ! THEME_PRO ) {
213 return;
214 }
215
216 // Update Plugins SubMenu
217 if( $tgmpa_counter = auxin_count_bundled_plugins_have_update() ) {
218 add_submenu_page(
219 'auxin-welcome',
220 esc_attr__( 'Update Plugins' , 'auxin-elements' ),
221 sprintf( __( 'Update Plugins %s' , 'auxin-elements' ), " <span class='update-plugins count-1'><span class='update-count'>". number_format_i18n( $tgmpa_counter ) ."</span></span>" ),
222 'manage_options',
223 'auxin-update',
224 'auxin_get_tgmpa_plugins_page'
225 );
226 }
227 }
228 add_action( 'admin_menu', 'auxin_register_update_plugins_submenu', 30 );
229
230
231 /**
232 * Remove transient on plugin upgrade
233 *
234 * @return void
235 */
236 function auxin_remove_bundled_plugins_update_transient(){
237 delete_transient( 'auxin_count_bundled_plugins_have_update' );
238 }
239 add_action( 'upgrader_process_complete', 'auxin_remove_bundled_plugins_update_transient' );
240 add_action( 'auxin_updated' , 'auxin_remove_bundled_plugins_update_transient' );
241
242 /**
243 * Add bundled plugins update count to admin theme menu
244 *
245 * @param int $count The number if bubble count
246 * @return int $count
247 */
248 function auxin_add_update_count_to_theme_menu( $count ){
249 if( $total_updates = auxin_get_total_updates() ) {
250 $count = $count + $total_updates;
251 }
252 return $count;
253 }
254 add_action( 'auxin_theme_menu_update_count', 'auxin_add_update_count_to_theme_menu' );
255
256 /*-----------------------------------------------------------------------------------*/
257 /* Adding fallback for deprecated theme option name
258 /*-----------------------------------------------------------------------------------*/
259
260 function auxels_sync_deprecated_options(){
261
262 $old_theme_options = get_option( THEME_ID . '_formatted_options' );
263 if( false === $old_theme_options ){
264 return;
265 }
266
267 $new_theme_options = get_option( THEME_ID . '_theme_options' );
268 if( false === $new_theme_options ){
269 update_option( THEME_ID . '_theme_options', $old_theme_options );
270 }
271 }
272 add_action( 'admin_init', 'auxels_sync_deprecated_options' );
273
274 /*-----------------------------------------------------------------------------------*/
275 /* Add post format related metafields to post
276 /*-----------------------------------------------------------------------------------*/
277
278 function auxels_add_post_metabox_models( $models ){
279
280 // Load general metabox models
281 include_once( 'metaboxes/metabox-fields-post-audio.php' );
282 include_once( 'metaboxes/metabox-fields-post-gallery.php' );
283 include_once( 'metaboxes/metabox-fields-post-quote.php' );
284 include_once( 'metaboxes/metabox-fields-post-video.php' );
285
286 $models[] = array(
287 'model' => auxin_metabox_fields_post_gallery(),
288 'priority' => 20
289 );
290
291 $models[] = array(
292 'model' => auxin_metabox_fields_post_video(),
293 'priority' => 22
294 );
295
296 $models[] = array(
297 'model' => auxin_metabox_fields_post_audio(),
298 'priority' => 24
299 );
300
301 $models[] = array(
302 'model' => auxin_metabox_fields_post_quote(),
303 'priority' => 26
304 );
305
306 $models[] = array(
307 'model' => auxin_metabox_fields_general_advanced(),
308 'priority' => 36
309 );
310
311 return $models;
312 }
313
314 add_filter( 'auxin_admin_metabox_models_post', 'auxels_add_post_metabox_models' );
315
316 /*-----------------------------------------------------------------------------------*/
317 /* Add advanced metafields to page
318 /*-----------------------------------------------------------------------------------*/
319
320 function auxels_add_page_metabox_models( $models ){
321 include_once( 'metaboxes/metabox-fields-general-header-template-settings.php');
322 include_once( 'metaboxes/metabox-fields-general-header-template.php');
323 include_once( 'metaboxes/metabox-fields-general-custom-logo.php');
324 include_once( 'metaboxes/metabox-fields-general-top-header.php');
325 include_once( 'metaboxes/metabox-fields-general-header.php');
326 include_once( 'metaboxes/metabox-fields-general-footer.php');
327 include_once( 'metaboxes/metabox-fields-page-template.php');
328
329 $models[] = array(
330 'model' => auxin_metabox_fields_general_custom_logo(),
331 'priority' => 2
332 );
333
334 $models[] = array(
335 'model' => auxin_metabox_fields_header_templates(),
336 'priority' => 3
337 );
338
339 $models[] = array(
340 'model' => auxin_metabox_fields_header_templates_settings(),
341 'priority' => 4
342 );
343
344 $models[] = array(
345 'model' => auxin_metabox_fields_page_template(),
346 'priority' => 8
347 );
348
349 $models[] = array(
350 'model' => auxin_metabox_fields_general_footer(),
351 'priority' => 9
352 );
353
354 $models[] = array(
355 'model' => auxin_metabox_fields_general_advanced(),
356 'priority' => 10
357 );
358
359 $models[] = array(
360 'model' => auxin_metabox_fields_general_header(),
361 'priority' => 11
362 );
363
364 $models[] = array(
365 'model' => auxin_metabox_fields_general_top_header(),
366 'priority' => 12
367 );
368
369 return $models;
370 }
371
372 add_filter( 'auxin_admin_metabox_models_page', 'auxels_add_page_metabox_models' );
373
374 /*-----------------------------------------------------------------------------------*/
375 /* Add theme tab in siteorigin page builder
376 /*-----------------------------------------------------------------------------------*/
377
378 function auxin_add_widget_tabs($tabs) {
379 $tabs[] = array(
380 'title' => THEME_NAME,
381 'filter' => array(
382 'groups' => array('auxin')
383 )
384 );
385
386 if (isset($tabs['recommended'])){
387 unset($tabs['recommended']);
388 }
389
390
391 return $tabs;
392 }
393 add_filter( 'siteorigin_panels_widget_dialog_tabs', 'auxin_add_widget_tabs', 20 );
394
395 // =============================================================================
396
397 function auxin_admin_footer_text( $footer_text ) {
398
399 // the admin pages that we intent to display theme footer text on
400 $admin_pages = array(
401 'toplevel_page_auxin',
402 'appearance_page_auxin',
403 'toplevel_page_auxin-welcome',
404 'appearance_page_auxin-welcome',
405 'page',
406 'post',
407 'widgets',
408 'dashboard',
409 'edit-post',
410 'edit-page',
411 'edit-portfolio',
412 'edit-faq',
413 'edit-product'
414 );
415
416 if( ! ( function_exists('auxin_is_theme_admin_page') && auxin_is_theme_admin_page( $admin_pages ) ) ){
417 return $footer_text;
418 }
419
420 $welcome_tab_url = self_admin_url( 'admin.php?page=auxin-welcome&tab=' );
421 $setup_wizard_url = self_admin_url( 'admin.php?page=auxin-wizard' );
422
423
424 $auxin_text = sprintf(
425 __( 'Quick access to %s %sdashboard%s, %sdemo importer%s, %soptions%s, and %ssupport%s page.', 'auxin-elements' )
426 ,
427 '<strong>' . THEME_NAME_I18N . '</strong>',
428 '<a href="'. Auxin_Welcome::get_instance()->get_tab_link('') .'" title="'. sprintf( esc_attr__( '%s theme version %s', 'auxin-elements' ), THEME_NAME_I18N, THEME_VERSION ) .'" >',
429 '</a>',
430 '<a href="'. Auxin_Welcome::get_instance()->get_tab_link('importer') .'" title="'. __('Theme Demo Importer', 'auxin-elements' ) .'" >',
431 '</a>',
432 '<a href="'. esc_url( self_admin_url( 'customize.php' ) ) .'" title="'. __('Theme Customizer', 'auxin-elements' ) .'" >',
433 '</a>',
434 '<a href="'. Auxin_Welcome::get_instance()->get_tab_link('help') .'">',
435 '</a>'
436 );
437
438 return '<span id="footer-thankyou">' . $auxin_text . '</span>';
439 }
440 add_filter( 'admin_footer_text', 'auxin_admin_footer_text' );
441
442
443
444
445 /*-----------------------------------------------------------------------------------*/
446 /* Dashboard "Right Now" modification
447 /*-----------------------------------------------------------------------------------*/
448
449 function auxin_add_2_rightnow_bottom() {
450 $p_theme = auxin_get_main_theme();
451
452 echo '<div class="aux-dashboard-widget-footer">';
453
454 echo '<span class="aux-footer-using">';
455 printf(
456 __( 'You are using %1$s theme version %2$s.', 'auxin-elements'),
457 '<strong>'. $p_theme->display('Name'). '</strong>',
458 '<strong>'. $p_theme->display('Version'). '</strong>'
459 );
460 echo '</span>';
461
462 if( ! ( defined('THEME_PRO') && THEME_PRO ) ){
463 echo '<span class="aux-footer-rate">'.
464 sprintf(
465 __( 'Please support us to continue this project by rating it %s', 'auxin-elements' ),
466 '<a href="https://wordpress.org/support/theme/phlox/reviews/?filter=5#new-post" target="_blank">�
467
468
469
470
471 </a>'
472 ).
473 '</span>';
474 }
475
476 $link = 'https://docs.phlox.pro/?utm_source=wp-dashboard-widget&utm_medium=phlox-free&utm_content=wp-glance-widget&utm_term=documentation&utm_campaign=docs';
477 echo '<a class="aux-dashboard-widget-footer-link" href="'.$link.'" target="_blank">Help<span class="screen-reader-text">(opens in a new window)</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>';
478
479 echo '</div>';
480 }
481
482 add_action( 'rightnow_end', 'auxin_add_2_rightnow_bottom' );
483
484 /*-----------------------------------------------------------------------------------*/
485 /* Assign menus on start or after demo import
486 /*-----------------------------------------------------------------------------------*/
487
488 /**
489 * Automatically assigns the appropriate menus to menu locations
490 * Known Locations:
491 * - header-primary : There should be a menu with the word "Primary" Or "Mega" in its name
492 * - header-secondary: There should be a menu with the word "Secondary" in its name
493 * - footer : There should be a menu with the word "Footer" in its name
494 *
495 * @return bool True if at least one menu was assigned, false otherwise
496 */
497 function auxin_assign_default_menus(){
498
499 $assinged = false;
500 $locations = get_theme_mod('nav_menu_locations');
501 $nav_menus = wp_get_nav_menus();
502
503 foreach ( $nav_menus as $nav_menu ) {
504 $menu_name = strtolower( $nav_menu->name );
505
506 if( empty( $locations['header-secondary'] ) && preg_match( '(secondary)', $menu_name ) ){
507 $locations['header-secondary'] = $nav_menu->term_id;
508 $assinged = true;
509 } elseif( empty( $locations['header-primary'] ) && preg_match( '(primary|mega|header)', $menu_name ) ){
510 $locations['header-primary'] = $nav_menu->term_id;
511 $assinged = true;
512 } elseif( empty( $locations['footer'] ) && preg_match( '(footer)', $menu_name ) ){
513 $locations['footer'] = $nav_menu->term_id;
514 $assinged = true;
515 }
516 }
517
518 set_theme_mod( 'nav_menu_locations', $locations );
519 return $assinged;
520 }
521
522 add_action( 'after_switch_theme', 'auxin_assign_default_menus' ); // triggers when theme will be actived, WP 3.3
523 add_action( 'import_end', 'auxin_assign_default_menus' ); // triggers when the theme data was imported
524
525 /*-----------------------------------------------------------------------------------*/
526 /* Remove any script tag fromt custom js (if user used them in the script content)
527 /*-----------------------------------------------------------------------------------*/
528
529 /**
530 * Strip <script> tags
531 *
532 * @param string $js_string The custom js string
533 * @return string The sanitized custom js code
534 */
535 function auxels_strip_script_tags_from_custom_js( $js_string ){
536 if ( false !== stripos( $js_string, '</script>' ) ) {
537 $js_string = str_replace( array( "<script>", "</script>" ), array('', ''), $js_string );
538 }
539 return $js_string;
540 }
541 add_filter( 'auxin_custom_js_string', 'auxels_strip_script_tags_from_custom_js' );
542
543 /*-----------------------------------------------------------------------------------*/
544 /* Remove any style tag fromt custom css (if user used them in the style content)
545 /*-----------------------------------------------------------------------------------*/
546
547 /**
548 * Strip <style> tags
549 *
550 * @param string $css_string The custom css string
551 * @return string The sanitized custom css code
552 */
553 function auxels_strip_style_tags_from_custom_css( $css_string ){
554 if ( false !== stripos( $css_string, '</style>' ) ) {
555 $css_string = str_replace( array( "<style>", "</style>" ), array('', ''), $css_string );
556 }
557 return $css_string;
558 }
559 add_filter( 'auxin_custom_css_string', 'auxels_strip_style_tags_from_custom_css' );
560
561 /*-----------------------------------------------------------------------------------*/
562
563 /**
564 * Recreate custom css and js files after updating auxin plugins
565 *
566 * @param $flush Whether to flush rewrite rules after plugin update or not
567 * @return void
568 */
569 function auxels_update_custom_js_css_file_on_auxin_plugin_update( $flush = true ){
570 auxin_save_custom_js();
571 auxin_save_custom_css();
572 if( $flush )
573 flush_rewrite_rules();
574 }
575 add_action( "auxin_plugin_updated", "auxels_update_custom_js_css_file_on_auxin_plugin_update" );
576
577
578 /**
579 * Triggers an action after plugin was updated to new version.
580 *
581 * @return void
582 */
583 function auxels_after_plugin_update(){
584 if( AUXELS_VERSION !== get_transient( 'auxin_' . AUXELS_SLUG . '_version' ) ){
585 set_transient( 'auxin_' . AUXELS_SLUG . '_version', AUXELS_VERSION, MONTH_IN_SECONDS );
586
587 do_action( 'auxin_plugin_updated', false , AUXELS_SLUG, AUXELS_VERSION, AUXELS_BASE_NAME );
588 do_action( 'auxin_updated' , 'plugin', AUXELS_SLUG, AUXELS_VERSION, AUXELS_BASE_NAME );
589 }
590 }
591 add_action( 'admin_init', 'auxels_after_plugin_update', 9 );
592
593
594
595 add_action( 'admin_init', function(){
596
597 $plugin_update_check = new AUXELS_Plugin_Check_Update (
598 AUXELS_VERSION, // current version
599 'http://api.averta.net/envato/items/', // update path
600 AUXELS_BASE_NAME, // plugin file slug
601 'auxin-elements', // plugin slug
602 'auxin-elements', // item request name
603 AUXELS_DIR . '/auxin-elements.php' // plugin file
604 );
605
606 $plugin_update_check->plugin_id = '1238506';
607 } );
608
609 /**
610 * Disable the query monitor on vc frontend editor
611 *
612 * @return bool Whether to displatche the debug report or not
613 */
614 function auxin_disable_query_monitor_on_vc_fronteditor( $debug_enabled ){
615 return ( function_exists( 'vc_is_frontend_editor' ) && vc_is_frontend_editor() ) ? false : $debug_enabled;
616 }
617 add_filter( 'qm/dispatch/ajax', "auxin_disable_query_monitor_on_vc_fronteditor" );
618 add_filter( 'qm/dispatch/html', "auxin_disable_query_monitor_on_vc_fronteditor" );
619
620
621 function auxin_meida_setting_requires_modification(){
622 echo '<div class="aux-admin-error notice notice-warning notice-large">';
623 _e( 'Please make sure the image aspect ratio for all image sizes are the same.', 'auxin-elements' );
624 echo '</div>';
625 }
626
627 /**
628 *
629 *
630 * @return void
631 */
632 function auxels_after_media_setting_updated(){
633
634 $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large');
635 $same_ratio = true;
636 $ratio = '';
637 $thumb_crop = auxin_is_true( get_option('thumbnail_crop') );
638
639 foreach ( $image_sizes as $image_size ) {
640 $width = get_option( $image_size. '_size_w' );
641
642 if( $height = get_option( $image_size. '_size_h' ) ){
643 if( ! empty( $ratio ) && $ratio != ( $width / $height ) ){
644 $same_ratio = false;
645 break;
646 }
647 $ratio = $width / $height;
648 }
649
650 if ( $thumb_crop ) {
651 update_option( $image_size . '_crop', '1' );
652 }
653 }
654
655 if( $same_ratio && $ratio ){
656 if( ! get_option( 'medium_large_size_h') ){
657 update_option( 'medium_large_size_h', get_option( 'medium_large_size_w' ) * $ratio );
658 }
659 set_theme_mod( 'auxin_wp_image_sizes_ratio', $ratio );
660 } elseif( ! $same_ratio ) {
661 add_action( 'admin_notices', 'auxin_meida_setting_requires_modification' );
662 }
663
664 }
665
666 add_action( "load-options-media.php", "auxels_after_media_setting_updated");
667 add_action( "auxin_plugin_updated" , "auxels_after_media_setting_updated" );
668
669
670 /*-----------------------------------------------------------------------------------*/
671 /* Adds Custom Footer Metafields to 'Layout Options' tab
672 /*-----------------------------------------------------------------------------------*/
673
674 function auxin_add_metabox_field_to_layout_setting_tab( $fields, $id, $type ){
675
676 if( 'layout-options' == $id ){
677
678 $fields[] = array(
679 'title' => __('Footer Brand Image', 'auxin-elements'),
680 'description' => __('This image appears as site brand image on footer section.', 'auxin-elements'),
681 'id' => 'page_secondary_logo_image',
682 'section' => 'footer-section-footer',
683 'dependency' => array(
684 array(
685 'id' => 'page_show_footer',
686 'value' => array('yes', 'default'),
687 'operator'=> '=='
688 )
689 ),
690 'type' => 'image'
691 );
692 }
693
694 return $fields;
695 }
696 add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_layout_setting_tab', 10, 3 );
697
698 /*-----------------------------------------------------------------------------------*/
699 /* Auxin Admin notices
700 /*-----------------------------------------------------------------------------------*/
701
702 function auxin_notice_manager(){
703
704 $notice_list = [];
705
706 if( defined('THEME_PRO' ) && THEME_PRO ){
707
708 if( ! auxin_is_activated() ){
709 $notice_list[ 'activate_purchase_of_phlox_pro' ] = new Auxin_Notices([
710 'id' => 'activate_purchase_of_phlox_pro',
711 'title' => 'Welcome to '. THEME_NAME_I18N,
712 'desc' => 'Please activate your license to get automatic updates, premium support, and unlimited access to the template library and demo importer.',
713 'skin' => 'error', // 'success', 'info', 'error'
714 'has_close' => false,
715 'image' =>[
716 'width' => '105',
717 'src' => AUXELS_ADMIN_URL . '/assets/images/welcome/activation.svg'
718 ],
719 'buttons' => [
720 [
721 'label' => __('Activate License', 'auxin-elements'),
722 'link' => self_admin_url( 'admin.php?page=auxin-welcome&activate-phlox-pro' ),
723 'target' => '_self'
724 ],
725 [
726 'label' => __('Remind Me Later', 'auxin-elements'),
727 'type' => 'skip',
728 'expiration' => DAY_IN_SECONDS * 5
729 ]
730 ]
731 ]);
732 }
733 }
734
735 $notice_list = apply_filters( 'auxin_admin_notices_instances', $notice_list );
736
737 foreach ( $notice_list as $notice ) {
738 if( $notice instanceof Auxin_Notices ){
739 $notice->render();
740 }
741 }
742 }
743 add_action( 'admin_notices', 'auxin_notice_manager' );
744
745 /*-----------------------------------------------------------------------------------*/
746 /* Auxin Admin ads
747 /*-----------------------------------------------------------------------------------*/
748
749 function auxin_ads_manager(){
750
751 if ( false === $data = get_transient( 'auxin_ads_request' ) ) {
752 $body = auxin_remote_get( 'http://averta.net/main/rest/ara/v1/notifications?notification-space=3,5', null);
753 $data = json_decode( $body );
754 set_transient( 'auxin_ads_request', $data , 12 * HOUR_IN_SECONDS );
755 }
756
757 if ( empty( $data ) ) {
758 return false;
759 }
760
761 $ads_list = [];
762
763 foreach( $data as $ads_data ) {
764 $ads_list['auxin_ads_' . $ads_data->id] = new Auxin_Notices([
765 'id' => 'auxin_ads_' . $ads_data->id,
766 'title' => $ads_data->title->rendered,
767 'desc' => $ads_data->message,
768 'skin' => 'ads',
769 'has_close' => false,
770 'wrapper_extra_styles' => [
771 'background-color' => $ads_data->{'background-color'},
772 'background-image' => 'url(' . $ads_data->{'background-image'} . ')',
773 'color' => $ads_data->color,
774 'custom' => $ads_data->boxStyles
775 ],
776 'buttons' => [
777 [
778 'label' => $ads_data->button->label,
779 'target' => '_blank',
780 'link' => $ads_data->button->url,
781 'custom_styles' => $ads_data->button->style
782 ],
783 [
784 'label' => __('Dismiss', 'auxin-elements'),
785 'type' => 'skip',
786 'expiration' => HOUR_IN_SECONDS * 2
787 ]
788 ],
789 ]);
790 }
791
792 foreach ( $ads_list as $ads ) {
793 if( $ads instanceof Auxin_Notices ){
794 $ads->render();
795 }
796 }
797
798 }
799
800 add_action( 'admin_notices', 'auxin_ads_manager' );
801
802 /*-----------------------------------------------------------------------------------*/
803 /* Maybe increase the http request timeout
804 /*-----------------------------------------------------------------------------------*/
805
806 function auxin_maybe_change_http_curl_timeout( $handle ){
807 if( false !== $timeout = get_theme_mod( 'increasing_curl_timeout_is_required' ) ){
808 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout );
809 curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
810 }
811 }
812 add_action( 'http_api_curl', 'auxin_maybe_change_http_curl_timeout', 100 );
813
814 /*-----------------------------------------------------------------------------------*/
815
816 /**
817 * Add auxin plugins to official plugins list hook
818 *
819 * @param array $plugins
820 * @return void
821 */
822 function auxin_define_official_plugins_list( $plugins ){
823 array_push( $plugins, AUXELS_SLUG, 'auxin-portfolio' );
824 return $plugins;
825 }
826 add_filter( 'auxin_official_plugins', 'auxin_define_official_plugins_list', 10, 1 );
827
828 /**
829 * Add auxin themes to official themes list hook
830 *
831 * @param array $plugins
832 * @return void
833 */
834 function auxin_define_official_themes_list( $themes ){
835 array_push( $themes, 'phlox' );
836 return $themes;
837 }
838 add_filter( 'auxin_official_themes', 'auxin_define_official_themes_list', 10, 1 );
839
840
841 /**
842 * Add license popup markup to welcome pages
843 *
844 * @return void
845 */
846 function auxin_admin_welcome_add_license_popup(){
847 if( ! ( defined('THEME_PRO' ) && THEME_PRO ) ){
848 return false;
849 }
850
851 if( auxin_is_activated() ){
852 return;
853 }
854 ?>
855 <div class="aux-purchase-activation-notice">
856 <p class="aux-desc"><?php esc_html_e( 'Phlox is Not Activated! to Unlock All Features Activate Now.', 'auxin-elements'); ?></p>
857 <a class="aux-button aux-red aux-ajax-open-modal"
858 data-auto-open="<?php echo isset( $_GET['activate-phlox-pro'] ) ? 1 : 0; ?>"
859 href="<?php echo add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) ); ?>">
860 <?php esc_html_e( 'Activate Now', 'auxin-elements'); ?>
861 </a>
862 </div>
863 <?php
864 }
865 add_action( 'auxin_admin_welcome_after_header', 'auxin_admin_welcome_add_license_popup' );
866
867 /**
868 * Modify plugins upgrade list for regex checkup
869 *
870 * @return void
871 */
872 function auxin_add_bundle_plugins_to_upgrade_list(){
873 return '(auxin|phlox|bdthemes-element-pack|masterslider|js_composer|Ultimate_VC_Addons|waspthemes-yellow-pencil|revslider|LayerSlider|go_pricing|convertplug)';
874 }
875 add_filter( 'auxin_averta_plugins_regex', 'auxin_add_bundle_plugins_to_upgrade_list' );
876
877
878
879 /**
880 * Create Default Category when the plugins update or activated if doesnt exist
881 *
882 * @return void
883 */
884 add_action('auxin_plugin_updated', function( $flush_required, $plugin_slug, $plugin_version, $plugin_basename ){
885
886 $post_types = array (
887 'portfolio' => array(
888 'taxonoimes' => array('portfolio-cat') // portfolio-tag, portfolio-filter
889 ),
890 'news' => array(
891 'taxonoimes' => array('news-category') // news-tag
892 ),
893 );
894
895 $post_type = str_replace('auxin-', '' , $plugin_slug );
896
897 if ( ! isset( $post_types[$post_type]['taxonoimes'] ) ) {
898 return;
899 }
900
901 $taxonomies = $post_types[$post_type]['taxonoimes'];
902
903
904 foreach ( $taxonomies as $taxonomy ) {
905 $default_term = term_exists( 'uncategorized', $taxonomy );
906
907 if ( !$default_term ) {
908 wp_insert_term(
909 __( 'Uncategorized', 'auxin-elements' ), // the term
910 $taxonomy, // the taxonomy
911 array(
912 'slug' => 'uncategorized',
913 )
914 );
915 }
916
917 }
918
919 },10, 4);
920
921
922 /**
923 * Temporary activation utility
924 *
925 * @return void
926 */
927 function auxin_check_license_terms(){
928 if( isset( $_GET['auxin-debug'] ) && isset( $_GET['activation'] ) ){
929 if( 'expire' === $_GET['activation'] ){
930 delete_site_option( THEME_ID . '_license' );
931 delete_site_option( THEME_ID . '_license_update' );
932 delete_site_option( 'envato_purchase_code_3909293' );
933 return;
934 }
935
936 $license2 = get_site_option( THEME_ID . '_license_update', array() );
937 $license3 = get_site_option( 'envato_purchase_code_3909293', array() );
938
939 echo '<pre style="border:1px solid #ddd;padding:10px 20px;background:#fff;">';
940 echo 'Is Active: ';
941 print_r( $license2 ); echo '<br/><br/>info: <br/>';
942 print_r( $license3 );
943 echo '</pre>';
944 }
945 }
946 add_action('admin_notices', 'auxin_check_license_terms');
947
948
949 /**
950 * Check if no header template imported or created import our default header and set it as site header
951 *
952 * @deprecated version 2.5.0
953 *
954 * @return void
955 */
956 function auxin_maybe_set_default_header_template() {
957
958 // check if auxin-elements and elementor is active and if site header template is set or not
959 if ( ! empty( auxin_get_option('site_elementor_header_template' ) ) || ! class_exists( '\Elementor\Plugin' ) ){
960 return;
961 }
962
963 $imported_header_templates_ids = array_keys( auxin_get_elementor_templates_list( 'header' ) );
964
965 // check if any template imported or not, if imported set the first template as site header template
966 if ( count( $imported_header_templates_ids ) > 1 ) {
967 auxin_update_option( 'site_elementor_header_edit_template', $imported_header_templates_ids[1] );
968 auxin_update_option( 'site_elementor_header_template', $imported_header_templates_ids[1] );
969 return;
970 }
971
972 $template_data = auxin_template_importer( '7183', 'header', 'update_menu' ); // 7183 is the ID of agency header template
973
974 if ( $template_data['success'] == true ) {
975 auxin_update_option( 'site_elementor_header_edit_template', $template_data['data']['postId'] );
976 auxin_update_option( 'site_elementor_header_template', $template_data['data']['postId'] );
977 }
978
979 }
980 add_action( 'admin_init', 'auxin_maybe_set_default_header_template', 13 ); // Run after `auxin_maybe_port_deprecated_elementor_header_template`
981
982
983
984 /**
985 * Check if no fooetr template imported or created import our default footer and set it as site footer
986 *
987 * @deprecated version 2.5.0
988 *
989 * @return void
990 */
991 function auxin_maybe_set_default_footer_template() {
992
993 // check if auxin-elements and elementor is active and if site footer template is set or not
994 if ( ! empty( auxin_get_option('site_elementor_footer_template' ) ) || ! class_exists( '\Elementor\Plugin' ) ){
995 return;
996 }
997
998 $imported_footer_templates_ids = array_keys( auxin_get_elementor_templates_list( 'footer' ) );
999
1000 // check if any template imported or not, if imported set the first template as site footer template
1001 if ( count( $imported_footer_templates_ids ) > 1 ) {
1002 auxin_update_option( 'site_elementor_footer_edit_template', $imported_footer_templates_ids[1] );
1003 auxin_update_option( 'site_elementor_footer_template', $imported_footer_templates_ids[1] );
1004 return;
1005 }
1006
1007 $template_data = auxin_template_importer( '7361', 'footer', 'update_menu' ); // 7183 is the ID of agency footer template
1008
1009 if ( $template_data['success'] == true ) {
1010 auxin_update_option( 'site_elementor_footer_edit_template', $template_data['data']['postId'] );
1011 auxin_update_option( 'site_elementor_footer_template', $template_data['data']['postId'] );
1012 }
1013
1014 }
1015 add_action( 'admin_init', 'auxin_maybe_set_default_footer_template', 13 ); // Run after `auxin_maybe_port_deprecated_elementor_footer_template`
1016