wpsl.php
4.19 KB
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
<?php
/**
* Understrap emails
*
* @package Understrap
*/
// Exit if accessed directly.
add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' );
function custom_frontend_meta_fields( $store_fields ) {
$store_fields['wpsl_first_name'] = array(
'name' => 'first_name',
'type' => 'text'
);
$store_fields['wpsl_last_name'] = array(
'name' => 'last_name',
'type' => 'text'
);
$store_fields['wpsl_email'] = array(
'name' => 'email',
'type' => 'text'
);
$store_fields['wpsl_phone'] = array(
'name' => 'phone',
'type' => 'text'
);
$store_fields['wpsl_ext'] = array(
'name' => 'ext',
'type' => 'int'
);
$store_fields['wpsl_fp_id'] = array(
'name' => 'fp_id',
'type' => 'text'
);
$store_fields['wpsl_designation'] = array(
'name' => 'designation',
'type' => 'text'
);
$store_fields['wpsl_unit'] = array(
'name' => 'unit',
'type' => 'text'
);
return $store_fields;
}
add_filter( 'wpsl_meta_box_fields', 'custom_meta_box_fields2' );
function custom_meta_box_fields2( $meta_fields ) {
$meta_fields[__( 'Additional Information', 'wpsl' )] = array(
'phone' => array(
'label' => __( 'Tel', 'wpsl' )
),
'ext' => array(
'label' => __( 'Ext', 'wpsl' )
),
'unit' => array(
'label' => __( 'Unit', 'wpsl' )
),
'email' => array(
'label' => __( 'Email', 'wpsl' )
),
'url' => array(
'label' => __( 'Url', 'wpsl' )
),
'first_name' => array(
'label' => __( 'First Name', 'wpsl' )
),
'last_name' => array(
'label' => __( 'Last Name', 'wpsl' )
),
'designation' => array(
'label' => __( 'Designation', 'wpsl' )
),
'fp_id' => array(
'label' => __( 'FP ID', 'wpsl' )
)
);
return $meta_fields;
}
add_filter('wpsl_templates', 'custom_templates');
function custom_templates($templates)
{
$templates[] = array(
'id' => 'store',
'name' => 'Custom store template',
'path' => get_stylesheet_directory() . '/' . 'wpsl-templates/store-listings-map-left.php',
);
return $templates;
}
add_filter('wpsl_listing_template', 'custom_listing_template');
function custom_listing_template()
{
global $wpsl, $wpsl_settings;
include( get_stylesheet_directory() . '/' . 'wpsl-templates/store-listings.php');
return $listing_template;
}
add_filter('wpsl_store_header_template', 'custom_store_header_template');
function custom_store_header_template()
{
$header_template = '<% if ( wpslSettings.storeUrl == 1 && url ) { %>' . "\r\n";
$header_template .= '<a href="<%= url %>" target="_blank" class="placelink"><%= store %></a>' . "\r\n";
$header_template .= '<% } else { %>' . "\r\n";
$header_template .= '<%= store %>' . "\r\n";
$header_template .= '<% } %>';
return $header_template;
}
add_filter( 'wpsl_info_window_template', 'custom_info_window_template' );
function custom_info_window_template() {
include( get_stylesheet_directory() . '/' . 'wpsl-templates/store-custom_more_info.php');
return $info_window_template;
}
function delete_autoload_map_transient()
{
global $wpdb;
$option_names = $wpdb->get_results("SELECT option_name AS transient_name FROM " . $wpdb->options . " WHERE option_name LIKE ('\_transient\_wpsl\_autoload\_%')");
if ($option_names) {
foreach ($option_names as $option_name) {
$transient_name = str_replace("_transient_", "", $option_name->transient_name);
delete_transient($transient_name);
}
}
}
add_shortcode( 'count_stores', 'count_stores' );
function count_stores( ) {
$count_pages = wp_count_posts( 'wpsl_stores' );
return ' <h2 class="find-number" id="find-number">'.$count_pages->publish.'</h2>' ;
}
add_action("wp_ajax_nopriv_send_planner_notice", "send_planner_notice");
add_action("wp_ajax_send_planner_notice", "send_planner_notice");
add_filter( 'wpsl_include_post_content', '__return_true' );