PluginProbe
IdeaPush / 3.11
IdeaPush v3.11
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 3.11, at ideapush.php

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