WordPress Landing Pages - Version 1.6.1

Version Description

Download this release

Release Info

Developer adbox
Plugin Icon 128x128 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 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.5.9
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.5.9' );
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.5.9
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($form_data['first-name'])) {
825
  $field = "wpleads_first_name";
826
  }
827
 
828
- if (preg_match( '/(?<!((first)))(last name|last_name|last)(?!\=)/im', $field) && !isset($form_data['last-name'])) {
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('WP_CTA_PATH') ) {
102
  return WP_CTA_URLPATH . 'shared/';
103
- } else if ( defined('LANDINGPAGES_PATH') ) {
104
  return LANDINGPAGES_URLPATH . '/shared/';
105
- } else if ( defined('WPL_PATH') ) {
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
- function __construct() {
9
- self::load_hooks();
10
- }
11
-
12
- private function load_hooks() {
13
- /* Register Leads Post Type */
14
- add_action( 'init' , array( __CLASS__ , 'register_post_type' ));
15
- add_action( 'init' , array( __CLASS__ , 'register_taxonomies' ));
16
-
17
- if (is_admin()) {
18
- add_action( 'edit_form_after_title', array( __CLASS__ , 'install_leads_prompt' ) );
19
-
20
- /* Remove lead tags menu item */
21
- add_filter( 'admin_menu' , array( __CLASS__ , 'remove_menus' ) );
22
- }
23
- }
24
-
25
- public static function register_post_type() {
26
- $lead_active = get_option( 'Leads_Activated' ); // Check if leads is activated
27
-
28
- $labels = array(
29
- 'name' => _x('Leads', 'post type general name'),
30
- 'singular_name' => _x('Lead', 'post type singular name'),
31
- 'add_new' => _x('Add New', 'Lead'),
32
- 'add_new_item' => __('Add New Lead'),
33
- 'edit_item' => __('Edit Lead'),
34
- 'new_item' => __('New Leads'),
35
- 'view_item' => __('View Leads'),
36
- 'search_items' => __('Search Leads'),
37
- 'not_found' => __('Nothing found'),
38
- 'not_found_in_trash' => __('Nothing found in Trash'),
39
- 'parent_item_colon' => ''
40
- );
41
-
42
- $args = array(
43
- 'labels' => $labels,
44
- 'public' => false,
45
- 'publicly_queryable' => true,
46
- 'show_ui' => true,
47
- 'query_var' => true,
48
- 'menu_icon' => INBOUDNOW_SHARED_URLPATH . 'assets/global/images/leads.png',
49
- 'capability_type' => 'post',
50
- 'hierarchical' => false,
51
- 'menu_position' => null,
52
- 'supports' => array('custom-fields','thumbnail')
53
- );
54
-
55
- $args['show_in_menu'] = ($lead_active) ? true : false;
56
-
57
- register_post_type( 'wp-lead' , $args );
58
-
59
- }
60
-
61
- /* Register Category Taxonomy */
62
- public static function register_taxonomies() {
63
-
64
- /* Register lead lists */
65
- $list_labels = array(
66
- 'name' => __( 'Lead Lists', 'leads' ),
67
- 'singular_name' => __( 'Lead List', 'leads' ),
68
- 'search_items' => __( 'Search Lead Lists' , 'leads' ),
69
- 'popular_items' => __( 'Popular Lead Lists' , 'leads' ),
70
- 'all_items' => __( 'All Lead Lists' , 'leads' ),
71
- 'parent_item' => null,
72
- 'parent_item_colon' => null,
73
- 'edit_item' => __( 'Edit Lead List' , 'leads' ),
74
- 'update_item' => __( 'Update Lead List' , 'leads' ),
75
- 'add_new_item' => __( 'Add New Lead List' , 'leads' ),
76
- 'new_item_name' => __( 'New Lead List' , 'leads' ),
77
- 'separate_items_with_commas' => __( 'Separate Lead Lists with commas' , 'leads' ),
78
- 'add_or_remove_items' => __( 'Add or remove Lead Lists' , 'leads' ),
79
- 'choose_from_most_used' => __( 'Choose from the most used lead List' , 'leads' ),
80
- 'not_found' => __( 'No Lead Lists found.' , 'leads' ),
81
- 'menu_name' => __( 'Lead Lists' , 'leads' ),
82
- );
83
-
84
- $list_args = array(
85
- 'hierarchical' => true,
86
- 'labels' => $list_labels,
87
- 'singular_label' => __( 'List Management' , 'leads' ),
88
- 'show_ui' => true,
89
- 'show_in_menu' => true,
90
- 'show_in_nav_menus' => false,
91
- 'show_admin_column' => true,
92
- 'query_var' => true,
93
- 'rewrite' => false,
94
- );
95
-
96
- register_taxonomy('wplead_list_category','wp-lead', $list_args );
97
-
98
- /* Register Lead Tags Taxonomy */
99
- $labels = array(
100
- 'name' => _x( 'Lead Tags', 'taxonomy general name' ),
101
- 'singular_name' => _x( 'Lead Tag', 'taxonomy singular name' ),
102
- 'search_items' => __( 'Search Lead Tags' ),
103
- 'popular_items' => __( 'Popular Lead Tags' ),
104
- 'all_items' => __( 'All Lead Tags' ),
105
- 'parent_item' => null,
106
- 'parent_item_colon' => null,
107
- 'edit_item' => __( 'Edit Lead Tag' ),
108
- 'update_item' => __( 'Update Lead Tag' ),
109
- 'add_new_item' => __( 'Add New Lead Tag' ),
110
- 'new_item_name' => __( 'New Lead Tag' ),
111
- 'separate_items_with_commas'=> __( 'Separate Lead Tags with commas' ),
112
- 'add_or_remove_items' => __( 'Add or remove Lead Tags' ),
113
- 'choose_from_most_used' => __( 'Choose from the most used lead tags' ),
114
- 'not_found' => __( 'No lead tags found.' ),
115
- 'menu_name' => __( 'Lead Tags' ),
116
- );
117
-
118
- $args = array(
119
- 'hierarchical' => false,
120
- 'labels' => $labels,
121
- 'show_ui' => true,
122
- 'show_admin_column' => true,
123
- 'show_in_menus' => false,
124
- 'show_in_nav_menus' => false,
125
- 'update_count_callback' => '_update_post_term_count',
126
- 'query_var' => true,
127
- 'rewrite' => array( 'slug' => 'lead-tag' ),
128
- );
129
-
130
- register_taxonomy( 'lead-tags', 'wp-lead', $args );
131
- }
132
-
133
- /**
134
- * Make sure that all list ids are intval
135
- *
136
- * @param MIXED $lists
137
- * @return ARRAY
138
- *
139
- */
140
- public static function intval_list_ids( $lists ) {
141
-
142
- if (is_array($lists)) {
143
- foreach ($lists as $key => $id) {
144
- $lists[ $key ] = intval($id);
145
- }
146
- } else {
147
- $lists = intval( $list_id );
148
- }
149
-
150
- return $lists;
151
- }
152
-
153
-
154
- /*
155
- * Adds lead to list
156
- *
157
- * @param lead_id INT
158
- * @param list_id MIXED INT,ARRAY
159
- *
160
- */
161
- public static function add_lead_to_list( $lead_id , $list_id ) {
162
-
163
- /* intval list ids */
164
- $list_id = Inbound_Leads::intval_list_ids( $list_id );
165
-
166
- wp_set_object_terms( $lead_id, $list_id , 'wplead_list_category', true );
167
- do_action('add_lead_to_lead_list' , $lead_id , $list_id );
168
- }
169
-
170
-
171
- /*
172
- * Removes lead from list
173
- *
174
- * @param lead_id INT
175
- * @param list_id MIXED INT, ARRAY
176
- *
177
- */
178
- public static function remove_lead_from_list( $lead_id , $list_id ) {
179
- /* intval list ids */
180
- $list_id = Inbound_Leads::intval_list_ids( $list_id );
181
-
182
- wp_remove_object_terms( $lead_id, $list_id , 'wplead_list_category', true );
183
- do_action('remove_lead_from_list' , $lead_id , $list_id );
184
- }
185
-
186
-
187
- /*
188
- * Adds tag to lead
189
- *
190
- * @param lead_id INT
191
- * @param tag_id MIXED INT, STRING, ARRAY
192
- *
193
- */
194
- public static function add_tag_to_lead( $lead_id , $list_id ) {
195
- wp_set_object_terms( $lead_id, $list_id , 'lead-tags', true );
196
- }
197
-
198
- /*
199
- * Get an array of all lead lists
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_as_array() {
204
-
205
- $args = array(
206
- 'hide_empty' => false,
207
- );
208
-
209
- $terms = get_terms('wplead_list_category', $args);
210
-
211
- foreach ( $terms as $term ) {
212
- $array[$term->term_id] = $term->name;
213
- }
214
-
215
- return $array;
216
- }
217
-
218
- /*
219
- * Remove tag from lead
220
- *
221
- * @param lead_id INT
222
- * @param tag_id MIXED INT,STRING,ARRAY
223
- *
224
- */
225
- public static function remove_tag_from_lead( $lead_id , $list_id ) {
226
- wp_remove_object_terms( $lead_id, $list_id , 'lead-tags', true );
227
- }
228
-
229
- /*
230
- * Shows message to install leads when leads is not installed or activated
231
- *
232
- */
233
- public static function install_leads_prompt() {
234
- global $post;
235
-
236
- if ( empty ( $post ) || 'wp-lead' !== get_post_type( $GLOBALS['post'] ) ) {
237
- return;
238
- }
239
-
240
- if (!is_plugin_active('leads/wordpress-leads.php')) {
241
- _e( 'WordPress Leads is not currently installed/activated to view and manage leads please turn it on.' , 'leads' );
242
- }
243
- }
244
-
245
- /*
246
- * Gets number of leads in list
247
- *
248
- * @param list_id INT of lead list taxonomy object
249
- *
250
- */
251
- public static function get_leads_count_in_list( $list_id ) {
252
-
253
- $query = new WP_Query( array(
254
- 'post_type' => 'wp-lead',
255
- 'tax_query' => array (
256
- 'relation' => 'AND',
257
- array (
258
- 'taxonomy' => 'wplead_list_category' ,
259
- 'field' => 'id' ,
260
- 'terms' => array( $list_id )
261
- )
262
- ),
263
- 'posts_per_page' => -1
264
- ) );
265
-
266
- $count = $query->post_count;
267
-
268
- return sprintf( __( '%d leads' , 'leads' ) , $count );
269
-
270
- }
271
-
272
- public static function remove_menus() {
273
- global $submenu;
274
-
275
- if (!current_user_can('activate_plugins') ) {
276
- return;
277
- }
278
-
279
- //print_r($submenu);exit;
280
- // This needs to be set to the URL for the admin menu section (aka "Menu Page")
281
- $menu_page = 'edit.php?post_type=wp-lead';
282
-
283
- // This needs to be set to the URL for the admin menu option to remove (aka "Submenu Page")
284
- $taxonomy_admin_page = 'edit-tags.php?taxonomy=lead-tags&amp;post_type=wp-lead';
285
-
286
- if ( !isset($submenu[$menu_page]) ) {
287
- return;
288
- }
289
-
290
- // This removes the menu option but doesn't disable the taxonomy
291
- foreach($submenu[$menu_page] as $index => $submenu_item) {
292
- if ($submenu_item[2]==$taxonomy_admin_page) {
293
- unset($submenu[$menu_page][$index]);
294
- }
295
- }
296
- }
297
-
298
- }
299
-
300
- /* Load Email Templates Post Type Pre Init */
301
- add_action('init' , function() {
302
- $GLOBALS['Inbound_Leads'] = new Inbound_Leads();
303
- } , 9 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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&amp;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
  }