/** * Process the submitted dequeue movie list * * Post IDs should be valid Movies CPT IDs. The method will return * an array of Post IDs if no error occured, a WP_Error instance * containing all errors if any. * * @since 1.0 * * @param array $movies Array of movies Post IDs to dequeue * * @return array|WP_Error Array of update movies Post IDs if no error occured, or WP_Error */ private static function dequeue_movies($movies) { $response = array(); $errors = new WP_Error(); if (is_null($movies) || !is_array($movies)) { $errors->add('invalid', __('Invalid movie list submitted.', 'wpmovielibrary')); return $errors; } $response = wpmoly_ajax_filter(array(__CLASS__, 'dequeue_movie'), array($movies), $loop = true); return $response; }
/** * Process the submitted movie list * * This method can be used through an AJAX callback; in this case * the nonce check is already done in callback so we only check * for nonce we're not doing AJAX. List is exploded by comma and * fed to import_movie() to create import drafts. * * If AJAX, the function echo a status message and simply dies. * If no AJAX, ir returns false on failure, and a status message * on success. * * @since 1.0 * * @param array $movies Array of movie titles to import * * @return mixed */ private static function import_movies($movies) { $errors = new WP_Error(); $response = array(); $movies = explode(',', $movies); $movies = array_map(__CLASS__ . '::prepare_movie_import', $movies); if (is_null($movies) || !is_array($movies)) { $errors->add('invalid', __('Invalid movie list submitted.', 'wpmovielibrary')); return $errors; } $response = wpmoly_ajax_filter(array(__CLASS__, 'import_movie'), array($movies), $loop = true); WPMOLY_Cache::clean_transient('clean', $force = true); return $response; }