/** * 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); } }
/** * Does the given component supports the type * * @param type $component * @param type $type * @return type */ function mpp_component_supports_type($component, $type) { return mpp_is_registered_component($component) && mediapress()->components[$component]->supports('type', $type); }