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; }
/** * Print Gallery status (private|public etc) * * @param type $gallery */ function mpp_gallery_status($gallery = false) { echo mpp_get_gallery_status($gallery); }
function mpp_media_record_activity($args) { $default = array('media_id' => null, 'action' => '', 'content' => '', 'type' => ''); $args = wp_parse_args($args, $default); if (!$args['media_id']) { return false; } $media_id = absint($args['media_id']); $media = mpp_get_media($media_id); if (!$media) { return false; } $gallery_id = $media->gallery_id; $gallery = mpp_get_gallery($gallery_id); $status = $media->status; //when a media is public, make sure to check that the gallery is public too if ($status == 'public') { $status = mpp_get_gallery_status($gallery); } //it is actually a gallery activity, isn't it? unset($args['media_id']); $args['status'] = $status; $args['gallery_id'] = $gallery->id; // $args['media_ids'] = (array) $media_id; return mpp_record_activity($args); }
/** * Post a gallery or media Main comment on single page * * @return type */ public function post_comment() { //this is BuddyPress dependent if (!function_exists('buddypress')) { exit(0); } // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } // Check the nonce check_admin_referer('post_update', '_wpnonce_post_update'); if (!is_user_logged_in()) { exit('-1'); } $mpp_type = $_POST['mpp-type']; $mpp_id = $_POST['mpp-id']; if (empty($_POST['content'])) { exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'mediapress') . '</p></div>'); } $activity_id = 0; if (empty($_POST['object']) && bp_is_active('activity')) { //we are preventing this comment to be set as the user's lastes_update $user_id = bp_loggedin_user_id(); $old_latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true); $activity_id = bp_activity_post_update(array('content' => $_POST['content'])); //restore if (!empty($old_latest_update)) { bp_update_user_meta($user_id, 'bp_latest_update', $old_latest_update); } } elseif ($_POST['object'] == 'groups') { if (!empty($_POST['item_id']) && bp_is_active('groups')) { $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id'])); } } else { $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']); } if (empty($activity_id)) { exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'mediapress') . '</p></div>'); } $status = ''; //if we have got activity id, let us add a meta key if ($mpp_type == 'gallery') { mpp_activity_update_gallery_id($activity_id, $mpp_id); mpp_activity_update_activity_type($activity_id, 'gallery_comment'); mpp_activity_update_context($activity_id, 'gallery'); $status = mpp_get_gallery_status($mpp_id); } elseif ($mpp_type == 'media') { $media = mpp_get_media($mpp_id); if (!$media) { die('-1'); } mpp_activity_update_gallery_id($activity_id, $media->gallery_id); mpp_activity_update_media_id($activity_id, $mpp_id); mpp_activity_update_activity_type($activity_id, 'media_comment'); mpp_activity_update_context($activity_id, 'media'); //also we need to keep the parent gallery id for caching $status = mpp_get_media_status($media); } $activity = new BP_Activity_Activity($activity_id); // $activity->component = buddypress()->mediapress->id; $activity->type = 'mpp_media_upload'; $activity->save(); //save activity privacy if ($status) { $status_object = mpp_get_status_object($status); if ($status_object) { bp_activity_update_meta($activity->id, 'activity-privacy', $status_object->activity_privacy); } } //create a shadow comment mpp_activity_create_comment_for_activity($activity_id); if (bp_has_activities('include=' . $activity_id)) { while (bp_activities()) { bp_the_activity(); mpp_locate_template(array('buddypress/activity/entry.php'), true); } } exit; }