/** * Are we on a root gallry page * * @return type */ function mpp_is_root_gallery() { $is_gallery = false; if (mpp_is_root_enabled() && is_singular(mpp_get_gallery_post_type())) { $is_gallery = true; } return apply_filters('mpp_is_root_gallery', $is_gallery); }
/** * Setup everything for BuddyPress Specific installation * */ public function setup_globals($args = array()) { $bp = buddypress(); //if the 'gallery' slug is not set , set it to mediapress? if (!defined('MPP_GALLERY_SLUG')) { define('MPP_GALLERY_SLUG', $this->id); } //get current component/component_id $this->component = mpp_get_current_component(); $this->component_id = mpp_get_current_component_id(); //override the component id if we are on user page if (bp_is_user()) { $this->component_id = bp_displayed_user_id(); } $globals = array('slug' => MPP_GALLERY_SLUG, 'root_slug' => isset($bp->pages->mediapress->slug) ? $bp->pages->mediapress->slug : MPP_GALLERY_SLUG, 'notification_callback' => 'mpp_format_notifications', 'has_directory' => mpp_get_option('has_gallery_directory'), 'search_string' => __('Search Galleries...', 'mediapress'), 'directory_title' => isset($bp->pages->mediapress->id) ? get_the_title($bp->pages->mediapress->id) : __('Gallery Directory', 'mediapress')); parent::setup_globals($globals); //it will call do_action("bp_gallery_setup_global") after setting up the constants properly //the only possibility of gallery as component is in case of root galler, gallery directory or user gallery //let us setup global queries $current_action = ''; //initialize query objects mediapress()->the_gallery_query = new MPP_Gallery_Query(); mediapress()->the_media_query = new MPP_Media_Query(); //set the status types allowed for current user $this->accessible_statuses = mpp_get_accessible_statuses($this->component, $this->component_id, get_current_user_id()); //is the root gallery enabled? if (mpp_is_root_enabled()) { $this->setup_root_gallery(); } //end of root gallery section //if it is either member gallery OR Gallery Directory, let us process it if (mpp_is_gallery_component()) { $this->action_variables = buddypress()->action_variables; //add the current action at the begining of the stack, we are doing it to unify the things for User gallery and component gallery array_unshift($this->action_variables, bp_current_action()); $this->setup_user_gallery(); } elseif (mpp_is_component_gallery()) { //are we on component gallery like groups or events etc? $this->action_variables = buddypress()->action_variables; $this->setup_component_gallery(); } //once we are here, the basic action variables for mediapress are setup and so //we can go ahead and test for the single gallery/media $mp = mediapress(); //setup Single Gallery specific things if (mpp_is_single_gallery()) { $current_action = $this->current_action; //setup and see the actions etc to find out what we need to do //if it is one of the edit actions, It was already taken care of, don't do anything if (in_array($current_action, mpp_get_reserved_actions())) { return; } //check if we are on management screen? if ($this->current_action == 'manage') { //this is media management page $mp->set_editing('gallery'); $mp->set_action('manage'); $mp->set_edit_action($this->current_manage_action); //on edit bulk media page if ($mp->is_edit_action('edit')) { $this->setup_gallery_media_query(); } } elseif ($media = $this->get_media_id($this->current_action, $this->component, $this->component_id)) { //yes, It is single media $this->setup_single_media_query($media); } else { //we already know it is single gallery, so let us setup the media list query $this->setup_gallery_media_query(); } } do_action('mpp_setup_globals'); }