/** * Check if a media exists or not * @param type $media_slug * @param type $component * @param type $component_id * @return type */ function mpp_media_exists($media_slug, $component, $component_id) { if (!$media_slug) { return false; } return mpp_post_exists(array('component' => $component, 'component_id' => $component_id, 'slug' => $media_slug, 'post_status' => 'inherit', 'post_type' => mpp_get_media_post_type())); }
/** * Check if a Gallery exists when the gallery slug, the associated component type and component id is given * * @param type $gallery_slug * @param type $component * @param type $component_id * @return boolean|object gallery post row or false */ function mpp_gallery_exists($gallery_slug_or_id, $component, $component_id) { $args = array('component' => $component, 'component_id' => $component_id, 'post_status' => 'publish', 'post_type' => mpp_get_gallery_post_type()); //won't work with form input/request uri if int if (is_int($gallery_slug_or_id)) { $args['id'] = absint($gallery_slug_or_id); } else { $args['slug'] = $gallery_slug_or_id; } return mpp_post_exists($args); }