/** * Setup Sitewide/root Galleries * @todo Make it work in 1.1 when we introduce site galleries * */ public function setup_sitewide_gallery() { global $wp_query; //this is our single gallery page if (mpp_is_sitewide_gallery_component()) { $gallery_id = get_queried_object_id(); //setup gallery query mediapress()->the_gallery_query = MPP_Gallery_Query::build_from_wp_query($wp_query); mediapress()->current_gallery = mpp_get_gallery($gallery_id); //check for end points to edit if (get_query_var('manage')) { $action = get_query_var('manage'); $this->current_action = 'manage'; $this->current_manage_action = $action; } elseif (get_query_var('media')) { $action = $this->parse_media_action(get_query_var('media')); $this->action_variables = $action; $this->current_action = $action[0]; $this->current_manage_action = ''; //$action; //push mpty string at top to make compatible with bp returned action variables array array_unshift($this->action_variables, ''); } elseif (get_query_var('paged')) { $this->mpage = absint(get_query_var('paged')); } } elseif (is_post_type_archive(mpp_get_gallery_post_type())) { mediapress()->the_gallery_query = new MPP_Gallery_Query(array('status' => 'public')); } }
/** * Load the Page template for MediaPress Single Sitewide Gallery * Looks for mediapress/default/single-gallery-$type-$status.php * mediapress/default/single-gallery-$type.php * mediapress/default/single-gallery.php * single-mpp-gallery.php * singular.php * index.php * in the child theme, then parent theme and finally falls back to check in wp-content/mediapress/template/mediapress/default * We don't provide any default copy for this as we are not going to mess with the page layout. Still, a theme developer has the choice to do it their own way * * Look at template_include hook and * * @see get_single_template() * @see get_query_template() * * @param string $template absolute path to the template file * @return string absolute path to the template file */ function mpp_filter_single_template_for_sitewide_gallery($template) { //our sitewide gallery is not enabled or we are not on single sitewide gallery no need to bother if (!mpp_is_active_component('sitewide') || !mpp_is_sitewide_gallery_component()) { return $template; } $default_template = 'mediapress/default/sitewide/home.php'; //modify it to use the current default template //load our template //should we load separate template for edit actions? $gallery = mpp_get_current_gallery(); $media = mpp_get_current_media(); $templates = array($default_template); /*if( $media ) { $type = $media->type; $status = $media->status; $slug = 'single-media'; //this is single media page } elseif( $gallery ) { //single gallery page $slug = 'single-gallery'; $type = $gallery->type; $status = $gallery->status; } //look inside theme's mediapress/ directory $templates = $default_template . $slug . '-' . $type . '-' . $status . '.php';//single-gallery-photo-public.php/single-media-photo-public.php $templates = $default_template . $slug . '-' . $type . '.php'; //single-gallery-photo.php/single-media-photo.php $templates = $default_template . $slug . '.php'; //single-gallery.php/single-media.php */ //we need to locate the template and if the template is not present in the themes, we need to setup theme compat $located = locate_template($templates); if ($located) { //mediapress()->set_theme_compat( false ); $template = $located; } else { //if not found, setup theme compat mpp_setup_sitewide_gallery_theme_compat(); } return $template; }
/** * Get current component type * @return type */ function mpp_get_current_component() { if (isset($_POST['_mpp_current_component'])) { $component = trim($_POST['_mpp_current_component']); if (!mpp_is_active_component($component)) { $component = ''; } } elseif (!mediapress()->is_bp_active() || mpp_is_sitewide_gallery_component()) { //if BuddyPress is not active, or BuddyPress is active and we are on the sitewide gallery page $component = 'sitewide'; } else { $component = 'members'; //may not be the best idea } return strtolower(apply_filters('mpp_get_current_component', $component)); //context sensitive }