/**
  * When a gallery is created/edit from dashboard, simulate the same behaviour as front end created galleries
  * 
  * @param type $post_id
  * @param type $post
  * @param type $update
  * @return type
  */
 public function update_gallery_details($post_id, $post, $update)
 {
     if (defined('DOING_AJAX') && DOING_AJAX || !is_admin()) {
         return;
     }
     $type = $this->get_editing_gallery_type();
     $gallery = mpp_get_gallery($post);
     if (empty($gallery->type) && $type) {
         wp_set_object_terms($post_id, mpp_underscore_it($type), mpp_get_type_taxname());
         $gallery->type = $type;
     }
     /**
      * On the front end, we are using the taxonomy term slugs as the value while on the backend we are using the term_id as the value
      * 
      * So, we are attaching this function only for the Dashboar created gallery
      * 
      * We do need to make it uniform in the futuer
      * 
      */
     //we need to set the object terms
     //we need to update the media count?
     //do we need to do anything else?
     //gallery-type
     //gallery-component
     //gallery status
     $type = empty($_POST['mpp-gallery-type']) ? '' : trim($_POST['mpp-gallery-type']);
     $status = empty($_POST['mpp-gallery-status']) ? '' : trim($_POST['mpp-gallery-status']);
     $component = empty($_POST['mpp-gallery-component']) ? '' : trim($_POST['mpp-gallery-component']);
     if ($type && mpp_is_registered_type($type)) {
         wp_set_object_terms($post_id, mpp_underscore_it($type), mpp_get_type_taxname());
     }
     if ($component && mpp_is_registered_component($component)) {
         wp_set_object_terms($post_id, mpp_underscore_it($component), mpp_get_component_taxname());
     }
     if ($status && mpp_is_registered_status($status)) {
         wp_set_object_terms($post_id, mpp_underscore_it($status), mpp_get_status_taxname());
     }
     //update media cout or recount?
     if (!empty($_POST['mpp-gallery-component-id'])) {
         mpp_update_gallery_meta($post_id, '_mpp_component_id', absint($_POST['mpp-gallery-component-id']));
     } else {
         //if component id is not given, check if it is members gallery, if so,
     }
     if (!$update) {
         do_action('mpp_gallery_created', $post_id);
     }
 }
/**
 * Update Gallery cover attachment id
 * 
 * @param type $gallery_id
 * @param type $cover_id
 * @return type
 */
function mpp_update_gallery_cover_id($gallery_id, $cover_id)
{
    return mpp_update_gallery_meta($gallery_id, '_mpp_cover_id', $cover_id);
}
/**
 * Set gallery view
 * 
 * @param type $gallery_id
 * @param type $view_id
 * @return type
 */
function mpp_update_gallery_view_id($gallery_id, $view_id)
{
    return mpp_update_gallery_meta($gallery_id, '_mpp_view', $view_id);
}
/**
 * Mark a Gallery as sorted
 * 
 */
function mpp_mark_gallery_sorted($gallery_id)
{
    return mpp_update_gallery_meta($gallery_id, '_mpp_is_sorted', 1);
}
Example #5
0
/**
 * Update the associated activity id for gallery
 * 
 * @param type $gallery_id
 * @param type $activity_id
 * @return type
 */
function mpp_gallery_update_activity_id($gallery_id, $activity_id)
{
    return mpp_update_gallery_meta($gallery_id, '_mpp_activity_id', $activity_id);
}