Version Description
Download this release
Release Info
Developer | adbox |
Plugin | WordPress Landing Pages |
Version | 1.6.1 |
Comparing to | |
See all releases |
Code changes from version 1.5.9 to 1.6.1
- landing-pages.php +2 -2
- readme.txt +1 -1
- shared/classes/class.form.php +2 -3
- shared/classes/class.load-shared.php +3 -3
- shared/classes/class.post-type.wp-lead.php +350 -303
landing-pages.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Landing Pages
|
4 |
Plugin URI: http://www.inboundnow.com/landing-pages/
|
5 |
Description: The first true all-in-one Landing Page solution for WordPress, including ongoing conversion metrics, a/b split testing, unlimited design options and so much more!
|
6 |
-
Version: 1.
|
7 |
Author: Inbound Now
|
8 |
Author URI: http://www.inboundnow.com/
|
9 |
Text Domain: landing-pages
|
@@ -38,7 +38,7 @@ if (!class_exists('Inbound_Landing_Pages_Plugin')) {
|
|
38 |
*/
|
39 |
private static function load_constants() {
|
40 |
|
41 |
-
define('LANDINGPAGES_CURRENT_VERSION', '1.
|
42 |
define('LANDINGPAGES_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
43 |
define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
44 |
define('LANDINGPAGES_PLUGIN_SLUG', plugin_basename( dirname(__FILE__) ) );
|
3 |
Plugin Name: Landing Pages
|
4 |
Plugin URI: http://www.inboundnow.com/landing-pages/
|
5 |
Description: The first true all-in-one Landing Page solution for WordPress, including ongoing conversion metrics, a/b split testing, unlimited design options and so much more!
|
6 |
+
Version: 1.6.1
|
7 |
Author: Inbound Now
|
8 |
Author URI: http://www.inboundnow.com/
|
9 |
Text Domain: landing-pages
|
38 |
*/
|
39 |
private static function load_constants() {
|
40 |
|
41 |
+
define('LANDINGPAGES_CURRENT_VERSION', '1.6.1' );
|
42 |
define('LANDINGPAGES_URLPATH', WP_PLUGIN_URL.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
43 |
define('LANDINGPAGES_PATH', WP_PLUGIN_DIR.'/'.plugin_basename( dirname(__FILE__) ).'/' );
|
44 |
define('LANDINGPAGES_PLUGIN_SLUG', plugin_basename( dirname(__FILE__) ) );
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
7 |
Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
|
8 |
Requires at least: 3.8
|
9 |
Tested up to: 3.9
|
10 |
-
Stable Tag: 1.
|
11 |
|
12 |
Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
|
13 |
|
7 |
Tags: landing pages, inbound marketing, conversion pages, split testing, a b test, a b testing, a/b test, a/b testing, coming soon page, email list, landing page, list building, maintenance page, squeeze page, inbound now, landing-pages, splash pages, cpa, click tracking, goal tracking, analytics, free landing page templates
|
8 |
Requires at least: 3.8
|
9 |
Tested up to: 3.9
|
10 |
+
Stable Tag: 1.6.1
|
11 |
|
12 |
Create landing pages for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own templates and more.
|
13 |
|
shared/classes/class.form.php
CHANGED
@@ -821,11 +821,11 @@ class Inbound_Forms {
|
|
821 |
$field = "wpleads_email_address";
|
822 |
}
|
823 |
|
824 |
-
if (preg_match( '/(?<!((last |last_)))name(?!\=)/im', $field) && !isset($
|
825 |
$field = "wpleads_first_name";
|
826 |
}
|
827 |
|
828 |
-
if (preg_match( '/(?<!((first)))(last name|last_name|last)(?!\=)/im', $field) && !isset($
|
829 |
$field = "wpleads_last_name";
|
830 |
}
|
831 |
|
@@ -836,7 +836,6 @@ class Inbound_Forms {
|
|
836 |
$form_post_data[$field] = strip_tags( $value );
|
837 |
}
|
838 |
|
839 |
-
|
840 |
$form_meta_data['post_id'] = $_POST['inbound_form_id']; // pass in form id
|
841 |
|
842 |
/* Send emails if passes spam checks - spam checks happen on lead store ajax script and here on the email actions script - redundantly */
|
821 |
$field = "wpleads_email_address";
|
822 |
}
|
823 |
|
824 |
+
if (preg_match( '/(?<!((last |last_)))name(?!\=)/im', $field) && !isset($form_post_data['wpleads_first_name'])) {
|
825 |
$field = "wpleads_first_name";
|
826 |
}
|
827 |
|
828 |
+
if (preg_match( '/(?<!((first)))(last name|last_name|last)(?!\=)/im', $field) && !isset($form_post_data['wpleads_last_name'])) {
|
829 |
$field = "wpleads_last_name";
|
830 |
}
|
831 |
|
836 |
$form_post_data[$field] = strip_tags( $value );
|
837 |
}
|
838 |
|
|
|
839 |
$form_meta_data['post_id'] = $_POST['inbound_form_id']; // pass in form id
|
840 |
|
841 |
/* Send emails if passes spam checks - spam checks happen on lead store ajax script and here on the email actions script - redundantly */
|
shared/classes/class.load-shared.php
CHANGED
@@ -98,11 +98,11 @@ if (!class_exists('Inbound_Load_Shared')) {
|
|
98 |
*
|
99 |
*/
|
100 |
public static function get_shared_urlpath() {
|
101 |
-
if ( defined('
|
102 |
return WP_CTA_URLPATH . 'shared/';
|
103 |
-
} else if ( defined('
|
104 |
return LANDINGPAGES_URLPATH . '/shared/';
|
105 |
-
} else if ( defined('
|
106 |
return WPL_URLPATH . '/shared/';
|
107 |
}
|
108 |
}
|
98 |
*
|
99 |
*/
|
100 |
public static function get_shared_urlpath() {
|
101 |
+
if ( defined('WP_CTA_URLPATH') ) {
|
102 |
return WP_CTA_URLPATH . 'shared/';
|
103 |
+
} else if ( defined('LANDINGPAGES_URLPATH') ) {
|
104 |
return LANDINGPAGES_URLPATH . '/shared/';
|
105 |
+
} else if ( defined('WPL_URLPATH') ) {
|
106 |
return WPL_URLPATH . '/shared/';
|
107 |
}
|
108 |
}
|
shared/classes/class.post-type.wp-lead.php
CHANGED
@@ -1,304 +1,351 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
if ( !class_exists('Inbound_Leads') ) {
|
5 |
-
|
6 |
-
class Inbound_Leads {
|
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 |
-
* @returns ARRAY of lead lists with term id as key and list name as value
|
202 |
-
*/
|
203 |
-
public static function
|
204 |
-
|
205 |
-
$args = array(
|
206 |
-
'hide_empty' => false,
|
207 |
-
);
|
208 |
-
|
209 |
-
$terms =
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
}
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
*
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
*
|
247 |
-
*
|
248 |
-
*
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
public static function
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
$
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
if ( !class_exists('Inbound_Leads') ) {
|
5 |
+
|
6 |
+
class Inbound_Leads {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initalize Inbound_Leads class
|
10 |
+
*/
|
11 |
+
function __construct() {
|
12 |
+
self::load_hooks();
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Load action hooks & filters
|
17 |
+
*/
|
18 |
+
private function load_hooks() {
|
19 |
+
/* Register Leads Post Type */
|
20 |
+
add_action( 'init' , array( __CLASS__ , 'register_post_type' ));
|
21 |
+
add_action( 'init' , array( __CLASS__ , 'register_taxonomies' ));
|
22 |
+
|
23 |
+
if (is_admin()) {
|
24 |
+
add_action( 'edit_form_after_title', array( __CLASS__ , 'install_leads_prompt' ) );
|
25 |
+
|
26 |
+
/* Remove lead tags menu item */
|
27 |
+
add_filter( 'admin_menu' , array( __CLASS__ , 'remove_menus' ) );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
/**
|
31 |
+
* Register wp-lead post type
|
32 |
+
*/
|
33 |
+
public static function register_post_type() {
|
34 |
+
$lead_active = get_option( 'Leads_Activated' ); // Check if leads is activated
|
35 |
+
|
36 |
+
$labels = array(
|
37 |
+
'name' => _x('Leads', 'post type general name'),
|
38 |
+
'singular_name' => _x('Lead', 'post type singular name'),
|
39 |
+
'add_new' => _x('Add New', 'Lead'),
|
40 |
+
'add_new_item' => __('Add New Lead'),
|
41 |
+
'edit_item' => __('Edit Lead'),
|
42 |
+
'new_item' => __('New Leads'),
|
43 |
+
'view_item' => __('View Leads'),
|
44 |
+
'search_items' => __('Search Leads'),
|
45 |
+
'not_found' => __('Nothing found'),
|
46 |
+
'not_found_in_trash' => __('Nothing found in Trash'),
|
47 |
+
'parent_item_colon' => ''
|
48 |
+
);
|
49 |
+
|
50 |
+
$args = array(
|
51 |
+
'labels' => $labels,
|
52 |
+
'public' => false,
|
53 |
+
'publicly_queryable' => true,
|
54 |
+
'show_ui' => true,
|
55 |
+
'query_var' => true,
|
56 |
+
'menu_icon' => INBOUDNOW_SHARED_URLPATH . 'assets/global/images/leads.png',
|
57 |
+
'capability_type' => 'post',
|
58 |
+
'hierarchical' => false,
|
59 |
+
'menu_position' => null,
|
60 |
+
'supports' => array('custom-fields','thumbnail')
|
61 |
+
);
|
62 |
+
|
63 |
+
$args['show_in_menu'] = ($lead_active) ? true : false;
|
64 |
+
|
65 |
+
register_post_type( 'wp-lead' , $args );
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Register Category Taxonomy
|
71 |
+
*/
|
72 |
+
public static function register_taxonomies() {
|
73 |
+
|
74 |
+
/* Register lead lists */
|
75 |
+
$list_labels = array(
|
76 |
+
'name' => __( 'Lead Lists', 'leads' ),
|
77 |
+
'singular_name' => __( 'Lead List', 'leads' ),
|
78 |
+
'search_items' => __( 'Search Lead Lists' , 'leads' ),
|
79 |
+
'popular_items' => __( 'Popular Lead Lists' , 'leads' ),
|
80 |
+
'all_items' => __( 'All Lead Lists' , 'leads' ),
|
81 |
+
'parent_item' => null,
|
82 |
+
'parent_item_colon' => null,
|
83 |
+
'edit_item' => __( 'Edit Lead List' , 'leads' ),
|
84 |
+
'update_item' => __( 'Update Lead List' , 'leads' ),
|
85 |
+
'add_new_item' => __( 'Add New Lead List' , 'leads' ),
|
86 |
+
'new_item_name' => __( 'New Lead List' , 'leads' ),
|
87 |
+
'separate_items_with_commas' => __( 'Separate Lead Lists with commas' , 'leads' ),
|
88 |
+
'add_or_remove_items' => __( 'Add or remove Lead Lists' , 'leads' ),
|
89 |
+
'choose_from_most_used' => __( 'Choose from the most used lead List' , 'leads' ),
|
90 |
+
'not_found' => __( 'No Lead Lists found.' , 'leads' ),
|
91 |
+
'menu_name' => __( 'Lead Lists' , 'leads' ),
|
92 |
+
);
|
93 |
+
|
94 |
+
$list_args = array(
|
95 |
+
'hierarchical' => true,
|
96 |
+
'labels' => $list_labels,
|
97 |
+
'singular_label' => __( 'List Management' , 'leads' ),
|
98 |
+
'show_ui' => true,
|
99 |
+
'show_in_menu' => true,
|
100 |
+
'show_in_nav_menus' => false,
|
101 |
+
'show_admin_column' => true,
|
102 |
+
'query_var' => true,
|
103 |
+
'rewrite' => false,
|
104 |
+
);
|
105 |
+
|
106 |
+
register_taxonomy('wplead_list_category','wp-lead', $list_args );
|
107 |
+
|
108 |
+
/* Register Lead Tags Taxonomy */
|
109 |
+
$labels = array(
|
110 |
+
'name' => _x( 'Lead Tags', 'taxonomy general name' ),
|
111 |
+
'singular_name' => _x( 'Lead Tag', 'taxonomy singular name' ),
|
112 |
+
'search_items' => __( 'Search Lead Tags' ),
|
113 |
+
'popular_items' => __( 'Popular Lead Tags' ),
|
114 |
+
'all_items' => __( 'All Lead Tags' ),
|
115 |
+
'parent_item' => null,
|
116 |
+
'parent_item_colon' => null,
|
117 |
+
'edit_item' => __( 'Edit Lead Tag' ),
|
118 |
+
'update_item' => __( 'Update Lead Tag' ),
|
119 |
+
'add_new_item' => __( 'Add New Lead Tag' ),
|
120 |
+
'new_item_name' => __( 'New Lead Tag' ),
|
121 |
+
'separate_items_with_commas'=> __( 'Separate Lead Tags with commas' ),
|
122 |
+
'add_or_remove_items' => __( 'Add or remove Lead Tags' ),
|
123 |
+
'choose_from_most_used' => __( 'Choose from the most used lead tags' ),
|
124 |
+
'not_found' => __( 'No lead tags found.' ),
|
125 |
+
'menu_name' => __( 'Lead Tags' ),
|
126 |
+
);
|
127 |
+
|
128 |
+
$args = array(
|
129 |
+
'hierarchical' => false,
|
130 |
+
'labels' => $labels,
|
131 |
+
'show_ui' => true,
|
132 |
+
'show_admin_column' => true,
|
133 |
+
'show_in_menus' => false,
|
134 |
+
'show_in_nav_menus' => false,
|
135 |
+
'update_count_callback' => '_update_post_term_count',
|
136 |
+
'query_var' => true,
|
137 |
+
'rewrite' => array( 'slug' => 'lead-tag' ),
|
138 |
+
);
|
139 |
+
|
140 |
+
register_taxonomy( 'lead-tags', 'wp-lead', $args );
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Make sure that all list ids are intval
|
145 |
+
*
|
146 |
+
* @param MIXED $lists
|
147 |
+
* @return ARRAY
|
148 |
+
*
|
149 |
+
*/
|
150 |
+
public static function intval_list_ids( $lists ) {
|
151 |
+
|
152 |
+
if (is_array($lists)) {
|
153 |
+
foreach ($lists as $key => $id) {
|
154 |
+
$lists[ $key ] = intval($id);
|
155 |
+
}
|
156 |
+
} else {
|
157 |
+
$lists = intval( $list_id );
|
158 |
+
}
|
159 |
+
|
160 |
+
return $lists;
|
161 |
+
}
|
162 |
+
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Adds lead to list
|
166 |
+
*
|
167 |
+
* @param lead_id INT
|
168 |
+
* @param list_id MIXED INT,ARRAY
|
169 |
+
*
|
170 |
+
*/
|
171 |
+
public static function add_lead_to_list( $lead_id , $list_id ) {
|
172 |
+
|
173 |
+
/* intval list ids */
|
174 |
+
$list_id = Inbound_Leads::intval_list_ids( $list_id );
|
175 |
+
|
176 |
+
wp_set_object_terms( $lead_id, $list_id , 'wplead_list_category', true );
|
177 |
+
do_action('add_lead_to_lead_list' , $lead_id , $list_id );
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Removes lead from list
|
183 |
+
*
|
184 |
+
* @param lead_id INT
|
185 |
+
* @param list_id MIXED INT, ARRAY
|
186 |
+
*
|
187 |
+
*/
|
188 |
+
public static function remove_lead_from_list( $lead_id , $list_id ) {
|
189 |
+
/* intval list ids */
|
190 |
+
$list_id = Inbound_Leads::intval_list_ids( $list_id );
|
191 |
+
|
192 |
+
wp_remove_object_terms( $lead_id, $list_id , 'wplead_list_category', true );
|
193 |
+
do_action('remove_lead_from_list' , $lead_id , $list_id );
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Get an array of all lead lists belonging to lead id
|
198 |
+
*
|
199 |
+
* @param INT $lead_id ID of lead
|
200 |
+
*
|
201 |
+
* @returns ARRAY of lead lists with term id as key and list name as value
|
202 |
+
*/
|
203 |
+
public static function get_lead_lists_by_lead_id( $lead_id ) {
|
204 |
+
|
205 |
+
$args = array(
|
206 |
+
'hide_empty' => false,
|
207 |
+
);
|
208 |
+
|
209 |
+
$terms = get_the_terms( $lead_id , 'wplead_list_category' );
|
210 |
+
|
211 |
+
if (!$terms) {
|
212 |
+
return array();
|
213 |
+
}
|
214 |
+
|
215 |
+
foreach ( $terms as $term ) {
|
216 |
+
$array[$term->term_id] = $term->name;
|
217 |
+
}
|
218 |
+
|
219 |
+
return $array;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Get an array of all lead lists
|
224 |
+
*
|
225 |
+
* @returns ARRAY of lead lists with term id as key and list name as value
|
226 |
+
*/
|
227 |
+
public static function get_lead_lists_as_array() {
|
228 |
+
|
229 |
+
$args = array(
|
230 |
+
'hide_empty' => false,
|
231 |
+
);
|
232 |
+
|
233 |
+
$terms = get_terms('wplead_list_category', $args);
|
234 |
+
|
235 |
+
foreach ( $terms as $term ) {
|
236 |
+
$array[$term->term_id] = $term->name;
|
237 |
+
}
|
238 |
+
|
239 |
+
return $array;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Get lead list infomration
|
244 |
+
*
|
245 |
+
* @param STRING $search accepts 'id' , 'slug' , 'name' or 'term_taxonomy_id'
|
246 |
+
* @param INT $list_id
|
247 |
+
*
|
248 |
+
* @returns ARRAY
|
249 |
+
*/
|
250 |
+
public static function get_lead_list_by( $search , $list_id ) {
|
251 |
+
return get_term_by( $search , $list_id , 'wplead_list_category', ARRAY_A);
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Adds tag to lead
|
256 |
+
*
|
257 |
+
* @param lead_id INT
|
258 |
+
* @param tag_id MIXED INT, STRING, ARRAY
|
259 |
+
*
|
260 |
+
*/
|
261 |
+
public static function add_tag_to_lead( $lead_id , $list_id ) {
|
262 |
+
wp_set_object_terms( $lead_id, $list_id , 'lead-tags', true );
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Remove tag from lead
|
267 |
+
*
|
268 |
+
* @param lead_id INT
|
269 |
+
* @param tag_id MIXED INT,STRING,ARRAY
|
270 |
+
*
|
271 |
+
*/
|
272 |
+
public static function remove_tag_from_lead( $lead_id , $list_id ) {
|
273 |
+
wp_remove_object_terms( $lead_id, $list_id , 'lead-tags', true );
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Shows message to install leads when leads is not installed or activated
|
278 |
+
*
|
279 |
+
*/
|
280 |
+
public static function install_leads_prompt() {
|
281 |
+
global $post;
|
282 |
+
|
283 |
+
if ( empty ( $post ) || 'wp-lead' !== get_post_type( $GLOBALS['post'] ) ) {
|
284 |
+
return;
|
285 |
+
}
|
286 |
+
|
287 |
+
if (!is_plugin_active('leads/wordpress-leads.php')) {
|
288 |
+
_e( 'WordPress Leads is not currently installed/activated to view and manage leads please turn it on.' , 'leads' );
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Gets number of leads in list
|
294 |
+
*
|
295 |
+
* @param list_id INT of lead list taxonomy object
|
296 |
+
*
|
297 |
+
*/
|
298 |
+
public static function get_leads_count_in_list( $list_id ) {
|
299 |
+
|
300 |
+
$query = new WP_Query( array(
|
301 |
+
'post_type' => 'wp-lead',
|
302 |
+
'tax_query' => array (
|
303 |
+
'relation' => 'AND',
|
304 |
+
array (
|
305 |
+
'taxonomy' => 'wplead_list_category' ,
|
306 |
+
'field' => 'id' ,
|
307 |
+
'terms' => array( $list_id )
|
308 |
+
)
|
309 |
+
),
|
310 |
+
'posts_per_page' => -1
|
311 |
+
) );
|
312 |
+
|
313 |
+
$count = $query->post_count;
|
314 |
+
|
315 |
+
return sprintf( __( '%d leads' , 'leads' ) , $count );
|
316 |
+
|
317 |
+
}
|
318 |
+
|
319 |
+
public static function remove_menus() {
|
320 |
+
global $submenu;
|
321 |
+
|
322 |
+
if (!current_user_can('activate_plugins') ) {
|
323 |
+
return;
|
324 |
+
}
|
325 |
+
|
326 |
+
//print_r($submenu);exit;
|
327 |
+
// This needs to be set to the URL for the admin menu section (aka "Menu Page")
|
328 |
+
$menu_page = 'edit.php?post_type=wp-lead';
|
329 |
+
|
330 |
+
// This needs to be set to the URL for the admin menu option to remove (aka "Submenu Page")
|
331 |
+
$taxonomy_admin_page = 'edit-tags.php?taxonomy=lead-tags&post_type=wp-lead';
|
332 |
+
|
333 |
+
if ( !isset($submenu[$menu_page]) ) {
|
334 |
+
return;
|
335 |
+
}
|
336 |
+
|
337 |
+
// This removes the menu option but doesn't disable the taxonomy
|
338 |
+
foreach($submenu[$menu_page] as $index => $submenu_item) {
|
339 |
+
if ($submenu_item[2]==$taxonomy_admin_page) {
|
340 |
+
unset($submenu[$menu_page][$index]);
|
341 |
+
}
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
}
|
346 |
+
|
347 |
+
/* Load Email Templates Post Type Pre Init */
|
348 |
+
add_action('init' , function() {
|
349 |
+
$GLOBALS['Inbound_Leads'] = new Inbound_Leads();
|
350 |
+
} , 9 );
|
351 |
}
|