PluginProbe
UpStream: a Project Management Plugin for WordPress / 2.1.0
UpStream: a Project Management Plugin for WordPress v2.1.0
trunk 1.39.0 1.39.1 1.39.2 1.39.3 2.0.7 2.1.0
upstream / includes / admin / options / class-upstream-options-general.php

class-upstream-options-general.php in UpStream: a Project Management Plugin for WordPress 2.1.0, at includes/admin/options/class-upstream-options-general.php

1,309 lines 41.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * UpStream_Options_General
4 *
5 * @package UpStream
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 if ( ! class_exists( 'UpStream_Options_General' ) ) :
14
15 /**
16 * CMB2 Theme Options
17 *
18 * @version 0.1.0
19 */
20 class UpStream_Options_General {
21
22
23 /**
24 * Array of metaboxes/fields
25 *
26 * @var array
27 */
28 public $id = 'upstream_general';
29
30 /**
31 * Page title
32 *
33 * @var string
34 */
35 protected $title = '';
36
37 /**
38 * Menu Title
39 *
40 * @var string
41 */
42 protected $menu_title = '';
43
44 /**
45 * Menu Title
46 *
47 * @var string
48 */
49 protected $description = '';
50
51 /**
52 * Holds an instance of the object
53 *
54 * @var Myprefix_Admin
55 **/
56 public static $instance = null;
57
58 /**
59 * Constructor
60 *
61 * @since 0.1.0
62 */
63 public function __construct() {
64 // Set our title.
65 $this->title = __( 'General', 'upstream' );
66 $this->menu_title = $this->title;
67 $this->description = '';
68
69 add_action( 'wp_ajax_upstream_admin_reset_capabilities', array( $this, 'reset_capabilities' ) );
70 add_action( 'wp_ajax_upstream_admin_refresh_projects_meta', array( $this, 'refresh_projects_meta' ) );
71 add_action( 'wp_ajax_upstream_admin_cleanup_update_cache', array( $this, 'cleanup_update_cache' ) );
72 add_action(
73 'wp_ajax_upstream_admin_migrate_milestones_get_projects',
74 array( $this, 'migrate_milestones_get_projects' )
75 );
76 add_action(
77 'wp_ajax_upstream_admin_migrate_milestones_for_project',
78 array( $this, 'migrate_milestones_for_project' )
79 );
80
81 add_action( 'wp_ajax_upstream_admin_import_file_prepare', array( $this, 'import_file_prepare' ) );
82 add_action( 'wp_ajax_upstream_admin_import_file_section', array( $this, 'import_file_section' ) );
83 add_action( 'wp_ajax_upstream_admin_signup', array( $this, 'signup' ) );
84
85 }
86
87 /**
88 * Returns the running object
89 *
90 * @return Myprefix_Admin
91 **/
92 public static function get_instance() {
93 if ( is_null( self::$instance ) ) {
94 self::$instance = new self();
95 }
96
97 return self::$instance;
98 }
99
100 /**
101 * Get a list of user roles.
102 *
103 * @return array
104 */
105 protected function get_roles() {
106 $list = array();
107 $roles = get_editable_roles();
108
109 foreach ( $roles as $role => $data ) {
110 $list[ $role ] = $data['name'];
111 }
112
113 return $list;
114 }
115
116
117 /**
118 * Add the options metabox to the array of metaboxes
119 *
120 * @since 0.1.0
121 */
122 public function options() {
123 $project_url = '<a target="_blank" href="' . home_url( 'projects' ) . '">' . home_url( 'projects' ) . '</a>';
124
125 $roles = $this->get_roles();
126
127 $options = apply_filters(
128 $this->id . '_option_fields',
129 array(
130 'id' => $this->id, // upstream_tasks.
131 'title' => $this->title,
132 'menu_title' => $this->menu_title,
133 'desc' => $this->description,
134 'show_on' => array(
135 'key' => 'options-page',
136 'value' => array( $this->id ),
137 ),
138 'show_names' => true,
139 'fields' => array(
140
141 /**
142 * General
143 */
144 array(
145 'name' => __( 'General', 'upstream' ),
146 'id' => 'general_title',
147 'type' => 'title',
148 ),
149 array(
150 'name' => __( 'Filter Closed Items', 'upstream' ),
151 'id' => 'filter_closed_items',
152 'type' => 'radio_inline',
153 'default' => '0',
154 'desc' => __(
155 'Choose whether Projects, Tasks and Bugs will only display items that have “open” statuses. Items with “closed” statuses will still be loaded on the page, but users will have to use filters to view them. This option only applies if “Archive Closed Items” is set to “No”',
156 'upstream'
157 ),
158 'options' => array(
159 0 => __( 'No', 'upstream' ),
160 1 => __( 'Yes', 'upstream' ),
161 ),
162 ),
163 array(
164 'name' => __( 'Archive Closed Items', 'upstream' ),
165 'id' => 'archive_closed_items',
166 'type' => 'radio_inline',
167 'default' => '1',
168 'desc' => __(
169 'Using the Archive feature means that Closed items are not loaded on the frontend. This can speed up your site if you have projects with many items. Do not use the Archive feature if you want users to find Closed items.',
170 'upstream'
171 ),
172 'options' => array(
173 0 => __( 'No', 'upstream' ),
174 1 => __( 'Yes', 'upstream' ),
175 ),
176 ),
177 array(
178 'name' => __( 'Show Users\' Names', 'upstream' ),
179 'id' => 'show_users_name',
180 'type' => 'radio_inline',
181 'default' => '0',
182 'desc' => __(
183 'Show names on Project list (Front page)',
184 'upstream'
185 ),
186 'options' => array(
187 0 => __( 'No', 'upstream' ),
188 1 => __( 'Yes', 'upstream' ),
189 ),
190 ),
191 array(
192 'name' => __( 'Project Users Roles', 'upstream' ),
193 'id' => 'project_user_roles',
194 'desc' => __(
195 'Select the user roles that should be used to filter the list of users on projects.',
196 'upstream'
197 ),
198 'type' => 'multicheck',
199 'default' => array( 'administrator', 'upstream_manager', 'upstream_user' ),
200 'options' => $roles,
201 ),
202
203 /**
204 * Labels
205 */
206 array(
207 'name' => __( 'Labels', 'upstream' ),
208 'id' => 'labels_title',
209 'type' => 'title',
210 'desc' => __(
211 'Here you can change the labels of various items. You could change Client to Customer or Bugs to Issues for example.<br>These labels will change on the frontend as well as in the admin area.',
212 'upstream'
213 ),
214 'before_row' => '<hr>',
215 ),
216 array(
217 'name' => __( 'Project Label', 'upstream' ),
218 'id' => 'project',
219 'type' => 'labels',
220 ),
221 array(
222 'name' => __( 'Client Label', 'upstream' ),
223 'id' => 'client',
224 'type' => 'labels',
225 ),
226 array(
227 'name' => __( 'Milestone Label', 'upstream' ),
228 'id' => 'milestone',
229 'type' => 'labels',
230 ),
231 array(
232 'name' => __( 'Milestone Categories Label', 'upstream' ),
233 'id' => 'milestone_categories',
234 'type' => 'labels',
235 ),
236 array(
237 'name' => __( 'Task Label', 'upstream' ),
238 'id' => 'task',
239 'type' => 'labels',
240 ),
241 array(
242 'name' => __( 'Bug Label', 'upstream' ),
243 'id' => 'bug',
244 'type' => 'labels',
245 ),
246 array(
247 'name' => __( 'File Label', 'upstream' ),
248 'id' => 'file',
249 'type' => 'labels',
250 ),
251 array(
252 'name' => __( 'Discussion Label', 'upstream' ),
253 'id' => 'discussion',
254 'type' => 'labels',
255 ),
256
257 /**
258 * Client
259 */
260 array(
261 'name' => sprintf(
262 // translators: $s: upstream_client_label.
263 __( '%s Area', 'upstream' ),
264 upstream_client_label()
265 ),
266 'id' => 'client_area_title',
267 'type' => 'title',
268 'desc' => sprintf(
269 // translators: %1$1s: upstream_client_label.
270 // translators: %2$2s: upstream_client_label_plural.
271 // translators: %3$4s: project_url.
272 // translators: %4$s: upstream_project_label.
273 __(
274 'Various options for the %1$1s login page and the frontend view. <br>%2$2s can view their projects by visiting %3$3s (URL is available after adding a %4$s).',
275 'upstream'
276 ),
277 upstream_client_label(),
278 upstream_client_label_plural(),
279 $project_url,
280 upstream_project_label()
281 ),
282 'before_row' => '<hr>',
283 ),
284 array(
285 'name' => __( 'Login Page Heading', 'upstream' ),
286 'id' => 'login_heading',
287 'type' => 'text',
288 'desc' => __( 'The heading used on the client login page.', 'upstream' ),
289 ),
290 array(
291 'name' => __( 'Login Page Text', 'upstream' ),
292 'id' => 'login_text',
293 'type' => 'textarea_small',
294 'desc' => __( 'Text or instructions that can be added below the login form.', 'upstream' ),
295
296 ),
297 array(
298 'name' => __( 'Login Page Client Logo', 'upstream' ),
299 'id' => 'login_client_logo',
300 'type' => 'radio_inline',
301 'desc' => __(
302 'Choose whether Client\'s Logo should be displayed on login page if available.',
303 'upstream'
304 ),
305 'default' => '1',
306 'options' => array(
307 0 => __( 'No', 'upstream' ),
308 1 => __( 'Yes', 'upstream' ),
309 ),
310 ),
311 array(
312 'name' => __( 'Login Page Project Name', 'upstream' ),
313 'id' => 'login_project_name',
314 'type' => 'radio_inline',
315 'desc' => __(
316 'Choose whether Project\'s name should be displayed on login page.',
317 'upstream'
318 ),
319 'default' => '1',
320 'options' => array(
321 0 => __( 'No', 'upstream' ),
322 1 => __( 'Yes', 'upstream' ),
323 ),
324 ),
325 array(
326 'name' => __( 'Admin Email', 'upstream' ),
327 'id' => 'admin_email',
328 'type' => 'text',
329 'desc' => __( 'The email address that clients can use to contact you.', 'upstream' ),
330 ),
331 array(
332 'name' => __( 'Admin Support Link Label', 'upstream' ),
333 'id' => 'admin_support_label',
334 'type' => 'text',
335 'desc' => __( 'Label that describes the Admin Support Link.', 'upstream' ),
336 'default' => __( 'Contact Admin', 'upstream' ),
337 ),
338 array(
339 'name' => __( 'Admin Support Link', 'upstream' ),
340 'id' => 'admin_support_link',
341 'type' => 'text',
342 'desc' => __(
343 'Link to contact form or knowledge base to help clients obtain support.',
344 'upstream'
345 ),
346 'default' => 'mailto:' . upstream_admin_email(),
347 ),
348 /**
349 * MEDIA
350 */
351 array(
352 'name' => __( 'Media', 'upstream' ),
353 'id' => 'media_filter',
354 'type' => 'title',
355 'desc' => __( 'Options to configure the list of media attachments.', 'upstream' ),
356 'before_row' => '<hr>',
357 ),
358 array(
359 'name' => __( 'Who can see all the media?', 'upstream' ),
360 'id' => 'media_unrestricted_roles',
361 'desc' => __(
362 'For security, UpStream users can normally only access their own media uploads. Select the roles who can see all the entire media library.',
363 'upstream'
364 ),
365 'type' => 'multicheck',
366 'default' => array( 'administrator' ),
367 'options' => $roles,
368
369 ),
370 array(
371 'name' => __( 'Who can post images in comments?', 'upstream' ),
372 'id' => 'media_comment_images',
373 'desc' => __(
374 'By default, not all WordPress users can upload images. Select the roles who can add images to UpStream comments.',
375 'upstream'
376 ),
377 'type' => 'multicheck',
378 'default' => array_keys( $roles ),
379 'options' => $roles,
380
381 ),
382 /**
383 * Collapse Sections
384 */
385 array(
386 'name' => __( 'Collapse Sections', 'upstream' ),
387 'id' => 'frontend_collapse_sections',
388 'type' => 'title',
389 'desc' => __(
390 'Options to collapse different sections on the client area on frontend.',
391 'upstream'
392 ),
393 'before_row' => '<hr>',
394 ),
395 array(
396 'name' => __( 'Collapse Project Details box', 'upstream' ),
397 'id' => 'collapse_project_details',
398 'type' => 'radio_inline',
399 'desc' => __(
400 'Choose whether to collapse the Project Details box automatically when a user opens a project page.',
401 'upstream'
402 ),
403 'default' => '0',
404 'options' => array(
405 0 => __( 'No', 'upstream' ),
406 1 => __( 'Yes', 'upstream' ),
407 ),
408 ),
409 array(
410 'name' => __( 'Collapse Project Progress box', 'upstream' ),
411 'id' => 'collapse_project_progress',
412 'type' => 'radio_inline',
413 'desc' => __(
414 'Choose whether to collapse the Project progress box automatically when a user opens a project page.',
415 'upstream'
416 ),
417 'default' => '0',
418 'options' => array(
419 0 => __( 'No', 'upstream' ),
420 1 => __( 'Yes', 'upstream' ),
421 ),
422 ),
423 array(
424 'name' => __( 'Collapse Project Milestones box', 'upstream' ),
425 'id' => 'collapse_project_milestones',
426 'type' => 'radio_inline',
427 'desc' => __(
428 'Choose whether to collapse the Milestones box automatically when a user opens a project page.',
429 'upstream'
430 ),
431 'default' => '0',
432 'options' => array(
433 0 => __( 'No', 'upstream' ),
434 1 => __( 'Yes', 'upstream' ),
435 ),
436 ),
437 array(
438 'name' => __( 'Collapse Project Tasks box', 'upstream' ),
439 'id' => 'collapse_project_tasks',
440 'type' => 'radio_inline',
441 'desc' => __(
442 'Choose whether to collapse the Tasks box automatically when a user opens a project page.',
443 'upstream'
444 ),
445 'default' => '0',
446 'options' => array(
447 0 => __( 'No', 'upstream' ),
448 1 => __( 'Yes', 'upstream' ),
449 ),
450 ),
451 array(
452 'name' => __( 'Collapse Project Bugs box', 'upstream' ),
453 'id' => 'collapse_project_bugs',
454 'type' => 'radio_inline',
455 'desc' => __(
456 'Choose whether to collapse the Bugs box automatically when a user opens a project page.',
457 'upstream'
458 ),
459 'default' => '0',
460 'options' => array(
461 0 => __( 'No', 'upstream' ),
462 1 => __( 'Yes', 'upstream' ),
463 ),
464 ),
465 array(
466 'name' => __( 'Collapse Project Files box', 'upstream' ),
467 'id' => 'collapse_project_files',
468 'type' => 'radio_inline',
469 'desc' => __(
470 'Choose whether to collapse the Files box automatically when a user opens a project page.',
471 'upstream'
472 ),
473 'default' => '0',
474 'options' => array(
475 0 => __( 'No', 'upstream' ),
476 1 => __( 'Yes', 'upstream' ),
477 ),
478 ),
479 array(
480 'name' => __( 'Collapse Project Discussion box', 'upstream' ),
481 'id' => 'collapse_project_discussion',
482 'type' => 'radio_inline',
483 'desc' => __(
484 'Choose whether to collapse the Discussion box automatically when a user opens a project page.',
485 'upstream'
486 ),
487 'default' => '0',
488 'options' => array(
489 0 => __( 'No', 'upstream' ),
490 1 => __( 'Yes', 'upstream' ),
491 ),
492 ),
493
494 /**
495 * Toggle Features
496 */
497 array(
498 'name' => __( 'Toggle Features', 'upstream' ),
499 'id' => 'toggle_features',
500 'type' => 'title',
501 'desc' => __( 'Options to toggle different sections and features.', 'upstream' ),
502 'before_row' => '<hr>',
503 ),
504 array(
505 'name' => __( 'Disable Project Progress box', 'upstream' ),
506 'id' => 'disable_project_progress',
507 'type' => 'radio_inline',
508 'desc' => __(
509 'Choose whether to disable the Project progress box on the front end.',
510 'upstream'
511 ),
512 'default' => '0',
513 'options' => array(
514 0 => __( 'No', 'upstream' ),
515 1 => __( 'Yes', 'upstream' ),
516 ),
517 ),
518 array(
519 'name' => __( 'Disable Clients and Client Users', 'upstream' ),
520 'id' => 'disable_clients',
521 'type' => 'radio_inline',
522 'desc' => __(
523 'Choose whether if Clients and Client Users can be added and used on Projects.',
524 'upstream'
525 ),
526 'default' => '0',
527 'options' => array(
528 0 => __( 'No', 'upstream' ),
529 1 => __( 'Yes', 'upstream' ),
530 ),
531 ),
532 array(
533 'name' => __( 'Select all client\'s users by default', 'upstream' ),
534 'id' => 'pre_select_users',
535 'type' => 'radio_inline',
536 'desc' => __(
537 'Choose whether if all client\'s users should be checked by default after change or select the client.',
538 'upstream'
539 ),
540 'default' => '0',
541 'options' => array(
542 0 => __( 'No', 'upstream' ),
543 1 => __( 'Yes', 'upstream' ),
544 ),
545 ),
546 array(
547 'name' => __( 'Disable Projects Categorization', 'upstream' ),
548 'id' => 'disable_categories',
549 'type' => 'radio_inline',
550 'desc' => __(
551 'Choose whether Projects can be sorted into categories by managers and users.',
552 'upstream'
553 ),
554 'default' => '0',
555 'options' => array(
556 0 => __( 'No', 'upstream' ),
557 1 => __( 'Yes', 'upstream' ),
558 ),
559 ),
560 array(
561 'name' => __( 'Project Progress Icons', 'upstream' ),
562 'id' => 'disable_project_overview',
563 'type' => 'radio_inline',
564 'desc' => __(
565 'Choose whether to display the Project Progress Icons section on frontend.',
566 'upstream'
567 ),
568 'default' => '0',
569 'options' => array(
570 1 => __( 'Do not show', 'upstream' ),
571 0 => __( 'Yes', 'upstream' ),
572 ),
573 ),
574 array(
575 'name' => __( 'Disable Project Details', 'upstream' ),
576 'id' => 'disable_project_details',
577 'type' => 'radio_inline',
578 'desc' => __(
579 'Choose whether to display the Project Details section on frontend.',
580 'upstream'
581 ),
582 'default' => '0',
583 'options' => array(
584 0 => __( 'No', 'upstream' ),
585 1 => __( 'Yes', 'upstream' ),
586 ),
587 ),
588 array(
589 'name' => __( 'Disable Bugs', 'upstream' ),
590 'id' => 'disable_bugs',
591 'type' => 'multicheck',
592 'desc' => __(
593 'Ticking this box will disable the Bugs section on both the frontend and the admin area.',
594 'upstream'
595 ),
596 'default' => '',
597 'options' => array(
598 'yes' => __( 'Disable the Bugs section?', 'upstream' ),
599 ),
600 'select_all_button' => false,
601 ),
602 array(
603 'name' => __( 'Disable Tasks', 'upstream' ),
604 'id' => 'disable_tasks',
605 'type' => 'multicheck',
606 'desc' => __(
607 'Ticking this box will disable the Tasks section on both the frontend and the admin area.',
608 'upstream'
609 ),
610 'default' => '',
611 'options' => array(
612 'yes' => __( 'Disable the Tasks section?', 'upstream' ),
613 ),
614 'select_all_button' => false,
615 ),
616 array(
617 'name' => __( 'Disable Milestones', 'upstream' ),
618 'id' => 'disable_milestones',
619 'type' => 'multicheck',
620 'desc' => __(
621 'Ticking this box will disable the Milestones section on both the frontend and the admin area. <strong>Warning: The project timeline and some other features require milestones to work properly.</strong>',
622 'upstream'
623 ),
624 'default' => '',
625 'options' => array(
626 'yes' => __( 'Disable the Milestones section?', 'upstream' ),
627 ),
628 'select_all_button' => false,
629 ),
630 array(
631 'name' => __( 'Disable Milestone Categories', 'upstream' ),
632 'id' => 'disable_milestone_categories',
633 'type' => 'radio_inline',
634 'desc' => __(
635 'Ticking this box will disable the Milestone Categories section on both the frontend and the admin area.',
636 'upstream'
637 ),
638 'default' => '1',
639 'options' => array(
640 0 => __( 'No', 'upstream' ),
641 1 => __( 'Yes', 'upstream' ),
642 ),
643 'select_all_button' => false,
644 ),
645 array(
646 'name' => __( 'Disable Files', 'upstream' ),
647 'id' => 'disable_files',
648 'type' => 'multicheck',
649 'desc' => __(
650 'Ticking this box will disable the Files section on both the frontend and the admin area.',
651 'upstream'
652 ),
653 'default' => '',
654 'options' => array(
655 'yes' => __( 'Disable the Files section?', 'upstream' ),
656 ),
657 'select_all_button' => false,
658 ),
659 array(
660 'name' => __( 'File Upload Manager (NOTE: DO NOT change after you have added files)', 'upstream' ),
661 'id' => 'use_upfs',
662 'type' => 'radio_inline',
663 'desc' => __(
664 'Choose which file upload system to use. <B>DO NOT CHANGE THIS SETTING AFTER YOU HAVE ADDED FILES</B>, since it will clear all files.',
665 'upstream'
666 ),
667 'default' => '0',
668 'options' => array(
669 '0' => __( 'Use WordPress built-in file uploads', 'upstream' ),
670 '1' => __( 'Use UpStream secure file uploads', 'upstream' ),
671 ),
672 ),
673 array(
674 'name' => __( 'UpStream secure file upload location', 'upstream' ),
675 'id' => 'upfs_location',
676 'type' => 'text',
677 'desc' => __(
678 'If UpStream secure file uploads is enabled, this must be set to a path on your web server that is writeable. Contact your system administrator for help.',
679 'upstream'
680 ),
681 'default' => '',
682 ),
683 array(
684 'name' => __( 'Disable Reports', 'upstream' ),
685 'id' => 'disable_reports',
686 'type' => 'radio_inline',
687 'desc' => __(
688 'Disable the reports section on the sidebar.',
689 'upstream'
690 ),
691 'default' => '0',
692 'options' => array(
693 '0' => __( 'Show reports section', 'upstream' ),
694 '1' => __( 'Disable section', 'upstream' ),
695 ),
696 ),
697 array(
698 'name' => __( 'Disable Discussion on Projects', 'upstream' ),
699 'id' => 'disable_project_comments',
700 'type' => 'radio_inline',
701 'desc' => __(
702 'Either allow comments on projects on both the frontend and the admin area or hide the section.',
703 'upstream'
704 ),
705 'default' => '1',
706 'options' => array(
707 '1' => __( 'Allow comments on projects', 'upstream' ),
708 '0' => __( 'Disable section', 'upstream' ),
709 ),
710 ),
711 array(
712 'name' => __( 'Disable Discussion on Projects', 'upstream' ),
713 'id' => 'disable_project_comments',
714 'type' => 'radio_inline',
715 'desc' => __(
716 'Either allow comments on projects on both the frontend and the admin area or hide the section.',
717 'upstream'
718 ),
719 'default' => '1',
720 'options' => array(
721 '1' => __( 'Allow comments on projects', 'upstream' ),
722 '0' => __( 'Disable section', 'upstream' ),
723 ),
724 ),
725 array(
726 'name' => __( 'Disable Discussion on Milestones', 'upstream' ),
727 'id' => 'disable_comments_on_milestones',
728 'type' => 'radio_inline',
729 'desc' => sprintf(
730 // translators: $s: Milestones label.
731 __( 'Either allow comments on %s or hide the section.', 'upstream' ),
732 __( 'Milestones', 'upstream' )
733 ),
734 'default' => '1',
735 'options' => array(
736 '1' => __( 'Allow comments on Milestones', 'upstream' ),
737 '0' => __( 'Disable section', 'upstream' ),
738 ),
739 ),
740 array(
741 'name' => __( 'Disable Discussion on Tasks', 'upstream' ),
742 'id' => 'disable_comments_on_tasks',
743 'type' => 'radio_inline',
744 'desc' => sprintf(
745 // translators: $s: Tasks label.
746 __( 'Either allow comments on %s or hide the section.', 'upstream' ),
747 __( 'Tasks', 'upstream' )
748 ),
749 'default' => '1',
750 'options' => array(
751 '1' => __( 'Allow comments on Tasks', 'upstream' ),
752 '0' => __( 'Disable section', 'upstream' ),
753 ),
754 ),
755 array(
756 'name' => __( 'Disable Discussion on Bugs', 'upstream' ),
757 'id' => 'disable_comments_on_bugs',
758 'type' => 'radio_inline',
759 'desc' => sprintf(
760 // translators: $s: Bugs label.
761 __( 'Either allow comments on %s or hide the section.', 'upstream' ),
762 __( 'Bugs', 'upstream' )
763 ),
764 'default' => '1',
765 'options' => array(
766 '1' => __( 'Allow comments on Bugs', 'upstream' ),
767 '0' => __( 'Disable section', 'upstream' ),
768 ),
769 ),
770 array(
771 'name' => __( 'Disable Discussion on Files', 'upstream' ),
772 'id' => 'disable_comments_on_files',
773 'type' => 'radio_inline',
774 'desc' => sprintf(
775 // translators: $s: Files label.
776 __( 'Either allow comments on %s or hide the section.', 'upstream' ),
777 __( 'Files', 'upstream' )
778 ),
779 'default' => '1',
780 'options' => array(
781 '1' => __( 'Allow comments on Files', 'upstream' ),
782 '0' => __( 'Disable section', 'upstream' ),
783 ),
784 ),
785 array(
786 'name' => __( 'Show all projects in the frontend sidebar', 'upstream' ),
787 'id' => 'show_all_projects_sidebar',
788 'type' => 'radio_inline',
789 'desc' => __(
790 'If enabled, all projects will be displayed in the sidebar on frontend.',
791 'upstream'
792 ),
793 'default' => '0',
794 'options' => array(
795 '0' => __( 'Show only the current project', 'upstream' ),
796 '1' => __( 'Show all projects', 'upstream' ),
797 ),
798 ),
799 array(
800 'name' => __( 'Override project locking on front end', 'upstream' ),
801 'id' => 'override_locking',
802 'type' => 'radio_inline',
803 'desc' => __(
804 'If enabled, users will be allowed to edit projects regardless of whether another person is making edits (only applies on the front end). Note that if you allow multiple users to edit a project simultaneously, there is a chance that changes may be overwritten.',
805 'upstream'
806 ),
807 'default' => '0',
808 'options' => array(
809 '0' => __( 'Users cannot edit simultaneously (safe)', 'upstream' ),
810 '1' => __( 'Multiple users can edit a project simultaneously', 'upstream' ),
811 ),
812 ),
813 array(
814 'name' => __( 'Send Notifications for New Comments', 'upstream' ),
815 'id' => 'send_notifications_for_new_comments',
816 'type' => 'radio_inline',
817 'options' => array(
818 '1' => __( 'Enabled' ),
819 '0' => __( 'Disabled' ),
820 ),
821 'default' => '1',
822 'desc' => __( 'Check this to send a notification to the owner and creator of a milestone, task, or bug when someone comments on it.' ),
823 ),
824 /**
825 * Localization
826 */
827 array(
828 'name' => __( 'Localization', 'upstream' ),
829 'id' => 'local_title',
830 'type' => 'title',
831 'before_row' => '<hr>',
832 'desc' => __(
833 'General options for localization, such as times.',
834 'upstream'
835 ),
836 ),
837 array(
838 'name' => __( 'Work Hours Per Day', 'upstream' ),
839 'id' => 'local_work_hours_per_day',
840 'type' => 'text',
841 'desc' => __( 'The number of work hours per day (used in determining days of work).', 'upstream' ),
842 'default' => 8,
843 ),
844 array(
845 'name' => __( 'Currency Symbol', 'upstream' ),
846 'id' => 'local_monetary_symbol',
847 'type' => 'text',
848 'desc' => __( 'The local currency symbol.', 'upstream' ),
849 'default' => '$',
850 ),
851
852 /**
853 * Maintenance
854 */
855 array(
856 'name' => __( 'Maintenance', 'upstream' ),
857 'id' => 'maintenance_title',
858 'type' => 'title',
859 'before_row' => '<hr>',
860 'desc' => __(
861 'General options for maintenance only. Be careful enabling any of these options.',
862 'upstream'
863 ),
864 ),
865 array(
866 'name' => __( 'Add default UpStream capabilities', 'upstream' ),
867 'id' => 'add_default_capabilities',
868 'type' => 'up_buttonsgroup',
869 'count' => 4,
870 'labels' => array(
871 __( 'Administrator', 'upstream' ),
872 __( 'UpStream Manager', 'upstream' ),
873 __( 'UpStream User', 'upstream' ),
874 __( 'UpStream Client User', 'upstream' ),
875 ),
876 'slugs' => array(
877 'administrator',
878 'upstream_manager',
879 'upstream_user',
880 'upstream_client_user',
881 ),
882 'desc' => __(
883 'Clicking this button will reset all the capabilities to the default set for the following user roles: administrator, upstream_manager, upstream_user and upstream_client_user. This can\'t be undone.',
884 'upstream'
885 ),
886 'onclick' => 'upstream_reset_capabilities(event);',
887 'nonce' => wp_create_nonce( 'upstream_reset_capabilities' ),
888 ),
889 array(
890 'name' => __( 'Update Project Data', 'upstream' ),
891 'id' => 'refresh_projects_meta',
892 'type' => 'up_button',
893 'label' => __( 'Update', 'upstream' ),
894 'desc' => __(
895 'Clicking this button will recalculate the data for all the projects, including: project members, milestones\' tasks statuses, created time, project author. This can\'t be undone and can take some time if you have many projects.',
896 'upstream'
897 ),
898 'onclick' => 'upstream_refresh_projects_meta(event);',
899 'nonce' => wp_create_nonce( 'upstream_refresh_projects_meta' ),
900 ),
901 array(
902 'name' => __( 'Migrate Legacy Milestones', 'upstream' ),
903 'id' => 'migrate_milestones',
904 'type' => 'up_button',
905 'label' => __( 'Start migration', 'upstream' ),
906 'desc' => __(
907 'Clicking this button will force to migrate again all the legacy milestones (project meta data) to the new post type. Only do this if you had any issue with the migrated data after updating to the version 1.24.0. This can\'t be undone and can take some time if you have many projects.',
908 'upstream'
909 ),
910 'onclick' => 'upstream_migrate_milestones(event);',
911 'nonce' => wp_create_nonce( 'upstream_migrate_milestones' ),
912 ),
913 array(
914 'name' => __( 'Cleanup Plugin\'s Update Cache', 'upstream' ),
915 'id' => 'cleanup_update_cache',
916 'type' => 'up_button',
917 'label' => __( 'Cleanup', 'upstream' ),
918 'desc' => __(
919 'If you’re having problems seeing UpStream extension updates, click this button and you see any new plugin releases.',
920 'upstream'
921 ),
922 'onclick' => 'upstream_cleanup_update_cache(event);',
923 'nonce' => wp_create_nonce( 'upstream_cleanup_update_cache' ),
924 ),
925 array(
926 'name' => __( 'Debug', 'upstream' ),
927 'id' => 'debug',
928 'type' => 'multicheck',
929 'desc' => __(
930 'Ticking this box will enable special debug code and a new menu to inspect the debug information.',
931 'upstream'
932 ),
933 'default' => '',
934 'options' => array(
935 '1' => __( 'Enabled', 'upstream' ),
936 ),
937 'select_all_button' => false,
938 ),
939 array(
940 'name' => __( 'Beta Features', 'upstream' ),
941 'id' => 'beta_features',
942 'type' => 'multicheck',
943 'desc' => __(
944 'Ticking this box will enable beta features.',
945 'upstream'
946 ),
947 'default' => '',
948 'options' => array(
949 '1' => __( 'Enabled', 'upstream' ),
950 ),
951 'select_all_button' => false,
952 ),
953 array(
954 'name' => __( 'Remove Data', 'upstream' ),
955 'id' => 'remove_data',
956 'type' => 'multicheck',
957 'desc' => __(
958 'Ticking this box will delete all UpStream data when plugin is uninstalled.',
959 'upstream'
960 ),
961 'default' => '',
962 'options' => array(
963 'yes' => __( 'Remove all data on uninstall?', 'upstream' ),
964 ),
965 'select_all_button' => false,
966 ),
967
968 ),
969 )
970 );
971
972 return $options;
973 }
974
975 /**
976 * Reset Capabilities
977 *
978 * @return void
979 */
980 public function reset_capabilities() {
981 $return = '';
982 $abort = false;
983 $post_data = isset( $_POST ) ? wp_unslash( $_POST ) : array();
984
985 if ( ! isset( $post_data['nonce'] ) ) {
986 $return = 'error';
987 $abort = true;
988 }
989
990 if ( ! wp_verify_nonce( sanitize_text_field( $post_data['nonce'] ), 'upstream_reset_capabilities' ) ) {
991 $return = 'error';
992 $abort = true;
993 }
994
995 $valid_roles = array(
996 'administrator',
997 'upstream_manager',
998 'upstream_user',
999 'upstream_client_user',
1000 );
1001
1002 $check_role = sanitize_text_field( $post_data['role'] );
1003 if ( ! isset( $post_data['role'] ) || ! in_array( $check_role, $valid_roles ) ) {
1004 $return = 'error';
1005 $abort = true;
1006 }
1007
1008 if ( ! $abort ) {
1009 // Reset capabilities.
1010 $roles = new UpStream_Roles();
1011 $roles->add_default_caps( $check_role );
1012
1013 $return = 'success';
1014 }
1015
1016 echo wp_json_encode( $return );
1017 exit();
1018 }
1019
1020 /**
1021 * Signup
1022 *
1023 * @return void
1024 */
1025 public function signup() {
1026 $post_data = isset( $_POST ) ? wp_unslash( $_POST ) : array();
1027
1028 if ( ! isset( $post_data['nonce'] ) ) {
1029 wp_die( esc_html__( 'Invalid Nonce' ), 'Forbidden', array( 'response' => 403 ) );
1030 }
1031
1032 if ( ! wp_verify_nonce( sanitize_text_field( $post_data['nonce'] ), 'upstream_signup' ) ) {
1033 wp_die( esc_html__( 'Invalid Nonce' ), 'Forbidden', array( 'response' => 403 ) );
1034 }
1035
1036 $response = wp_remote_post(
1037 'https://www.getdrip.com/forms/934026428/submissions',
1038 array(
1039 'body' => array(
1040 'fields[email]' => sanitize_email( $post_data['email'] ),
1041 ),
1042 )
1043 );
1044
1045 }
1046
1047 /**
1048 * Import File Prepare
1049 *
1050 * @return void
1051 */
1052 public function import_file_prepare() {
1053 $get_data = isset( $_GET ) ? wp_unslash( $_GET ) : array();
1054
1055 if ( ! isset( $get_data['nonce'] ) ) {
1056 wp_die( esc_html__( 'Invalid Nonce' ), 'Forbidden', array( 'response' => 403 ) );
1057 }
1058
1059 if ( ! wp_verify_nonce( sanitize_text_field( $get_data['nonce'] ), 'upstream_import_file' ) ) {
1060 wp_die( esc_html__( 'Invalid Nonce' ), 'Forbidden', array( 'response' => 403 ) );
1061 }
1062
1063 $return = array();
1064
1065 $file_id = (int) $get_data['fileId'];
1066 if ( ! $file_id ) {
1067 wp_die( esc_html__( 'Invalid File' ), 'Forbidden', array( 'response' => 403 ) );
1068 }
1069 $file = get_attached_file( $file_id );
1070
1071 if ( ! current_user_can( 'administrator' ) ) {
1072 $return = array( 'error' => __( 'You must be an administrator to import data.', 'upstream' ) );
1073 } elseif ( ! $file ) {
1074 $return = array( 'error' => __( 'No file found.', 'upstream' ) );
1075 } else {
1076
1077 $res = UpStream_Import::prepare_file( $file );
1078 if ( $res['message'] ) {
1079 $return = array( 'error' => $res['message'] );
1080 } else {
1081 $return = array( 'total' => $res['lines'] );
1082 }
1083 }
1084
1085 echo wp_json_encode( $return );
1086 exit();
1087 }
1088
1089 /**
1090 * Import File Section
1091 *
1092 * @return void
1093 */
1094 public function import_file_section() {
1095 $return = '';
1096 $abort = false;
1097 $post_data = isset( $_POST ) ? wp_unslash( $_POST ) : array();
1098
1099 if ( ! isset( $post_data['nonce'] ) ) {
1100 $return = 'error';
1101 $abort = true;
1102 }
1103
1104 if ( ! wp_verify_nonce( sanitize_text_field( $post_data['nonce'] ), 'upstream_import_file' ) ) {
1105 $return = 'error';
1106 $abort = true;
1107 }
1108
1109 if ( ! isset( $post_data['lineNo'] ) ) {
1110 $return = 'error';
1111 $abort = true;
1112 }
1113
1114 if ( ! $abort ) {
1115
1116 if ( ! current_user_can( 'administrator' ) ) {
1117 $return = array(
1118 'success' => false,
1119 'message' => __( 'You must be an administrator to import data.', 'upstream' ),
1120 );
1121 } else {
1122
1123 $file_id = intval( $post_data['fileId'] );
1124 $line_start = intval( $post_data['lineNo'] );
1125
1126 // returns false if there is no file with that ID.
1127 $file = get_attached_file( $file_id );
1128
1129 if ( $file ) {
1130
1131 $res = UpStream_Import::import_file( $file, $line_start );
1132 if ( $res ) {
1133 $return = array(
1134 'success' => false,
1135 'message' => $res,
1136 );
1137 } else {
1138 $return = array( 'success' => true );
1139 }
1140 } else {
1141 $return = array(
1142 'success' => false,
1143 'message' => __( 'The file could not be found.', 'upstream' ),
1144 );
1145 }
1146 }
1147 } else {
1148 $return = array(
1149 'success' => false,
1150 'message' => __( 'A general error occurred.', 'upstream' ),
1151 );
1152 }
1153
1154 echo wp_json_encode( $return );
1155 exit();
1156 }
1157
1158 /**
1159 * Refresh Projects Meta
1160 *
1161 * @return void
1162 */
1163 public function refresh_projects_meta() {
1164 $return = '';
1165 $abort = false;
1166 $post_data = isset( $_POST ) ? wp_unslash( $_POST ) : array();
1167
1168 if ( ! isset( $_POST['nonce'] ) ) {
1169 $return = 'error';
1170 $abort = true;
1171 }
1172
1173 if ( ! wp_verify_nonce( sanitize_text_field( $post_data['nonce'] ), 'upstream_refresh_projects_meta' ) ) {
1174 $return = 'error';
1175 $abort = true;
1176 }
1177
1178 if ( ! $abort ) {
1179 if ( ! class_exists( 'Upstream_Counts' ) ) {
1180 include_once UPSTREAM_PLUGIN_DIR . '/includes/class-upstream-counts.php';
1181 }
1182
1183 $counts = new Upstream_Counts( 0 );
1184 $projects = $counts->projects;
1185
1186 if ( ! empty( $projects ) ) {
1187 foreach ( $projects as $project ) {
1188 $project_object = new UpStream_Project( $project->ID );
1189 $project_object->update_project_meta();
1190 }
1191 }
1192
1193 $return = 'success';
1194 }
1195
1196 echo wp_json_encode( $return );
1197 exit();
1198 }
1199
1200 /**
1201 * Cleanup Update Cache
1202 *
1203 * @return void
1204 */
1205 public function cleanup_update_cache() {
1206 $return = '';
1207 $abort = false;
1208 $post_data = isset( $_POST ) ? wp_unslash( $_POST ) : array();
1209
1210 if ( ! isset( $_POST['nonce'] ) ) {
1211 $return = 'error';
1212 $abort = true;
1213 }
1214
1215 if ( ! wp_verify_nonce( sanitize_text_field( $post_data['nonce'] ), 'upstream_cleanup_update_cache' ) ) {
1216 $return = 'error';
1217 $abort = true;
1218 }
1219
1220 if ( ! $abort ) {
1221 $addons = apply_filters( 'allex_addons', array(), 'upstream' );
1222
1223 foreach ( $addons as $extension ) {
1224 $extension = str_replace( 'upstream-', '', $extension['slug'] );
1225 delete_transient( 'upstream.' . $extension . ':plugin_latest_version' );
1226 }
1227 delete_site_transient( 'update_plugins' );
1228
1229 $return = 'success';
1230 }
1231
1232 echo wp_json_encode( $return );
1233 exit();
1234 }
1235
1236 /**
1237 * Migrate the project milestones
1238 */
1239 public function migrate_milestones_get_projects() {
1240 $get_data = isset( $_GET ) ? wp_unslash( $_GET ) : array();
1241
1242 if ( ! isset( $get_data['nonce'] ) ) {
1243 wp_die( esc_html__( 'Invalid Nonce' ), 'Forbidden', array( 'response' => 403 ) );
1244 }
1245
1246 if ( ! wp_verify_nonce( sanitize_text_field( $get_data['nonce'] ), 'upstream_migrate_milestones' ) ) {
1247 wp_die( esc_html__( 'Invalid Nonce' ), 'Forbidden', array( 'response' => 403 ) );
1248 }
1249
1250 $return = array();
1251
1252 $projects = get_posts(
1253 array(
1254 'post_type' => 'project',
1255 'post_status' => 'any',
1256 'meta_key' => '_upstream_project_milestones',
1257 'posts_per_page' => -1,
1258 )
1259 );
1260
1261 if ( ! empty( $projects ) ) {
1262 foreach ( $projects as $project ) {
1263 $milestones = get_post_meta( $project->ID, '_upstream_project_milestones', true );
1264
1265 $return[] = array(
1266 'id' => $project->ID,
1267 'title' => $project->post_title,
1268 'count' => count( $milestones ),
1269 );
1270 }
1271 }
1272
1273 echo wp_json_encode( $return );
1274 exit();
1275 }
1276
1277 /**
1278 * Migrate Milestones For Project
1279 *
1280 * @return void
1281 */
1282 public function migrate_milestones_for_project() {
1283 $post_data = isset( $_POST ) ? wp_unslash( $_POST ) : array();
1284
1285 if ( ! isset( $post_data['nonce'] ) ) {
1286 wp_die( esc_html__( 'Invalid Nonce' ), 'Forbidden', array( 'response' => 403 ) );
1287 }
1288
1289 if ( ! wp_verify_nonce( sanitize_text_field( $post_data['nonce'] ), 'upstream_migrate_milestones' ) ) {
1290 wp_die( esc_html__( 'Invalid Nonce' ), 'Forbidden', array( 'response' => 403 ) );
1291 }
1292
1293 $return = array();
1294
1295 if ( ! isset( $post_data['projectId'] ) || empty( absint( $post_data['projectId'] ) ) ) {
1296 wp_die( esc_html__( 'Invalid project id' ), 'Project not found', array( 'response' => 400 ) );
1297 }
1298
1299 // next function will do nothing if project does not exists.
1300 $project_id = absint( $post_data['projectId'] );
1301
1302 $return['success'] = \UpStream\Milestones::migrate_legacy_milestones_for_project( $project_id );
1303
1304 echo wp_json_encode( $return );
1305 exit();
1306 }
1307 }
1308 endif;
1309