-
Notifications
You must be signed in to change notification settings - Fork 35
/
cp-loader.php
78 lines (60 loc) · 2.39 KB
/
cp-loader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/*
Plugin Name: CollabPress
Plugin URI: http://collabpress.org/
Description: A Project Management Plugin for WordPress
Version: 1.4-dev
Author: WebDevStudios.com
Author URI: http://webdevstudios.com/
License: GPLv2
*/
/* Copyright 2011 WebDevStudios (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// PHP Constant Declarations
require_once( 'constants.php' );
// Before CollabPress
do_action( 'cp_before_collabpress' );
//front-end querystring support
$cp_qs_add = cp_frontend_querystrings();
// Define the dashboard link
$cp_dashboard = ( is_admin() ) ? 'admin.php?page=collabpress-dashboard' : '?' .$cp_qs_add. 'cp=front';
// If we're processing an AJAX request,
// set the dashboard link according to the origin of the request
if ( ! empty( $_REQUEST['data']['collabpress_ajax_request_origin'] ) ) {
$cp_dashboard = ( $_REQUEST['data']['collabpress_ajax_request_origin'] == 'admin' ) ? 'admin.php?page=collabpress-dashboard' : '?' .$cp_qs_add. 'cp=front';
}
define( 'COLLABPRESS_DASHBOARD', $cp_dashboard );
// CollabPress Core
require_once( 'includes/cp-core.php' );
// activation hook
register_activation_hook( __FILE__, 'cp_activation' );
/**
* Returns the query string of CollabPress values
* e.g. task=3&task-list=4
*/
function cp_frontend_querystrings() {
// grab any query strings that exist
$cp_all_querystrings = ( $_SERVER["QUERY_STRING"] ) ? $_SERVER["QUERY_STRING"] : '';
$cp_querystrings = explode( '&', $cp_all_querystrings );
//set pattern to strip out
$pattern = "/^cp|project|task-list|task|view|activity_page/";
$cp_qs_add = '';
foreach ( $cp_querystrings as $cp_querystring ) {
if ( ! preg_match( $pattern, $cp_querystring ) ) {
$cp_qs_add .= $cp_querystring .'&';
}
}
if ( $cp_qs_add != '&' ) :
return $cp_qs_add;
endif;
}