/** * Check for a specific Movie Meta/Detail. * * Has to be called inside the loop. * * @since 2.1.4.2 * * @param string Movie format. * * @return boolean */ function wpmoly_has_movie_meta($meta, $value) { $metas = (array) WPMOLY_Movies::get_movie_meta(null, $meta); return in_array($value, $metas); }
/** * Update movie images/posters title, description, caption... * * @since 2.0 * * @param int $attachment_id Current image Post ID * @param int $post_id Related Post ID * @param string $image_type Image type, 'backdrop' or 'poster' * @param array $data Image data */ private static function update_attachment_meta($attachment_id, $post_id, $image_type, $data) { if (!get_post($attachment_id) || !get_post($post_id)) { return false; } if ('poster' != $image_type) { $image_type = 'image'; } $tmdb_id = WPMOLY_Movies::get_movie_meta($post_id, 'tmdb_id'); $title = WPMOLY_Movies::get_movie_meta($post_id, 'title'); $production = WPMOLY_Movies::get_movie_meta($post_id, 'production_companies'); $director = WPMOLY_Movies::get_movie_meta($post_id, 'director'); $original_title = WPMOLY_Movies::get_movie_meta($post_id, 'original_title'); $production = explode(',', $production); $production = trim(array_shift($production)); $year = WPMOLY_Movies::get_movie_meta($post_id, 'release_date'); $year = apply_filters('wpmoly_format_movie_date', $year, 'Y'); $find = array('{title}', '{originaltitle}', '{year}', '{production}', '{director}'); $replace = array($title, $original_title, $year, $production, $director); $_description = str_replace($find, $replace, wpmoly_o("{$image_type}-description")); $_title = str_replace($find, $replace, wpmoly_o("{$image_type}-title")); $attachment = array('ID' => $attachment_id, 'post_title' => $_title, 'post_content' => $_description, 'post_excerpt' => $_description); update_post_meta($attachment_id, '_wpmoly_' . $image_type . '_related_tmdb_id', $tmdb_id); update_post_meta($attachment_id, '_wpmoly_' . $image_type . '_related_meta_data', $data); update_post_meta($attachment_id, '_wp_attachment_image_alt', $_title); $update = wp_update_post($attachment); }
/** * Show some info about movies in post view. * * Add a filter on the_content hook to display infos selected in options * about the movie: note, director, overview, actors… * * @since 1.0 * * @param string $content The original post content * * @return string The filtered content containing original content plus movie infos if available, the untouched original content else. */ public static function movie_vintage_content($content = null) { // Naughty PHP 5.3 fix $details = WPMOLY_Movies::movie_details(); $metadata = WPMOLY_Movies::movie_metadata(); $html = $details . $metadata; /** * Filter vintage content * * @param string $html New content: details + metadata * @param string $details Details content * @param string $metadata Metadata content * @param string $content Old content */ $html = apply_filters('wpmoly_movie_vintage_content', $html, $details, $metadata, $content); return $html; }
foreach ($movies as $post) { setup_postdata($post); if ('1' == $headbox_enable) { echo WPMOLY_Movies::movie_content(); } else { ?> <div id="post-<?php the_ID(); ?> " class="wpmoly movies archives movie"> <h2><?php the_title(); ?> </h2> <?php echo WPMOLY_Movies::movie_vintage_content(); ?> </div> <?php } } wp_reset_postdata(); } else { ?> <h5><?php _e('This is somewhat embarrassing, isn’t it?', 'wpmovielibrary'); ?> </h5> <p><?php _e('We could’t find any movie matching your criteria.', 'wpmovielibrary'); ?>
/** * Set the uninstallation instructions * * @since 1.0 */ private static function _uninstall() { WPMOLY_Utils::uninstall(); WPMOLY_Movies::uninstall(); WPMOLY_Collections::uninstall(); WPMOLY_Genres::uninstall(); WPMOLY_Actors::uninstall(); WPMOLY_Settings::uninstall(); }