/** * CollabPress shortcode handler */ function cp_project_shortcode() { //verify user has permission to view shortcode if (is_user_logged_in()) { if (cp_check_permissions('shortcode_user_role')) { cp_admin_menu_page_load(); } else { _e('You do not have access to this project.', 'collabpress'); } } else { _e('You must be logged in to view this page.', 'collabpress'); } }
<?php //verify user has permission to view settings if (cp_check_permissions('settings_user_role')) { ?> <div id="collabpress-wrap" class="wrap"> <?php echo cp_screen_icon('collabpress'); ?> <h2><?php _e('CollabPress Settings', 'collabpress'); ?> </h2> <?php // User Notice $sent_data = $_POST ? $_POST : $_GET; cp_user_notice($sent_data); ?> <form method="post" action="options.php"> <?php settings_fields('cp_options_group'); ?> <?php $options = cp_get_options(); ?> <?php //clear activity log if (isset($_POST['cp_clear_activity']) && $_POST['cp_clear_activity'] == 'Delete Log') { //delete all activity log posts
$taskID = isset($_GET['cp-complete-task-id']) ? absint($_GET['cp-complete-task-id']) : null; //get current task status $task_status = get_post_meta($taskID, '_cp-task-status', true); if ($taskID && $task_status != 'complete') { //set the task to complete update_post_meta($taskID, '_cp-task-status', 'complete'); // Add Activity cp_add_activity(__('completed', 'collabpress'), __('task', 'collabpress'), $current_user->ID, $taskID); do_action('cp_task_completed', $taskID); } elseif ($taskID) { //open the task update_post_meta($taskID, '_cp-task-status', 'open'); // Add Activity cp_add_activity(__('opened', 'collabpress'), __('task', 'collabpress'), $current_user->ID, $taskID); do_action('cp_task_reopened', $taskID); } } // Delete Task if (isset($_GET['cp-delete-task-id'])) { //check nonce for security check_admin_referer('cp-action-delete_task' . absint($_GET['cp-delete-task-id'])); //verify user has permission to delete tasks and post ID is a task CPT if (cp_check_permissions('settings_user_role') && 'cp-tasks' === get_post_type(absint($_GET['cp-delete-task-id']))) { $cp_task_id = absint($_GET['cp-delete-task-id']); //delete the task wp_trash_post($cp_task_id, true); //add activity log cp_add_activity(__('deleted', 'collabpress'), __('task', 'collabpress'), $current_user->ID, $cp_task_id); do_action('cp_task_deleted', $cp_task_id); } }