PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.9.15
Shortcodes and extra features for Phlox theme v2.9.15
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 4 years ago compatibility 4 years ago metaboxes 4 years ago admin-ajax.php 4 years ago admin-hooks.php 4 years ago admin-the-functions.php 4 years ago index.php 5 years ago
admin-hooks.php
948 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="'.$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 /**
563 * Disable the query monitor on vc frontend editor
564 *
565 * @return bool Whether to displatche the debug report or not
566 */
567 function auxin_disable_query_monitor_on_vc_fronteditor( $debug_enabled ){
568 return ( function_exists( 'vc_is_frontend_editor' ) && vc_is_frontend_editor() ) ? false : $debug_enabled;
569 }
570 add_filter( 'qm/dispatch/ajax', "auxin_disable_query_monitor_on_vc_fronteditor" );
571 add_filter( 'qm/dispatch/html', "auxin_disable_query_monitor_on_vc_fronteditor" );
572
573
574 function auxin_meida_setting_requires_modification(){
575 echo '<div class="aux-admin-error notice notice-warning notice-large">';
576 _e( 'Please make sure the image aspect ratio for all image sizes are the same.', 'auxin-elements' );
577 echo '</div>';
578 }
579
580 /**
581 *
582 *
583 * @return void
584 */
585 function auxels_after_media_setting_updated(){
586
587 $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large');
588 $same_ratio = true;
589 $ratio = '';
590 $thumb_crop = auxin_is_true( get_option('thumbnail_crop') );
591
592 foreach ( $image_sizes as $image_size ) {
593 $width = get_option( $image_size. '_size_w' );
594
595 if( $height = get_option( $image_size. '_size_h' ) ){
596 if( ! empty( $ratio ) && $ratio != ( $width / $height ) ){
597 $same_ratio = false;
598 break;
599 }
600 $ratio = $width / $height;
601 }
602
603 if ( $thumb_crop ) {
604 update_option( $image_size . '_crop', '1' );
605 }
606 }
607
608 if( $same_ratio && $ratio ){
609 if( ! get_option( 'medium_large_size_h') ){
610 update_option( 'medium_large_size_h', get_option( 'medium_large_size_w' ) * $ratio );
611 }
612 set_theme_mod( 'auxin_wp_image_sizes_ratio', $ratio );
613 } elseif( ! $same_ratio ) {
614 add_action( 'admin_notices', 'auxin_meida_setting_requires_modification' );
615 }
616
617 }
618
619 add_action( "load-options-media.php", "auxels_after_media_setting_updated");
620 add_action( "auxin_plugin_updated" , "auxels_after_media_setting_updated" );
621
622
623 /*-----------------------------------------------------------------------------------*/
624 /* Adds Custom Footer Metafields to 'Layout Options' tab
625 /*-----------------------------------------------------------------------------------*/
626
627 function auxin_add_metabox_field_to_layout_setting_tab( $fields, $id, $type ){
628
629 if( 'layout-options' == $id ){
630
631 $fields[] = array(
632 'title' => __('Footer Brand Image', 'auxin-elements'),
633 'description' => __('This image appears as site brand image on footer section.', 'auxin-elements'),
634 'id' => 'page_secondary_logo_image',
635 'section' => 'footer-section-footer',
636 'dependency' => array(
637 array(
638 'id' => 'page_show_footer',
639 'value' => array('yes', 'default'),
640 'operator'=> '=='
641 )
642 ),
643 'type' => 'image'
644 );
645 }
646
647 return $fields;
648 }
649 add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_layout_setting_tab', 10, 3 );
650
651 /*-----------------------------------------------------------------------------------*/
652 /* Auxin Admin notices
653 /*-----------------------------------------------------------------------------------*/
654
655 function auxin_notice_manager(){
656
657 $notice_list = [];
658
659 if( defined('THEME_PRO' ) && THEME_PRO ){
660
661 if( ! auxin_is_activated() ){
662 $notice_list[ 'activate_purchase_of_phlox_pro' ] = new Auxin_Notices([
663 'id' => 'activate_purchase_of_phlox_pro',
664 'title' => 'Welcome to '. THEME_NAME_I18N,
665 'desc' => 'Please activate your license to get automatic updates, premium support, and unlimited access to the template library and demo importer.',
666 'skin' => 'error', // 'success', 'info', 'error'
667 'has_close' => false,
668 'image' =>[
669 'width' => '105',
670 'src' => AUXELS_ADMIN_URL . '/assets/images/welcome/activation.svg'
671 ],
672 'buttons' => [
673 [
674 'label' => __('Activate License', 'auxin-elements'),
675 'link' => self_admin_url( 'admin.php?page=auxin-welcome&activate-phlox-pro' ),
676 'target' => '_self'
677 ],
678 [
679 'label' => __('Remind Me Later', 'auxin-elements'),
680 'type' => 'skip',
681 'expiration' => DAY_IN_SECONDS * 5
682 ]
683 ]
684 ]);
685 }
686 }
687
688 $notice_list = apply_filters( 'auxin_admin_notices_instances', $notice_list );
689
690 foreach ( $notice_list as $notice ) {
691 if( $notice instanceof Auxin_Notices ){
692 $notice->render();
693 }
694 }
695 }
696 add_action( 'admin_notices', 'auxin_notice_manager' );
697
698 /*-----------------------------------------------------------------------------------*/
699 /* Auxin Admin ads
700 /*-----------------------------------------------------------------------------------*/
701
702 function auxin_ads_manager(){
703 $api_id = ( defined('THEME_PRO' ) && THEME_PRO ) ? '27' : '26';
704 Auxin_Notices::get_ads_notices( $api_id );
705 }
706
707 add_action( 'admin_notices', 'auxin_ads_manager' );
708
709 /*-----------------------------------------------------------------------------------*/
710 /* Maybe increase the http request timeout
711 /*-----------------------------------------------------------------------------------*/
712
713 function auxin_maybe_change_http_curl_timeout( $handle ){
714 if( false !== $timeout = get_theme_mod( 'increasing_curl_timeout_is_required' ) ){
715 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout );
716 curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
717 }
718 }
719 add_action( 'http_api_curl', 'auxin_maybe_change_http_curl_timeout', 100 );
720
721 /*-----------------------------------------------------------------------------------*/
722
723 /**
724 * Add auxin plugins to official plugins list hook
725 *
726 * @param array $plugins
727 * @return void
728 */
729 function auxin_define_official_plugins_list( $plugins ){
730 array_push( $plugins, AUXELS_SLUG, 'auxin-portfolio' );
731 return $plugins;
732 }
733 add_filter( 'auxin_official_plugins', 'auxin_define_official_plugins_list', 10, 1 );
734
735 /**
736 * Add auxin themes to official themes list hook
737 *
738 * @param array $plugins
739 * @return void
740 */
741 function auxin_define_official_themes_list( $themes ){
742 array_push( $themes, 'phlox' );
743 return $themes;
744 }
745 add_filter( 'auxin_official_themes', 'auxin_define_official_themes_list', 10, 1 );
746
747
748 /**
749 * Add license popup markup to welcome pages
750 *
751 * @return void
752 */
753 function auxin_admin_welcome_add_license_popup(){
754 if( ! ( defined('THEME_PRO' ) && THEME_PRO ) ){
755 return false;
756 }
757
758 if( auxin_is_activated() ){
759 return;
760 }
761 ?>
762 <div class="aux-purchase-activation-notice">
763 <p class="aux-desc"><?php esc_html_e( 'Phlox is Not Activated! to Unlock All Features Activate Now.', 'auxin-elements'); ?></p>
764 <a class="aux-button aux-red aux-ajax-open-modal"
765 data-auto-open="<?php echo isset( $_GET['activate-phlox-pro'] ) ? 1 : 0; ?>"
766 href="<?php echo add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) ); ?>">
767 <?php esc_html_e( 'Activate Now', 'auxin-elements'); ?>
768 </a>
769 </div>
770 <?php
771 }
772 add_action( 'auxin_admin_welcome_after_header', 'auxin_admin_welcome_add_license_popup' );
773
774 /**
775 * Modify plugins upgrade list for regex checkup
776 *
777 * @return void
778 */
779 function auxin_add_bundle_plugins_to_upgrade_list(){
780 return '(auxin|phlox|bdthemes-element-pack|masterslider|js_composer|Ultimate_VC_Addons|waspthemes-yellow-pencil|revslider|LayerSlider|go_pricing|convertplug)';
781 }
782 add_filter( 'auxin_averta_plugins_regex', 'auxin_add_bundle_plugins_to_upgrade_list' );
783
784
785
786 /**
787 * Create Default Category when the plugins update or activated if doesnt exist
788 *
789 * @return void
790 */
791 add_action('auxin_plugin_updated', function( $flush_required, $plugin_slug, $plugin_version, $plugin_basename ){
792
793 $post_types = array (
794 'portfolio' => array(
795 'taxonoimes' => array('portfolio-cat') // portfolio-tag, portfolio-filter
796 ),
797 'news' => array(
798 'taxonoimes' => array('news-category') // news-tag
799 ),
800 );
801
802 $post_type = str_replace('auxin-', '' , $plugin_slug );
803
804 if ( ! isset( $post_types[$post_type]['taxonoimes'] ) ) {
805 return;
806 }
807
808 $taxonomies = $post_types[$post_type]['taxonoimes'];
809
810
811 foreach ( $taxonomies as $taxonomy ) {
812 $default_term = term_exists( 'uncategorized', $taxonomy );
813
814 if ( !$default_term ) {
815 wp_insert_term(
816 __( 'Uncategorized', 'auxin-elements' ), // the term
817 $taxonomy, // the taxonomy
818 array(
819 'slug' => 'uncategorized',
820 )
821 );
822 }
823
824 }
825
826 },10, 4);
827
828
829 /**
830 * Temporary activation utility
831 *
832 * @return void
833 */
834 function auxin_check_license_terms(){
835 if( isset( $_GET['auxin-debug'] ) && isset( $_GET['activation'] ) ){
836 if( 'expire' === $_GET['activation'] ){
837 delete_site_option( THEME_ID . '_license' );
838 delete_site_option( THEME_ID . '_license_update' );
839 delete_site_option( 'envato_purchase_code_3909293' );
840 return;
841 }
842
843 $license2 = get_site_option( THEME_ID . '_license_update', array() );
844 $license3 = get_site_option( 'envato_purchase_code_3909293', array() );
845
846 echo '<pre style="border:1px solid #ddd;padding:10px 20px;background:#fff;">';
847 echo 'Is Active: ';
848 print_r( $license2 ); echo '<br/><br/>info: <br/>';
849 print_r( $license3 );
850 echo '</pre>';
851 }
852 }
853 add_action('admin_notices', 'auxin_check_license_terms');
854
855
856 /**
857 * Check if no header template imported or created import our default header and set it as site header
858 *
859 * @deprecated version 2.5.0
860 *
861 * @return void
862 */
863 function auxin_maybe_set_default_header_template() {
864
865 // check if auxin-elements and elementor is active and if site header template is set or not
866 if ( ! empty( auxin_get_option('site_elementor_header_template' ) ) || ! class_exists( '\Elementor\Plugin' ) || get_theme_mod( 'default_template_imported' ) ){
867 return;
868 }
869
870 $imported_header_templates_ids = array_keys( auxin_get_elementor_templates_list( 'header' ) );
871
872 // check if any template imported or not, if imported set the first template as site header template
873 if ( count( $imported_header_templates_ids ) > 1 ) {
874 auxin_update_option( 'site_elementor_header_edit_template', $imported_header_templates_ids[1] );
875 auxin_update_option( 'site_elementor_header_template', $imported_header_templates_ids[1] );
876 return;
877 }
878
879 $template_data = auxin_template_importer( AUXELS_ADMIN_DIR . '/assets/json/header.json', 'header', 'update_menu' );
880
881 if ( $template_data['success'] == true ) {
882 auxin_update_option( 'site_elementor_header_edit_template', $template_data['data']['postId'] );
883 auxin_update_option( 'site_elementor_header_template', $template_data['data']['postId'] );
884 set_theme_mod( 'default_template_imported', true );
885 }
886
887 }
888 add_action( 'admin_init', 'auxin_maybe_set_default_header_template', 13 ); // Run after `auxin_maybe_port_deprecated_elementor_header_template`
889
890
891
892 /**
893 * Check if no fooetr template imported or created import our default footer and set it as site footer
894 *
895 * @deprecated version 2.5.0
896 *
897 * @return void
898 */
899 function auxin_maybe_set_default_footer_template() {
900
901 // check if auxin-elements and elementor is active and if site footer template is set or not
902 if ( ! empty( auxin_get_option('site_elementor_footer_template' ) ) || ! class_exists( '\Elementor\Plugin' ) ){
903 return;
904 }
905
906 $imported_footer_templates_ids = array_keys( auxin_get_elementor_templates_list( 'footer' ) );
907
908 // check if any template imported or not, if imported set the first template as site footer template
909 if ( count( $imported_footer_templates_ids ) > 1 ) {
910 auxin_update_option( 'site_elementor_footer_edit_template', $imported_footer_templates_ids[1] );
911 auxin_update_option( 'site_elementor_footer_template', $imported_footer_templates_ids[1] );
912 return;
913 }
914
915 $template_data = auxin_template_importer( AUXELS_ADMIN_DIR . '/assets/json/footer.json', 'footer', 'update_menu' ); // 7183 is the ID of agency footer template
916
917 if ( $template_data['success'] == true ) {
918 auxin_update_option( 'site_elementor_footer_edit_template', $template_data['data']['postId'] );
919 auxin_update_option( 'site_elementor_footer_template', $template_data['data']['postId'] );
920 }
921
922 }
923 add_action( 'admin_init', 'auxin_maybe_set_default_footer_template', 13 ); // Run after `auxin_maybe_port_deprecated_elementor_footer_template`
924
925 /**
926 * Display feedback rate notice if date requirements where passed
927 *
928 * @return void
929 */
930 function auxin_show_feedback_notice_conditionally() {
931
932 // If the appropriate time if passed for showing feedback notice
933 if( '' === get_option( 'auxin_show_rate_scale_notice', '' ) ){
934 $passed_diff_time = auxin_get_passed_installed_time();
935 if( isset( $passed_diff_time->days ) && $passed_diff_time->days > 7 ){
936 update_option( 'auxin_show_rate_scale_notice', 1 );
937 }
938 }
939
940 // If remind me later snooze date is passed for showing feedback notice
941 $remind_notice_time = get_theme_mod( 'rate_scale_notice_remind_later_date' );
942 if( $remind_notice_time && ( time() > $remind_notice_time ) ){
943 update_option( 'auxin_show_rate_scale_notice', 1 );
944 set_theme_mod( 'rate_scale_notice_remind_later_date', 0 );
945 }
946 }
947 add_action( 'save_post', 'auxin_show_feedback_notice_conditionally' );
948