/**
  * Callback for WPMOLY_Import movie import method.
  * 
  * Checks the AJAX nonce and calls import_movies() to
  * create import drafts of all movies passed through the list.
  *
  * @since    1.0
  */
 public static function import_movies_callback()
 {
     wpmoly_check_ajax_referer('import-movies-list');
     $movies = isset($_POST['movies']) && '' != $_POST['movies'] ? esc_textarea($_POST['movies']) : null;
     $response = self::import_movies($movies);
     wpmoly_ajax_response($response, array(), wpmoly_create_nonce('import-movies-list'));
 }
 /**
  * AJAX callback for movie update.
  *
  * @since    2.0
  */
 public function update_movie_callback()
 {
     wpmoly_check_ajax_referer('update-movie');
     $movie_id = isset($_POST['movie_id']) && '' != $_POST['movie_id'] ? intval($_POST['movie_id']) : null;
     if (is_null($movie_id)) {
         wp_die(0);
     }
     $response = self::update_movie($movie_id);
     wpmoly_ajax_response($response, array(), wpmoly_create_nonce('update-movie'));
 }
 /**
  * Upload an image and set it as featured image of the submitted
  * post.
  * 
  * Extract params from $_POST values. Image URL and post ID are
  * required, title is optional. If no title is submitted file's
  * basename will be used as image name.
  * 
  * Return the uploaded image ID to updated featured image preview
  * in editor.
  *
  * @since    1.0
  */
 public static function set_featured_image_callback()
 {
     wpmoly_check_ajax_referer('set-movie-poster');
     $image = isset($_POST['image']) && '' != $_POST['image'] ? $_POST['image'] : null;
     $post_id = isset($_POST['post_id']) && '' != $_POST['post_id'] ? $_POST['post_id'] : null;
     $title = isset($_POST['title']) && '' != $_POST['title'] ? $_POST['title'] : null;
     $tmdb_id = isset($_POST['tmdb_id']) && '' != $_POST['tmdb_id'] ? $_POST['tmdb_id'] : null;
     if (1 != wpmoly_o('poster-featured')) {
         return new WP_Error('no_featured', __('Movie Posters as featured images option is deactivated. Update your settings to activate this.', 'wpmovielibrary'));
     }
     if (is_null($image) || is_null($post_id)) {
         return new WP_Error('invalid', __('An error occured when trying to import image: invalid data or Post ID.', 'wpmovielibrary'));
     }
     $response = self::set_image_as_featured($image, $post_id, $tmdb_id, $title);
     wpmoly_ajax_response($response);
 }
예제 #4
0
 /**
  * AJAX Callback to load more movies to the Widget.
  * 
  * @since    1.0
  */
 public static function wpmoly_load_more_movies_callback()
 {
     wpmoly_check_ajax_referer('load-more-widget-movies');
     $widget = isset($_GET['widget']) && '' != $_GET['widget'] ? $_GET['widget'] : null;
     $offset = isset($_GET['offset']) && '' != $_GET['offset'] ? $_GET['offset'] : 0;
     $limit = isset($_GET['limit']) && '' != $_GET['limit'] ? $_GET['limit'] : null;
     if (is_null($widget) || !class_exists($widget)) {
         wp_die(0);
     }
     $class = $widget::get_instance();
     $class->get_widget_content($limit, $offset);
     wp_die();
 }
 /**
  * Callback for Queued Movies Import.
  *
  * @since    1.0
  */
 public static function import_queued_movie_callback()
 {
     wpmoly_check_ajax_referer('import-queued-movies');
     $post_id = isset($_POST['post_id']) && '' != $_POST['post_id'] ? $_POST['post_id'] : null;
     $response = self::import_queued_movie($post_id);
     wpmoly_ajax_response($response, array(), wpmoly_create_nonce('import-queued-movies'));
 }
 /**
  * Save metadata once they're collected.
  *
  * @since    2.0.3
  */
 public static function save_meta_callback()
 {
     $post_id = isset($_POST['post_id']) && '' != $_POST['post_id'] ? intval($_POST['post_id']) : null;
     $data = isset($_POST['data']) && '' != $_POST['data'] ? $_POST['data'] : null;
     if (is_null($post_id)) {
         return new WP_Error('invalid', __('Empty or invalid Post ID or Movie Details', 'wpmovielibrary'));
     }
     wpmoly_check_ajax_referer('save-movie-meta');
     $response = self::save_movie_meta($post_id, $data);
     wpmoly_ajax_response($response, array(), wpmoly_create_nonce('save-movie-meta'));
 }
 /**
  * Search callback
  *
  * @since    1.0
  */
 public static function search_movie_callback()
 {
     wpmoly_check_ajax_referer('search-movies');
     $type = isset($_GET['type']) && '' != $_GET['type'] ? $_GET['type'] : '';
     $data = isset($_GET['data']) && '' != $_GET['data'] ? $_GET['data'] : '';
     $lang = isset($_GET['lang']) && '' != $_GET['lang'] ? $_GET['lang'] : wpmoly_o('api-language');
     $_id = isset($_GET['post_id']) && '' != $_GET['post_id'] ? $_GET['post_id'] : null;
     if ('' == $data || '' == $type) {
         return false;
     }
     if ('title' == $type) {
         $response = self::get_movie_by_title($data, $lang, $_id);
     } else {
         if ('id' == $type) {
             $response = self::get_movie_by_id($data, $lang, $_id);
         }
     }
     wpmoly_ajax_response($response);
 }