PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / trunk
Shortcodes and extra features for Phlox theme vtrunk
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 5 months ago compatibility 1 year ago metaboxes 5 months ago admin-ajax.php 1 month ago admin-hooks.php 1 year ago admin-the-functions.php 1 year ago index.php 2 years ago
admin-hooks.php
936 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 /* Adds subtitle meta field to 'Title setting' tab
71 /*-----------------------------------------------------------------------------------*/
72
73 function auxin_add_metabox_field_to_title_setting_tab( $fields, $id, $type ){
74
75 if( 'general-title' == $id ){
76 array_splice(
77 $fields,
78 1, 0,
79 array(
80 array(
81 'title' => __('Subtitle for Title Bar', 'auxin-elements'),
82 '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'),
83 'id' => 'page_subtitle',
84 'type' => 'editor',
85 'default' => '',
86 'dependency' => array(
87 array(
88 'id' => 'aux_title_bar_show',
89 'value' => array('default', 'yes'),
90 'operator'=> '=='
91 )
92 )
93 ),
94 array(
95 'title' => __('Subtitle Position', 'auxin-elements'),
96 'description' => '',
97 'id' => 'subtitle_position',
98 'type' => 'select',
99 'default' => 'after',
100 'choices' => array(
101 'before' => __( 'Before Title', 'auxin-elements' ),
102 'after' => __( 'After Title', 'auxin-elements' ),
103 ),
104 'dependency' => array(
105 array(
106 'id' => 'aux_title_bar_show',
107 'value' => array('default', 'yes'),
108 'operator'=> '=='
109 )
110 )
111 )
112 )
113 );
114 }
115
116 return $fields;
117 }
118 add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_title_setting_tab', 10, 3 );
119
120
121 /*-----------------------------------------------------------------------------------*/
122 /* Registers special theme admin menu
123 /*-----------------------------------------------------------------------------------*/
124
125 function auxin_elements_admin_bar_add_upgrade_phlox( $wp_admin_bar ){
126
127 // Skip for Pro version
128 if( defined('THEME_PRO') && THEME_PRO ){
129 return;
130 }
131
132 $wp_admin_bar->add_menu( array(
133 'id' => 'phlox-upgrade',
134 'title' => __( 'Upgrade Phlox', 'auxin-elements' ),
135 'parent' => 'top-secondary',
136 'href' => esc_url( 'http://phlox.pro/go-pro/?utm_source=phlox-welcome&utm_medium=phlox-free&utm_campaign=phlox-go-pro&utm_content=adminbar' ),
137 'meta' => array(
138 'class' => 'auxin-upgrade-top-bar',
139 'target' => '_blank'
140 )
141 ));
142
143 }
144 add_action( 'admin_bar_menu', 'auxin_elements_admin_bar_add_upgrade_phlox', 199 );
145
146
147 function auxin_elements_admin_bar_notices( $wp_admin_bar ){
148
149 if( auxin_get_option( 'auxin_maintenance_enable', 0 ) ){
150 $wp_admin_bar->add_menu( array(
151 'id' => 'phlox-maintenance',
152 'title' => __( 'Maintenance Mode', 'auxin-elements' ),
153 'parent' => 'top-secondary',
154 'href' => self_admin_url( 'customize.php?autofocus[control]=auxin_maintenance_enable_control' ),
155 'meta' => array(
156 'class' => 'auxin-alarm-top-bar',
157 'target' => '_self'
158 )
159 ));
160 }
161
162 }
163 add_action( 'admin_bar_menu', 'auxin_elements_admin_bar_notices', 195 );
164
165 /**
166 * Remove theme submenu under appearance
167 *
168 * @return void
169 */
170 function auxin_elements_remnove_theme_submenu(){
171 remove_submenu_page( "themes.php", "tgmpa-install-plugins");
172 }
173 add_action( "admin_menu", "auxin_elements_remnove_theme_submenu", 12 );
174
175
176 /*-----------------------------------------------------------------------------------*/
177 /* Check Bundled Plugins Updates
178 /*-----------------------------------------------------------------------------------*/
179
180
181 /**
182 * Add a submenu to TGMPA plugins update page
183 *
184 * @return void
185 */
186 function auxin_register_update_plugins_submenu(){
187 global $menu;
188
189 if( ! defined('THEME_PRO') || ! THEME_PRO ) {
190 return;
191 }
192
193 // Update Plugins SubMenu
194 if( $tgmpa_counter = auxin_count_bundled_plugins_have_update() ) {
195 add_submenu_page(
196 'auxin-welcome',
197 esc_attr__( 'Update Plugins' , 'auxin-elements' ),
198 sprintf( __( 'Update Plugins %s' , 'auxin-elements' ), " <span class='update-plugins count-1'><span class='update-count'>". number_format_i18n( $tgmpa_counter ) ."</span></span>" ),
199 'manage_options',
200 'auxin-update',
201 'auxin_get_tgmpa_plugins_page'
202 );
203 }
204 }
205 add_action( 'admin_menu', 'auxin_register_update_plugins_submenu', 30 );
206
207
208 /**
209 * Remove transient on plugin upgrade
210 *
211 * @return void
212 */
213 function auxin_remove_bundled_plugins_update_transient(){
214 delete_transient( 'auxin_count_bundled_plugins_have_update' );
215 }
216 add_action( 'upgrader_process_complete', 'auxin_remove_bundled_plugins_update_transient' );
217 add_action( 'auxin_updated' , 'auxin_remove_bundled_plugins_update_transient' );
218
219 /**
220 * Add bundled plugins update count to admin theme menu
221 *
222 * @param int $count The number if bubble count
223 * @return int $count
224 */
225 function auxin_add_update_count_to_theme_menu( $count ){
226 if( $total_updates = auxin_get_total_updates() ) {
227 $count = $count + $total_updates;
228 }
229 return $count;
230 }
231 add_action( 'auxin_theme_menu_update_count', 'auxin_add_update_count_to_theme_menu' );
232
233 /*-----------------------------------------------------------------------------------*/
234 /* Adding fallback for deprecated theme option name
235 /*-----------------------------------------------------------------------------------*/
236
237 function auxels_sync_deprecated_options(){
238
239 $old_theme_options = get_option( THEME_ID . '_formatted_options' );
240 if( false === $old_theme_options ){
241 return;
242 }
243
244 $new_theme_options = get_option( THEME_ID . '_theme_options' );
245 if( false === $new_theme_options ){
246 update_option( THEME_ID . '_theme_options', $old_theme_options );
247 }
248 }
249 add_action( 'admin_init', 'auxels_sync_deprecated_options' );
250
251 /*-----------------------------------------------------------------------------------*/
252 /* Add post format related metafields to post
253 /*-----------------------------------------------------------------------------------*/
254
255 function auxels_add_post_metabox_models( $models ){
256
257 // Load general metabox models
258 include_once( 'metaboxes/metabox-fields-post-audio.php' );
259 include_once( 'metaboxes/metabox-fields-post-gallery.php' );
260 include_once( 'metaboxes/metabox-fields-post-quote.php' );
261 include_once( 'metaboxes/metabox-fields-post-video.php' );
262
263 $models[] = array(
264 'model' => auxin_metabox_fields_post_gallery(),
265 'priority' => 20
266 );
267
268 $models[] = array(
269 'model' => auxin_metabox_fields_post_video(),
270 'priority' => 22
271 );
272
273 $models[] = array(
274 'model' => auxin_metabox_fields_post_audio(),
275 'priority' => 24
276 );
277
278 $models[] = array(
279 'model' => auxin_metabox_fields_post_quote(),
280 'priority' => 26
281 );
282
283 $models[] = array(
284 'model' => auxin_metabox_fields_general_advanced(),
285 'priority' => 36
286 );
287
288 return $models;
289 }
290
291 add_filter( 'auxin_admin_metabox_models_post', 'auxels_add_post_metabox_models' );
292
293 /*-----------------------------------------------------------------------------------*/
294 /* Add advanced metafields to page
295 /*-----------------------------------------------------------------------------------*/
296
297 function auxels_add_page_metabox_models( $models ){
298 include_once( 'metaboxes/metabox-fields-general-header-template-settings.php');
299 include_once( 'metaboxes/metabox-fields-general-header-template.php');
300 include_once( 'metaboxes/metabox-fields-general-custom-logo.php');
301 include_once( 'metaboxes/metabox-fields-general-top-header.php');
302 include_once( 'metaboxes/metabox-fields-general-header.php');
303 include_once( 'metaboxes/metabox-fields-general-footer-template-settings.php');
304 include_once( 'metaboxes/metabox-fields-general-footer-template.php');
305 include_once( 'metaboxes/metabox-fields-general-footer.php');
306 include_once( 'metaboxes/metabox-fields-page-template.php');
307
308 $models[] = array(
309 'model' => auxin_metabox_fields_general_custom_logo(),
310 'priority' => 2
311 );
312
313 $models[] = array(
314 'model' => auxin_metabox_fields_header_templates(),
315 'priority' => 3
316 );
317
318 $models[] = array(
319 'model' => auxin_metabox_fields_header_templates_settings(),
320 'priority' => 4
321 );
322
323 $models[] = array(
324 'model' => auxin_metabox_fields_page_template(),
325 'priority' => 8
326 );
327
328 $models[] = array(
329 'model' => auxin_metabox_fields_footer_templates(),
330 'priority' => 9
331 );
332
333 $models[] = array(
334 'model' => auxin_metabox_fields_footer_templates_settings(),
335 'priority' => 10
336 );
337
338 $models[] = array(
339 'model' => auxin_metabox_fields_general_advanced(),
340 'priority' => 11
341 );
342
343 $models[] = array(
344 'model' => auxin_metabox_fields_general_header(),
345 'priority' => 12
346 );
347
348 $models[] = array(
349 'model' => auxin_metabox_fields_general_top_header(),
350 'priority' => 13
351 );
352
353 $models[] = array(
354 'model' => auxin_metabox_fields_general_footer(),
355 'priority' => 14
356 );
357
358 return $models;
359 }
360
361 add_filter( 'auxin_admin_metabox_models_page', 'auxels_add_page_metabox_models' );
362
363 // =============================================================================
364
365 function auxin_admin_footer_text( $footer_text ) {
366
367 // the admin pages that we intent to display theme footer text on
368 $admin_pages = array(
369 'toplevel_page_auxin',
370 'appearance_page_auxin',
371 'toplevel_page_auxin-welcome',
372 'appearance_page_auxin-welcome',
373 'page',
374 'post',
375 'widgets',
376 'dashboard',
377 'edit-post',
378 'edit-page',
379 'edit-portfolio',
380 'edit-faq',
381 'edit-product'
382 );
383
384 if( ! ( function_exists('auxin_is_theme_admin_page') && auxin_is_theme_admin_page( $admin_pages ) ) ){
385 return $footer_text;
386 }
387
388 $welcome_tab_url = self_admin_url( 'admin.php?page=auxin-welcome&tab=' );
389 $setup_wizard_url = self_admin_url( 'admin.php?page=auxin-wizard' );
390
391
392 $auxin_text = sprintf(
393 __( 'Quick access to %s %sdashboard%s, %sdemo importer%s, %soptions%s, and %ssupport%s page.', 'auxin-elements' )
394 ,
395 '<strong>' . THEME_NAME_I18N . '</strong>',
396 '<a href="'. Auxin_Welcome::get_instance()->get_tab_link('') .'" title="'. sprintf( esc_attr__( '%s theme version %s', 'auxin-elements' ), THEME_NAME_I18N, THEME_VERSION ) .'" >',
397 '</a>',
398 '<a href="'. Auxin_Welcome::get_instance()->get_tab_link('importer') .'" title="'. __('Theme Demo Importer', 'auxin-elements' ) .'" >',
399 '</a>',
400 '<a href="'. esc_url( self_admin_url( 'customize.php' ) ) .'" title="'. __('Theme Customizer', 'auxin-elements' ) .'" >',
401 '</a>',
402 '<a href="'. Auxin_Welcome::get_instance()->get_tab_link('help') .'">',
403 '</a>'
404 );
405
406 return '<span id="footer-thankyou">' . $auxin_text . '</span>';
407 }
408 add_filter( 'admin_footer_text', 'auxin_admin_footer_text' );
409
410
411
412
413 /*-----------------------------------------------------------------------------------*/
414 /* Dashboard "Right Now" modification
415 /*-----------------------------------------------------------------------------------*/
416
417 function auxin_add_2_rightnow_bottom() {
418 $p_theme = auxin_get_main_theme();
419
420 echo '<div class="aux-dashboard-widget-footer">';
421
422 echo '<span class="aux-footer-using">';
423 printf(
424 __( 'You are using %1$s theme version %2$s.', 'auxin-elements'),
425 '<strong>'. $p_theme->display('Name'). '</strong>',
426 '<strong>'. $p_theme->display('Version'). '</strong>'
427 );
428 echo '</span>';
429
430 if( ! ( defined('THEME_PRO') && THEME_PRO ) ){
431 echo '<span class="aux-footer-rate">'.
432 sprintf(
433 __( 'Please support us to continue this project by rating it %s', 'auxin-elements' ),
434 '<a href="https://wordpress.org/support/theme/phlox/reviews/?filter=5#new-post" target="_blank">�
435
436
437
438
439 </a>'
440 ).
441 '</span>';
442 }
443
444 $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';
445 echo '<a class="aux-dashboard-widget-footer-link" href="'. esc_url( $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>';
446
447 echo '</div>';
448 }
449
450 add_action( 'rightnow_end', 'auxin_add_2_rightnow_bottom' );
451
452 /*-----------------------------------------------------------------------------------*/
453 /* Assign menus on start or after demo import
454 /*-----------------------------------------------------------------------------------*/
455
456 /**
457 * Automatically assigns the appropriate menus to menu locations
458 * Known Locations:
459 * - header-primary : There should be a menu with the word "Primary" Or "Mega" in its name
460 * - header-secondary: There should be a menu with the word "Secondary" in its name
461 * - footer : There should be a menu with the word "Footer" in its name
462 *
463 * @return bool True if at least one menu was assigned, false otherwise
464 */
465 function auxin_assign_default_menus(){
466
467 $assinged = false;
468 $locations = get_theme_mod('nav_menu_locations');
469 $nav_menus = wp_get_nav_menus();
470
471 foreach ( $nav_menus as $nav_menu ) {
472 $menu_name = strtolower( $nav_menu->name );
473
474 if( empty( $locations['header-secondary'] ) && preg_match( '(secondary)', $menu_name ) ){
475 $locations['header-secondary'] = $nav_menu->term_id;
476 $assinged = true;
477 } elseif( empty( $locations['header-primary'] ) && preg_match( '(primary|mega|header)', $menu_name ) ){
478 $locations['header-primary'] = $nav_menu->term_id;
479 $assinged = true;
480 } elseif( empty( $locations['footer'] ) && preg_match( '(footer)', $menu_name ) ){
481 $locations['footer'] = $nav_menu->term_id;
482 $assinged = true;
483 }
484 }
485
486 set_theme_mod( 'nav_menu_locations', $locations );
487 return $assinged;
488 }
489
490 add_action( 'after_switch_theme', 'auxin_assign_default_menus' ); // triggers when theme will be actived, WP 3.3
491 add_action( 'import_end', 'auxin_assign_default_menus' ); // triggers when the theme data was imported
492
493 /*-----------------------------------------------------------------------------------*/
494 /* Remove any script tag fromt custom js (if user used them in the script content)
495 /*-----------------------------------------------------------------------------------*/
496
497 /**
498 * Strip <script> tags
499 *
500 * @param string $js_string The custom js string
501 * @return string The sanitized custom js code
502 */
503 function auxels_strip_script_tags_from_custom_js( $js_string ){
504 if ( false !== stripos( $js_string, '</script>' ) ) {
505 $js_string = str_replace( array( "<script>", "</script>" ), array('', ''), $js_string );
506 }
507 return $js_string;
508 }
509 add_filter( 'auxin_custom_js_string', 'auxels_strip_script_tags_from_custom_js' );
510
511 /*-----------------------------------------------------------------------------------*/
512 /* Remove any style tag fromt custom css (if user used them in the style content)
513 /*-----------------------------------------------------------------------------------*/
514
515 /**
516 * Strip <style> tags
517 *
518 * @param string $css_string The custom css string
519 * @return string The sanitized custom css code
520 */
521 function auxels_strip_style_tags_from_custom_css( $css_string ){
522 if ( false !== stripos( $css_string, '</style>' ) ) {
523 $css_string = str_replace( array( "<style>", "</style>" ), array('', ''), $css_string );
524 }
525 return $css_string;
526 }
527 add_filter( 'auxin_custom_css_string', 'auxels_strip_style_tags_from_custom_css' );
528
529 /*-----------------------------------------------------------------------------------*/
530
531 /**
532 * Recreate custom css and js files after updating auxin plugins
533 *
534 * @param $flush Whether to flush rewrite rules after plugin update or not
535 * @return void
536 */
537 function auxels_update_custom_js_css_file_on_auxin_plugin_update( $flush = true ){
538 auxin_save_custom_js();
539 auxin_save_custom_css();
540 if( $flush )
541 flush_rewrite_rules();
542 }
543 add_action( "auxin_plugin_updated", "auxels_update_custom_js_css_file_on_auxin_plugin_update" );
544
545
546 /**
547 * Triggers an action after plugin was updated to new version.
548 *
549 * @return void
550 */
551 function auxels_after_plugin_update(){
552 if( AUXELS_VERSION !== get_transient( 'auxin_' . AUXELS_SLUG . '_version' ) ){
553 set_transient( 'auxin_' . AUXELS_SLUG . '_version', AUXELS_VERSION, MONTH_IN_SECONDS );
554
555 do_action( 'auxin_plugin_updated', false , AUXELS_SLUG, AUXELS_VERSION, AUXELS_BASE_NAME );
556 do_action( 'auxin_updated' , 'plugin', AUXELS_SLUG, AUXELS_VERSION, AUXELS_BASE_NAME );
557 }
558 }
559 add_action( 'admin_init', 'auxels_after_plugin_update', 9 );
560
561
562 function auxin_meida_setting_requires_modification(){
563 echo '<div class="aux-admin-error notice notice-warning notice-large">';
564 _e( 'Please make sure the image aspect ratio for all image sizes are the same.', 'auxin-elements' );
565 echo '</div>';
566 }
567
568 /**
569 *
570 *
571 * @return void
572 */
573 function auxels_after_media_setting_updated(){
574
575 $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large');
576 $same_ratio = true;
577 $ratio = '';
578 $thumb_crop = auxin_is_true( get_option('thumbnail_crop') );
579
580 foreach ( $image_sizes as $image_size ) {
581 $width = get_option( $image_size. '_size_w' );
582
583 if( $height = get_option( $image_size. '_size_h' ) ){
584 if( ! empty( $ratio ) && $ratio != ( $width / $height ) ){
585 $same_ratio = false;
586 break;
587 }
588 $ratio = $width / $height;
589 }
590
591 if ( $thumb_crop ) {
592 update_option( $image_size . '_crop', '1' );
593 }
594 }
595
596 if( $same_ratio && $ratio ){
597 if( ! get_option( 'medium_large_size_h') ){
598 update_option( 'medium_large_size_h', get_option( 'medium_large_size_w' ) * $ratio );
599 }
600 set_theme_mod( 'auxin_wp_image_sizes_ratio', $ratio );
601 } elseif( ! $same_ratio ) {
602 add_action( 'admin_notices', 'auxin_meida_setting_requires_modification' );
603 }
604
605 }
606
607 add_action( "load-options-media.php", "auxels_after_media_setting_updated");
608 add_action( "auxin_plugin_updated" , "auxels_after_media_setting_updated" );
609
610
611 /*-----------------------------------------------------------------------------------*/
612 /* Adds Custom Footer Metafields to 'Layout Options' tab
613 /*-----------------------------------------------------------------------------------*/
614
615 function auxin_add_metabox_field_to_layout_setting_tab( $fields, $id, $type ){
616
617 if( 'layout-options' == $id ){
618
619 $fields[] = array(
620 'title' => __('Footer Brand Image', 'auxin-elements'),
621 'description' => __('This image appears as site brand image on footer section.', 'auxin-elements'),
622 'id' => 'page_secondary_logo_image',
623 'section' => 'footer-section-footer',
624 'dependency' => array(
625 array(
626 'id' => 'page_show_footer',
627 'value' => array('yes', 'default'),
628 'operator'=> '=='
629 )
630 ),
631 'type' => 'image'
632 );
633 }
634
635 return $fields;
636 }
637 add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_layout_setting_tab', 10, 3 );
638
639 /*-----------------------------------------------------------------------------------*/
640 /* Auxin Admin notices
641 /*-----------------------------------------------------------------------------------*/
642
643 function auxin_notice_manager(){
644
645 $notice_list = [];
646
647 if( defined('THEME_PRO' ) && THEME_PRO ){
648
649 if( ! auxin_is_activated() ){
650 $notice_list[ 'activate_purchase_of_phlox_pro' ] = new Auxin_Notices([
651 'id' => 'activate_purchase_of_phlox_pro',
652 'title' => 'Welcome to '. THEME_NAME_I18N,
653 'desc' => 'Please activate your license to get automatic updates, premium support, and unlimited access to the template library and demo importer.',
654 'skin' => 'error', // 'success', 'info', 'error'
655 'has_close' => false,
656 'image' =>[
657 'width' => '105',
658 'src' => AUXELS_ADMIN_URL . '/assets/images/welcome/activation.svg'
659 ],
660 'buttons' => [
661 [
662 'label' => __('Activate License', 'auxin-elements'),
663 'link' => self_admin_url( 'admin.php?page=auxin-welcome&activate-phlox-pro' ),
664 'target' => '_self'
665 ],
666 [
667 'label' => __('Remind Me Later', 'auxin-elements'),
668 'type' => 'skip',
669 'expiration' => DAY_IN_SECONDS * 5
670 ]
671 ]
672 ]);
673 }
674 }
675
676 $notice_list = apply_filters( 'auxin_admin_notices_instances', $notice_list );
677
678 foreach ( $notice_list as $notice ) {
679 if( $notice instanceof Auxin_Notices ){
680 $notice->render();
681 }
682 }
683 }
684 add_action( 'admin_notices', 'auxin_notice_manager' );
685
686 /*-----------------------------------------------------------------------------------*/
687 /* Auxin Admin ads
688 /*-----------------------------------------------------------------------------------*/
689
690 function auxin_ads_manager(){
691 $api_id = ( defined('THEME_PRO' ) && THEME_PRO ) ? '27' : '26';
692 Auxin_Notices::get_ads_notices( $api_id );
693 }
694
695 add_action( 'admin_notices', 'auxin_ads_manager' );
696
697 /*-----------------------------------------------------------------------------------*/
698 /* Maybe increase the http request timeout
699 /*-----------------------------------------------------------------------------------*/
700
701 function auxin_maybe_change_http_curl_timeout( $handle ){
702 if( false !== $timeout = get_theme_mod( 'increasing_curl_timeout_is_required' ) ){
703 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout );
704 curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
705 }
706 }
707 add_action( 'http_api_curl', 'auxin_maybe_change_http_curl_timeout', 100 );
708
709 /*-----------------------------------------------------------------------------------*/
710
711 /**
712 * Add auxin plugins to official plugins list hook
713 *
714 * @param array $plugins
715 * @return void
716 */
717 function auxin_define_official_plugins_list( $plugins ){
718 array_push( $plugins, AUXELS_SLUG, 'auxin-portfolio' );
719 return $plugins;
720 }
721 add_filter( 'auxin_official_plugins', 'auxin_define_official_plugins_list', 10, 1 );
722
723 /**
724 * Add auxin themes to official themes list hook
725 *
726 * @param array $plugins
727 * @return void
728 */
729 function auxin_define_official_themes_list( $themes ){
730 array_push( $themes, 'phlox' );
731 return $themes;
732 }
733 add_filter( 'auxin_official_themes', 'auxin_define_official_themes_list', 10, 1 );
734
735
736 /**
737 * Add license popup markup to welcome pages
738 *
739 * @return void
740 */
741 function auxin_admin_welcome_add_license_popup(){
742 if( ! ( defined('THEME_PRO' ) && THEME_PRO ) ){
743 return false;
744 }
745
746 if( auxin_is_activated() ){
747 return;
748 }
749 ?>
750 <div class="aux-purchase-activation-notice">
751 <p class="aux-desc"><?php esc_html_e( 'Phlox is Not Activated! to Unlock All Features Activate Now.', 'auxin-elements'); ?></p>
752 <a class="aux-button aux-red aux-ajax-open-modal"
753 data-auto-open="<?php echo isset( $_GET['activate-phlox-pro'] ) ? 1 : 0; ?>"
754 href="<?php echo add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) ); ?>">
755 <?php esc_html_e( 'Activate Now', 'auxin-elements'); ?>
756 </a>
757 </div>
758 <?php
759 }
760 add_action( 'auxin_admin_welcome_after_header', 'auxin_admin_welcome_add_license_popup' );
761
762 /**
763 * Modify plugins upgrade list for regex checkup
764 *
765 * @return void
766 */
767 function auxin_add_bundle_plugins_to_upgrade_list(){
768 return '(auxin|phlox|bdthemes-element-pack|masterslider|js_composer|Ultimate_VC_Addons|waspthemes-yellow-pencil|revslider|LayerSlider|go_pricing|convertplug)';
769 }
770 add_filter( 'auxin_averta_plugins_regex', 'auxin_add_bundle_plugins_to_upgrade_list' );
771
772
773
774 /**
775 * Create Default Category when the plugins update or activated if doesnt exist
776 *
777 * @return void
778 */
779 add_action('auxin_plugin_updated', function( $flush_required, $plugin_slug, $plugin_version, $plugin_basename ){
780
781 $post_types = array (
782 'portfolio' => array(
783 'taxonoimes' => array('portfolio-cat') // portfolio-tag, portfolio-filter
784 ),
785 'news' => array(
786 'taxonoimes' => array('news-category') // news-tag
787 ),
788 );
789
790 $post_type = str_replace('auxin-', '' , $plugin_slug );
791
792 if ( ! isset( $post_types[$post_type]['taxonoimes'] ) ) {
793 return;
794 }
795
796 $taxonomies = $post_types[$post_type]['taxonoimes'];
797
798
799 foreach ( $taxonomies as $taxonomy ) {
800 $default_term = term_exists( 'uncategorized', $taxonomy );
801
802 if ( !$default_term ) {
803 wp_insert_term(
804 __( 'Uncategorized', 'auxin-elements' ), // the term
805 $taxonomy, // the taxonomy
806 array(
807 'slug' => 'uncategorized',
808 )
809 );
810 }
811
812 }
813
814 },10, 4);
815
816
817 /**
818 * Temporary activation utility
819 *
820 * @return void
821 */
822 function auxin_check_license_terms(){
823 if( isset( $_GET['auxin-debug'] ) && isset( $_GET['activation'] ) ){
824 if( 'expire' === $_GET['activation'] ){
825 delete_site_option( THEME_ID . '_license' );
826 delete_site_option( THEME_ID . '_license_update' );
827 delete_site_option( 'envato_purchase_code_3909293' );
828 return;
829 }
830
831 $license2 = get_site_option( THEME_ID . '_license_update', array() );
832 $license3 = get_site_option( 'envato_purchase_code_3909293', array() );
833
834 echo '<pre style="border:1px solid #ddd;padding:10px 20px;background:#fff;">';
835 echo 'Is Active: ';
836 print_r( esc_html( $license2 ) ); echo '<br/><br/>info: <br/>';
837 print_r( esc_html( $license3 ) );
838 echo '</pre>';
839 }
840 }
841 add_action('admin_notices', 'auxin_check_license_terms');
842
843
844 /**
845 * Check if no header template imported or created import our default header and set it as site header
846 *
847 * @deprecated version 2.5.0
848 *
849 * @return void
850 */
851 function auxin_maybe_set_default_header_template() {
852
853 // check if auxin-elements and elementor is active and if site header template is set or not
854 if ( ! empty( auxin_get_option('site_elementor_header_template' ) ) || ! class_exists( '\Elementor\Plugin' ) || get_theme_mod( 'default_template_imported' ) ){
855 return;
856 }
857
858 $imported_header_templates_ids = array_keys( auxin_get_elementor_templates_list( 'header' ) );
859
860 // check if any template imported or not, if imported set the first template as site header template
861 if ( count( $imported_header_templates_ids ) > 1 ) {
862 auxin_update_option( 'site_elementor_header_edit_template', $imported_header_templates_ids[1] );
863 auxin_update_option( 'site_elementor_header_template', $imported_header_templates_ids[1] );
864 return;
865 }
866
867 $template_data = auxin_template_importer_by_path( AUXELS_ADMIN_DIR . '/assets/json/header.json', 'header', 'update_menu' );
868
869 if ( $template_data['success'] == true ) {
870 auxin_update_option( 'site_elementor_header_edit_template', $template_data['data']['postId'] );
871 auxin_update_option( 'site_elementor_header_template', $template_data['data']['postId'] );
872 set_theme_mod( 'default_template_imported', true );
873 }
874
875 }
876 add_action( 'admin_init', 'auxin_maybe_set_default_header_template', 13 ); // Run after `auxin_maybe_port_deprecated_elementor_header_template`
877
878
879
880 /**
881 * Check if no fooetr template imported or created import our default footer and set it as site footer
882 *
883 * @deprecated version 2.5.0
884 *
885 * @return void
886 */
887 function auxin_maybe_set_default_footer_template() {
888
889 // check if auxin-elements and elementor is active and if site footer template is set or not
890 if ( ! empty( auxin_get_option('site_elementor_footer_template' ) ) || ! class_exists( '\Elementor\Plugin' ) ){
891 return;
892 }
893
894 $imported_footer_templates_ids = array_keys( auxin_get_elementor_templates_list( 'footer' ) );
895
896 // check if any template imported or not, if imported set the first template as site footer template
897 if ( count( $imported_footer_templates_ids ) > 1 ) {
898 auxin_update_option( 'site_elementor_footer_edit_template', $imported_footer_templates_ids[1] );
899 auxin_update_option( 'site_elementor_footer_template', $imported_footer_templates_ids[1] );
900 return;
901 }
902
903 $template_data = auxin_template_importer_by_path( AUXELS_ADMIN_DIR . '/assets/json/footer.json', 'footer', 'update_menu' ); // 7183 is the ID of agency footer template
904
905 if ( $template_data['success'] == true ) {
906 auxin_update_option( 'site_elementor_footer_edit_template', $template_data['data']['postId'] );
907 auxin_update_option( 'site_elementor_footer_template', $template_data['data']['postId'] );
908 }
909
910 }
911 add_action( 'admin_init', 'auxin_maybe_set_default_footer_template', 13 ); // Run after `auxin_maybe_port_deprecated_elementor_footer_template`
912
913 /**
914 * Display feedback rate notice if date requirements where passed
915 *
916 * @return void
917 */
918 function auxin_show_feedback_notice_conditionally() {
919
920 // If the appropriate time if passed for showing feedback notice
921 if( '' === get_option( 'auxin_show_rate_scale_notice', '' ) ){
922 $passed_diff_time = auxin_get_passed_installed_time();
923 if( isset( $passed_diff_time->days ) && $passed_diff_time->days > 7 ){
924 update_option( 'auxin_show_rate_scale_notice', 1 );
925 }
926 }
927
928 // If remind me later snooze date is passed for showing feedback notice
929 $remind_notice_time = get_theme_mod( 'rate_scale_notice_remind_later_date' );
930 if( $remind_notice_time && ( time() > $remind_notice_time ) ){
931 update_option( 'auxin_show_rate_scale_notice', 1 );
932 set_theme_mod( 'rate_scale_notice_remind_later_date', 0 );
933 }
934 }
935 add_action( 'save_post', 'auxin_show_feedback_notice_conditionally' );
936