/** * Set our page markers to determine if we're on a Social Paper page. * * @access private * * @param WP_Query $q */ function _cacsp_set_markers($q) { // bail if this is not the main query if (false === $q->is_main_query()) { return; } $post_type = isset($q->query['post_type']) ? $q->query['post_type'] : ''; if (empty($post_type)) { if ($q->is_page) { $post_type = 'page'; // kind of a catch-all... we don't support the 'attachment' post type } else { $post_type = 'post'; } } // check to see if we support this post type if (false === in_array($post_type, (array) cacsp_get_supported_post_types(), true)) { return; } // set our markers if ($q->is_archive && 'cacsp_paper' === $post_type) { Social_Paper::$is_archive = true; // always reset scope to all @setcookie('bp-papers-scope', 'all', 0, '/'); if (is_user_logged_in()) { $user_filter = false; if (!empty($_GET['user']) && get_current_user_id() === (int) $_GET['user']) { $user_filter = true; } if ($user_filter) { $q->set('author', (int) get_current_user_id()); $q->set('publish_status', array('publish', 'private')); } } } elseif ($q->is_singular) { Social_Paper::$is_page = true; } // add marker if we're on the 'new' page slug if (!empty($q->query['cacsp_paper']) && 'new' === $q->query['cacsp_paper']) { Social_Paper::$is_new = true; } }