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 / includes / general-hooks.php
auxin-elements / includes Last commit date
classes 8 years ago elements 8 years ago define.php 8 years ago general-functions.php 8 years ago general-hooks.php 8 years ago general-shortcodes.php 8 years ago index.php 8 years ago
general-hooks.php
1657 lines
1 <?php
2 /**
3 * Before Single Products Summary Div
4 *
5 *
6 * @package Auxin
7 * @license LICENSE.txt
8 * @author
9 * @link http://averta.net/phlox/
10 * @copyright (c) 2010-2017
11 */
12
13
14
15 /**
16 * Adds a mian css class indicator to body tag
17 *
18 * @param array $classes List of body css classes
19 * @return array The modified list of body css classes
20 */
21 function auxels_body_class( $classes ) {
22 $classes[] = '_auxels';
23
24 return $classes;
25 }
26 add_filter( 'body_class', 'auxels_body_class' );
27
28
29 /**
30 * Add meta custom field types for vc
31 *
32 * @return void
33 */
34 function auxin_add_vc_field_types(){
35
36 if ( defined( 'WPB_VC_VERSION' ) ) {
37
38 // aux_iconpicker field type definition for VC
39 vc_add_shortcode_param( 'aux_iconpicker', 'auxin_aux_iconpicker_settings_field', ADMIN_JS_URL . 'scripts.js' );
40 function auxin_aux_iconpicker_settings_field( $settings, $value ) {
41
42 $font_icons = Auxin()->Font_Icons->get_icons_list('fontastic');
43 $output = '<div class="aux-element-field aux-iconpicker">';
44 $output .= sprintf( '<select name="%1$s" id="%1$s" class="aux-fonticonpicker aux-select wpb_vc_param_value wpb-select ' .
45 esc_attr( $settings['param_name'] ) . ' ' . $settings['type'] . '_field" >', esc_attr($settings['param_name']) );
46 $output .= '<option value="">' . __('Choose ..', 'auxin-elements') . '</option>';
47
48 if( is_array( $font_icons ) ) {
49 foreach ( $font_icons as $icon ) {
50 $icon_id = trim( $icon->classname, '.' );
51 // $output .= '<option value="'. $icon_id .'" '. selected( $instance[$id], $icon_id, false ) .' >'. $icon->name . '</option>';
52 $output .= '<option value="'. $icon_id .'" '. selected( esc_attr( $value ) , $icon_id, false ) .' >'. $icon->name . '</option>';
53
54 }
55 }
56
57 $output .= '</select>';
58 $output .= '</div>';
59
60 return $output; // This is html markup that will be outputted in content elements edit form
61 }
62
63 // aux_visual_select field type definition for VC
64 vc_add_shortcode_param( 'aux_visual_select', 'auxin_aux_visual_select_settings_field', ADMIN_JS_URL . 'scripts.js' );
65 function auxin_aux_visual_select_settings_field( $settings, $value ) {
66
67 $output = '<select name="' . esc_attr($settings['param_name']) .
68 '" class="aux-element-field visual-select-wrapper wpb_vc_param_value wpb-select ' .
69 esc_attr( $settings['param_name'] ) . ' ' . $settings['type'] . '_field" '.
70 ' id="' . esc_attr($settings['param_name']) .
71 '" data-option="' . esc_attr( $value ) . '" >';
72 foreach ( $settings['choices'] as $id => $option_info ) {
73 $active_attr = ( $id == esc_attr( $value ) ) ? 'selected' : '';
74 $data_class = isset( $option_info['css_class'] ) && ! empty( $option_info['css_class'] ) ? 'data-class="'. $option_info['css_class'].'"' : '';
75 $data_symbol = empty( $data_class ) && isset( $option_info['image'] ) && ! empty( $option_info['image'] ) ? 'data-symbol="'. $option_info['image'].'"' : '';
76 $css_classs = 'class="'. ($id) .'"';
77 $output .= sprintf( '<option value="%s" %s %s %s %s>%s</option>', $id,$css_classs, $active_attr, $data_symbol, $data_class, $option_info['label'] );
78 }
79 $output .= '</select>';
80
81 return $output; // This is html markup that will be outputted in content elements edit form
82 }
83
84 // aux_select_audio field type definition for VC
85 vc_add_shortcode_param( 'aux_select_audio', 'aux_select_audio_settings_field', ADMIN_JS_URL . 'scripts.js' );
86 function aux_select_audio_settings_field( $settings, $value ) {
87
88 // Store attachment src for avertaAttachMedia field
89 if( !empty( $value) ) {
90 $att_ids = explode( ',', $value );
91 $attach_ids_list = auxin_get_the_resized_attachment_src( $att_ids, 80, 80, true );
92 if(!empty($att_ids)) {
93 printf( "<script>auxin.attachmedia = jQuery.extend( auxin.attachmedia, %s );</script>", json_encode( array_unique( $attach_ids_list ) ) );
94 }
95 }
96 $output = '';
97 $output .= '<div class="aux-element-field av3_container aux_select_image axi-attachmedia-wrapper">'.
98 '<input type="text" class="wpb-multiselect wpb_vc_param_value ' . esc_sql($settings['param_name']) . ' ' . $settings['type'] . '_field" name="' . esc_attr($settings['param_name']) . '" ' . 'id="' . esc_attr($settings['param_name']) . '" '
99 . 'value="' . esc_attr( $value ) . '" data-media-type="audio" data-limit="1" data-multiple="0"'
100 .'data-add-to-list="'.__('Add Audio', 'auxin-elements').'" '
101 .'data-uploader-submit="'.__('Add Audio', 'auxin-elements').'"'
102 .'data-uploader-title="'.__('Select Audio', 'auxin-elements').'"> '
103 .'</div>';
104
105 return $output; // This is html markup that will be outputted in content elements edit form
106 }
107
108 // aux_select_video field type definition for VC
109 vc_add_shortcode_param( 'aux_select_video', 'aux_select_video_settings_field', ADMIN_JS_URL . 'scripts.js' );
110 function aux_select_video_settings_field( $settings, $value ) {
111
112 // Store attachment src for avertaAttachMedia field
113 if( !empty( $value) ) {
114 $att_ids = explode( ',', $value );
115 $attach_ids_list = auxin_get_the_resized_attachment_src( $att_ids, 80, 80, true );
116 if(!empty($att_ids)) {
117 printf( "<script>auxin.attachmedia = jQuery.extend( auxin.attachmedia, %s );</script>", json_encode( array_unique( $attach_ids_list ) ) );
118 }
119 }
120 $output = '';
121 $output .= '<div class="aux-element-field av3_container aux_select_image axi-attachmedia-wrapper">'.
122 '<input type="text" class="wpb-multiselect wpb_vc_param_value ' . esc_sql($settings['param_name']) . ' ' . $settings['type'] . '_field" name="' . esc_attr($settings['param_name']) . '" ' . 'id="' . esc_attr($settings['param_name']) . '" '
123 . 'value="' . esc_attr( $value ) . '" data-media-type="video" data-limit="1" data-multiple="0"'
124 .'data-add-to-list="'.__('Add Video', 'auxin-elements').'" '
125 .'data-uploader-submit="'.__('Add Video', 'auxin-elements').'"'
126 .'data-uploader-title="'.__('Select Video', 'auxin-elements').'"> '
127 .'</div>';
128
129 return $output; // This is html markup that will be outputted in content elements edit form
130 }
131
132 // aux_select2_multiple field type definition for VC
133 vc_add_shortcode_param( 'aux_select2_multiple', 'aux_multiple_selector_settings_field', ADMIN_JS_URL . 'scripts.js' );
134 function aux_multiple_selector_settings_field( $settings, $value ) {
135
136 if( gettype( $value ) === "string" ) {
137 $value = explode( ",", $value);
138 }
139 $select = $value;
140 $output = '';
141 $output .= '<select multiple="multiple" name="' . esc_sql($settings['param_name']) . '" style="width:100%" ' . ' class="wpb-multiselect wpb_vc_param_value aux-select2-multiple ' . esc_sql($settings['param_name']) . ' ' . $settings['type'] . '_field" '. '>';
142 foreach ( $settings['value'] as $id => $option_info ) {
143 $active_attr = in_array( $id, $select) ? 'selected="selected"' : '';
144 $output .= sprintf( '<option value="%s" %s >%s</option>', $id, $active_attr, $option_info );
145 }
146 $output.= '</select>';
147
148 return $output; // This is html markup that will be outputted in content elements edit form
149 }
150
151 // aux_taxonomy field type definition for VC
152 vc_add_shortcode_param( 'aux_taxonomy', 'aux_taxonomy_selector_settings_field', ADMIN_JS_URL . 'scripts.js' );
153 function aux_taxonomy_selector_settings_field( $settings, $value ) {
154
155 $categories = get_terms(
156 array( 'taxonomy' => $settings['taxonomy'],
157 'orderby' => 'count',
158 'hide_empty' => true
159 ));
160
161 $categories_list = array( ' ' => __('All Categories', AUXPFO_DOMAIN ) );
162 foreach ( $categories as $key => $value_id ) {
163 $categories_list[$value_id->term_id] = $value_id->name;
164 }
165 if( gettype( $value ) === "string" ) {
166 $value = explode( ",", $value);
167 }
168 $selected = $value;
169 $output = '';
170 $output .= '<select multiple="multiple" name="' . $settings['param_name'] . '" style="width:100%" ' . ' class="wpb-multiselect wpb_vc_param_value aux-select2-multiple ' . esc_sql($settings['param_name']) . ' ' . 'aux-admin-select2 ' . $settings['type'] . '_field" '. '>';
171 foreach ( $categories_list as $id => $options_info ) {
172 $active_attr = in_array( $id, $selected) ? 'selected="selected"' : '';
173 $output .= sprintf( '<option value="%s" %s >%s</option>', $id, $active_attr, $options_info );
174 }
175 $output.= '</select>';
176
177 return $output; // This is html markup that will be outputted in content elements edit form
178 }
179
180 vc_add_shortcode_param( 'aux_switch', 'auxin_aux_switch_settings_field', ADMIN_JS_URL . 'scripts.js' );
181 function auxin_aux_switch_settings_field( $settings, $value ) {
182 $active_attr = auxin_is_true( $value ) ? 'checked="checked"' : '';
183 return '<div class="av3_container aux_switch">'.
184 '<input type="checkbox" name="' . esc_attr( $settings['param_name'] ) . '" class="wpb_vc_param_value wpb_checkbox checkbox '.
185 esc_attr( $settings['param_name'] ) . ' ' .
186 esc_attr( $settings['type'] ) . '_field' .
187 '" value="' . esc_attr( $value ) . '" ' . $active_attr . ' >' .
188 '</div>'; // This is html markup that will be outputted in content elements edit form
189 }
190
191
192
193 }
194
195 /**
196 * Enqueue all my widget's admin scripts
197 */
198 function auxin_widgets_enqueue_scripts(){
199 wp_enqueue_script('auxin_widget');
200
201 }
202 add_action( 'admin_print_scripts-widgets.php', 'auxin_widgets_enqueue_scripts' );
203
204 // Add this to enqueue your scripts on Page Builder too
205 add_action('siteorigin_panel_enqueue_admin_scripts', 'auxin_widgets_enqueue_scripts');
206
207 /**
208 * This part is for adding Auxin font icon to Visual composer icon
209 * this is just temporary and need to move and write in a better manner when it is compelete
210 * TODO: just for now to see it is working
211 */
212
213 // Add Auxin icons to Visual Composer icons
214 $settings = array(
215 'name' => __( 'Auxin Icons', 'auxin-elements' ),
216 'category' => THEME_NAME,
217 'params' => array(
218 array(
219 'type' => 'dropdown',
220 'heading' => __( 'Icon library', 'auxin-elements' ),
221 'value' => array(
222 __( 'Font Awesome', 'auxin-elements' ) => 'fontawesome',
223 __( 'Open Iconic', 'auxin-elements' ) => 'openiconic',
224 __( 'Typicons', 'auxin-elements' ) => 'typicons',
225 __( 'Entypo', 'auxin-elements' ) => 'entypo',
226 __( 'Linecons', 'auxin-elements' ) => 'linecons',
227 __( 'Auxin', 'auxin-elements' ) => 'auxin'
228 ),
229 'admin_label' => true,
230 'param_name' => 'type',
231 'description' => __( 'Select icon library.', 'auxin-elements' )
232 ),
233 array(
234 'type' => 'iconpicker',
235 'heading' => __( 'Icon', 'auxin-elements' ),
236 'param_name' => 'icon_auxin',
237 'value' => 'auxin-icon-basket-1', // default value to backend editor admin_label
238 'settings' => array(
239 'emptyIcon' => false,
240 // default true, display an "EMPTY" icon?
241 'type' => 'auxin',
242 'iconsPerPage' => 4000
243 // default 100, how many icons per/page to display, we use (big number) to display all icons in single page
244 ),
245 'dependency' => array(
246 'element' => 'type',
247 'value' => 'auxin'
248 ),
249 'description' => __( 'Select icon from library.', 'auxin-elements' )
250 ),
251 array(
252 'type' => 'iconpicker',
253 'heading' => __( 'Icon', 'auxin-elements' ),
254 'param_name' => 'icon_fontawesome',
255 'value' => 'fa fa-adjust', // default value to backend editor admin_label
256 'settings' => array(
257 'emptyIcon' => false,
258 // default true, display an "EMPTY" icon?
259 'iconsPerPage' => 4000
260 // default 100, how many icons per/page to display, we use (big number) to display all icons in single page
261 ),
262 'dependency' => array(
263 'element' => 'type',
264 'value' => 'fontawesome'
265 ),
266 'description' => __( 'Select icon from library.', 'auxin-elements' )
267 ),
268 array(
269 'type' => 'iconpicker',
270 'heading' => __( 'Icon', 'auxin-elements' ),
271 'param_name' => 'icon_openiconic',
272 'value' => 'vc-oi vc-oi-dial', // default value to backend editor admin_label
273 'settings' => array(
274 'emptyIcon' => false, // default true, display an "EMPTY" icon?
275 'type' => 'openiconic',
276 'iconsPerPage' => 4000 // default 100, how many icons per/page to display
277 ),
278 'dependency' => array(
279 'element' => 'type',
280 'value' => 'openiconic'
281 ),
282 'description' => __( 'Select icon from library.', 'auxin-elements' )
283 ),
284 array(
285 'type' => 'iconpicker',
286 'heading' => __( 'Icon', 'auxin-elements' ),
287 'param_name' => 'icon_typicons',
288 'value' => 'typcn typcn-adjust-brightness', // default value to backend editor admin_label
289 'settings' => array(
290 'emptyIcon' => false, // default true, display an "EMPTY" icon?
291 'type' => 'typicons',
292 'iconsPerPage' => 4000 // default 100, how many icons per/page to display
293 ),
294 'dependency' => array(
295 'element' => 'type',
296 'value' => 'typicons'
297 ),
298 'description' => __( 'Select icon from library.', 'auxin-elements' )
299 ),
300 array(
301 'type' => 'iconpicker',
302 'heading' => __( 'Icon', 'auxin-elements' ),
303 'param_name' => 'icon_entypo',
304 'value' => 'entypo-icon entypo-icon-note', // default value to backend editor admin_label
305 'settings' => array(
306 'emptyIcon' => false, // default true, display an "EMPTY" icon?
307 'type' => 'entypo',
308 'iconsPerPage' => 4000 // default 100, how many icons per/page to display
309 ),
310 'dependency' => array(
311 'element' => 'type',
312 'value' => 'entypo'
313 ),
314 ),
315 array(
316 'type' => 'iconpicker',
317 'heading' => __( 'Icon', 'auxin-elements' ),
318 'param_name' => 'icon_linecons',
319 'value' => 'vc_li vc_li-heart', // default value to backend editor admin_label
320 'settings' => array(
321 'emptyIcon' => false, // default true, display an "EMPTY" icon?
322 'type' => 'linecons',
323 'iconsPerPage' => 4000 // default 100, how many icons per/page to display
324 ),
325 'dependency' => array(
326 'element' => 'type',
327 'value' => 'linecons'
328 ),
329 'description' => __( 'Select icon from library.', 'auxin-elements' ),
330 ),
331
332 array(
333 'type' => 'colorpicker',
334 'heading' => __( 'Custom color', 'auxin-elements' ),
335 'param_name' => 'custom_color',
336 'description' => __( 'Select custom icon color.', 'auxin-elements' ),
337 'dependency' => array(
338 'element' => 'color',
339 'value' => 'custom'
340 ),
341 ),
342 array(
343 'type' => 'dropdown',
344 'heading' => __( 'Background shape', 'auxin-elements' ),
345 'param_name' => 'background_style',
346 'value' => array(
347 __( 'None', 'auxin-elements' ) => '',
348 __( 'Circle', 'auxin-elements' ) => 'rounded',
349 __( 'Square', 'auxin-elements' ) => 'boxed',
350 __( 'Rounded', 'auxin-elements' ) => 'rounded-less',
351 __( 'Outline Circle', 'auxin-elements' ) => 'rounded-outline',
352 __( 'Outline Square', 'auxin-elements' ) => 'boxed-outline',
353 __( 'Outline Rounded', 'auxin-elements' ) => 'rounded-less-outline'
354 ),
355 'description' => __( 'Select background shape and style for icon.', 'auxin-elements' )
356 ),
357
358 array(
359 'type' => 'colorpicker',
360 'heading' => __( 'Custom background color', 'auxin-elements' ),
361 'param_name' => 'custom_background_color',
362 'description' => __( 'Select custom icon background color.', 'auxin-elements' ),
363 'dependency' => array(
364 'element' => 'background_color',
365 'value' => 'custom'
366 ),
367 ),
368
369 array(
370 'type' => 'dropdown',
371 'heading' => __( 'Icon alignment', 'auxin-elements' ),
372 'param_name' => 'align',
373 'value' => array(
374 __( 'Left', 'auxin-elements' ) => 'left',
375 __( 'Right', 'auxin-elements' ) => 'right',
376 __( 'Center', 'auxin-elements' ) => 'center'
377 ),
378 'description' => __( 'Select icon alignment.', 'auxin-elements' ),
379 ),
380
381 ),
382
383 );
384
385 if ( defined( 'WPB_VC_VERSION' ) ) {
386
387 // vc_map_update('vc_icon', $settings );
388
389 // TODO: This is a sample we need to create an array for all the icons and also enque its css file
390 // add_filter( 'vc_iconpicker-type-auxin', 'vc_iconpicker_type_auxin' );
391 function vc_iconpicker_type_auxin( $icons ) {
392 $auxin_icons = array(
393 "Test" => array(
394 array( 'auxin-icon auxin-icon-2-arrows' => __( 'Arrow', 'auxin-elements' ) ),
395 array( 'auxin-icon auxin-icon-basket-1' => __( 'Arrow', 'auxin-elements' ) ),
396 array( 'auxin-icon auxin-icon-back-pack' => __( 'Back', 'auxin-elements' ) )
397 )
398 );
399
400 return array_merge( $icons, $auxin_icons );
401 }
402
403 // add_action( 'vc_backend_editor_enqueue_js_css', 'auxin_vc_iconpicker_editor_jscss' );
404 // @see Vc_Frontend_Editor::enqueueAdmin (wp-content/plugins/js_composer/include/classes/editors/class-vc-frontend-editor.php),
405 // used to enqueue needed js/css files when frontend editor is rendering
406 // add_action( 'vc_frontend_editor_enqueue_js_css', 'auxin_vc_iconpicker_editor_jscss' );
407 function auxin_vc_iconpicker_editor_jscss () {
408 wp_enqueue_style( 'auxin_font' );
409 }
410
411 // @see Vc_Base::frontCss, used to append actions when frontCss(frontend editor/and real view mode) method called
412 // This action registers all styles(fonts) to be enqueue later
413 add_action( 'vc_base_register_front_css', 'auxin_vc_iconpicker_base_register_css' );
414
415 // @see Vc_Base::registerAdminCss, used to append action when registerAdminCss(backend editor) method called
416 // This action registers all styles(fonts) to be enqueue later
417 add_action( 'vc_base_register_admin_css', 'auxin_vc_iconpicker_base_register_css' );
418 function auxin_vc_iconpicker_base_register_css () {
419 wp_register_style( 'auxin_font', vc_asset_url( 'css/lib/auxin-font/auxin-font.css' ), false, WPB_VC_VERSION, 'screen' );
420 }
421
422
423 }
424
425 }
426 add_action( 'auxin_admin_loaded', 'auxin_add_vc_field_types' );
427
428
429 /**
430 * load custom shortcodes, templates and element in visual composer start
431 *
432 * @return void
433 */
434 function auxin_on_vc_plugin_loaded(){
435 global $vc_manager;
436 if( ! is_null( $vc_manager ) ) {
437 $auxin_shortcodes_template_dir = AUXELS_PUB_DIR . '/templates/vcomposer';
438 $vc_manager->setCustomUserShortcodesTemplateDir( $auxin_shortcodes_template_dir );
439 }
440 }
441 add_action( 'plugins_loaded', 'auxin_on_vc_plugin_loaded' );
442
443
444
445 function auxin_add_theme_options_in_plugin( $fields_sections_list ){
446
447 // Sub section - Custom JS ------------------------------------
448
449 $fields_sections_list['sections'][] = array(
450 'id' => 'general-section-custom-js',
451 'parent' => 'general-section', // section parent's id
452 'title' => __( 'Custom JS Code', 'auxin-elements'),
453 'description' => __( 'Your Custom Javascript', 'auxin-elements')
454 );
455
456 $fields_sections_list['fields'][] = array(
457 'title' => __('Custom Javascript in Head', 'auxin-elements'),
458 'description' => sprintf( __('You can add your custom javascript code here.%s DO NOT use %s tag.', 'auxin-elements'), '<br />' , '<code>&lt;script&gt;</code>' )."<br />".
459 __('In order to save your custom javascript code, you are expected to execute the code prior for saving.', 'auxin-elements'),
460 'id' => 'auxin_user_custom_js_head',
461 'section' => 'general-section-custom-js',
462 'dependency' => array(),
463 'default' => '',
464 'transport' => 'postMessage',
465 'button_labels' => array( 'label' => __('Execute', 'auxin-elements') ),
466 'mode' => 'javascript',
467 'type' => 'code'
468 );
469
470 $fields_sections_list['fields'][] = array(
471 'title' => __('Custom Javascript in Footer', 'auxin-elements'),
472 'description' => sprintf( __('You can add your custom javascript code here.%s DO NOT use %s tag.', 'auxin-elements'), '<br />' , '<code>&lt;script&gt;</code>' )."<br />".
473 __('In order to save your custom javascript code, you are expected to execute the code prior for saving.', 'auxin-elements'),
474 'id' => 'auxin_user_custom_js',
475 'section' => 'general-section-custom-js',
476 'dependency' => array(),
477 'default' => '',
478 'transport' => 'postMessage',
479 'button_labels' => array( 'label' => __('Execute', 'auxin-elements') ),
480 'mode' => 'javascript',
481 'type' => 'code'
482 );
483
484
485 // Sub section - SEO ----------------------------------
486
487 $fields_sections_list['sections'][] = array(
488 'id' => 'general-section-seo',
489 'parent' => 'general-section', // section parent's id
490 'title' => __( 'Google API Keys & SEO', 'auxin-elements'),
491 'description' => __( 'Google API Keys & SEO', 'auxin-elements')
492 );
493
494
495 $fields_sections_list['fields'][] = array(
496 'title' => __('Built in SEO', 'auxin-elements'),
497 'description' => __('In case of using SEO plugins like "WordPress SEO by Yoast" or "All in One SEO Pack" you can disable built-in SEO for maximum compatibility.',
498 'auxin-elements'),
499 'id' => 'enable_theme_seo',
500 'section' => 'general-section-seo',
501 'dependency' => array(),
502 'default' => '1',
503 'type' => 'switch'
504 );
505
506 $fields_sections_list['fields'][] = array(
507 'title' => __('Google analytics code', 'auxin-elements'),
508 'description' => sprintf( __('You can add your Google analytics code here.%s DO NOT use %s tag.', 'auxin-elements'), '<br />' , '<code>&lt;script&gt;</code>' ),
509 'id' => 'auxin_user_google_analytics',
510 'section' => 'general-section-seo',
511 'dependency' => array(),
512 'default' => '',
513 'transport' => 'postMessage',
514 'mode' => 'javascript',
515 'button_labels' => array( 'label' => false ),
516 'type' => 'code'
517 );
518
519 $fields_sections_list['fields'][] = array(
520 'title' => __('Google maps API key', 'auxin-elements'),
521 'description' => sprintf(
522 __( 'In order to use google maps on your website, you have to %s create an api key %s and insert it in this field.', 'auxin-elements' ),
523 '<a href="https://developers.google.com/maps/documentation/javascript/" target="_blank">',
524 '</a>'
525 ),
526 'id' => 'auxin_google_map_api_key',
527 'section' => 'general-section-seo',
528 'dependency' => array(),
529 'default' => '',
530 'transport' => 'postMessage',
531 'mode' => 'javascript',
532 'type' => 'text'
533 );
534
535 $fields_sections_list['fields'][] = array(
536 'title' => __('Google marketing code', 'auxin-elements'),
537 'description' => sprintf( __('You can add your Google marketing code here.%s DO NOT use %s tag.', 'auxin-elements'), '<br />' , '<code>&lt;script&gt;</code>' ),
538 'id' => 'auxin_user_google_marketing',
539 'section' => 'general-section-seo',
540 'dependency' => array(),
541 'default' => '',
542 'transport' => 'postMessage',
543 'mode' => 'javascript',
544 'button_labels' => array( 'label' => false ),
545 'type' => 'code'
546 );
547
548
549
550 $fields_sections_list['fields'][] = array(
551 'title' => __('Footer Brand Image', 'auxin-elements'),
552 'description' => __('This image appears as site brand image on footer section.', 'auxin-elements'),
553 'id' => 'site_secondary_logo_image',
554 'section' => 'footer-section-footer',
555 'dependency' => array(
556 array(
557 'id' => 'show_site_footer',
558 'value' => array('1'),
559 'operator'=> '=='
560 )
561 ),
562 'default' => '',
563 'transport' => 'postMessage',
564 'partial' => array(
565 'selector' => '.aux-logo-footer .aux-logo-anchor',
566 'container_inclusive' => false,
567 'render_callback' => function(){ echo _auxin_get_footer_logo_image(); }
568 ),
569 'type' => 'image'
570 );
571
572 $fields_sections_list['fields'][] = array(
573 'title' => __('Footer Brand Height', 'auxin-elements'),
574 'description' => __('Specifies maximum height of logo in footer.', 'auxin-elements'),
575 'id' => 'site_secondary_logo_max_height',
576 'section' => 'footer-section-footer',
577 'dependency' => array(
578 array(
579 'id' => 'show_site_footer',
580 'value' => array('1'),
581 'operator'=> '=='
582 )
583 ),
584 'default' => '50',
585 'transport' => 'postMessage',
586 'post_js' => '$(".aux-logo-footer .aux-logo-anchor img").css( "max-height", $.trim(to) + "px" );',
587 'style_callback' => function( $value = null ){
588 if( ! $value ){
589 $value = auxin_get_option( 'site_secondary_logo_max_height' );
590 }
591 $value = trim( $value, 'px');
592 return $value ? ".aux-logo-footer .aux-logo-anchor img { max-height:{$value}px; }" : '';
593 },
594 'type' => 'text'
595 );
596
597
598
599
600 // Sub section - Login page customizer -------------------------------
601
602 $fields_sections_list['sections'][] = array(
603 'id' => 'tools-section-login',
604 'parent' => 'tools-section', // section parent's id
605 'title' => __( 'Login Page', 'auxin-elements'),
606 'description' => __( 'Preview login page', 'auxin-elements') . ' '. sprintf(
607 '<a href="%s" class="section-title-icon axicon-link-ext" target="_self" title="%s" ></a>',
608 '?url='.wp_login_url(), __('Preview login page', 'auxin-elements')
609 )
610 );
611
612
613
614 $fields_sections_list['fields'][] = array(
615 'title' => __('Login Skin', 'auxin-elements'),
616 'description' => __('Specifies a skin for login page of your website.', 'auxin-elements'),
617 'id' => 'auxin_login_skin',
618 'section' => 'tools-section-login',
619 'dependency' => array(),
620 'choices' => array(
621 'default' => array(
622 'label' => __('Default', 'auxin-elements'),
623 'image' => AUXIN_URL . 'images/visual-select/login-skin-default.svg'
624 ),
625 'clean-white' => array(
626 'label' => __('Clean white', 'auxin-elements'),
627 'image' => AUXIN_URL . 'images/visual-select/login-skin-light.svg'
628 ),
629 'simple-white' => array(
630 'label' => __('Simple white', 'auxin-elements'),
631 'image' => AUXIN_URL . 'images/visual-select/login-skin-simple-light.svg'
632 ),
633 'simple-gray' => array(
634 'label' => __('Simple gray', 'auxin-elements'),
635 'image' => AUXIN_URL . 'images/visual-select/login-skin-simple-gray.svg'
636 )
637 ),
638 'transport' => 'refresh',
639 'default' => 'default',
640 'type' => 'radio-image'
641 );
642
643 $fields_sections_list['fields'][] = array(
644 'title' => __('Login message', 'auxin-elements'),
645 'description' => __('Enter a text to display above the login form.', 'auxin-elements'),
646 'id' => 'auxin_login_message',
647 'section' => 'tools-section-login',
648 'dependency' => array(),
649 'transport' => 'refresh',
650 'type' => 'textarea',
651 'default' => ''
652 );
653
654 //--------------------------------
655
656 $fields_sections_list['fields'][] = array(
657 'title' => __('Login Page Logo', 'auxin-elements'),
658 'description' => __('Specifies a logo to display on login page.(width of logo image could be up to 320px)', 'auxin-elements'),
659 'id' => 'auxin_login_logo_image',
660 'section' => 'tools-section-login',
661 'dependency' => array(),
662 'transport' => 'refresh',
663 'default' => '',
664 'type' => 'image'
665 );
666
667
668 $fields_sections_list['fields'][] = array(
669 'title' => __('Logo Width', 'auxin-elements'),
670 'description' => __('Specifies width of logo image in pixel.', 'auxin-elements'),
671 'id' => 'auxin_login_logo_width',
672 'section' => 'tools-section-login',
673 'dependency' => array(),
674 'transport' => 'refresh',
675 'default' => '84',
676 'type' => 'text'
677 );
678
679
680 $fields_sections_list['fields'][] = array(
681 'title' => __('Logo Height', 'auxin-elements'),
682 'description' => __('Specifies height of logo image in pixel.', 'auxin-elements'),
683 'id' => 'auxin_login_logo_height',
684 'section' => 'tools-section-login',
685 'dependency' => array(),
686 'transport' => 'refresh',
687 'default' => '84',
688 'type' => 'text'
689 );
690
691 //--------------------------------
692
693 $fields_sections_list['fields'][] = array(
694 'title' => __('Enable Background', 'auxin-elements'),
695 'description' => __('Enable it to display custom background on login page.', 'auxin-elements'),
696 'id' => 'auxin_login_bg_show',
697 'section' => 'tools-section-login',
698 'type' => 'switch',
699 'transport' => 'refresh',
700 'wrapper_class' => 'collapse-head',
701 'default' => '0'
702 );
703
704
705 $fields_sections_list['fields'][] = array(
706 'title' => __( 'Background Color', 'auxin-elements'),
707 'description' => __( 'Specifies background color of website.', 'auxin-elements'),
708 'id' => 'auxin_login_bg_color',
709 'section' => 'tools-section-login',
710 'type' => 'color',
711 'dependency' => array(
712 array(
713 'id' => 'auxin_login_bg_show',
714 'value' => array( '1' )
715 )
716 ),
717 'transport' => 'refresh',
718 'default' => ''
719 );
720
721 $fields_sections_list['fields'][] = array(
722 'title' => __('Background Image', 'auxin-elements'),
723 'description' => __('You can upload custom image for background of login page', 'auxin-elements'),
724 'id' => 'auxin_login_bg_image',
725 'section' => 'tools-section-login',
726 'type' => 'image',
727 'dependency' => array(
728 array(
729 'id' => 'auxin_login_bg_show',
730 'value' => array( '1' )
731 )
732 ),
733 'transport' => 'refresh',
734 'default' => ''
735 );
736
737 $fields_sections_list['fields'][] = array(
738 'title' => __('Background Size', 'auxin-elements'),
739 'description' => __('Specifies background size on login page.', 'auxin-elements'),
740 'id' => 'auxin_login_bg_size',
741 'section' => 'tools-section-login',
742 'type' => 'radio-image',
743 'choices' => array(
744 'auto' => array(
745 'label' => __('Auto', 'auxin-elements'),
746 'css_class' => 'axiAdminIcon-bg-size-1',
747 ),
748 'contain' => array(
749 'label' => __('Contain', 'auxin-elements'),
750 'css_class' => 'axiAdminIcon-bg-size-2'
751 ),
752 'cover' => array(
753 'label' => __('Cover', 'auxin-elements'),
754 'css_class' => 'axiAdminIcon-bg-size-3'
755 )
756 ),
757 'dependency' => array(
758 array(
759 'id' => 'auxin_login_bg_show',
760 'value' => array( '1' )
761 )
762 ),
763 'transport' => 'refresh',
764 'default' => 'auto'
765 );
766
767 $fields_sections_list['fields'][] = array(
768 'title' => __('Background Pattern', 'auxin-elements'),
769 'description' => sprintf(__('You can select one of these patterns as login background image. %s Some of these can be used as a pattern over your background image.', 'auxin-elements'), '<br>'),
770 'id' => 'auxin_login_bg_pattern',
771 'section' => 'tools-section-login',
772 'choices' => auxin_get_background_patterns( array( 'none' => array( 'label' =>__('None', 'auxin-elements'), 'image' => AUXIN_URL . 'images/visual-select/none-pattern.svg' ) ), 'before' ),
773 'type' => 'radio-image',
774 'dependency' => array(
775 array(
776 'id' => 'auxin_login_bg_show',
777 'value' => array( '1' )
778 )
779 ),
780 'transport' => 'refresh',
781 'default' => ''
782 );
783
784 $fields_sections_list['fields'][] = array(
785 'title' => __( 'Background Repeat', 'auxin-elements'),
786 'description' => __( 'Specifies how background image repeats.', 'auxin-elements'),
787 'id' => 'auxin_login_bg_repeat',
788 'section' => 'tools-section-login',
789 'choices' => array(
790 'no-repeat' => array(
791 'label' => __('No repeat', 'auxin-elements'),
792 'css_class' => 'axiAdminIcon-none',
793 ),
794 'repeat' => array(
795 'label' => __('Repeat horizontally and vertically', 'auxin-elements'),
796 'css_class' => 'axiAdminIcon-repeat-xy',
797 ),
798 'repeat-x' => array(
799 'label' => __('Repeat horizontally', 'auxin-elements'),
800 'css_class' => 'axiAdminIcon-repeat-x',
801 ),
802 'repeat-y' => array(
803 'label' => __('Repeat vertically', 'auxin-elements'),
804 'css_class' => 'axiAdminIcon-repeat-y',
805 )
806 ),
807 'type' => 'radio-image',
808 'dependency' => array(
809 array(
810 'id' => 'auxin_login_bg_show',
811 'value' => array( '1' )
812 )
813 ),
814 'transport' => 'refresh',
815 'default' => 'no-repeat'
816 );
817
818 $fields_sections_list['fields'][] = array(
819 'title' => __( 'Background Position', 'auxin-elements'),
820 'description' => __('Specifies background image position.', 'auxin-elements'),
821 'id' => 'auxin_login_bg_position',
822 'section' => 'tools-section-login',
823 'choices' => array(
824 'left top' => array(
825 'label' => __('Left top', 'auxin-elements'),
826 'css_class' => 'axiAdminIcon-top-left'
827 ),
828 'center top' => array(
829 'label' => __('Center top', 'auxin-elements'),
830 'css_class' => 'axiAdminIcon-top-center'
831 ),
832 'right top' => array(
833 'label' => __('Right top', 'auxin-elements'),
834 'css_class' => 'axiAdminIcon-top-right'
835 ),
836
837 'left center' => array(
838 'label' => __('Left center', 'auxin-elements'),
839 'css_class' => 'axiAdminIcon-center-left'
840 ),
841 'center center' => array(
842 'label' => __('Center center', 'auxin-elements'),
843 'css_class' => 'axiAdminIcon-center-center'
844 ),
845 'right center' => array(
846 'label' => __('Right center', 'auxin-elements'),
847 'css_class' => 'axiAdminIcon-center-right'
848 ),
849
850 'left bottom' => array(
851 'label' => __('Left bottom', 'auxin-elements'),
852 'css_class' => 'axiAdminIcon-bottom-left'
853 ),
854 'center bottom' => array(
855 'label' => __('Center bottom', 'auxin-elements'),
856 'css_class' => 'axiAdminIcon-bottom-center'
857 ),
858 'right bottom' => array(
859 'label' => __('Right bottom', 'auxin-elements'),
860 'css_class' => 'axiAdminIcon-bottom-right'
861 )
862 ),
863 'type' => 'radio-image',
864 'dependency' => array(
865 array(
866 'id' => 'auxin_login_bg_show',
867 'value' => array( '1' )
868 )
869 ),
870 'transport' => 'refresh',
871 'default' => 'left top'
872 );
873
874 $fields_sections_list['fields'][] = array(
875 'title' => __('Background Attachment', 'auxin-elements'),
876 'description' => __('Specifies whether the background is fixed or scrollable as user scrolls the page.', 'auxin-elements'),
877 'id' => 'auxin_login_bg_attach',
878 'section' => 'tools-section-login',
879 'type' => 'radio-image',
880 'choices' => array(
881 'scroll' => array(
882 'label' => __('Scroll', 'auxin-elements'),
883 'css_class' => 'axiAdminIcon-bg-attachment-scroll',
884 ),
885 'fixed' => array(
886 'label' => __('Fixed', 'auxin-elements'),
887 'css_class' => 'axiAdminIcon-bg-attachment-fixed',
888 )
889 ),
890 'dependency' => array(
891 array(
892 'id' => 'auxin_login_bg_show',
893 'value' => array( '1' )
894 )
895 ),
896 'transport' => 'refresh',
897 'default' => 'scroll'
898 );
899
900 //--------------------------------
901
902 $fields_sections_list['fields'][] = array(
903 'title' => __('Custom CSS class name', 'auxin-elements'),
904 'description' => __('In this field you can define custom CSS class name for login page.
905 This class name will be added to body classes in login page and is useful for advance custom styling purposes.', 'auxin-elements'),
906 'id' => 'auxin_login_body_class',
907 'section' => 'tools-section-login',
908 'dependency' => array(),
909 'transport' => 'refresh',
910 'default' => '',
911 'type' => 'text'
912 );
913
914
915 return $fields_sections_list;
916 }
917
918 add_filter( 'auxin_defined_option_fields_sections', 'auxin_add_theme_options_in_plugin', 12, 1 );
919
920
921
922
923
924 /*-----------------------------------------------------------------------------------*/
925 /* Injects JavaScript codes from theme options in head
926 /*-----------------------------------------------------------------------------------*/
927
928 function auxin_ele_add_js_to_head() {
929 if( $inline_js = auxin_get_option( 'auxin_user_custom_js_head' ) ){
930 echo '<script>'. $inline_js .'</script>';
931 }
932 }
933 add_action( 'wp_head','auxin_ele_add_js_to_head' );
934
935
936 /*-----------------------------------------------------------------------------------*/
937 /* Injects JavaScript codes from theme options in JS file
938 /*-----------------------------------------------------------------------------------*/
939
940 function auxin_ele_add_theme_options_to_js_file( $js ){
941 $js['theme_options_custom'] = auxin_get_option( 'auxin_user_custom_js' );
942
943 $js['theme_options_google_analytics'] = auxin_get_option( 'auxin_user_google_analytics' );
944 $js['theme_options_google_marketing'] = auxin_get_option( 'auxin_user_google_marketing' );
945
946 // Will be deprecated in version 1.4
947 unset( $js['option_panel_custom'] );
948 unset( $js['option_panel_google_analytics'] );
949 unset( $js['option_panel_google_marketing'] );
950
951 return $js;
952 }
953 add_filter( 'auxin_custom_js_file_content', 'auxin_ele_add_theme_options_to_js_file' );
954
955
956 /*-----------------------------------------------------------------------------------*/
957 /* Adds the custom CSS class of the login page to body element
958 /*-----------------------------------------------------------------------------------*/
959
960 function auxin_login_body_class( $classes ){
961
962 if( $custom_class = auxin_get_option('auxin_login_body_class' ) ){
963 $classes['auxin_custom'] = $custom_class;
964 }
965
966 if( $custom_skin = auxin_get_option('auxin_login_skin' ) ){
967 $classes['auxin_skin'] = esc_attr( 'auxin-login-skin-' . $custom_skin );
968 }
969
970 return $classes;
971 }
972 add_action( 'auxin_functions_ready', function(){
973 add_filter( 'login_body_class', 'auxin_login_body_class' );
974 });
975
976
977
978 /*-----------------------------------------------------------------------------------*/
979 /* Adds proper styles for background and logo on login page
980 /*-----------------------------------------------------------------------------------*/
981
982 function auxin_login_head(){
983
984 $styles = '';
985
986 if( $bg_image_id = auxin_get_option( 'auxin_login_logo_image' ) ){
987 $bg_image = wp_get_attachment_url( $bg_image_id );
988 $styles .= "background-image: url( $bg_image ); ";
989
990 $bg_width = auxin_get_option( 'auxin_login_logo_width' , '84' );
991 $bg_height = auxin_get_option( 'auxin_login_logo_height', '84' );
992
993 $bg_width = rtrim( $bg_width , 'px' ) . 'px';
994 $bg_height = rtrim( $bg_height, 'px' ) . 'px';
995
996 $styles .= "background-size: $bg_width $bg_height; ";
997 $styles .= "width: $bg_width; height: $bg_height; ";
998
999 echo "<style>#login h1 a { $styles }</style>";
1000 }
1001
1002 if( auxin_get_option( 'auxin_login_bg_show' ) ){
1003
1004 // get styles for background image
1005 $bg_styles = auxin_generate_styles_for_backgroud_fields( 'auxin_login_bg', 'option', array(
1006 'color' => 'auxin_login_bg_color',
1007 'image' => 'auxin_login_bg_image',
1008 'repeat' => 'auxin_login_bg_repeat',
1009 'size' => 'auxin_login_bg_size',
1010 'position' => 'auxin_login_bg_position',
1011 'attachment' => 'auxin_login_bg_attachment',
1012 'clip' => 'auxin_login_bg_clip'
1013 ) );
1014
1015 $pattern_style = auxin_generate_styles_for_backgroud_fields( 'auxin_login_bg', 'option', array(
1016 'pattern' => 'auxin_login_bg_pattern'
1017 ) );
1018
1019 echo "<style>body.login { $bg_styles } body.login:before { $pattern_style }</style>";
1020 }
1021
1022 }
1023 add_action( 'auxin_functions_ready', function(){
1024 add_action( 'login_head', 'auxin_login_head' );
1025 });
1026
1027
1028 /*-----------------------------------------------------------------------------------*/
1029 /* Changes the login header url to home url
1030 /*-----------------------------------------------------------------------------------*/
1031
1032 function auxin_login_headerurl( $login_header_url ){
1033
1034 if ( ! is_multisite() ) {
1035 $login_header_url = home_url();
1036 }
1037 return $login_header_url;
1038 }
1039 add_action( 'auxin_functions_ready', function(){
1040 add_filter( 'login_headerurl', 'auxin_login_headerurl' );
1041 });
1042
1043 /*-----------------------------------------------------------------------------------*/
1044 /* Changes the login header url to home url
1045 /*-----------------------------------------------------------------------------------*/
1046
1047 function auxin_login_headertitle( $login_header_title ){
1048
1049 if ( ! is_multisite() ) {
1050 $login_header_title = get_bloginfo( 'name' );
1051 }
1052 return $login_header_title;
1053 }
1054 add_action( 'auxin_functions_ready', function(){
1055 add_filter( 'login_headertitle', 'auxin_login_headertitle' );
1056 });
1057
1058 /*-----------------------------------------------------------------------------------*/
1059 /* Adds custom message above the login form
1060 /*-----------------------------------------------------------------------------------*/
1061
1062 function auxin_login_message( $login_message ){
1063
1064 if( $custom_message = auxin_get_option( 'auxin_login_message' ) ){
1065
1066 $message_wrapper_start = '<div class="message">';
1067 $message_wrapper_end = "</div>\n";
1068
1069 $custom_message_markup = $message_wrapper_start . $custom_message . $message_wrapper_end;
1070
1071 /**
1072 * Filter instructional messages displayed above the login form.
1073 *
1074 * @param string $custom_message Login message.
1075 */
1076 $login_message .= apply_filters( 'auxin_login_message', $custom_message_markup, $custom_message, $message_wrapper_start, $message_wrapper_end );
1077 }
1078
1079 return $login_message;
1080 }
1081 add_action( 'auxin_functions_ready', function(){
1082 add_filter( 'login_message', 'auxin_login_message' );
1083 });
1084
1085
1086 /*-----------------------------------------------------------------------------------*/
1087 /* Prints the custom js codes of a single page to the source page
1088 /*-----------------------------------------------------------------------------------*/
1089
1090 function auxin_custom_js_for_pages( $js, $post ){
1091 // The custom JS code for specific page
1092 if( $post && ! is_404() && is_singular() ) {
1093 $js .= get_post_meta( $post->ID, 'aux_page_custom_js', true );
1094 }
1095
1096 }
1097 add_filter( 'auxin_footer_inline_script', 'auxin_custom_js_for_pages', 15, 2 );
1098
1099
1100 /*-----------------------------------------------------------------------------------*/
1101 /* Add preconnect for Google Fonts.
1102 /*-----------------------------------------------------------------------------------*/
1103
1104 /**
1105 * Add preconnect for Google Fonts.
1106 *
1107 * @param array $urls URLs to print for resource hints.
1108 * @param string $relation_type The relation type the URLs are printed.
1109 * @return array $urls URLs to print for resource hints.
1110 */
1111 function auxin_resource_hints( $urls, $relation_type ) {
1112 if ( wp_style_is( 'auxin-fonts-google', 'queue' ) && 'preconnect' === $relation_type ) {
1113 $urls[] = array(
1114 'href' => 'https://fonts.gstatic.com',
1115 'crossorigin',
1116 );
1117 }
1118 return $urls;
1119 }
1120 //add_filter( 'wp_resource_hints', 'auxin_resource_hints', 10, 2 );
1121
1122
1123 /*-----------------------------------------------------------------------------------*/
1124 /* Setup Header
1125 /*-----------------------------------------------------------------------------------*/
1126
1127 function auxin_after_setup_theme_extra(){
1128 // gererate shortcodes in widget text
1129 add_filter('widget_text', 'do_shortcode');
1130 }
1131 add_action( 'after_setup_theme', 'auxin_after_setup_theme_extra' );
1132
1133 /*-----------------------------------------------------------------------------------*/
1134 /* add excerpts to pages
1135 /*-----------------------------------------------------------------------------------*/
1136
1137 function auxin_add_excerpts_to_pages() {
1138 add_post_type_support( 'page', 'excerpt' );
1139 }
1140 add_action( 'init', 'auxin_add_excerpts_to_pages' );
1141
1142
1143 /*-----------------------------------------------------------------------------------*/
1144 /* Add some user contact fields
1145 /*-----------------------------------------------------------------------------------*/
1146
1147 function auxin_user_contactmethods($user_contactmethods){
1148 $user_contactmethods['twitter'] = __('Twitter' , 'auxin-elements');
1149 $user_contactmethods['facebook'] = __('Facebook' , 'auxin-elements');
1150 $user_contactmethods['googleplus'] = __('Google Plus', 'auxin-elements');
1151 $user_contactmethods['flickr'] = __('Flickr' , 'auxin-elements');
1152 $user_contactmethods['delicious'] = __('Delicious' , 'auxin-elements');
1153 $user_contactmethods['pinterest'] = __('Pinterest' , 'auxin-elements');
1154 $user_contactmethods['github'] = __('GitHub' , 'auxin-elements');
1155 $user_contactmethods['skills'] = __('Skills' , 'auxin-elements');
1156
1157 return $user_contactmethods;
1158 }
1159 add_filter('user_contactmethods', 'auxin_user_contactmethods');
1160
1161
1162 /*-----------------------------------------------------------------------------------*/
1163 /* Add home page menu arg to menu item list
1164 /*-----------------------------------------------------------------------------------*/
1165
1166 function auxin_add_home_page_to_menu_args( $args ) {
1167 $args['show_home'] = true;
1168 return $args;
1169 }
1170 add_filter( 'wp_page_menu_args', 'auxin_add_home_page_to_menu_args' );
1171
1172 /*-----------------------------------------------------------------------------------*/
1173 /* Print meta tags to preview post while sharing on facebook
1174 /*-----------------------------------------------------------------------------------*/
1175
1176 if( ! defined('WPSEO_VERSION') && ! class_exists('All_in_One_SEO_Pack') ){
1177
1178 function auxin_facebook_header_meta (){
1179
1180 if( ! defined('AUXIN_VERSION') ){
1181 return;
1182 }
1183
1184 // return if built-in seo is disabled or "SEO by yoast" is active
1185 if( ! auxin_get_option( 'enable_theme_seo', 1 ) ) return;
1186
1187 global $post;
1188 if( ! isset( $post ) || ! is_singular() || is_search() || is_404() ) return;
1189 setup_postdata( $post );
1190
1191 $featured_image = auxin_get_the_post_thumbnail_src( $post->ID, 90, 90, true, 90 );
1192 $post_excerpt = get_the_excerpt();
1193 ?>
1194 <meta name="title" content="<?php echo esc_attr( $post->post_title ); ?>" />
1195 <meta name="description" content="<?php echo esc_attr( $post_excerpt ); ?>" />
1196 <?php if( $featured_image) { ?>
1197 <link rel="image_src" href="<?php echo $featured_image; ?>" />
1198 <?php }
1199
1200 }
1201
1202 add_action( 'wp_head', 'auxin_facebook_header_meta' );
1203 }
1204
1205 /*-----------------------------------------------------------------------------------*/
1206 /* Add SiteOrigin class prefix and custom field classes path
1207 /*-----------------------------------------------------------------------------------*/
1208 if ( auxin_is_plugin_active( 'so-widgets-bundle/so-widgets-bundle.php') ) {
1209
1210 function auxels_register_auxin_siteorigin_class_prefix( $class_prefixes ) {
1211 $class_prefixes[] = 'Auxin_SiteOrigin_Field_';
1212 return $class_prefixes;
1213 }
1214
1215 add_filter( 'siteorigin_widgets_field_class_prefixes', 'auxels_register_auxin_siteorigin_class_prefix' );
1216
1217
1218 function auxels_register_custom_fields( $class_paths ) {
1219 $class_paths[] = AUXELS_ADMIN_DIR . '/includes/compatibility/siteorigin/fields/';
1220 return $class_paths;
1221 }
1222
1223 add_filter( 'siteorigin_widgets_field_class_paths', 'auxels_register_custom_fields' );
1224 }
1225
1226
1227 /**
1228 * Replace WooCommerce Default Pagination with auxin pagination
1229 *
1230 */
1231 remove_action( 'woocommerce_pagination' , 'woocommerce_pagination', 10 );
1232 add_action ( 'woocommerce_pagination', 'auxin_woocommerce_pagination' , 10 );
1233
1234 function auxin_woocommerce_pagination() {
1235 auxin_the_paginate_nav(
1236 array( 'css_class' => auxin_get_option('archive_pagination_skin') )
1237 );
1238 }
1239
1240
1241
1242
1243 function auxels_add_post_type_metafields(){
1244
1245 $all_post_types = auxin_get_possible_post_types(true);
1246
1247 $auxin_is_admin = is_admin();
1248
1249 foreach ( $all_post_types as $post_type => $is_post_type_allowed ) {
1250
1251 if( ! $is_post_type_allowed ){
1252 continue;
1253 }
1254
1255 // define metabox args
1256 $metabox_args = array( 'post_type' => $post_type );
1257
1258 switch( $post_type ) {
1259
1260 case 'page':
1261
1262 $metabox_args['hub_id'] = 'axi_meta_hub_page';
1263 $metabox_args['hub_title'] = __('Page Options', 'auxin-elements');
1264 $metabox_args['to_post_types'] = array( $post_type );
1265
1266 break;
1267
1268 case 'post':
1269
1270 $metabox_args['hub_id'] = 'axi_meta_hub_post';
1271 $metabox_args['hub_title'] = __('Post Options', 'auxin-elements');
1272 $metabox_args['to_post_types'] = array( $post_type );
1273
1274 default:
1275 break;
1276 }
1277
1278 // Load metabox fields on admin
1279 if( $auxin_is_admin ){
1280 auxin_maybe_render_metabox_hub_for_post_type( $metabox_args );
1281 }
1282
1283 }
1284
1285 }
1286
1287 //add_action( 'init', 'auxels_add_post_type_metafields' );
1288
1289 /*-----------------------------------------------------------------------------------*/
1290 /* Add custom blog page tamplate
1291 /*-----------------------------------------------------------------------------------*/
1292
1293 /**
1294 * Add custom page templates
1295 *
1296 * @param string $result The current custom blog page template markup
1297 * @param string $page_template The name of page template
1298 *
1299 * @return string The markup for current page template
1300 */
1301 function auxels_blog_page_templates( $result, $page_template ){
1302
1303 // page number
1304 $paged = max( 1, get_query_var('paged'), get_query_var('page') );
1305
1306 // posts perpage
1307 $per_page = get_option( 'posts_per_page' );
1308
1309 // if template type is masonry
1310 if( strpos( $page_template, 'blog-type-6' ) ){
1311
1312 $args = array(
1313 'title' => '',
1314 'num' => $per_page,
1315 'paged' => $paged,
1316 'order_by' => 'menu_order date',
1317 'order' => 'desc',
1318 'show_media' => true,
1319 'exclude_without_media' => 0,
1320 'exclude_custom_post_formats' => 0,
1321 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 0 ) ),
1322 'show_title' => true,
1323 'show_info' => true,
1324 'show_readmore' => true,
1325 'show_author_footer' => false,
1326 'tag' => '',
1327 'reset_query' => true
1328 );
1329
1330 // get the shortcode base blog page
1331 $result = auxin_widget_recent_posts_masonry_callback( $args );
1332 }
1333
1334 // if template type is tiles
1335 elseif( strpos( $page_template, 'blog-type-9' ) ){
1336
1337 $args = array(
1338 'title' => '',
1339 'num' => $per_page,
1340 'paged' => $paged,
1341 'order_by' => 'menu_order date',
1342 'order' => 'desc',
1343 'show_media' => true,
1344 'exclude_without_media' => 0,
1345 'exclude_custom_post_formats' => 0,
1346 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 0 ) ),
1347 'show_title' => true,
1348 'show_info' => true,
1349 'show_readmore' => true,
1350 'show_author_footer' => false,
1351 'tag' => '',
1352 'reset_query' => true
1353 );
1354
1355 // get the shortcode base blog page
1356 $result = auxin_widget_recent_posts_tiles_callback( $args );
1357 }
1358
1359 // if template type is land
1360 elseif( strpos( $page_template, 'blog-type-8' ) ){
1361
1362 $args = array(
1363 'title' => '',
1364 'num' => $per_page,
1365 'paged' => $paged,
1366 'order_by' => 'menu_order date',
1367 'order' => 'desc',
1368 'show_media' => true,
1369 'exclude_without_media' => 0,
1370 'exclude_custom_post_formats' => 0,
1371 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 0 ) ),
1372 'show_excerpt' => true,
1373 'excerpt_len' => '160',
1374 'show_title' => true,
1375 'show_info' => true,
1376 'show_readmore' => true,
1377 'show_author_footer' => false,
1378 'tag' => '',
1379 'reset_query' => true
1380 );
1381
1382 // get the shortcode base blog page
1383 $result = auxin_widget_recent_posts_land_style_callback( $args );
1384 }
1385
1386 // if template type is timeline
1387 elseif( strpos( $page_template, 'blog-type-7' ) ){
1388
1389 $args = array(
1390 'title' => '',
1391 'num' => $per_page,
1392 'paged' => $paged,
1393 'order_by' => 'menu_order date',
1394 'order' => 'desc',
1395 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 1 ) ),
1396 'show_media' => true,
1397 'show_excerpt' => true,
1398 'excerpt_len' => '160',
1399 'show_title' => true,
1400 'show_info' => true,
1401 'show_readmore' => true,
1402 'show_author_footer' => false,
1403 'timeline_alignment' => 'center',
1404 'tag' => '',
1405 'reset_query' => true
1406 );
1407
1408 // get the shortcode base blog page
1409 $result = auxin_widget_recent_posts_timeline_callback( $args );
1410 }
1411
1412 // if template type is grid
1413 elseif( strpos( $page_template, 'blog-type-5' ) ){
1414
1415 $desktop_cnum = 4;
1416 $tablet_cnum = 3;
1417 $phone_cnum = 1;
1418
1419 $args = array(
1420 'title' => '',
1421 'num' => $per_page,
1422 'order_by' => 'menu_order date',
1423 'order' => 'desc',
1424 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 1 ) ),
1425 'paged' => $paged,
1426 'show_media' => true,
1427 'display_like' => esc_attr( auxin_get_option( 'show_blog_archive_like_button', 1 ) ),
1428 'show_excerpt' => true,
1429 'excerpt_len' => '160',
1430 'show_title' => true,
1431 'show_info' => true,
1432 'show_readmore' => true,
1433 'show_author_footer' => false,
1434 'desktop_cnum' => $desktop_cnum,
1435 'tablet_cnum' => $tablet_cnum,
1436 'phone_cnum' => $phone_cnum,
1437 'preview_mode' => 'grid',
1438 'tag' => '',
1439 'reset_query' => true
1440 );
1441
1442 // get the shortcode base blog page
1443 $result = auxin_widget_recent_posts_callback( $args );
1444 }
1445
1446 return $result;
1447 }
1448
1449 add_filter( 'auxin_blog_page_template_archive_content', 'auxels_blog_page_templates', 10, 2 );
1450
1451
1452 /*-----------------------------------------------------------------------------------*/
1453 /* Add custom blog archive tamplate types
1454 /*-----------------------------------------------------------------------------------*/
1455
1456 /**
1457 * Add custom page templates
1458 *
1459 * @param string $result The current custom blog loop template markup
1460 * @param string $page_template The ID of template type option
1461 *
1462 * @return string The markup for current blog archive page
1463 */
1464 function auxels_add_blog_archive_custom_template_layouts( $result, $template_type_id ){
1465
1466
1467 if( 6 == $template_type_id ){
1468
1469 $args = array(
1470 'exclude_without_media' => esc_attr( auxin_get_option( 'exclude_without_media' ) ),
1471 'exclude_custom_post_formats' => 0,
1472 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 1 ) ),
1473 'display_like' => esc_attr( auxin_get_option( 'show_blog_archive_like_button', 1 ) ),
1474 'show_media' => true,
1475 'show_excerpt' => true,
1476 'excerpt_len' => esc_attr( auxin_get_option( 'blog_content_on_listing_length' ) ),
1477 'show_info' => true,
1478 'author_or_readmore' => 'readmore',
1479 'desktop_cnum' => esc_attr( auxin_get_option( 'post_index_column_number' ) ),
1480 'tablet_cnum' => esc_attr( auxin_get_option( 'post_index_column_number_tablet' ) ),
1481 'phone_cnum' => esc_attr( auxin_get_option( 'post_index_column_number_mobile' ) ),
1482 'tag' => '',
1483 'extra_classes' => '',
1484 'custom_el_id' => '',
1485 'reset_query' => false,
1486 'use_wp_query' => true,
1487 );
1488
1489 $result = auxin_widget_recent_posts_masonry_callback( $args );
1490
1491 // if template type is tiles
1492 } elseif( 9 == $template_type_id ){
1493
1494 $args = array(
1495 'exclude_without_media' => esc_attr( auxin_get_option( 'exclude_without_media' ) ),
1496 'exclude_custom_post_formats' => 0,
1497 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 1 ) ),
1498 'show_media' => true,
1499 'show_excerpt' => true,
1500 'excerpt_len' => esc_attr( auxin_get_option( 'blog_content_on_listing_length' ) ),
1501 'display_title' => true,
1502 'show_info' => true,
1503 'author_or_readmore' => 'readmore',
1504 'tag' => '',
1505 'extra_classes' => '',
1506 'custom_el_id' => '',
1507 'reset_query' => false,
1508 'use_wp_query' => true
1509 );
1510
1511 $result = auxin_widget_recent_posts_tiles_callback( $args );
1512
1513 // if template type is land
1514 } elseif( 8 == $template_type_id ){
1515
1516 $args = array(
1517 'exclude_without_media' => esc_attr( auxin_get_option( 'exclude_without_media' ) ),
1518 'exclude_custom_post_formats' => 0,
1519 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 1 ) ),
1520 'show_media' => true,
1521 'display_like' => esc_attr( auxin_get_option( 'show_blog_archive_like_button', 1 ) ),
1522 'show_excerpt' => true,
1523 'excerpt_len' => esc_attr( auxin_get_option( 'blog_content_on_listing_length' ) ),
1524 'display_title' => true,
1525 'show_info' => true,
1526 'author_or_readmore' => 'readmore',
1527 'image_aspect_ratio' => esc_attr( auxin_get_option( 'post_image_aspect_ratio' ) ),
1528 'tag' => '',
1529 'extra_classes' => '',
1530 'custom_el_id' => '',
1531 'reset_query' => false,
1532 'use_wp_query' => true
1533 );
1534
1535 $result = auxin_widget_recent_posts_land_style_callback( $args );
1536
1537 // if template type is timeline
1538 } elseif( 7 == $template_type_id ){
1539
1540 $args = array(
1541 'exclude_without_media' => esc_attr( auxin_get_option( 'exclude_without_media' ) ),
1542 'exclude_custom_post_formats' => 0,
1543 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 1 ) ),
1544 'show_media' => true,
1545 'display_like' => esc_attr( auxin_get_option( 'show_blog_archive_like_button', 1 ) ),
1546 'show_excerpt' => true,
1547 'excerpt_len' => esc_attr( auxin_get_option( 'blog_content_on_listing_length' ) ),
1548 'display_title' => true,
1549 'show_info' => true,
1550 'author_or_readmore' => 'readmore',
1551 'image_aspect_ratio' => esc_attr( auxin_get_option( 'post_image_aspect_ratio' ) ),
1552 'timeline_alignment' => esc_attr( auxin_get_option( 'post_index_timeline_alignment', 'center' ) ),
1553 'tag' => '',
1554 'reset_query' => false,
1555 'use_wp_query' => true
1556 );
1557
1558 $result = auxin_widget_recent_posts_timeline_callback( $args );
1559
1560 // if template type is grid
1561 } elseif( 5 == $template_type_id ){
1562
1563 $args = array(
1564 'exclude_without_media' => esc_attr( auxin_get_option( 'exclude_without_media' ) ),
1565 'exclude_custom_post_formats' => 0,
1566 'exclude_quote_link' => esc_attr( auxin_get_option( 'post_exclude_quote_link_formats', 1 ) ),
1567 'show_media' => true,
1568 'show_excerpt' => true,
1569 'show_info' => esc_attr( auxin_get_option( 'display_post_info', 1 ) ),
1570 'post_info_position' => esc_attr( auxin_get_option( 'post_info_position', 'after-title' ) ),
1571 'show_date' => true,
1572 'display_categories' => esc_attr( auxin_get_option( 'display_post_info_categories', 1 ) ),
1573 'display_like' => esc_attr( auxin_get_option( 'show_blog_archive_like_button', 1 ) ),
1574 'content_layout' => esc_attr( auxin_get_option( 'post_index_column_content_layout', 'full' ) ),
1575 'excerpt_len' => esc_attr( auxin_get_option( 'blog_content_on_listing_length' ) ),
1576 'display_title' => true,
1577 'author_or_readmore' => 'readmore',
1578 'image_aspect_ratio' => esc_attr( auxin_get_option( 'post_image_aspect_ratio' ) ),
1579 'desktop_cnum' => esc_attr( auxin_get_option( 'post_index_column_number' ) ),
1580 'tablet_cnum' => esc_attr( auxin_get_option( 'post_index_column_number_tablet' ) ),
1581 'phone_cnum' => esc_attr( auxin_get_option( 'post_index_column_number_mobile' ) ),
1582 'preview_mode' => 'grid',
1583 'tag' => '',
1584 'reset_query' => false,
1585 'use_wp_query' => true
1586 );
1587
1588 $result = auxin_widget_recent_posts_callback( $args );
1589 }
1590
1591 return $result;
1592 }
1593
1594 add_filter( 'auxin_blog_archive_custom_template_layouts', 'auxels_add_blog_archive_custom_template_layouts', 10, 2 );
1595
1596
1597 /*-----------------------------------------------------------------------------------*/
1598 /* Add Boxed layout to siteorigin row layout types
1599 /*-----------------------------------------------------------------------------------*/
1600
1601 function auxin_so_row_style_attributes( $attributes, $style ){
1602
1603 if ( ! empty( $style['row_stretch'] ) && 'boxed' === $style['row_stretch'] ) {
1604 if( ( $key = array_search( 'siteorigin-panels-stretch', $attributes['class'] ) ) !== false ) {
1605 unset( $attributes['class'][ $key ] );
1606 }
1607 $attributes['class'][] = 'aux-fold';
1608 }
1609
1610 return $attributes;
1611 }
1612 add_filter( 'siteorigin_panels_row_style_attributes', 'auxin_so_row_style_attributes', 12, 2 );
1613
1614 /*-----------------------------------------------------------------------------------*/
1615 /* Add Boxed layout to siteorigin row layout types
1616 /*-----------------------------------------------------------------------------------*/
1617
1618 function auxin_so_row_style_fields( $fields ){
1619 $fields['row_stretch']['options']['boxed'] = __( 'Boxed', 'auxin-elements' );
1620
1621 return $fields;
1622 }
1623 add_filter( 'siteorigin_panels_row_style_fields', 'auxin_so_row_style_fields', 15 );
1624
1625 /*-----------------------------------------------------------------------------------*/
1626 /* Filtering wp_title to improve seo and letting seo plugins to filter the output too
1627 /*-----------------------------------------------------------------------------------*/
1628
1629 if( ! defined( 'WPSEO_VERSION') ){
1630
1631 function auxin_wp_title($title, $sep, $seplocation) {
1632 global $page, $paged, $post;
1633
1634 // Don't affect feeds
1635 if ( is_feed() ) return $title;
1636
1637 // Add the blog name
1638 if ( 'right' == $seplocation )
1639 $title .= get_bloginfo( 'name' );
1640 else
1641 $title = get_bloginfo( 'name' ) . $title;
1642
1643 // Add the blog description for the home/front page
1644 $site_description = get_bloginfo( 'description', 'display' );
1645 if ( $site_description && ( is_home() || is_front_page() ) )
1646 $title .= " $sep $site_description";
1647
1648 // Add a page number if necessary
1649 if ( $paged >= 2 || $page >= 2 )
1650 $title .= " $sep " . sprintf( __( 'Page %s', 'auxin-elements'), max( $paged, $page ) );
1651
1652 return $title;
1653 }
1654
1655 add_filter( 'wp_title', 'auxin_wp_title', 10, 3 );
1656 }
1657