PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.4.14
Shortcodes and extra features for Phlox theme v2.4.14
2.17.22 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 7 years ago metaboxes 6 years ago modules 10 years ago admin-ajax.php 7 years ago admin-hooks.php 6 years ago admin-the-functions.php 7 years ago index.php 7 years ago
admin-hooks.php
961 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
322 include_once( 'metaboxes/metabox-fields-general-top-header.php');
323 include_once( 'metaboxes/metabox-fields-general-header.php');
324 include_once( 'metaboxes/metabox-fields-general-footer.php');
325 include_once( 'metaboxes/metabox-fields-page-template.php');
326
327 $models[] = array(
328 'model' => auxin_metabox_fields_general_top_header(),
329 'priority' => 13
330 );
331
332 $models[] = array(
333 'model' => auxin_metabox_fields_general_header(),
334 'priority' => 16
335 );
336
337 $models[] = array(
338 'model' => auxin_metabox_fields_general_footer(),
339 'priority' => 20
340 );
341
342 $models[] = array(
343 'model' => auxin_metabox_fields_page_template(),
344 'priority' => 15
345 );
346
347 $models[] = array(
348 'model' => auxin_metabox_fields_general_advanced(),
349 'priority' => 36
350 );
351
352
353 return $models;
354 }
355
356 add_filter( 'auxin_admin_metabox_models_page', 'auxels_add_page_metabox_models' );
357
358 /*-----------------------------------------------------------------------------------*/
359 /* Add theme tab in siteorigin page builder
360 /*-----------------------------------------------------------------------------------*/
361
362 function auxin_add_widget_tabs($tabs) {
363 $tabs[] = array(
364 'title' => THEME_NAME,
365 'filter' => array(
366 'groups' => array('auxin')
367 )
368 );
369
370 if (isset($tabs['recommended'])){
371 unset($tabs['recommended']);
372 }
373
374
375 return $tabs;
376 }
377 add_filter( 'siteorigin_panels_widget_dialog_tabs', 'auxin_add_widget_tabs', 20 );
378
379 // =============================================================================
380
381 function auxin_admin_footer_text( $footer_text ) {
382
383 // the admin pages that we intent to display theme footer text on
384 $admin_pages = array(
385 'toplevel_page_auxin',
386 'appearance_page_auxin',
387 'toplevel_page_auxin-welcome',
388 'appearance_page_auxin-welcome',
389 'page',
390 'post',
391 'widgets',
392 'dashboard',
393 'edit-post',
394 'edit-page',
395 'edit-portfolio',
396 'edit-faq',
397 'edit-product'
398 );
399
400 if( ! ( function_exists('auxin_is_theme_admin_page') && auxin_is_theme_admin_page( $admin_pages ) ) ){
401 return $footer_text;
402 }
403
404 $welcome_tab_url = self_admin_url( 'admin.php?page=auxin-welcome&tab=' );
405 $setup_wizard_url = self_admin_url( 'admin.php?page=auxin-wizard' );
406
407
408 $auxin_text = sprintf(
409 __( 'Quick access to %s %sdashboard%s, %sdemo importer%s, %soptions%s, and %ssupport%s page.', 'auxin-elements' )
410 ,
411 '<strong>' . THEME_NAME_I18N . '</strong>',
412 '<a href="'. Auxin_Welcome::get_instance()->get_tab_link('') .'" title="'. sprintf( esc_attr__( '%s theme version %s', 'auxin-elements' ), THEME_NAME_I18N, THEME_VERSION ) .'" >',
413 '</a>',
414 '<a href="'. Auxin_Welcome::get_instance()->get_tab_link('importer') .'" title="'. __('Theme Demo Importer', 'auxin-elements' ) .'" >',
415 '</a>',
416 '<a href="'. esc_url( self_admin_url( 'customize.php' ) ) .'" title="'. __('Theme Customizer', 'auxin-elements' ) .'" >',
417 '</a>',
418 '<a href="'. Auxin_Welcome::get_instance()->get_tab_link('help') .'">',
419 '</a>'
420 );
421
422 return '<span id="footer-thankyou">' . $auxin_text . '</span>';
423 }
424 add_filter( 'admin_footer_text', 'auxin_admin_footer_text' );
425
426
427
428
429 /*-----------------------------------------------------------------------------------*/
430 /* Dashboard "Right Now" modification
431 /*-----------------------------------------------------------------------------------*/
432
433 function auxin_add_2_rightnow_bottom() {
434 $p_theme = auxin_get_main_theme();
435
436 echo '<div class="aux-dashboard-widget-footer">';
437
438 echo '<span class="aux-footer-using">';
439 printf(
440 __( 'You are using %1$s theme version %2$s.', 'auxin-elements'),
441 '<strong>'. $p_theme->display('Name'). '</strong>',
442 '<strong>'. $p_theme->display('Version'). '</strong>'
443 );
444 echo '</span>';
445
446 if( ! ( defined('THEME_PRO') && THEME_PRO ) ){
447 echo '<span class="aux-footer-rate">'.
448 sprintf(
449 __( 'Please support us to continue this project by rating it %s', 'auxin-elements' ),
450 '<a href="https://wordpress.org/support/theme/phlox/reviews/?filter=5#new-post" target="_blank">�
451
452
453
454
455 </a>'
456 ).
457 '</span>';
458 }
459
460 $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';
461 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>';
462
463 echo '</div>';
464 }
465
466 add_action( 'rightnow_end', 'auxin_add_2_rightnow_bottom' );
467
468 /*-----------------------------------------------------------------------------------*/
469 /* Assign menus on start or after demo import
470 /*-----------------------------------------------------------------------------------*/
471
472 /**
473 * Automatically assigns the appropriate menus to menu locations
474 * Known Locations:
475 * - header-primary : There should be a menu with the word "Primary" Or "Mega" in its name
476 * - header-secondary: There should be a menu with the word "Secondary" in its name
477 * - footer : There should be a menu with the word "Footer" in its name
478 *
479 * @return bool True if at least one menu was assigned, false otherwise
480 */
481 function auxin_assign_default_menus(){
482
483 $assinged = false;
484 $locations = get_theme_mod('nav_menu_locations');
485 $nav_menus = wp_get_nav_menus();
486
487 foreach ( $nav_menus as $nav_menu ) {
488 $menu_name = strtolower( $nav_menu->name );
489
490 if( empty( $locations['header-secondary'] ) && preg_match( '(secondary)', $menu_name ) ){
491 $locations['header-secondary'] = $nav_menu->term_id;
492 $assinged = true;
493 } elseif( empty( $locations['header-primary'] ) && preg_match( '(primary|mega|header)', $menu_name ) ){
494 $locations['header-primary'] = $nav_menu->term_id;
495 $assinged = true;
496 } elseif( empty( $locations['footer'] ) && preg_match( '(footer)', $menu_name ) ){
497 $locations['footer'] = $nav_menu->term_id;
498 $assinged = true;
499 }
500 }
501
502 set_theme_mod( 'nav_menu_locations', $locations );
503 return $assinged;
504 }
505
506 add_action( 'after_switch_theme', 'auxin_assign_default_menus' ); // triggers when theme will be actived, WP 3.3
507 add_action( 'import_end', 'auxin_assign_default_menus' ); // triggers when the theme data was imported
508
509 /*-----------------------------------------------------------------------------------*/
510 /* Remove any script tag fromt custom js (if user used them in the script content)
511 /*-----------------------------------------------------------------------------------*/
512
513 /**
514 * Strip <script> tags
515 *
516 * @param string $js_string The custom js string
517 * @return string The sanitized custom js code
518 */
519 function auxels_strip_script_tags_from_custom_js( $js_string ){
520 if ( false !== stripos( $js_string, '</script>' ) ) {
521 $js_string = str_replace( array( "<script>", "</script>" ), array('', ''), $js_string );
522 }
523 return $js_string;
524 }
525 add_filter( 'auxin_custom_js_string', 'auxels_strip_script_tags_from_custom_js' );
526
527 /*-----------------------------------------------------------------------------------*/
528 /* Remove any style tag fromt custom css (if user used them in the style content)
529 /*-----------------------------------------------------------------------------------*/
530
531 /**
532 * Strip <style> tags
533 *
534 * @param string $css_string The custom css string
535 * @return string The sanitized custom css code
536 */
537 function auxels_strip_style_tags_from_custom_css( $css_string ){
538 if ( false !== stripos( $css_string, '</style>' ) ) {
539 $css_string = str_replace( array( "<style>", "</style>" ), array('', ''), $css_string );
540 }
541 return $css_string;
542 }
543 add_filter( 'auxin_custom_css_string', 'auxels_strip_style_tags_from_custom_css' );
544
545 /*-----------------------------------------------------------------------------------*/
546
547 /**
548 * Recreate custom css and js files after updating auxin plugins
549 *
550 * @param $flush Whether to flush rewrite rules after plugin update or not
551 * @return void
552 */
553 function auxels_update_custom_js_css_file_on_auxin_plugin_update( $flush = true ){
554 auxin_save_custom_js();
555 auxin_save_custom_css();
556 if( $flush )
557 flush_rewrite_rules();
558 }
559 add_action( "auxin_plugin_updated", "auxels_update_custom_js_css_file_on_auxin_plugin_update" );
560
561
562 /**
563 * Triggers an action after plugin was updated to new version.
564 *
565 * @return void
566 */
567 function auxels_after_plugin_update(){
568 if( AUXELS_VERSION !== get_transient( 'auxin_' . AUXELS_SLUG . '_version' ) ){
569 set_transient( 'auxin_' . AUXELS_SLUG . '_version', AUXELS_VERSION, MONTH_IN_SECONDS );
570
571 do_action( 'auxin_plugin_updated', false , AUXELS_SLUG, AUXELS_VERSION, AUXELS_BASE_NAME );
572 do_action( 'auxin_updated' , 'plugin', AUXELS_SLUG, AUXELS_VERSION, AUXELS_BASE_NAME );
573 }
574 }
575 add_action( 'admin_init', 'auxels_after_plugin_update', 9 );
576
577
578
579 add_action( 'admin_init', function(){
580
581 $plugin_update_check = new AUXELS_Plugin_Check_Update (
582 AUXELS_VERSION, // current version
583 'http://api.averta.net/envato/items/', // update path
584 AUXELS_BASE_NAME, // plugin file slug
585 'auxin-elements', // plugin slug
586 'auxin-elements', // item request name
587 AUXELS_DIR . '/auxin-elements.php' // plugin file
588 );
589
590 $plugin_update_check->plugin_id = '1238506';
591 } );
592
593 /**
594 * Disable the query monitor on vc frontend editor
595 *
596 * @return bool Whether to displatche the debug report or not
597 */
598 function auxin_disable_query_monitor_on_vc_fronteditor( $debug_enabled ){
599 return ( function_exists( 'vc_is_frontend_editor' ) && vc_is_frontend_editor() ) ? false : $debug_enabled;
600 }
601 add_filter( 'qm/dispatch/ajax', "auxin_disable_query_monitor_on_vc_fronteditor" );
602 add_filter( 'qm/dispatch/html', "auxin_disable_query_monitor_on_vc_fronteditor" );
603
604
605 function auxin_meida_setting_requires_modification(){
606 echo '<div class="aux-admin-error notice notice-warning notice-large">';
607 _e( 'Please make sure the image aspect ratio for all image sizes are the same.', 'auxin-elements' );
608 echo '</div>';
609 }
610
611 /**
612 *
613 *
614 * @return void
615 */
616 function auxels_after_media_setting_updated(){
617
618 $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large');
619 $same_ratio = true;
620 $ratio = '';
621 $thumb_crop = auxin_is_true( get_option('thumbnail_crop') );
622
623 foreach ( $image_sizes as $image_size ) {
624 $width = get_option( $image_size. '_size_w' );
625
626 if( $height = get_option( $image_size. '_size_h' ) ){
627 if( ! empty( $ratio ) && $ratio != ( $width / $height ) ){
628 $same_ratio = false;
629 break;
630 }
631 $ratio = $width / $height;
632 }
633
634 if ( $thumb_crop ) {
635 update_option( $image_size . '_crop', '1' );
636 }
637 }
638
639 if( $same_ratio && $ratio ){
640 if( ! get_option( 'medium_large_size_h') ){
641 update_option( 'medium_large_size_h', get_option( 'medium_large_size_w' ) * $ratio );
642 }
643 set_theme_mod( 'auxin_wp_image_sizes_ratio', $ratio );
644 } elseif( ! $same_ratio ) {
645 add_action( 'admin_notices', 'auxin_meida_setting_requires_modification' );
646 }
647
648 }
649
650 add_action( "load-options-media.php", "auxels_after_media_setting_updated");
651 add_action( "auxin_plugin_updated" , "auxels_after_media_setting_updated" );
652
653
654 /*-----------------------------------------------------------------------------------*/
655 /* Adds Custom Footer Metafields to 'Layout Options' tab
656 /*-----------------------------------------------------------------------------------*/
657
658 function auxin_add_metabox_field_to_layout_setting_tab( $fields, $id, $type ){
659
660 if( 'layout-options' == $id ){
661
662 $fields[] = array(
663 'title' => __('Footer Brand Image', 'auxin-elements'),
664 'description' => __('This image appears as site brand image on footer section.', 'auxin-elements'),
665 'id' => 'page_secondary_logo_image',
666 'section' => 'footer-section-footer',
667 'dependency' => array(
668 array(
669 'id' => 'page_show_footer',
670 'value' => array('yes', 'default'),
671 'operator'=> '=='
672 )
673 ),
674 'type' => 'image'
675 );
676 }
677
678 return $fields;
679 }
680 add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_layout_setting_tab', 10, 3 );
681
682 /*-----------------------------------------------------------------------------------*/
683 /* Auxin Admin notices
684 /*-----------------------------------------------------------------------------------*/
685
686 function auxin_notice_manager(){
687
688 $notice_list = [];
689
690 if( defined('THEME_PRO' ) && THEME_PRO ){
691
692 if( ! auxin_is_activated() ){
693 $notice_list[ 'activate_purchase_of_phlox_pro' ] = new Auxin_Notices([
694 'id' => 'activate_purchase_of_phlox_pro',
695 'title' => 'Welcome to '. THEME_NAME_I18N,
696 'desc' => 'Please activate your license to get automatic updates, premium support, and unlimited access to the template library and demo importer.',
697 'skin' => 'error', // 'success', 'info', 'error'
698 'has_close' => false,
699 'image' =>[
700 'width' => '105',
701 'src' => AUXELS_ADMIN_URL . '/assets/images/welcome/activation.svg'
702 ],
703 'buttons' => [
704 [
705 'label' => __('Activate License', 'auxin-elements'),
706 'link' => self_admin_url( 'admin.php?page=auxin-welcome&activate-phlox-pro' ),
707 'target' => '_self'
708 ],
709 [
710 'label' => __('Remind Me Later', 'auxin-elements'),
711 'type' => 'skip',
712 'expiration' => DAY_IN_SECONDS * 5
713 ]
714 ]
715 ]);
716 }
717
718 if( ! is_plugin_active( 'auxin-pro-tools/auxin-pro-tools.php' ) ){
719 $plugin_title = __( 'Phlox Pro Features', 'auxin-elements' );
720 $button_label = sprintf( esc_html__( 'Activate %s', 'auxin-elements' ), $plugin_title );
721 $installed_plugins = get_plugins();
722 if( ! isset( $installed_plugins[ 'auxin-pro-tools/auxin-pro-tools.php' ] ) ){
723 $button_label = sprintf( esc_html__( 'Install %s', 'auxin-elements' ), $plugin_title );
724 }
725
726 $notice_list[ 'activate_plugin_phlox_pro_tools' ] = new Auxin_Notices([
727 'id' => 'activate_plugin_phlox_pro_tools',
728 'title' => __('Please install Phlox Pro features', 'auxin-elements' ),
729 'desc' => sprintf( __( 'To take full advantages of Phlox Pro, please install %s plugin.', 'auxin-elements' ), '<strong>'. $plugin_title .'</strong>' ),
730 'skin' => 'default', // 'success', 'info', 'error'
731 'has_close' => false,
732 'buttons' => [
733 [
734 'label' => $button_label,
735 'target' => '_self',
736 'link' => self_admin_url( 'admin.php?page=auxin-welcome&tab=plugins&items=auxin-pro-tools&view=abstract' )
737 ],
738 [
739 'label' => __('Not Now', 'auxin-elements'),
740 'type' => 'skip',
741 'expiration' => HOUR_IN_SECONDS * 2
742 ]
743 ]
744 ]);
745 }
746
747 }
748
749 $notice_list = apply_filters( 'auxin_admin_notices_instances', $notice_list );
750
751 foreach ( $notice_list as $notice ) {
752 if( $notice instanceof Auxin_Notices ){
753 $notice->render();
754 }
755 }
756 }
757 add_action( 'admin_notices', 'auxin_notice_manager' );
758
759 /*-----------------------------------------------------------------------------------*/
760 /* Auxin Admin ads
761 /*-----------------------------------------------------------------------------------*/
762
763 function auxin_ads_manager(){
764
765 if ( false === $data = get_transient( 'auxin_ads_request' ) ) {
766 $body = auxin_remote_get( 'http://averta.net/main/rest/ara/v1/notifications?notification-space=3,5', null);
767 $data = json_decode( $body );
768 set_transient( 'auxin_ads_request', $data , 12 * HOUR_IN_SECONDS );
769 }
770
771 if ( empty( $data ) ) {
772 return false;
773 }
774
775 $ads_list = [];
776
777 foreach( $data as $ads_data ) {
778 $ads_list['auxin_ads_' . $ads_data->id] = new Auxin_Notices([
779 'id' => 'auxin_ads_' . $ads_data->id,
780 'title' => $ads_data->title->rendered,
781 'desc' => $ads_data->message,
782 'skin' => 'ads',
783 'has_close' => false,
784 'wrapper_extra_styles' => [
785 'background-color' => $ads_data->{'background-color'},
786 'background-image' => 'url(' . $ads_data->{'background-image'} . ')',
787 'color' => $ads_data->color,
788 'custom' => $ads_data->boxStyles
789 ],
790 'buttons' => [
791 [
792 'label' => $ads_data->button->label,
793 'target' => '_blank',
794 'link' => $ads_data->button->url,
795 'custom_styles' => $ads_data->button->style
796 ],
797 [
798 'label' => __('Dismiss', 'auxin-elements'),
799 'type' => 'skip',
800 'expiration' => HOUR_IN_SECONDS * 2
801 ]
802 ],
803 ]);
804 }
805
806 foreach ( $ads_list as $ads ) {
807 if( $ads instanceof Auxin_Notices ){
808 $ads->render();
809 }
810 }
811
812 }
813
814 add_action( 'admin_notices', 'auxin_ads_manager' );
815
816 /*-----------------------------------------------------------------------------------*/
817 /* Maybe increase the http request timeout
818 /*-----------------------------------------------------------------------------------*/
819
820 function auxin_maybe_change_http_curl_timeout( $handle ){
821 if( false !== $timeout = get_theme_mod( 'increasing_curl_timeout_is_required' ) ){
822 curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout );
823 curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
824 }
825 }
826 add_action( 'http_api_curl', 'auxin_maybe_change_http_curl_timeout', 100 );
827
828 /*-----------------------------------------------------------------------------------*/
829
830 /**
831 * Add auxin plugins to official plugins list hook
832 *
833 * @param array $plugins
834 * @return void
835 */
836 function auxin_define_official_plugins_list( $plugins ){
837 array_push( $plugins, AUXELS_SLUG, 'auxin-portfolio' );
838 return $plugins;
839 }
840 add_filter( 'auxin_official_plugins', 'auxin_define_official_plugins_list', 10, 1 );
841
842 /**
843 * Add auxin themes to official themes list hook
844 *
845 * @param array $plugins
846 * @return void
847 */
848 function auxin_define_official_themes_list( $themes ){
849 array_push( $themes, 'phlox' );
850 return $themes;
851 }
852 add_filter( 'auxin_official_themes', 'auxin_define_official_themes_list', 10, 1 );
853
854
855 /**
856 * Add license popup markup to welcome pages
857 *
858 * @return void
859 */
860 function auxin_admin_welcome_add_license_popup(){
861 if( ! ( defined('THEME_PRO' ) && THEME_PRO ) ){
862 return false;
863 }
864
865 if( auxin_is_activated() ){
866 return;
867 }
868 ?>
869 <div class="aux-purchase-activation-notice">
870 <p class="aux-desc"><?php esc_html_e( 'Phlox is Not Activated! to Unlock All Features Activate Now.', 'auxin-elements'); ?></p>
871 <a class="aux-button aux-red aux-ajax-open-modal"
872 data-auto-open="<?php echo isset( $_GET['activate-phlox-pro'] ) ? 1 : 0; ?>"
873 href="<?php echo add_query_arg( array( 'action' => 'auxin_display_actvation_form', 'nonce' => wp_create_nonce( 'aux-activation-form' ) ), admin_url( 'admin-ajax.php' ) ); ?>">
874 <?php esc_html_e( 'Activate Now', 'auxin-elements'); ?>
875 </a>
876 </div>
877 <?php
878 }
879 add_action( 'auxin_admin_welcome_after_header', 'auxin_admin_welcome_add_license_popup' );
880
881 /**
882 * Modify plugins upgrade list for regex checkup
883 *
884 * @return void
885 */
886 function auxin_add_bundle_plugins_to_upgrade_list(){
887 return '(auxin|phlox|bdthemes-element-pack|masterslider|js_composer|Ultimate_VC_Addons|waspthemes-yellow-pencil|revslider|LayerSlider|go_pricing|convertplug)';
888 }
889 add_filter( 'auxin_averta_plugins_regex', 'auxin_add_bundle_plugins_to_upgrade_list' );
890
891
892
893 /**
894 * Create Default Category when the plugins update or activated if doesnt exist
895 *
896 * @return void
897 */
898 add_action('auxin_plugin_updated', function( $flush_required, $plugin_slug, $plugin_version, $plugin_basename ){
899
900 $post_types = array (
901 'portfolio' => array(
902 'taxonoimes' => array('portfolio-cat') // portfolio-tag, portfolio-filter
903 ),
904 'news' => array(
905 'taxonoimes' => array('news-category') // news-tag
906 ),
907 );
908
909 $post_type = str_replace('auxin-', '' , $plugin_slug );
910
911 if ( ! isset( $post_types[$post_type]['taxonoimes'] ) ) {
912 return;
913 }
914
915 $taxonomies = $post_types[$post_type]['taxonoimes'];
916
917
918 foreach ( $taxonomies as $taxonomy ) {
919 $default_term = term_exists( 'uncategorized', $taxonomy );
920
921 if ( !$default_term ) {
922 wp_insert_term(
923 __( 'Uncategorized', 'auxin-elements' ), // the term
924 $taxonomy, // the taxonomy
925 array(
926 'slug' => 'uncategorized',
927 )
928 );
929 }
930
931 }
932
933 },10, 4);
934
935
936 /**
937 * Temporary activation utility
938 *
939 * @return void
940 */
941 function auxin_check_license_terms(){
942 if( isset( $_GET['auxin-debug'] ) && isset( $_GET['activation'] ) ){
943 if( 'expire' === $_GET['activation'] ){
944 delete_site_option( THEME_ID . '_license' );
945 delete_site_option( THEME_ID . '_license_update' );
946 delete_site_option( 'envato_purchase_code_3909293' );
947 return;
948 }
949
950 $license2 = get_site_option( THEME_ID . '_license_update', array() );
951 $license3 = get_site_option( 'envato_purchase_code_3909293', array() );
952
953 echo '<pre style="border:1px solid #ddd;padding:10px 20px;background:#fff;">';
954 echo 'Is Active: ';
955 print_r( $license2 ); echo '<br/><br/>info: <br/>';
956 print_r( $license3 );
957 echo '</pre>';
958 }
959 }
960 add_action('admin_notices', 'auxin_check_license_terms');
961