-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
233 lines (163 loc) · 6.45 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?php
//
// Recommended way to include parent theme styles.
// (Please see http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme)
//
function sanosan_enqueue_styles() {
wp_enqueue_style( 'sanosan-parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'sanosan-style',
get_stylesheet_directory_uri() . '/style.css',
array('parent-style')
);
/**
* Theme Front end main js
* 'jquery', 'carousel' , 'sed-livequery' , 'jquery-ui-accordion' , 'jquery-ui-tabs'
*/
wp_enqueue_script( "sanosan-script-js" , get_stylesheet_directory_uri() . '/assets/js/script.js' , array( 'jquery', 'carousel' , 'sed-livequery' , 'jquery-ui-accordion' ) , "1.0.0" , true );
//wp_enqueue_script('sed-masonry');
//wp_enqueue_script('lightbox');
//wp_enqueue_script('jquery-scrollbar');
//wp_enqueue_style('custom-scrollbar');
wp_enqueue_style("carousel");
//wp_enqueue_style("lightbox");
}
add_action( 'wp_enqueue_scripts', 'sanosan_enqueue_styles' , 0 );
add_action( 'after_setup_theme', 'sed_sanosan_theme_setup' );
function sed_sanosan_theme_setup() {
load_child_theme_textdomain( 'sanosan', get_stylesheet_directory() . '/languages' );
remove_filter( 'excerpt_more', 'twentyseventeen_excerpt_more' );
/**
* Short Description (excerpt).
*/
add_filter( 'sanosan_short_description', 'wptexturize' );
add_filter( 'sanosan_short_description', 'convert_smilies' );
add_filter( 'sanosan_short_description', 'convert_chars' );
add_filter( 'sanosan_short_description', 'wpautop' );
add_filter( 'sanosan_short_description', 'shortcode_unautop' );
add_filter( 'sanosan_short_description', 'prepend_attachment' );
add_filter( 'sanosan_short_description', 'do_shortcode', 11 ); // AFTER wpautop()
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'services' => __( 'Services Menu', 'twentyseventeen' ),
) );
}
function sanosan_excerpt_more( $link ) {
if ( is_admin() ) {
return $link;
}
return ' … ';
}
add_filter( 'excerpt_more', 'sanosan_excerpt_more' );
function sanosan_excerpt_length( $length ) {
return 650;
}
add_filter( 'excerpt_length', 'sanosan_excerpt_length', 999 );
/**
* Add Site Editor Modules
*
* @param $modules
* @return mixed
*/
function sed_sanosan_add_modules( $modules ){
global $sed_pb_modules;
$module_name = "themes/sanosan/site-editor/modules/posts/posts.php";
$modules[$module_name] = $sed_pb_modules->get_module_data(get_stylesheet_directory() . '/site-editor/modules/posts/posts.php', true, true);
return $modules;
}
add_filter("sed_modules" , "sed_sanosan_add_modules" );
function sanosan_register_theme_fields( $fields ){
/* $fields['products_archive_description'] = array(
'type' => 'textarea',
'label' => __('Product Archive Description', 'site-editor'),
//'description' => '',
'transport' => 'postMessage' ,
'setting_id' => 'sanosan_products_archive_description',
'default' => '',
"panel" => "general_settings" ,
);
$fields['home_page_products_description'] = array(
'type' => 'textarea',
'label' => __('Home Page Product Description', 'site-editor'),
//'description' => '',
'transport' => 'postMessage' ,
'setting_id' => 'sanosan_home_page_products_description',
'default' => '',
"panel" => "general_settings" ,
);
$locale = get_locale();
if( $locale == 'fa_IR' ) {
$fields['english_site_url'] = array(
'type' => 'text',
'label' => __('English Site Url', 'site-editor'),
//'description' => '',
'transport' => 'postMessage',
'setting_id' => 'sanosan_english_site_url',
'default' => 'http://eng.sanosan.com',
"panel" => "general_settings",
);
}
$fields[ 'intro_logo' ] = array(
'setting_id' => 'sanosan_intro_logo',
'label' => __('Intro Logo', 'translation_domain'),
'type' => 'image',
//'priority' => 10,
'default' => '',
'transport' => 'postMessage' ,
'panel' => 'general_settings'
);*/
return $fields;
}
//add_filter( "sed_theme_options_fields_filter" , 'sanosan_register_theme_fields' , 10000 );
add_action( 'pre_get_posts', 'sanosan_per_page_query' );
/**
* Customize category query using pre_get_posts.
*
* @author FAT Media <http://youneedfat.com>
* @copyright Copyright (c) 2013, FAT Media, LLC
* @license GPL-2.0+
* @todo Change prefix to theme or plugin prefix
*
*/
function sanosan_per_page_query( $query ) {
/*$is_blog = ( is_home() && is_front_page() ) || ( is_home() && !is_front_page() );
if ( $query->is_main_query() && ! $query->is_feed() && ! is_admin() && ( is_category() || is_tag() || $is_blog ) ) {
$query->set( 'posts_per_page', '2' ); //Change this number to anything you like.
}*/
if ( $query->is_main_query() && ! $query->is_feed() && ! is_admin() && is_post_type_archive('sano_faq') ) {
$query->set( 'posts_per_page', '100' ); //Change this number to anything you like.
}
}
function sanosan_product_wishlist( $atts ) {
/*$atts = shortcode_atts( array(
'foo' => 'no foo',
'baz' => 'default baz'
), $atts, 'bartag' );*/
$tg_el = The_Grid_Elements();
return $tg_el->get_product_wishlist();
}
add_shortcode( 'sanosan_wishlist', 'sanosan_product_wishlist' );
/**
* Search & Filter Pro Update mata fields before render
*
* @param $input_object
* @param $sfid
* @return mixed
*/
function filter_function_name($input_object, $sfid){
if( $input_object['name'] == '_sfm_agancy_brand' ) {
//var_dump( $input_object );//udpate this field before rendering
$options = $input_object['options'];
foreach ( $options AS $key => $option ){
$post_id = (int) $option->value;
if( $post_id ) {
$input_object['options'][$key]->label = get_the_title($post_id);
}
}
}
return $input_object;
}
add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);
/**
* Site Editor Shop WooCommerce
*/
require dirname(__FILE__) . '/inc/woocommerce.php';