PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 1.3.14
Shortcodes and extra features for Phlox theme v1.3.14
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 8 years ago compatibility 8 years ago metaboxes 8 years ago modules 9 years ago admin-ajax.php 8 years ago admin-hooks.php 8 years ago admin-the-functions.php 8 years ago index.php 8 years ago
admin-hooks.php
464 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 axion_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", "axion_init_shortcode_manager");
38
39 /*-----------------------------------------------------------------------------------*/
40 /* Add Editor styles
41 /*-----------------------------------------------------------------------------------*/
42
43 function auxin_register_mce_buttons_style(){
44 wp_register_style('auxin_mce_buttons' , AUXELS_ADMIN_URL. '/assets/css/editor.css', NULL, '1.1');
45 wp_enqueue_style('auxin_mce_buttons');
46 }
47 add_action('admin_enqueue_scripts', 'auxin_register_mce_buttons_style');
48
49
50
51 /*-----------------------------------------------------------------------------------*/
52 /* Adds demos tab in theme about (welcome) page
53 /*-----------------------------------------------------------------------------------*/
54
55 function auxin_welcome_page_display_section_demos(){
56 // all the demos information should add into this array
57 $demos_list = auxin_get_demo_info_list();
58
59 if( ! empty( $demos_list ) ){
60 $wpnonce = wp_create_nonce( 'auxin-import' );
61 ?>
62 <h2 class="aux-featur"><?php _e('Choose the demo you want.', 'auxin-elements'); ?></h2>
63 <h4 class="aux-featur demos-subtitle"><?php _e('Please note that, it is recommended to import a demo on a clean WordPress installation.', 'auxin-elements'); ?></h4>
64 <div class="changelog feature-section three-col">
65 <?php
66 foreach( $demos_list as $demo_id => $demo_info ){
67 ?>
68 <div class="col" id="<?php echo esc_attr( $demo_info['id'] ); ?>">
69 <img class="demos-img" src="<?php echo esc_attr( $demo_info['thumb_url'] ); ?>" alt="<?php echo esc_attr( $demo_info['title'] ); ?>">
70 <h3><?php echo $demo_info['title']; ?></h3>
71 <p><?php echo $demo_info['desc' ]; ?></p>
72 <a href="<?php echo esc_url( $demo_info['preview_url'] ); ?>" class="button button-primary aux-button" target="_blank"><?php _e('Preview', 'auxin-elements'); ?></a>
73 <a href="<?php echo admin_url( 'import.php?import=auxin-importer&demo-id=' . $demo_id. '&_wpnonce=' . $wpnonce ); ?>" class="button button-primary aux-button import-demo">
74 <?php _e( 'Import Demo', 'auxin-elements' ); ?>
75 </a>
76 </div>
77 <?php
78 }
79 echo '</div>';
80 }
81 }
82
83 function auxin_welcome_add_section_demos( $sections ){
84
85 $sections['demos'] = array(
86 'label' => __( 'Demos', 'auxin-elements' ),
87 'description' => sprintf(__( 'you can see and import the %s demos in this section.', 'auxin-elements'), THEME_NAME_I18N ),
88 'callback' => 'auxin_welcome_page_display_section_demos'
89 );
90
91 return $sections;
92 }
93
94 add_filter( 'auxin_admin_welcome_sections', 'auxin_welcome_add_section_demos', 60 );
95
96 /*-----------------------------------------------------------------------------------*/
97 /* Adds system status tab in theme about (welcome) page
98 /*-----------------------------------------------------------------------------------*/
99
100 function auxin_about_system_status( $sections ){
101
102 $sections['status'] = array(
103 'label' => __( 'System Status', 'auxin-elements' ),
104 'description' => __( 'The informaition about your WordPress installation which can be helpful for debugging or monitoring your website.', 'auxin-elements'),
105 'callback' => 'auxin_get_about_system_status'
106 );
107
108 return $sections;
109 }
110
111 add_filter( 'auxin_admin_welcome_sections', 'auxin_about_system_status', 100 );
112
113
114 /*-----------------------------------------------------------------------------------*/
115 /* Adds feedback tab in theme about (welcome) page
116 /*-----------------------------------------------------------------------------------*/
117
118 function auxin_welcome_page_display_section_feedback(){
119 // the previous rate of the client
120 $previous_rate = auxin_get_option( 'user_rating' );
121 $support_tab_url = admin_url( 'themes.php?page=auxin-welcome&tab=support' );
122 ?>
123
124 <div class="changelog feature-section two-col feedback">
125
126 <form class="aux-feedback-form" action="<?php echo admin_url( 'admin.php?page=auxin-welcome&tab=feedback'); ?>" method="post" >
127
128 <div class="aux-rating-section">
129 <h2 class="aux-featur"><?php _e('How likely are you to recommend Phlox to a friend?', 'auxin-elements' ); ?></h2>
130 <div class="aux-theme-ratings">
131 <?php
132 for( $i = 1; $i <= 5; $i++ ){
133 printf(
134 '<div class="aux-rate-cell"><input type="radio" name="theme_rate" id="theme-rating%1$s" value="%1$s" %2$s/><label class="rating" for="theme-rating%1$s">%1$s</label></div>',
135 $i, checked( $previous_rate, $i, false )
136 );
137 }
138 ?>
139
140 </div>
141 <div class="aux-ratings-measure">
142 <p>Don't like it</p>
143 <p>Like it so much</p>
144 </div>
145 </div>
146
147 <div class="aux-feedback-section aux-hide">
148 <h2 class="aux-featur"><?php _e('Please explain why you gave this score (optional)', 'auxin-elements'); ?></h2>
149 <h4 class="aux-featur feedback-subtitle">
150 <?php
151 printf( __( 'Please do not use this form to get support, in this case please check the %s help section %s', 'auxin-elements' ),
152 '<a href="' . $support_tab_url . '">', '</a>' ); ?>
153 </h4>
154 <textarea placeholder="Enter your feedback here" rows="10" name="feedback" class="large-text"></textarea>
155 <input type="text" placeholder="Email address (Optional)" name="email" class="text-input" />
156 <?php wp_nonce_field( 'phlox_feedback' ); ?>
157
158 <input type="submit" class="button button-primary aux-button" value="Submit feedback" />
159
160 <div class="aux-sending-status">
161 <img class="ajax-progress aux-hide" src="<?php echo AUXIN_URL; ?>/css/images/elements/saving.gif" />
162 <span class="ajax-response aux-hide" ><?php _e( 'Submitting your feedback ..', 'auxin-elements' ); ?></span>
163 </div>
164
165 </div>
166
167 <?php auxin_send_feedback_mail(); ?>
168 </form>
169 </div>
170
171 <?php
172 }
173
174 function auxin_welcome_add_section_feedback( $sections ){
175
176 $sections['feedback'] = array(
177 'label' => __( 'Feedback', 'auxin-elements' ),
178 'description' => sprintf(__( 'Please leave a feedback and help us to improve %s theme.', 'auxin-elements'), THEME_NAME_I18N ),
179 'callback' => 'auxin_welcome_page_display_section_feedback'
180 );
181
182 return $sections;
183 }
184
185 add_filter( 'auxin_admin_welcome_sections', 'auxin_welcome_add_section_feedback', 90 );
186
187 function auxin_send_feedback_mail(){
188 if ( ! ( ! isset( $_POST['phlox_feedback'] ) || ! wp_verify_nonce( $_POST['phlox_feedback'], 'feedback_send') ) ) {
189
190 $email = ! empty( $_POST["email"] ) ? sanitize_email( $_POST["email"] ) : 'Empty';
191 $feedback = ! empty( $_POST["feedback"] ) ? esc_textarea( $_POST["feedback"] ) : '';
192
193 if( $feedback ){
194 wp_mail( 'info@averta.net', 'feedback from phlox dashboard', $feedback . chr(0x0D).chr(0x0A) . 'Email: ' . $email );
195 $text = __( 'Thanks for your feedback', 'auxin-elements' );
196 } else{
197 $text = __('Please try again and fill up at least the feedback field.', 'auxin-elements');
198 }
199
200 printf('<p class="notification">%s</p>', $text);
201 }
202 }
203
204 /*-----------------------------------------------------------------------------------*/
205 /* Adds subtitle meta field to 'Title setting' tab
206 /*-----------------------------------------------------------------------------------*/
207
208 function auxin_add_metabox_field_to_title_setting_tab( $fields, $id, $type ){
209
210 if( 'general-title' == $id ){
211 array_unshift(
212 $fields,
213 array(
214 'title' => __('Subtitle', 'auxin-elements'),
215 'description' => __('Second Title (optional). Note: You have to enable "Display Title Bar Section" option in order to display the subtitle.', 'auxin-elements'),
216 'id' => 'page_subtitle',
217 'type' => 'editor',
218 'default' => ''
219 )
220 );
221 }
222
223 return $fields;
224 }
225 add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_title_setting_tab', 10, 3 );
226
227
228 /*-----------------------------------------------------------------------------------*/
229 /* Adds Custom JavaScript meta field to 'Advanced setting' tab
230 /*-----------------------------------------------------------------------------------*/
231
232 function auxin_add_metabox_field_to_advanced_setting_tab( $fields, $id, $type ){
233
234 if( 'general-advanced' == $id ){
235 $fields[] = array(
236 'title' => __('Custom JavaScript Code', 'auxin-elements'),
237 'description' => __('Attention: The following custom JavaScript code will be applied ONLY to this page.', 'auxin-elements').'<br />'.
238 __('For defining global JavaScript roles, please use custom javaScript field on option panel.', 'auxin-elements' ),
239 'id' => 'aux_page_custom_js',
240 'type' => 'code',
241 'mode' => 'javascript',
242 'default' => ''
243 );
244 }
245 return $fields;
246 }
247 add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_advanced_setting_tab', 10, 3 );
248
249
250 /*-----------------------------------------------------------------------------------*/
251 /* Adding fallback for deprecated theme option name
252 /*-----------------------------------------------------------------------------------*/
253
254 function auxels_sync_deprecated_options(){
255
256 $old_theme_options = get_option( THEME_ID . '_formatted_options' );
257 if( false === $old_theme_options ){
258 return;
259 }
260
261 $new_theme_options = get_option( THEME_ID . '_theme_options' );
262 if( false === $new_theme_options ){
263 update_option( THEME_ID . '_theme_options', $old_theme_options );
264 }
265 }
266 add_action( 'admin_init', 'auxels_sync_deprecated_options' );
267
268 /*-----------------------------------------------------------------------------------*/
269 /* Add allowed custom mieme types
270 /*-----------------------------------------------------------------------------------*/
271
272 function auxin_mime_types( $mimes ) {
273 $mimes['svg'] = 'image/svg+xml';
274 return $mimes;
275 }
276
277 add_filter('upload_mimes', 'auxin_mime_types');
278
279
280 /*======================================================================*/
281
282 function auxin_elements_add_post_metabox_models( $models ){
283
284 // Load general metabox models
285 include_once( 'metaboxes/metabox-fields-post-audio.php' );
286 include_once( 'metaboxes/metabox-fields-post-gallery.php' );
287 include_once( 'metaboxes/metabox-fields-post-quote.php' );
288 include_once( 'metaboxes/metabox-fields-post-video.php' );
289
290 $models[] = array(
291 'model' => auxin_metabox_fields_post_gallery(),
292 'priority' => 20
293 );
294
295 $models[] = array(
296 'model' => auxin_metabox_fields_post_video(),
297 'priority' => 22
298 );
299
300 $models[] = array(
301 'model' => auxin_metabox_fields_post_audio(),
302 'priority' => 24
303 );
304
305 $models[] = array(
306 'model' => auxin_metabox_fields_post_quote(),
307 'priority' => 26
308 );
309
310 $models[] = array(
311 'model' => auxin_metabox_fields_general_advanced(),
312 'priority' => 36
313 );
314
315 return $models;
316 }
317
318 add_filter( 'auxin_admin_metabox_models_post', 'auxin_elements_add_post_metabox_models' );
319
320
321 /*-----------------------------------------------------------------------------------*/
322 /* Add theme tab in siteorigin page builder
323 /*-----------------------------------------------------------------------------------*/
324
325 function auxin_add_widget_tabs($tabs) {
326 $tabs[] = array(
327 'title' => THEME_NAME,
328 'filter' => array(
329 'groups' => array('auxin')
330 )
331 );
332
333 if (isset($tabs['recommended'])){
334 unset($tabs['recommended']);
335 }
336
337
338 return $tabs;
339 }
340 add_filter( 'siteorigin_panels_widget_dialog_tabs', 'auxin_add_widget_tabs', 20 );
341
342 // =============================================================================
343
344
345 function auxin_admin_footer_text( $footer_text ) {
346
347 // the admin pages that we intent to display theme footer text on
348 $admin_pages = array(
349 'toplevel_page_auxin',
350 'appearance_page_auxin',
351 'toplevel_page_auxin-welcome',
352 'appearance_page_auxin-welcome',
353 'page',
354 'post',
355 'widgets',
356 'dashboard',
357 'edit-post',
358 'edit-page',
359 'edit-portfolio'
360 );
361
362 if( ! ( function_exists('auxin_is_theme_admin_page') && auxin_is_theme_admin_page( $admin_pages ) ) ){
363 return $footer_text;
364 }
365
366 $welcome_tab_url = admin_url( 'themes.php?page=auxin-welcome&tab=' );
367
368 $auxin_text = sprintf(
369 __( 'Quick access to %sdashboard%s, %soptions%s, %ssupport%s and %sfeedback%s page.', 'auxin-elements' ),
370 '<a href="'. $welcome_tab_url .'features" title="Version ' . THEME_NAME_I18N . '" >' . THEME_NAME_I18N . ' ',
371 '</a>',
372 '<a href="'. admin_url( 'customize.php' ). '?url=' . $welcome_tab_url .'features" title="'. __('Theme Customizer', 'auxin-elements' ) .'" >',
373 '</a>',
374 '<a href="'. $welcome_tab_url .'support">',
375 '</a>',
376 '<a href="'. $welcome_tab_url .'feedback">',
377 '</a>'
378 );
379
380 return '<span id="footer-thankyou">' . $auxin_text . '</span>';
381 }
382 add_filter( 'admin_footer_text', 'auxin_admin_footer_text' );
383
384
385
386 /*-----------------------------------------------------------------------------------*/
387 /* Assign menus on start or after demo import
388 /*-----------------------------------------------------------------------------------*/
389
390 /**
391 * Automatically assigns the appropriate menus to menu locations
392 * Known Locations:
393 * - header-primary : There should be a menu with the word "Primary" Or "Mega" in its name
394 * - header-secondary: There should be a menu with the word "Secondary" in its name
395 * - footer : There should be a menu with the word "Footer" in its name
396 *
397 * @return bool True if at least one menu was assigned, false otherwise
398 */
399 function auxin_assign_default_menus(){
400
401 $assinged = false;
402 $locations = get_theme_mod('nav_menu_locations');
403 $nav_menus = wp_get_nav_menus();
404
405 foreach ( $nav_menus as $nav_menu ) {
406 $menu_name = strtolower( $nav_menu->name );
407
408 if( empty( $locations['header-secondary'] ) && preg_match( '(secondary)', $menu_name ) ){
409 $locations['header-secondary'] = $nav_menu->term_id;
410 $assinged = true;
411 } elseif( empty( $locations['header-primary'] ) && preg_match( '(primary|mega|header)', $menu_name ) ){
412 $locations['header-primary'] = $nav_menu->term_id;
413 $assinged = true;
414 } elseif( empty( $locations['footer'] ) && preg_match( '(footer)', $menu_name ) ){
415 $locations['footer'] = $nav_menu->term_id;
416 $assinged = true;
417 }
418 }
419
420 set_theme_mod( 'nav_menu_locations', $locations );
421 return $assinged;
422 }
423
424 add_action( 'after_switch_theme', 'auxin_assign_default_menus' ); // triggers when theme will be actived, WP 3.3
425 add_action( 'import_end', 'auxin_assign_default_menus' ); // triggers when the theme data was imported
426
427 /*-----------------------------------------------------------------------------------*/
428 /* Remove any script tag fromt custom js (if user used them in the script content)
429 /*-----------------------------------------------------------------------------------*/
430
431 /**
432 * Strip <script> tags
433 *
434 * @param string $js_string The custom js string
435 * @return string The sanitized custom js code
436 */
437 function auxels_strip_script_tags_from_custom_js( $js_string ){
438 if ( false !== stripos( $js_string, '</script>' ) ) {
439 $js_string = str_replace( array( "<script>", "</script>" ), array('', ''), $js_string );
440 }
441 return $js_string;
442 }
443 add_filter( 'auxin_custom_js_string', 'auxels_strip_script_tags_from_custom_js' );
444
445 /*-----------------------------------------------------------------------------------*/
446 /* Remove any style tag fromt custom css (if user used them in the style content)
447 /*-----------------------------------------------------------------------------------*/
448
449 /**
450 * Strip <style> tags
451 *
452 * @param string $css_string The custom css string
453 * @return string The sanitized custom css code
454 */
455 function auxels_strip_style_tags_from_custom_css( $css_string ){
456 if ( false !== stripos( $css_string, '</style>' ) ) {
457 $css_string = str_replace( array( "<style>", "</style>" ), array('', ''), $css_string );
458 }
459 return $css_string;
460 }
461 add_filter( 'auxin_custom_css_string', 'auxels_strip_style_tags_from_custom_css' );
462
463 /*-----------------------------------------------------------------------------------*/
464