/** * Initializes variables * * @since 1.0 */ public function init() { $this->modules = array('WPMOLY_Dashboard' => WPMOLY_Dashboard::get_instance(), 'WPMOLY_Settings' => WPMOLY_Settings::get_instance(), 'WPMOLY_TMDb' => WPMOLY_TMDb::get_instance(), 'WPMOLY_Utils' => WPMOLY_Utils::get_instance(), 'WPMOLY_Metaboxes' => WPMOLY_Metaboxes::get_instance(), 'WPMOLY_Edit_Movies' => WPMOLY_Edit_Movies::get_instance(), 'WPMOLY_Media' => WPMOLY_Media::get_instance(), 'WPMOLY_Import' => WPMOLY_Import::get_instance(), 'WPMOLY_Queue' => WPMOLY_Queue::get_instance()); $this->screen_hooks = array('edit' => 'post.php', 'new' => 'post-new.php', 'movie' => 'movie', 'movies' => 'edit.php', 'widgets' => 'widgets.php', 'settings' => sprintf('%s_page_wpmovielibrary-settings', strtolower(__('Movies', 'wpmovielibrary')))); $this->hidden_pages = array(); }
/** * Prepare movie images to Media Modal query creating an array * matching wp_prepare_attachment_for_js() filtered attachments. * * This is used by WPMOLY_Edit_Movies::load_images_callback() to * show movie images in Media Modal instead of regular images, * which needs to fed JSONified Attachments to the AJAX callback * to append to the modal. * * @since 1.0 * * @param array $images The images to prepare * @param object $post Related Movie Posts * @param string $image_type Which type of image we're dealing with, simple image or poster. * * @return array The prepared images */ public static function fake_jsonify_movie_images($images, $post, $image_type) { $image_type = 'poster' == $image_type ? 'poster' : 'backdrop'; $base_url = WPMOLY_TMDb::get_image_url(null, $image_type); $json_images = array(); $i = 0; foreach ($images as $image) { $i++; $_date = time(); $_title = $post->post_title; $_orientation = $image['aspect_ratio'] > 1 ? 'landscape' : 'portrait'; $delete_nonce = current_user_can('delete_post', $post->ID) ? wp_create_nonce('delete-post_' . $post->ID) : false; $edit_nonce = current_user_can('edit_post', $post->ID) ? wp_create_nonce('update-post_' . $post->ID) : false; $image_editor_none = current_user_can('edit_post', $post->ID) ? wp_create_nonce('image_editor-' . $post->ID) : false; $json_images[] = array('id' => $post->ID . '_' . $i, 'title' => $_title, 'filename' => substr($image['file_path'], 1), 'url' => $base_url['original'] . $image['file_path'], 'link' => get_permalink($post->ID), 'alt' => '', 'author' => "" . get_current_user_id(), 'description' => '', 'caption' => '', 'name' => substr($image['file_path'], 1, -4), 'status' => "inherit", 'uploadedTo' => $post->ID, 'date' => $_date * 1000, 'modified' => $_date * 1000, 'menuOrder' => 0, 'mime' => "image/jpeg", 'type' => "image", 'subtype' => "jpeg", 'icon' => includes_url('images/crystal/default.png'), 'dateFormatted' => date(get_option('date_format'), $_date), 'nonces' => array('delete' => $delete_nonce, 'update' => $edit_nonce, 'edit' => $image_editor_none), 'editLink' => "#", 'sizes' => array('thumbnail' => array('height' => 154, 'orientation' => $_orientation, 'url' => $base_url['small'] . $image['file_path'], 'width' => 154), 'medium' => array('height' => floor(300 / $image['aspect_ratio']), 'orientation' => $_orientation, 'url' => ('poster' == $image_type ? $base_url['x-small'] : $base_url['small']) . $image['file_path'], 'width' => 300), 'large' => array('height' => floor(500 / $image['aspect_ratio']), 'orientation' => $_orientation, 'url' => $base_url['full'] . $image['file_path'], 'width' => 500), 'full' => array('height' => $image['height'], 'orientation' => $_orientation, 'url' => $base_url['original'] . $image['file_path'], 'width' => $image['width'])), 'height' => $image['height'], 'width' => $image['width'], 'orientation' => $_orientation, 'compat' => array('item' => '', 'meta' => ''), 'metadata' => $image); } return $json_images; }
/** * Load the Movie Images and display a jsonified result.s * * @since 1.0 * * @param int $tmdb_id Movie TMDb ID to fetch images * @param array $post Related Movie Post * * @return array Movie posters */ public static function load_movie_posters($tmdb_id, $post) { $posters = WPMOLY_TMDb::get_movie_posters($tmdb_id); $posters = apply_filters('wpmoly_jsonify_movie_images', $posters, $post, 'poster'); return $posters; }