PluginProbe
IdeaPush / 1.16
IdeaPush v1.16
trunk 1.11 1.13 1.14 1.15 1.16 1.2 1.21 1.22 1.23 1.24 1.25 1.26 1.27 1.3 1.4 1.5 1.6 1.7 2.0 2.2 2.4 3.0 3.10 3.11 All 78 releases
ideapush / ideapush.php

ideapush.php in IdeaPush 1.16, at ideapush.php

1,125 lines 33.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Plugin Name: IdeaPush - Feature Request Manager
4 * Plugin URI: https://www.northernbeacheswebsites.com.au
5 * Description: IdeaPush is a feature request management system for WordPress
6 * Version: 1.16
7 * Author: Martin Gibson
8 * Text Domain: ideapush
9 * Support: https://www.northernbeacheswebsites.com.au/contact
10 * Licence: GPL2
11 */
12
13 // Assign global variables
14 global $ideapush_is_pro;
15 $ideapush_is_pro = "NO";
16
17
18 //the first YES/NO in the array is if the feature is pro, the second YES/NO in the array is if a save settings button is necessary
19 global $ideapush_pro_features;
20 $ideapush_pro_features = array('Boards' => array('NO','YES'),'Notifications' => array('NO','YES'), 'Statuses' => array('NO','YES'), 'Design' => array('NO','YES'), 'Idea Form' => array('NO','YES'), 'IdeaPush Support' => array('NO','NO'),'IdeaPush Pro' => array('YES','YES'));
21
22 //get plugin version number
23 function idea_push_plugin_get_version() {
24 if ( ! function_exists( 'get_plugins' ) )
25 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
26 $plugin_folder = get_plugins( '/' . plugin_basename( dirname( __FILE__ ) ) );
27 $plugin_file = basename( ( __FILE__ ) );
28 return $plugin_folder[$plugin_file]['Version'];
29 }
30
31
32 function idea_push_create_custom_post_type() {
33
34 //SVG of the icon
35 $menu_icon_svg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDIyLjAuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMiIgYmFzZVByb2ZpbGU9InRpbnkiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIgoJIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8cGF0aCBmaWxsPSIjNzhDMTQ4IiBkPSJNMTAsMEM0LjUsMCwwLDQuNSwwLDEwczQuNSwxMCwxMCwxMHMxMC00LjUsMTAtMTBTMTUuNSwwLDEwLDB6IE04LjEsMTIuMWwtMS42LDEuNQoJYy0wLjIsMC4yLTAuNCwwLjMtMC43LDAuM2MtMC4zLDAtMC41LTAuMS0wLjctMC4zbC0xLjYtMS41Yy0wLjItMC4yLTAuMi0wLjYsMC0wLjljMC4yLTAuMiwwLjYtMC4yLDAuOSwwbDEuNCwxLjRsMS40LTEuNAoJQzcuMywxMS4xLDcuNSwxMSw3LjYsMTFzMC4zLDAuMSwwLjQsMC4yQzguMywxMS40LDguMywxMS44LDguMSwxMi4xeiBNOC4xLDlDNy45LDkuMSw3LjgsOS4yLDcuNiw5LjJTNy4zLDkuMSw3LjIsOUw1LjgsNy42TDQuNCw5CglDNC4yLDkuMiwzLjgsOS4yLDMuNiw5Yy0wLjItMC4yLTAuMi0wLjYsMC0wLjlsMS42LTEuNWMwLjItMC4yLDAuNC0wLjMsMC43LTAuM2MwLjMsMCwwLjUsMC4xLDAuNywwLjNsMS42LDEuNQoJQzguMyw4LjQsOC4zLDguOCw4LjEsOXogTTE1LjIsMTRoLTQuNmMtMC44LDAtMS40LTAuNi0xLjQtMS40YzAtMC44LDAuNi0xLjQsMS40LTEuNGg0LjZjMC44LDAsMS40LDAuNiwxLjQsMS40CglDMTYuNiwxMy4zLDE2LDE0LDE1LjIsMTR6IE0xNS4yLDkuMmgtNC42Yy0wLjgsMC0xLjQtMC42LTEuNC0xLjRjMC0wLjgsMC42LTEuNCwxLjQtMS40aDQuNmMwLjgsMCwxLjQsMC42LDEuNCwxLjQKCUMxNi42LDguNSwxNiw5LjIsMTUuMiw5LjJ6Ii8+Cjwvc3ZnPgo=';
36
37 // Set UI labels for Custom Post Type
38 $labels = array(
39 'name' => _x( 'Ideas', 'Post Type General Name', 'ideapush' ),
40 'singular_name' => _x( 'Idea', 'Post Type Singular Name', 'ideapush' ),
41 'menu_name' => __( 'IdeaPush', 'ideapush' ),
42 'parent_item_colon' => __( 'Parent Idea', 'ideapush' ),
43 'all_items' => __( 'All Ideas', 'ideapush' ),
44 'view_item' => __( 'View Idea', 'ideapush' ),
45 'add_new_item' => __( 'Add New Idea', 'ideapush' ),
46 'add_new' => __( 'Add New', 'ideapush' ),
47 'edit_item' => __( 'Edit Idea', 'ideapush' ),
48 'update_item' => __( 'Update Idea', 'ideapush' ),
49 'search_items' => __( 'Search Idea', 'ideapush' ),
50 'not_found' => __( 'Not Found', 'ideapush' ),
51 'not_found_in_trash' => __( 'Not found in Trash', 'ideapush' ),
52 );
53
54 // Set other options for Custom Post Type
55 $args = array(
56 'label' => __( 'ideas', 'ideapush' ),
57 'description' => __( 'IdeaPush ideas', 'ideapush' ),
58 'labels' => $labels,
59 // Features this CPT supports in Post Editor
60 // 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields',),
61 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'revisions',),
62
63 // You can associate this CPT with a taxonomy or custom taxonomy.
64 'taxonomies' => array( 'idea-boards' ),
65 /* A hierarchical CPT is like Pages and can have
66 * Parent and child items. A non-hierarchical CPT
67 * is like Posts.
68 */
69 'hierarchical' => false,
70 'public' => true,
71 'show_ui' => true,
72 'show_in_menu' => true,
73 'show_in_nav_menus' => true,
74 'show_in_admin_bar' => true,
75 'menu_position' => 5,
76 'menu_icon' => $menu_icon_svg,
77 'can_export' => true,
78 'has_archive' => true,
79 'exclude_from_search' => false,
80 'publicly_queryable' => true,
81 'capability_type' => 'page',
82 );
83
84 // Registering your Custom Post Type
85 register_post_type( 'idea', $args );
86
87 }
88
89 /* Hook into the 'init' action so that the function
90 * Containing our post type registration is not
91 * unnecessarily executed.
92 */
93
94 add_action( 'init', 'idea_push_create_custom_post_type', 0 );
95
96
97 //when activating or deactivating the plugin lets fluch the rewrite rules because otherwise the single post pages may produce an error
98 register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );
99 register_activation_hook( __FILE__, 'idea_push_flush_rewrites' );
100 function idea_push_flush_rewrites() {
101 // call your CPT registration function here (it should also be hooked into 'init')
102 idea_push_create_custom_post_type();
103 flush_rewrite_rules();
104
105 //lets also create a new user role for guests
106 add_role( 'idea_push_guest', 'IdeaPush Guest', array( 'read' => true, 'level_0' => true ) );
107
108 }
109
110
111
112 //add a settings link on the plugin page
113 function idea_push_add_settings_link( $links ) {
114 $settings_link = '<a href="edit.php?post_type=idea&page=idea_push_settings">' . __( 'Settings','ideapush' ) . '</a>';
115 $ideas_link = '<a href="edit.php?post_type=idea">' . __( 'All Ideas','ideapush' ) . '</a>';
116 array_unshift( $links, $settings_link );
117 array_unshift( $links, $ideas_link );
118
119
120 return $links;
121 }
122 $plugin = plugin_basename( __FILE__ );
123 add_filter( "plugin_action_links_$plugin", 'idea_push_add_settings_link' );
124
125
126
127 //create boards taxonomy
128 add_action( 'init', 'idea_push_create_taxonomy_boards', 0 );
129
130 function idea_push_create_taxonomy_boards() {
131
132 // Labels part for the GUI
133
134 $labels = array(
135 'name' => _x( 'Boards', 'taxonomy general name' ),
136 'singular_name' => _x( 'Board', 'taxonomy singular name' ),
137 'search_items' => __( 'Search Boards' ),
138 'popular_items' => __( 'Popular Boards' ),
139 'all_items' => __( 'All Boards' ),
140 'parent_item' => null,
141 'parent_item_colon' => null,
142 'edit_item' => __( 'Edit Board' ),
143 'update_item' => __( 'Update Board' ),
144 'add_new_item' => __( 'Add New Board' ),
145 'new_item_name' => __( 'New Board Name' ),
146 'separate_items_with_commas' => __( 'Separate boards with commas' ),
147 'add_or_remove_items' => __( 'Add or remove boards' ),
148 'choose_from_most_used' => __( 'Choose from the most used boards' ),
149 'menu_name' => __( 'Boards' ),
150 );
151
152 // Now register the non-hierarchical taxonomy like tag
153
154 register_taxonomy('boards','idea',array(
155 'hierarchical' => true,
156 'labels' => $labels,
157 'show_ui' => true,
158 'show_in_menu' => false,
159 'show_in_nav_menus' => false,
160 'show_admin_column' => true,
161 'update_count_callback' => '_update_post_term_count',
162 'query_var' => true,
163 'rewrite' => array( 'slug' => 'ip-board' ),
164 ));
165
166 }
167
168
169 //create tags taxonomy
170 add_action( 'init', 'idea_push_create_taxonomy_tags', 0 );
171
172 function idea_push_create_taxonomy_tags() {
173
174 // Labels part for the GUI
175
176 $labels = array(
177 'name' => _x( 'Tags', 'taxonomy general name' ),
178 'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
179 'search_items' => __( 'Search tags' ),
180 'popular_items' => __( 'Popular Tags' ),
181 'all_items' => __( 'All Tags' ),
182 'parent_item' => null,
183 'parent_item_colon' => null,
184 'edit_item' => __( 'Edit Tag' ),
185 'update_item' => __( 'Update Tag' ),
186 'add_new_item' => __( 'Add New Tag' ),
187 'new_item_name' => __( 'New Tag Name' ),
188 'separate_items_with_commas' => __( 'Separate tags with commas' ),
189 'add_or_remove_items' => __( 'Add or remove tags' ),
190 'choose_from_most_used' => __( 'Choose from the most used tags' ),
191 'menu_name' => __( 'Tags' ),
192 );
193
194 // Now register the non-hierarchical taxonomy like tag
195
196 register_taxonomy('tags','idea',array(
197 'hierarchical' => false,
198 'labels' => $labels,
199 'show_ui' => true,
200 'show_in_menu' => true,
201 'show_in_nav_menus' => false,
202 'show_admin_column' => true,
203 'update_count_callback' => '_update_post_term_count',
204 'query_var' => true,
205 'rewrite' => array( 'slug' => 'ip-tag' ),
206 ));
207
208 }
209
210
211
212 //create status taxonomy
213 add_action( 'init', 'idea_push_create_taxonomy_status', 0 );
214
215 function idea_push_create_taxonomy_status() {
216
217 // Labels part for the GUI
218
219 $labels = array(
220 'name' => _x( 'Status', 'taxonomy general name' ),
221 'singular_name' => _x( 'Status', 'taxonomy singular name' ),
222 'search_items' => __( 'Search Statuses' ),
223 'popular_items' => __( 'Popular Statuses' ),
224 'all_items' => __( 'All Statuses' ),
225 'parent_item' => null,
226 'parent_item_colon' => null,
227 'edit_item' => __( 'Edit Status' ),
228 'update_item' => __( 'Update Status' ),
229 'add_new_item' => __( 'Add New Status' ),
230 'new_item_name' => __( 'New Status Name' ),
231 'separate_items_with_commas' => __( 'Separate statuses with commas' ),
232 'add_or_remove_items' => __( 'Add or remove statuses' ),
233 'choose_from_most_used' => __( 'Choose from the most used statuses' ),
234 'menu_name' => __( 'Statuses' ),
235 );
236
237 // Now register the non-hierarchical taxonomy like tag
238
239 register_taxonomy('status','idea',array(
240 'hierarchical' => true,
241 'labels' => $labels,
242 'show_ui' => true,
243 'show_in_quick_edit' => false,
244 'show_in_menu' => false,
245 'show_in_nav_menus' => false,
246 'show_admin_column' => true,
247 'update_count_callback' => '_update_post_term_count',
248 'query_var' => true,
249 'rewrite' => array( 'slug' => 'ip-status' ),
250 ));
251
252 }
253
254
255
256
257 //create predefined statuses
258 add_action( 'init', 'idea_push_create_predefined_statuses', 0 );
259
260 function idea_push_create_predefined_statuses() {
261
262 if(get_term_by('name', 'Open', 'status') == false){
263 wp_insert_term(
264 'Open', // the term
265 'status', // the taxonomy
266 array(
267 'description'=> '',
268 'slug' => 'open'
269 )
270 );
271 }
272
273 if(get_term_by('name', 'Reviewed', 'status') == false){
274 wp_insert_term(
275 'Reviewed', // the term
276 'status', // the taxonomy
277 array(
278 'description'=> '',
279 'slug' => 'reviewed'
280 )
281 );
282 }
283
284 if(get_term_by('name', 'Approved', 'status') == false){
285 wp_insert_term(
286 'Approved', // the term
287 'status', // the taxonomy
288 array(
289 'description'=> '',
290 'slug' => 'approved'
291 )
292 );
293 }
294
295 if(get_term_by('name', 'Declined', 'status') == false){
296 wp_insert_term(
297 'Declined', // the term
298 'status', // the taxonomy
299 array(
300 'description'=> '',
301 'slug' => 'declined'
302 )
303 );
304 }
305
306 if(get_term_by('name', 'In Progress', 'status') == false){
307 wp_insert_term(
308 'In Progress', // the term
309 'status', // the taxonomy
310 array(
311 'description'=> '',
312 'slug' => 'in-progress'
313 )
314 );
315 }
316
317 if(get_term_by('name', 'Completed', 'status') == false){
318 wp_insert_term(
319 'Completed', // the term
320 'status', // the taxonomy
321 array(
322 'description'=> '',
323 'slug' => 'completed'
324 )
325 );
326 }
327
328
329
330
331 }
332
333
334
335
336
337
338
339
340
341
342 //lets add our settings page
343 add_action( 'admin_menu', 'idea_push_add_settings_page' );
344 add_action( 'admin_init', 'idea_push_settings_init' );
345
346 function idea_push_add_settings_page() {
347
348 global $idea_push_wp_settings_page;
349
350 $idea_push_wp_settings_page = add_submenu_page('edit.php?post_type=idea', __('Settings','ideapush'), __('Settings','ideapush'), 'manage_options', 'idea_push_settings', 'idea_push_settings_page_content');
351
352 }
353
354 //callback function of setting page
355 function idea_push_settings_page_content(){
356 require('inc/options/options-page-wrapper.php');
357 }
358
359 //Gets, sets and renders options
360 require('inc/options/options-output.php');
361
362 //produces the shortcode
363 require('inc/shortcode/ideaboard-shortcode.php');
364
365 //function that generates list items
366 require('inc/shortcode/idea-list-items.php');
367
368 //function that creates the idea form
369 require('inc/shortcode/create-idea-form.php');
370
371 //function that creates the idea table header
372 require('inc/shortcode/idea-table-header.php');
373
374 //function that creates ideas
375 require('inc/functions/create-idea.php');
376
377 //function that creates votes
378 require('inc/functions/create-vote.php');
379
380 //function that changes the status
381 require('inc/functions/status-change.php');
382
383 //common functions that assist other functions run
384 require('inc/functions/helper-functions.php');
385
386 //function that creates a user
387 require('inc/functions/create-user.php');
388
389 //function puts idea stuff on the single idea page
390 require('inc/functions/single-idea.php');
391
392 //function that adds our metabox
393 require('inc/functions/create-metaboxes.php');
394
395
396
397 //get pro options
398 if($ideapush_is_pro=="YES"){
399 require('inc/pro-ip/idea-push-pro.php');
400 }
401
402
403
404
405 function test(){
406
407 $current = get_current_screen();
408 print_r($current);
409 }
410 add_action('admin_init','test');
411
412
413
414
415 // Load admin style and scripts
416 function idea_push_register_admin_styles($hook)
417 {
418
419 global $idea_push_wp_settings_page;
420 global $idea_push_wp_reports_page;
421
422 if($hook != $idea_push_wp_reports_page && $hook != $idea_push_wp_settings_page )
423 return;
424
425 //css
426 wp_enqueue_style( 'wp-color-picker' );
427 wp_enqueue_style( 'custom-admin-style-ideapush', plugins_url( '/inc/css/adminstyle.css', __FILE__ ));
428 wp_enqueue_style( 'font-awesome', plugins_url( '/inc/css/font-awesome.min.css', __FILE__ ));
429
430 //js
431 wp_enqueue_script( 'custom-admin-script-ideapush', plugins_url( '/inc/js/adminscript.js', __FILE__ ), array( 'jquery','wp-color-picker' ));
432 wp_enqueue_script('jquery-ui-dialog');
433 wp_enqueue_script('jquery-ui-accordion');
434 wp_enqueue_script('jquery-ui-tabs');
435 wp_enqueue_script('jquery-ui-datepicker');
436 wp_enqueue_script('jquery-form');
437
438
439 wp_enqueue_script('clipboard', plugins_url('/inc/js/clipboard.min.js', __FILE__ ), array( 'jquery'));
440
441 }
442 add_action( 'admin_enqueue_scripts', 'idea_push_register_admin_styles' );
443
444
445
446 // Load styles and scripts for the single idea page
447 function idea_push_register_admin_styles_single()
448 {
449
450 global $post_type;
451
452 if('idea' != $post_type)
453 return;
454
455 //css
456
457 //js
458 wp_enqueue_script( 'custom-frontend-script-single-idea', plugins_url( '/inc/js/singleideascript.js', __FILE__ ), array( 'jquery'), '1.0.0');
459
460 }
461 add_action( 'admin_enqueue_scripts', 'idea_push_register_admin_styles_single' );
462
463
464
465
466
467
468
469
470
471
472
473
474
475 // Load frontend style and scripts
476 function idea_push_register_frontend_styles()
477 {
478 //get settings
479 $options = get_option('idea_push_settings');
480
481 //css
482 wp_enqueue_style( 'custom-frontend-style-ideapush', plugins_url( '/inc/css/frontendstyle.css', __FILE__ ),array(),'1.0.2');
483 wp_enqueue_style( 'font-awesome', plugins_url( '/inc/css/font-awesome.min.css', __FILE__ ));
484
485
486 //js
487 wp_register_script( 'custom-frontend-script-ideapush', plugins_url( '/inc/js/frontendscript.js', __FILE__ ), array( 'jquery'), '1.0.2');
488
489 wp_localize_script('custom-frontend-script-ideapush','get_new_ideas', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
490 wp_localize_script('custom-frontend-script-ideapush','is_person_logged_in', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
491 wp_localize_script('custom-frontend-script-ideapush','submit_vote', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
492 wp_localize_script('custom-frontend-script-ideapush','create_user', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
493 wp_localize_script('custom-frontend-script-ideapush','header_render', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
494 wp_localize_script('custom-frontend-script-ideapush','form_render', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
495 wp_localize_script('custom-frontend-script-ideapush','create_idea', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
496 wp_localize_script('custom-frontend-script-ideapush','delete_idea', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
497 wp_localize_script('custom-frontend-script-ideapush','change_status', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
498 wp_localize_script('custom-frontend-script-ideapush','update_vote_counter', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
499 wp_localize_script('custom-frontend-script-ideapush','below_title_header', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
500 wp_localize_script('custom-frontend-script-ideapush','is_person_able_to_add_tag', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
501
502
503
504 wp_enqueue_script(array('custom-frontend-script-ideapush'));
505 wp_enqueue_script('scroll-reveal', plugins_url('/inc/js/scrollreveal.min.js', __FILE__ ), array( 'jquery'));
506 wp_enqueue_script('read-more', plugins_url('/inc/js/readmore.min.js', __FILE__ ), array( 'jquery'));
507 wp_enqueue_script('jquery-ui-dialog');
508
509
510 if(strlen($options['idea_push_recaptcha_site_key']) > 0){
511 wp_enqueue_script('google-recaptcha', 'https://www.google.com/recaptcha/api.js');
512 }
513
514
515
516 }
517 add_action( 'wp_enqueue_scripts', 'idea_push_register_frontend_styles' );
518
519
520
521
522
523
524
525
526
527 //create taxonomy item
528 //this is used to create a taxonomy for the board when the user creates a board from the plugin settings
529 function idea_push_add_taxonomy_item() {
530
531 //get options
532 $options = get_option('idea_push_settings');
533
534 //get is pro
535 global $ideapush_is_pro;
536
537 //get board name from ajax call
538 $boardName = idea_push_sanitization_validation($_POST['boardName'],'boardname');
539
540 if($boardName == false){
541 wp_die();
542 }
543
544
545
546
547 //lets first check if the board already exists
548 if(get_term_by('name', $boardName, 'boards') == false){
549
550 //lets check if licenced
551 if(($ideapush_is_pro == 'YES' && strlen($options['idea_push_purchase_email'])>0 && strlen($options['idea_push_order_id'])>0) || wp_count_terms('boards',array( "hide_empty" => 0 )) == 0){
552
553 $boardNameSlug = strtolower($boardName);
554 $boardNameSlug = preg_replace('/\s+/', '-', $boardNameSlug);
555
556 wp_insert_term(
557 $boardName, // the term
558 'boards', // the taxonomy
559 array(
560 'description'=> '',
561 'slug' => $boardNameSlug
562 )
563 );
564
565 //lets return the item id
566
567 $getTermId = get_term_by('name', $boardName, 'boards');
568 $termId = $getTermId->term_id;
569
570 echo $termId;
571
572
573 } else {
574 echo 'NOT-PRO';
575 }
576
577
578
579
580 } else {
581
582 echo 'TERM-EXISTS';
583
584
585 }
586
587 //die
588 wp_die();
589
590
591 }
592 add_action( 'wp_ajax_add_taxonomy_item', 'idea_push_add_taxonomy_item' );
593
594
595
596
597
598
599
600
601
602 //lets delete existing taxonomies and rename others where necessary
603 function idea_push_taxonomy_save_routine() {
604
605
606 //get board name from ajax call
607 $comparisonData = $_POST['comparisonData'];
608 $explodeTheData = explode("||", $comparisonData);
609
610 $boardIdArray = array();
611
612 foreach($explodeTheData as $board){
613
614 $anotherExplosion = explode("|", $board);
615 $boardId = $anotherExplosion[0];
616 $boardName = $anotherExplosion[1];
617
618 array_push($boardIdArray,$boardId);
619
620 //now lets change the name of existing taxonomies
621 $termObject = get_term($boardId,'boards');
622
623 //if the there's a match lets update the name if it has changed
624 if(!is_wp_error($termObject)){
625
626 $termName = $termObject->name;
627
628 if($boardName !== $termName){
629 //they don't match so lets update this term name with the new board name
630 wp_update_term($boardId,'boards',array('name' => $boardName));
631 }
632 }
633
634 }
635
636
637 //lets cycle through the existing terms in the taxonomy
638 $existingTerms = get_terms('boards',array( "hide_empty" => 0 ));
639
640 foreach($existingTerms as $term){
641
642 $termId = $term->term_id;
643
644 if(!in_array($termId,$boardIdArray)){
645 //if the term is not in our array delete it because it's not authorised to exist and it will cause confusion
646 wp_delete_term($termId,'boards');
647
648 }
649 }
650
651
652 //die
653 wp_die();
654
655
656 }
657 add_action( 'wp_ajax_taxonomy_save_routine', 'idea_push_taxonomy_save_routine' );
658
659
660
661
662
663
664
665
666 //add additional body class to the shortcode page for good measure
667 function idea_push_add_body_class($class) {
668
669 global $post;
670
671 if( isset($post->post_content) && has_shortcode( $post->post_content, 'ideapush' ) ) {
672 $class[] = 'idea-push';
673 }
674 return $class;
675 }
676 add_filter( 'body_class', 'idea_push_add_body_class' );
677
678
679
680 //add notification icon to menu item
681
682 add_action( 'admin_menu', 'idea_push_menu_bubble' );
683
684 function idea_push_menu_bubble() {
685 global $menu;
686
687 $count = idea_push_count_pending_ideas() + idea_push_count_ideas_review_status();
688
689
690 if ($count > 0) {
691
692 foreach ( $menu as $key => $value ) {
693
694 if ( $menu[$key][2] == 'edit.php?post_type=idea' ) {
695
696 $menu[$key][0] .= ' <span class="update-plugins"><span class="plugin-count">' . $count . '</span></span>';
697
698 return;
699 }
700 }
701 }
702 }
703
704
705 function idea_push_above_all_ideas_table() {
706
707 $screen = get_current_screen();
708
709 if ( $screen->id == 'edit-idea' ) {
710
711 echo '<style>
712
713 .idea-tasks div {
714 display: inline-block;
715 background: #fff;
716 padding: 10px;
717 border: 1px solid #e5e5e5;
718 border-radius: 6px;
719 margin-right: 10px;
720 margin-top: 10px;
721 margin-bottom: -10px;
722
723 }
724
725 .idea-tasks a {
726 text-decoration: none;
727
728 }
729
730 .pending-count, .reviewed-count {
731 display: inline-block;
732 vertical-align: top;
733 margin: 1px 0 0 5px;
734 padding: 0 5px;
735 min-width: 7px;
736 height: 17px;
737 border-radius: 11px;
738 background-color: #ca4a1f;
739 color: #fff;
740 font-size: 9px;
741 line-height: 17px;
742 text-align: center;
743 z-index: 26;
744
745 }
746
747 .column-status .open {
748 background-color: #4eb5e1;
749 color: #fff !important;
750 }
751
752 .column-status .in-progress {
753 background-color: #a7a9ac;
754 color: #fff !important;
755 }
756
757
758 .column-status .completed {
759 background-color: #414042;
760 color: #fff !important;
761 }
762
763 .column-status .reviewed {
764 background-color: #fbbf67;
765 color: #fff !important;
766 }
767
768 .column-status .approved {
769 background-color: #5eb46a;
770 color: #fff !important;
771 }
772
773 .column-status .declined {
774 background-color: #f05d55;
775 color: #fff !important;
776 }
777
778
779 .column-status a {
780
781 text-transform: uppercase;
782 padding: 3px 6px;
783 border-radius: 3px;
784 font-weight: 600;
785 font-size: smaller;
786 }
787
788 </style>';
789
790 $pendingEditPage = get_admin_url().'edit.php?post_status=pending&post_type=idea';
791 $reviewEditPage = get_admin_url().'edit.php?post_type=idea&status=reviewed';
792
793 $countPendingIdeas = idea_push_count_pending_ideas();
794 $countReviewStatus = idea_push_count_ideas_review_status();
795
796
797 echo '<div class="idea-tasks">';
798
799 if($countPendingIdeas > 0){
800 echo '<div class="pending-approval">';
801 echo '<a href="'.$pendingEditPage.'" class="pending-count-description">'.__( 'Ideas Pending Release', 'ideapush' ).'</a>';
802 echo '<span class="pending-count">'.$countPendingIdeas.'</span>';
803 echo '</div>';
804 }
805
806 if($countReviewStatus > 0){
807 echo '<div class="reviewed-status">';
808 echo '<a href="'.$reviewEditPage.'" class="reviewed-count-description">'.__( 'Ideas Needing Review', 'ideapush' ).'</a>';
809 echo '<span class="reviewed-count">'.$countReviewStatus.'</span>';
810 echo '</div>';
811 }
812
813 echo '</div>';
814
815
816 }
817
818
819 }
820 add_action( 'admin_notices', 'idea_push_above_all_ideas_table' );
821
822
823
824
825
826 add_filter( 'manage_edit-idea_columns', 'mycustomposttype_columns_definition' ) ;
827
828
829 function mycustomposttype_columns_definition( $columns ) {
830
831 $columns['votes'] = __( 'Votes' );
832 unset( $new['taxonomy-status'] );
833 $columns['status'] = __( 'Status' );
834
835 $customOrder = array('cb','title', 'author','taxonomy-boards' ,'status','taxonomy-tags','votes', 'comments','date');
836
837
838 foreach ($customOrder as $colname)
839 $new[$colname] = $columns[$colname];
840 return $new;
841 }
842
843
844
845
846 add_action( 'manage_idea_posts_custom_column' , 'idea_push_vote_column_content', 10, 2 );
847
848 function idea_push_vote_column_content( $column, $post_id ) {
849 switch ( $column ) {
850
851 // display a thumbnail photo
852 case 'votes' :
853 echo get_post_meta( $post_id , 'votes' , true );
854 break;
855 case 'status' :
856 $getTerms = get_the_terms( $post_id, 'status' );
857
858 foreach($getTerms as $term) {
859 $status = $term->name;
860 }
861
862 $className = strtolower($status);
863 $className = str_replace(" ","-",$className);
864
865 echo '<a class="'.$className.'" href="'.get_admin_url().'edit.php?post_type=idea&status='.$className.'">'.$status.'</a>';
866 break;
867
868 }
869 }
870
871
872 add_filter( 'manage_edit-idea_sortable_columns', 'idea_push_sortable_vote_column' );
873
874 function idea_push_sortable_vote_column( $columns ) {
875 $columns['votes'] = 'votes';
876 return $columns;
877 }
878
879
880 add_action( 'pre_get_posts', 'idea_push_custom_orderby' );
881
882 function idea_push_custom_orderby( $query ) {
883 if ( ! is_admin() )
884 return;
885
886 $orderby = $query->get( 'orderby');
887
888 if ( 'votes' == $orderby ) {
889 $query->set( 'meta_key', 'votes' );
890 $query->set( 'orderby', 'meta_value_num' );
891 }
892
893 }
894
895
896
897
898 add_filter( 'template_include', 'idea_push_ip_tag_template', 99 );
899
900 function idea_push_ip_tag_template( $template ) {
901
902
903
904 if ( is_tax( 'tags' )) {
905 $template = dirname( __FILE__ ) . '/inc/templates/ip-tag.php';
906 return $template;
907 } else {
908 return $template;
909 }
910
911 }
912
913
914 function idea_push_languages() {
915 load_plugin_textdomain( 'ideapush', false, 'ideapush/inc/languages' );
916 }
917 add_action('init', 'idea_push_languages');
918
919
920
921
922
923
924 add_action( 'pre_get_posts', function ( $query ) {
925
926 //get options
927 $options = get_option('idea_push_settings');
928
929 //get board configuration
930 $boardConfiguration = $options['idea_push_board_configuration'];
931
932 //split board configuration
933 $splitBoardConfiguration = explode('||',$boardConfiguration);
934
935 $boardsToHide = array();
936
937 //cycle through boards
938 foreach($splitBoardConfiguration as $boardConfig){
939
940 if(!empty($boardConfig)){
941
942 $furtherSplitBoardConfiguration = explode('|',$boardConfig);
943
944 if($furtherSplitBoardConfiguration[13] == 'Yes'){
945
946 $term = get_term($furtherSplitBoardConfiguration[0], 'boards' );
947 $slug = $term->slug;
948
949 array_push($boardsToHide,$slug);
950 }
951 }
952
953 }
954
955
956 global $wp_the_query;
957 if($query === $wp_the_query && $query->is_search() && !is_admin()) {
958 $tax_query = array(
959 array(
960 'taxonomy' => 'boards',
961 'field' => 'slug',
962 'terms' => $boardsToHide,
963 'operator' => 'NOT IN',
964 )
965 );
966 $query->set( 'tax_query', $tax_query );
967 }
968
969
970 });
971
972
973
974
975
976
977
978
979
980
981
982
983
984 //add custom css to the frontend
985 function idea_push_custom_css() {
986
987 //get options
988 $options = get_option('idea_push_settings');
989
990
991 if(isset($options['idea_push_custom_css']) && strlen($options['idea_push_custom_css'])>0){
992
993 wp_enqueue_style( 'custom-frontend-style', plugins_url( '/inc/css/frontendstyle.css', __FILE__ ) );
994 wp_add_inline_style( 'custom-frontend-style', $options['idea_push_custom_css'] );
995
996 }
997
998 }
999 add_action( 'wp_enqueue_scripts', 'idea_push_custom_css', 999 );
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017 //do pro updates
1018 //initialise the update check
1019 if($ideapush_is_pro == 'YES'){
1020
1021 require 'inc/pro-ip/plugin-update-checker/plugin-update-checker.php';
1022 $updateChecker = Puc_v4_Factory::buildUpdateChecker(
1023 'https://northernbeacheswebsites.com.au/?update_action=get_metadata&update_slug=ideapush', //Metadata URL.
1024 __FILE__, //Full path to the main plugin file.
1025 'ideapush' //Plugin slug. Usually it's the same as the name of the directory.
1026 );
1027
1028
1029 //add queries to the update call
1030 $updateChecker->addQueryArgFilter('filter_update_checks_ideapush');
1031 function filter_update_checks_ideapush($queryArgs) {
1032
1033
1034 $pluginSettings = get_option('idea_push_settings');
1035
1036 if(isset($pluginSettings['idea_push_purchase_email']) && isset($pluginSettings['idea_push_order_id'])){
1037
1038 $purchaseEmailAddress = $pluginSettings['idea_push_purchase_email'];
1039 $orderId = $pluginSettings['idea_push_order_id'];
1040 $siteUrl = get_site_url();
1041
1042 if (!empty($purchaseEmailAddress) && !empty($orderId)) {
1043 $queryArgs['purchaseEmailAddress'] = $purchaseEmailAddress;
1044 $queryArgs['orderId'] = $orderId;
1045 $queryArgs['siteUrl'] = $siteUrl;
1046 $queryArgs['productId'] = '9719';
1047 }
1048
1049 }
1050
1051 return $queryArgs;
1052 }
1053
1054
1055
1056 // define the puc_request_info_result-<slug> callback
1057 function filter_puc_request_info_result_slug_ideapush( $plugininfo, $result ) {
1058 //get the message from the server and set as transient
1059 set_transient('ideapush-update',$plugininfo->{'message'},YEAR_IN_SECONDS * 1);
1060
1061 return $plugininfo;
1062 };
1063 add_filter( "puc_request_info_result-ideapush", 'filter_puc_request_info_result_slug_ideapush', 10, 2 );
1064
1065
1066
1067
1068
1069
1070 $path = plugin_basename( __FILE__ );
1071
1072 add_action("after_plugin_row_{$path}", function( $plugin_file, $plugin_data, $status ) {
1073
1074 //get plugin settings
1075 $pluginSettings = get_option('idea_push_settings');
1076
1077
1078 if (!empty($pluginSettings['idea_push_purchase_email']) && !empty($pluginSettings['idea_push_order_id'])) {
1079
1080
1081
1082 //get transient
1083 $message = get_transient('ideapush-update');
1084
1085 if($message !== 'Yes'){
1086
1087 $purchaseLink = 'https://northernbeacheswebsites.com.au/ideapush-pro/';
1088
1089 if($message == 'Incorrect Details'){
1090 $displayMessage = 'The Order ID and Purchase ID you entered is not correct. Please double check the details you entered to receive product updates.';
1091 } elseif ($message == 'Licence Expired'){
1092 $displayMessage = 'Your licence has expired. Please <a href="'.$purchaseLink.'" target="_blank">purchase a new licence</a> to receive further updates for this plugin.';
1093 } elseif ($message == 'Website Mismatch') {
1094 $displayMessage = 'This plugin has already been registered on another website using your details. Under the licence terms this plugin can only be used on one website. Please <a href="'.$purchaseLink.'" target="_blank">click here</a> to purchase an additional licence.';
1095 } else {
1096 $displayMessage = '';
1097 }
1098
1099 echo '<tr class="plugin-update-tr active"><td colspan="3" class="plugin-update colspanchange"><div class="update-message notice inline notice-error notice-alt"><p class="installer-q-icon">'.$displayMessage.'</p></div></td></tr>';
1100
1101 }
1102
1103 } else {
1104
1105 echo '<tr class="plugin-update-tr active"><td colspan="3" class="plugin-update colspanchange"><div class="update-message notice inline notice-error notice-alt"><p class="installer-q-icon">Please enter your Order ID and Purchase ID in the plugin settings to receive automatics updates.</p></div></td></tr>';
1106
1107 }
1108
1109
1110 }, 10, 3 );
1111
1112
1113 }
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125 ?>