Exemplo n.º 1
0
/**
 * Setup the $cp PHP global
 */
function cp_setup_cp_global()
{
    global $cp, $wpdb;
    $cp = new StdClass();
    // Set custom table names
    $cp->tables = new stdClass();
    $cp->tables->project_users = $wpdb->prefix . 'cp_project_users';
    // If we're not on a CollabPress page, bail.
    if (!is_collabpress_page()) {
        return;
    }
    // Set up the default keys
    $defaults = array('project' => false, 'task' => false, 'cp_page' => false, 'view' => false);
    // Parse query string variables and set CollabPress global appropriately
    foreach ($defaults as $key => $value) {
        if (!empty($_REQUEST[$key])) {
            switch ($key) {
                case 'project':
                    $cp->project = get_post($_REQUEST[$key]);
                    break;
                case 'task':
                    $cp->task = get_post($_REQUEST[$key]);
                    $cp->project = get_post(cp_get_task_project_id($cp->task->ID));
                    break;
                default:
                    $cp->{$key} = $_REQUEST[$key];
                    break;
            }
        }
    }
    // Set the view if it's not declared in the query string.
    // We'll use it later for choosing the template to be loaded.
    if (empty($cp->view)) {
        if (!empty($cp->task)) {
            $cp->view = 'task';
        } else {
            if (!empty($cp->project)) {
                $cp->view = 'project';
            } else {
                $cp->view = 'dashboard';
            }
        }
    }
    do_action('cp_global_setup');
}
Exemplo n.º 2
0
function cp_overview_nav()
{
    ?>
<ul>
		<li class="<?php 
    echo is_collabpress_page('dashboard') ? 'current' : '';
    ?>
">
			<a href="<?php 
    cp_permalink();
    ?>
">
				<?php 
    _e('Dashboard', 'collabpress');
    ?>
			</a>
		</li>
		<li class="<?php 
    echo is_collabpress_page('activity') ? 'current' : '';
    ?>
" >
			<a href="<?php 
    cp_activity_permalink();
    ?>
">
				<?php 
    _e('Activity', 'collabpress');
    ?>
			</a>
		</li>
		<li class="<?php 
    echo is_collabpress_page('calendar') ? 'current' : '';
    ?>
">
			<a href="<?php 
    cp_calendar_permalink();
    ?>
">
				<?php 
    _e('Calendar', 'collabpress');
    ?>
			</a>
		</li>
	</ul><?php 
}
Exemplo n.º 3
0
function cp_define_ajaxurl()
{
    if (is_collabpress_page()) {
        ?>
<script>var ajaxurl = '<?php 
        echo admin_url('admin-ajax.php');
        ?>
';</script><?php 
    }
}