@@ -11,157 +11,157 @@ |
||
| 11 | 11 | |
| 12 | 12 | class Video_Processor { |
| 13 | 13 | |
| 14 | - private function get_data_for_videos( $embedded_videos ) { |
|
| 15 | - |
|
| 16 | - $youtube_videos = $this->get_youtube_videos( $embedded_videos ); |
|
| 17 | - |
|
| 18 | - $youtube_provider = Provider_Factory::get_provider( Provider_Factory::YOUTUBE ); |
|
| 19 | - $youtube_videos = $youtube_provider->get_videos_data( $youtube_videos ); |
|
| 20 | - |
|
| 21 | - $vimeo_videos = $this->get_vimeo_videos( $embedded_videos ); |
|
| 22 | - |
|
| 23 | - $vimeo_provider = Provider_Factory::get_provider( Provider_Factory::VIMEO ); |
|
| 24 | - $vimeo_videos = $vimeo_provider->get_videos_data( $vimeo_videos ); |
|
| 25 | - |
|
| 26 | - return array_merge( $youtube_videos, $vimeo_videos ); |
|
| 27 | - |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @param $storage Storage |
|
| 32 | - * @param $post_id int |
|
| 33 | - * @param $embedded_videos array<Embedded_Video> |
|
| 34 | - */ |
|
| 35 | - private function remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos ) { |
|
| 36 | - |
|
| 37 | - $videos_to_be_deleted = $this->get_videos_to_be_deleted( $storage, $post_id, $embedded_videos ); |
|
| 38 | - $storage->remove_videos( $videos_to_be_deleted, $post_id ); |
|
| 39 | - |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @param Storage $storage |
|
| 44 | - * @param $post_id |
|
| 45 | - * @param array $embedded_videos |
|
| 46 | - * |
|
| 47 | - * @return array |
|
| 48 | - */ |
|
| 49 | - private function get_videos_to_be_deleted( Storage $storage, $post_id, array $embedded_videos ) { |
|
| 50 | - $videos_in_store = $storage->get_all_videos( $post_id ); |
|
| 51 | - $embedded_video_urls = array_map( function ( $embedded_video ) { |
|
| 52 | - /** |
|
| 53 | - * @var $embedded_video Embedded_Video |
|
| 54 | - */ |
|
| 55 | - return $embedded_video->get_url(); |
|
| 56 | - }, $embedded_videos ); |
|
| 57 | - |
|
| 58 | - return array_filter( $videos_in_store, function ( $video ) use ( $embedded_video_urls ) { |
|
| 59 | - /** |
|
| 60 | - * @var $video Video |
|
| 61 | - */ |
|
| 62 | - return ! in_array( $video->id, $embedded_video_urls ); |
|
| 63 | - } ); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @param \WP_Post $post |
|
| 68 | - * @param $post_id |
|
| 69 | - */ |
|
| 70 | - public function process_video_urls( \WP_Post $post, $post_id ) { |
|
| 71 | - |
|
| 72 | - $parser = Parser_Factory::get_parser_from_content( $post->post_content ); |
|
| 73 | - |
|
| 74 | - $embedded_videos = $parser->get_videos( $post_id ); |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Filters the embedded videos on post contet, custom plugins can add their video urls |
|
| 78 | - * by constructing \Default_Embedded_Video or implement Embedded_Video class |
|
| 79 | - * @since 3.31.4 |
|
| 80 | - * Filter name : wl_videoobject_embedded_videos |
|
| 81 | - * @param $embedded_videos array<Embedded_Video> |
|
| 82 | - * @param $post_id int The post id for the videoobject is processed. |
|
| 83 | - * @return array<Embedded_Video> |
|
| 84 | - */ |
|
| 85 | - $embedded_videos = apply_filters('wl_videoobject_embedded_videos', $embedded_videos, $post_id ); |
|
| 86 | - |
|
| 87 | - $storage = Video_Storage_Factory::get_storage(); |
|
| 88 | - |
|
| 89 | - // Before sending api requests we need to check if there are any videos in |
|
| 90 | - // store which is not present on post content, remove them if there are |
|
| 91 | - // any |
|
| 92 | - $this->remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos ); |
|
| 93 | - |
|
| 94 | - $embedded_videos = $this->get_videos_without_existing_data( $storage, $post_id, $embedded_videos ); |
|
| 95 | - |
|
| 96 | - // Return early after removing all the videos. |
|
| 97 | - if ( ! $embedded_videos ) { |
|
| 98 | - return; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $videos = $this->get_data_for_videos( $embedded_videos ); |
|
| 102 | - |
|
| 103 | - if ( ! $videos ) { |
|
| 104 | - return; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - foreach ( $videos as $video ) { |
|
| 108 | - $storage->add_video( $post_id, $video ); |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @param $storage Storage |
|
| 114 | - * @param $post_id int |
|
| 115 | - * @param $embedded_videos array<Embedded_Video> |
|
| 116 | - * |
|
| 117 | - * @return array<Embedded_Video> Return array of embedded videos which are not in store. |
|
| 118 | - */ |
|
| 119 | - private function get_videos_without_existing_data( $storage, $post_id, $embedded_videos ) { |
|
| 120 | - $videos_in_store = $storage->get_all_videos( $post_id ); |
|
| 121 | - $video_ids_in_store = array_map( function ( $video ) { |
|
| 122 | - return $video->id; |
|
| 123 | - }, $videos_in_store ); |
|
| 124 | - |
|
| 125 | - return array_filter( $embedded_videos, function ( $embedded_video ) use ( $video_ids_in_store ) { |
|
| 126 | - return ! in_array( $embedded_video->get_url(), $video_ids_in_store ); |
|
| 127 | - } ); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @param $embedded_videos |
|
| 132 | - * |
|
| 133 | - * @return array |
|
| 134 | - */ |
|
| 135 | - private function get_youtube_videos( $embedded_videos ) { |
|
| 136 | - return array_filter( $embedded_videos, function ( $embedded_video ) { |
|
| 137 | - /** |
|
| 138 | - * it should have youtube.com or youtu.be in the url |
|
| 139 | - * |
|
| 140 | - * @param $embedded_video Embedded_Video |
|
| 141 | - */ |
|
| 142 | - $video_url = $embedded_video->get_url(); |
|
| 143 | - |
|
| 144 | - return strpos( $video_url, "youtube.com" ) !== false || |
|
| 145 | - strpos( $video_url, "youtu.be" ) !== false; |
|
| 146 | - } ); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * @param $embedded_videos |
|
| 151 | - * |
|
| 152 | - * @return array |
|
| 153 | - */ |
|
| 154 | - private function get_vimeo_videos( $embedded_videos ) { |
|
| 155 | - return array_filter( $embedded_videos, function ( $embedded_video ) { |
|
| 156 | - /** |
|
| 157 | - * it should have vimeo.com in the url |
|
| 158 | - * |
|
| 159 | - * @param $embedded_video Embedded_Video |
|
| 160 | - */ |
|
| 161 | - $video_url = $embedded_video->get_url(); |
|
| 162 | - |
|
| 163 | - return strpos( $video_url, "vimeo.com" ) !== false; |
|
| 164 | - } ); |
|
| 165 | - } |
|
| 14 | + private function get_data_for_videos( $embedded_videos ) { |
|
| 15 | + |
|
| 16 | + $youtube_videos = $this->get_youtube_videos( $embedded_videos ); |
|
| 17 | + |
|
| 18 | + $youtube_provider = Provider_Factory::get_provider( Provider_Factory::YOUTUBE ); |
|
| 19 | + $youtube_videos = $youtube_provider->get_videos_data( $youtube_videos ); |
|
| 20 | + |
|
| 21 | + $vimeo_videos = $this->get_vimeo_videos( $embedded_videos ); |
|
| 22 | + |
|
| 23 | + $vimeo_provider = Provider_Factory::get_provider( Provider_Factory::VIMEO ); |
|
| 24 | + $vimeo_videos = $vimeo_provider->get_videos_data( $vimeo_videos ); |
|
| 25 | + |
|
| 26 | + return array_merge( $youtube_videos, $vimeo_videos ); |
|
| 27 | + |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @param $storage Storage |
|
| 32 | + * @param $post_id int |
|
| 33 | + * @param $embedded_videos array<Embedded_Video> |
|
| 34 | + */ |
|
| 35 | + private function remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos ) { |
|
| 36 | + |
|
| 37 | + $videos_to_be_deleted = $this->get_videos_to_be_deleted( $storage, $post_id, $embedded_videos ); |
|
| 38 | + $storage->remove_videos( $videos_to_be_deleted, $post_id ); |
|
| 39 | + |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @param Storage $storage |
|
| 44 | + * @param $post_id |
|
| 45 | + * @param array $embedded_videos |
|
| 46 | + * |
|
| 47 | + * @return array |
|
| 48 | + */ |
|
| 49 | + private function get_videos_to_be_deleted( Storage $storage, $post_id, array $embedded_videos ) { |
|
| 50 | + $videos_in_store = $storage->get_all_videos( $post_id ); |
|
| 51 | + $embedded_video_urls = array_map( function ( $embedded_video ) { |
|
| 52 | + /** |
|
| 53 | + * @var $embedded_video Embedded_Video |
|
| 54 | + */ |
|
| 55 | + return $embedded_video->get_url(); |
|
| 56 | + }, $embedded_videos ); |
|
| 57 | + |
|
| 58 | + return array_filter( $videos_in_store, function ( $video ) use ( $embedded_video_urls ) { |
|
| 59 | + /** |
|
| 60 | + * @var $video Video |
|
| 61 | + */ |
|
| 62 | + return ! in_array( $video->id, $embedded_video_urls ); |
|
| 63 | + } ); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @param \WP_Post $post |
|
| 68 | + * @param $post_id |
|
| 69 | + */ |
|
| 70 | + public function process_video_urls( \WP_Post $post, $post_id ) { |
|
| 71 | + |
|
| 72 | + $parser = Parser_Factory::get_parser_from_content( $post->post_content ); |
|
| 73 | + |
|
| 74 | + $embedded_videos = $parser->get_videos( $post_id ); |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Filters the embedded videos on post contet, custom plugins can add their video urls |
|
| 78 | + * by constructing \Default_Embedded_Video or implement Embedded_Video class |
|
| 79 | + * @since 3.31.4 |
|
| 80 | + * Filter name : wl_videoobject_embedded_videos |
|
| 81 | + * @param $embedded_videos array<Embedded_Video> |
|
| 82 | + * @param $post_id int The post id for the videoobject is processed. |
|
| 83 | + * @return array<Embedded_Video> |
|
| 84 | + */ |
|
| 85 | + $embedded_videos = apply_filters('wl_videoobject_embedded_videos', $embedded_videos, $post_id ); |
|
| 86 | + |
|
| 87 | + $storage = Video_Storage_Factory::get_storage(); |
|
| 88 | + |
|
| 89 | + // Before sending api requests we need to check if there are any videos in |
|
| 90 | + // store which is not present on post content, remove them if there are |
|
| 91 | + // any |
|
| 92 | + $this->remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos ); |
|
| 93 | + |
|
| 94 | + $embedded_videos = $this->get_videos_without_existing_data( $storage, $post_id, $embedded_videos ); |
|
| 95 | + |
|
| 96 | + // Return early after removing all the videos. |
|
| 97 | + if ( ! $embedded_videos ) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $videos = $this->get_data_for_videos( $embedded_videos ); |
|
| 102 | + |
|
| 103 | + if ( ! $videos ) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + foreach ( $videos as $video ) { |
|
| 108 | + $storage->add_video( $post_id, $video ); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @param $storage Storage |
|
| 114 | + * @param $post_id int |
|
| 115 | + * @param $embedded_videos array<Embedded_Video> |
|
| 116 | + * |
|
| 117 | + * @return array<Embedded_Video> Return array of embedded videos which are not in store. |
|
| 118 | + */ |
|
| 119 | + private function get_videos_without_existing_data( $storage, $post_id, $embedded_videos ) { |
|
| 120 | + $videos_in_store = $storage->get_all_videos( $post_id ); |
|
| 121 | + $video_ids_in_store = array_map( function ( $video ) { |
|
| 122 | + return $video->id; |
|
| 123 | + }, $videos_in_store ); |
|
| 124 | + |
|
| 125 | + return array_filter( $embedded_videos, function ( $embedded_video ) use ( $video_ids_in_store ) { |
|
| 126 | + return ! in_array( $embedded_video->get_url(), $video_ids_in_store ); |
|
| 127 | + } ); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @param $embedded_videos |
|
| 132 | + * |
|
| 133 | + * @return array |
|
| 134 | + */ |
|
| 135 | + private function get_youtube_videos( $embedded_videos ) { |
|
| 136 | + return array_filter( $embedded_videos, function ( $embedded_video ) { |
|
| 137 | + /** |
|
| 138 | + * it should have youtube.com or youtu.be in the url |
|
| 139 | + * |
|
| 140 | + * @param $embedded_video Embedded_Video |
|
| 141 | + */ |
|
| 142 | + $video_url = $embedded_video->get_url(); |
|
| 143 | + |
|
| 144 | + return strpos( $video_url, "youtube.com" ) !== false || |
|
| 145 | + strpos( $video_url, "youtu.be" ) !== false; |
|
| 146 | + } ); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * @param $embedded_videos |
|
| 151 | + * |
|
| 152 | + * @return array |
|
| 153 | + */ |
|
| 154 | + private function get_vimeo_videos( $embedded_videos ) { |
|
| 155 | + return array_filter( $embedded_videos, function ( $embedded_video ) { |
|
| 156 | + /** |
|
| 157 | + * it should have vimeo.com in the url |
|
| 158 | + * |
|
| 159 | + * @param $embedded_video Embedded_Video |
|
| 160 | + */ |
|
| 161 | + $video_url = $embedded_video->get_url(); |
|
| 162 | + |
|
| 163 | + return strpos( $video_url, "vimeo.com" ) !== false; |
|
| 164 | + } ); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | } |
| 168 | 168 | \ No newline at end of file |
@@ -11,19 +11,19 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class Video_Processor { |
| 13 | 13 | |
| 14 | - private function get_data_for_videos( $embedded_videos ) { |
|
| 14 | + private function get_data_for_videos($embedded_videos) { |
|
| 15 | 15 | |
| 16 | - $youtube_videos = $this->get_youtube_videos( $embedded_videos ); |
|
| 16 | + $youtube_videos = $this->get_youtube_videos($embedded_videos); |
|
| 17 | 17 | |
| 18 | - $youtube_provider = Provider_Factory::get_provider( Provider_Factory::YOUTUBE ); |
|
| 19 | - $youtube_videos = $youtube_provider->get_videos_data( $youtube_videos ); |
|
| 18 | + $youtube_provider = Provider_Factory::get_provider(Provider_Factory::YOUTUBE); |
|
| 19 | + $youtube_videos = $youtube_provider->get_videos_data($youtube_videos); |
|
| 20 | 20 | |
| 21 | - $vimeo_videos = $this->get_vimeo_videos( $embedded_videos ); |
|
| 21 | + $vimeo_videos = $this->get_vimeo_videos($embedded_videos); |
|
| 22 | 22 | |
| 23 | - $vimeo_provider = Provider_Factory::get_provider( Provider_Factory::VIMEO ); |
|
| 24 | - $vimeo_videos = $vimeo_provider->get_videos_data( $vimeo_videos ); |
|
| 23 | + $vimeo_provider = Provider_Factory::get_provider(Provider_Factory::VIMEO); |
|
| 24 | + $vimeo_videos = $vimeo_provider->get_videos_data($vimeo_videos); |
|
| 25 | 25 | |
| 26 | - return array_merge( $youtube_videos, $vimeo_videos ); |
|
| 26 | + return array_merge($youtube_videos, $vimeo_videos); |
|
| 27 | 27 | |
| 28 | 28 | } |
| 29 | 29 | |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | * @param $post_id int |
| 33 | 33 | * @param $embedded_videos array<Embedded_Video> |
| 34 | 34 | */ |
| 35 | - private function remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos ) { |
|
| 35 | + private function remove_videos_from_store_if_not_present_in_content($storage, $post_id, $embedded_videos) { |
|
| 36 | 36 | |
| 37 | - $videos_to_be_deleted = $this->get_videos_to_be_deleted( $storage, $post_id, $embedded_videos ); |
|
| 38 | - $storage->remove_videos( $videos_to_be_deleted, $post_id ); |
|
| 37 | + $videos_to_be_deleted = $this->get_videos_to_be_deleted($storage, $post_id, $embedded_videos); |
|
| 38 | + $storage->remove_videos($videos_to_be_deleted, $post_id); |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
@@ -46,20 +46,20 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return array |
| 48 | 48 | */ |
| 49 | - private function get_videos_to_be_deleted( Storage $storage, $post_id, array $embedded_videos ) { |
|
| 50 | - $videos_in_store = $storage->get_all_videos( $post_id ); |
|
| 51 | - $embedded_video_urls = array_map( function ( $embedded_video ) { |
|
| 49 | + private function get_videos_to_be_deleted(Storage $storage, $post_id, array $embedded_videos) { |
|
| 50 | + $videos_in_store = $storage->get_all_videos($post_id); |
|
| 51 | + $embedded_video_urls = array_map(function($embedded_video) { |
|
| 52 | 52 | /** |
| 53 | 53 | * @var $embedded_video Embedded_Video |
| 54 | 54 | */ |
| 55 | 55 | return $embedded_video->get_url(); |
| 56 | - }, $embedded_videos ); |
|
| 56 | + }, $embedded_videos); |
|
| 57 | 57 | |
| 58 | - return array_filter( $videos_in_store, function ( $video ) use ( $embedded_video_urls ) { |
|
| 58 | + return array_filter($videos_in_store, function($video) use ($embedded_video_urls) { |
|
| 59 | 59 | /** |
| 60 | 60 | * @var $video Video |
| 61 | 61 | */ |
| 62 | - return ! in_array( $video->id, $embedded_video_urls ); |
|
| 62 | + return ! in_array($video->id, $embedded_video_urls); |
|
| 63 | 63 | } ); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | * @param \WP_Post $post |
| 68 | 68 | * @param $post_id |
| 69 | 69 | */ |
| 70 | - public function process_video_urls( \WP_Post $post, $post_id ) { |
|
| 70 | + public function process_video_urls(\WP_Post $post, $post_id) { |
|
| 71 | 71 | |
| 72 | - $parser = Parser_Factory::get_parser_from_content( $post->post_content ); |
|
| 72 | + $parser = Parser_Factory::get_parser_from_content($post->post_content); |
|
| 73 | 73 | |
| 74 | - $embedded_videos = $parser->get_videos( $post_id ); |
|
| 74 | + $embedded_videos = $parser->get_videos($post_id); |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Filters the embedded videos on post contet, custom plugins can add their video urls |
@@ -82,30 +82,30 @@ discard block |
||
| 82 | 82 | * @param $post_id int The post id for the videoobject is processed. |
| 83 | 83 | * @return array<Embedded_Video> |
| 84 | 84 | */ |
| 85 | - $embedded_videos = apply_filters('wl_videoobject_embedded_videos', $embedded_videos, $post_id ); |
|
| 85 | + $embedded_videos = apply_filters('wl_videoobject_embedded_videos', $embedded_videos, $post_id); |
|
| 86 | 86 | |
| 87 | 87 | $storage = Video_Storage_Factory::get_storage(); |
| 88 | 88 | |
| 89 | 89 | // Before sending api requests we need to check if there are any videos in |
| 90 | 90 | // store which is not present on post content, remove them if there are |
| 91 | 91 | // any |
| 92 | - $this->remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos ); |
|
| 92 | + $this->remove_videos_from_store_if_not_present_in_content($storage, $post_id, $embedded_videos); |
|
| 93 | 93 | |
| 94 | - $embedded_videos = $this->get_videos_without_existing_data( $storage, $post_id, $embedded_videos ); |
|
| 94 | + $embedded_videos = $this->get_videos_without_existing_data($storage, $post_id, $embedded_videos); |
|
| 95 | 95 | |
| 96 | 96 | // Return early after removing all the videos. |
| 97 | - if ( ! $embedded_videos ) { |
|
| 97 | + if ( ! $embedded_videos) { |
|
| 98 | 98 | return; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $videos = $this->get_data_for_videos( $embedded_videos ); |
|
| 101 | + $videos = $this->get_data_for_videos($embedded_videos); |
|
| 102 | 102 | |
| 103 | - if ( ! $videos ) { |
|
| 103 | + if ( ! $videos) { |
|
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - foreach ( $videos as $video ) { |
|
| 108 | - $storage->add_video( $post_id, $video ); |
|
| 107 | + foreach ($videos as $video) { |
|
| 108 | + $storage->add_video($post_id, $video); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return array<Embedded_Video> Return array of embedded videos which are not in store. |
| 118 | 118 | */ |
| 119 | - private function get_videos_without_existing_data( $storage, $post_id, $embedded_videos ) { |
|
| 120 | - $videos_in_store = $storage->get_all_videos( $post_id ); |
|
| 121 | - $video_ids_in_store = array_map( function ( $video ) { |
|
| 119 | + private function get_videos_without_existing_data($storage, $post_id, $embedded_videos) { |
|
| 120 | + $videos_in_store = $storage->get_all_videos($post_id); |
|
| 121 | + $video_ids_in_store = array_map(function($video) { |
|
| 122 | 122 | return $video->id; |
| 123 | - }, $videos_in_store ); |
|
| 123 | + }, $videos_in_store); |
|
| 124 | 124 | |
| 125 | - return array_filter( $embedded_videos, function ( $embedded_video ) use ( $video_ids_in_store ) { |
|
| 126 | - return ! in_array( $embedded_video->get_url(), $video_ids_in_store ); |
|
| 125 | + return array_filter($embedded_videos, function($embedded_video) use ($video_ids_in_store) { |
|
| 126 | + return ! in_array($embedded_video->get_url(), $video_ids_in_store); |
|
| 127 | 127 | } ); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return array |
| 134 | 134 | */ |
| 135 | - private function get_youtube_videos( $embedded_videos ) { |
|
| 136 | - return array_filter( $embedded_videos, function ( $embedded_video ) { |
|
| 135 | + private function get_youtube_videos($embedded_videos) { |
|
| 136 | + return array_filter($embedded_videos, function($embedded_video) { |
|
| 137 | 137 | /** |
| 138 | 138 | * it should have youtube.com or youtu.be in the url |
| 139 | 139 | * |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | $video_url = $embedded_video->get_url(); |
| 143 | 143 | |
| 144 | - return strpos( $video_url, "youtube.com" ) !== false || |
|
| 145 | - strpos( $video_url, "youtu.be" ) !== false; |
|
| 144 | + return strpos($video_url, "youtube.com") !== false || |
|
| 145 | + strpos($video_url, "youtu.be") !== false; |
|
| 146 | 146 | } ); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @return array |
| 153 | 153 | */ |
| 154 | - private function get_vimeo_videos( $embedded_videos ) { |
|
| 155 | - return array_filter( $embedded_videos, function ( $embedded_video ) { |
|
| 154 | + private function get_vimeo_videos($embedded_videos) { |
|
| 155 | + return array_filter($embedded_videos, function($embedded_video) { |
|
| 156 | 156 | /** |
| 157 | 157 | * it should have vimeo.com in the url |
| 158 | 158 | * |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | $video_url = $embedded_video->get_url(); |
| 162 | 162 | |
| 163 | - return strpos( $video_url, "vimeo.com" ) !== false; |
|
| 163 | + return strpos($video_url, "vimeo.com") !== false; |
|
| 164 | 164 | } ); |
| 165 | 165 | } |
| 166 | 166 | |