Ejemplo n.º 1
0
function mpp_filter_body_class($classes, $class)
{
    $new_classes = array();
    $component = mpp_get_current_component();
    //if not mediapress pages, return
    if (!mpp_is_gallery_component() && !mpp_is_component_gallery()) {
        return $classes;
    }
    //ok, It must be mpp pages
    $new_classes[] = 'mpp-page';
    //for all mediapress pages
    //if it is a directory page
    if (mpp_is_gallery_directory()) {
        $new_classes[] = 'mpp-page-directory';
    } elseif (mpp_is_gallery_component() || mpp_is_component_gallery()) {
        //we are on user gallery  page or a component gallery page
        //append class mpp-page-members or mpp-page-groups or mpp-page-events etc depending on the current associated component
        $new_classes[] = 'mpp-page-' . $component;
        if (mpp_is_media_management()) {
            //is it edit media?
            $new_classes[] = 'mpp-page-media-management';
            $new_classes[] = 'mpp-page-media-management-' . mpp_get_media_type();
            //mpp-photo-management, mpp-audio-management
            $new_classes[] = 'mpp-page-media-manage-action-' . mediapress()->get_edit_action();
            //mpp-photo-management, mpp-audio-management
        } elseif (mpp_is_single_media()) {
            //is it single media
            $new_classes[] = 'mpp-page-media-single';
            $new_classes[] = 'mpp-page-media-single-' . mpp_get_media_type();
        } elseif (mpp_is_gallery_management()) {
            //id gallery management?
            $new_classes[] = 'mpp-page-gallery-management';
            $new_classes[] = 'mpp-page-gallery-management-' . mpp_get_gallery_type();
            $new_classes[] = 'mpp-page-gallery-manage-action-' . mediapress()->get_edit_action();
        } elseif (mpp_is_single_gallery()) {
            //is singe gallery
            $new_classes[] = 'mpp-page-single-gallery';
            $new_classes[] = 'mpp-page-single-gallery-' . mpp_get_gallery_type();
            $new_classes[] = 'mpp-page-single-gallery-' . mpp_get_gallery_status();
        } else {
            //it is the gallery listing page of the component
            $new_classes[] = 'mpp-page-gallery-list';
            //home could have been a better name
            $new_classes[] = 'mpp-page-gallery-list-' . $component;
            //home could have been a better name
        }
    }
    if (!empty($new_classes)) {
        $classes = array_merge($classes, $new_classes);
    }
    return $classes;
}
 /**
  * Setup everything for BuddyPress Specific installation
  * 
  */
 public function setup_globals($args = array())
 {
     //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 (function_exists('bp_is_user') && bp_is_user()) {
         $this->component_id = bp_displayed_user_id();
     }
     //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();
     if (!mpp_is_enabled($this->component, $this->component_id)) {
         return;
         //do not setup
     }
     //set the status types allowed for current user
     $this->accessible_statuses = mpp_get_accessible_statuses($this->component, $this->component_id, get_current_user_id());
     $this->status = $this->accessible_statuses;
     //is this sitewide gallery?
     if (mpp_is_enabled('sitewide', $this->component_id)) {
         $this->setup_sitewide_gallery();
     }
     //I know we are not using ifelse, check setup_root_gallery() to know why
     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();
     }
     //fire this action to allow plugins do their own thing on mediapress()->the_gallery_query
     do_action('mpp_setup_gallery_query', $this);
     //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()) {
         //will save some db query with a few themes
         if (has_action('wp_head', 'adjacent_posts_rel_link_wp_head')) {
             remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
         }
         $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
         //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');
 }
Ejemplo n.º 3
0
 /**
  * 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');
 }