Completed
Pull Request — master (#1641)
by Naveen
01:35
created
src/wordlift/videoobject/provider/client/class-jw-player-client.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,50 +11,50 @@
 block discarded – undo
11 11
  */
12 12
 class Jw_Player_Client extends Singleton implements Client {
13 13
 
14
-	public function get_data( $video_urls ) {
14
+    public function get_data( $video_urls ) {
15 15
 
16
-		$videos_data = array();
16
+        $videos_data = array();
17 17
 
18
-		foreach ( $video_urls as $video_url ) {
19
-			$data = wp_remote_get( $video_url );
20
-			if ( is_wp_error( $data ) ) {
21
-				continue;
22
-			}
23
-			$json_body = wp_remote_retrieve_body( $data );
18
+        foreach ( $video_urls as $video_url ) {
19
+            $data = wp_remote_get( $video_url );
20
+            if ( is_wp_error( $data ) ) {
21
+                continue;
22
+            }
23
+            $json_body = wp_remote_retrieve_body( $data );
24 24
 
25
-			$video_data = json_decode( $json_body, true );
26
-			if ( ! $video_data ) {
27
-				continue;
28
-			}
29
-			$video_data['id'] = $video_url;
30
-			$videos_data[]    = $video_data;
31
-		}
25
+            $video_data = json_decode( $json_body, true );
26
+            if ( ! $video_data ) {
27
+                continue;
28
+            }
29
+            $video_data['id'] = $video_url;
30
+            $videos_data[]    = $video_data;
31
+        }
32 32
 
33
-		return $videos_data;
33
+        return $videos_data;
34 34
 
35
-	}
35
+    }
36 36
 
37
-	public function get_video_ids( $video_urls ) {
37
+    public function get_video_ids( $video_urls ) {
38 38
 
39
-		return array_filter(
40
-			$video_urls,
41
-			function ( $item ) {
42
-				return strpos( $item, 'https://cdn.jwplayer.com/v2/media/', 0 ) !== false;
43
-			}
44
-		);
39
+        return array_filter(
40
+            $video_urls,
41
+            function ( $item ) {
42
+                return strpos( $item, 'https://cdn.jwplayer.com/v2/media/', 0 ) !== false;
43
+            }
44
+        );
45 45
 
46
-	}
46
+    }
47 47
 
48
-	public static function get_api_key() {
49
-		// Method not implemented, since we dont need api key
50
-	}
48
+    public static function get_api_key() {
49
+        // Method not implemented, since we dont need api key
50
+    }
51 51
 
52
-	public static function get_api_key_option_name() {
53
-		// Method not implemented, since we dont need api key
54
-	}
52
+    public static function get_api_key_option_name() {
53
+        // Method not implemented, since we dont need api key
54
+    }
55 55
 
56
-	public function get_api_url() {
57
-		// Method not implemented, since we dont need api key
58
-	}
56
+    public function get_api_url() {
57
+        // Method not implemented, since we dont need api key
58
+    }
59 59
 
60 60
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class Jw_Player_Client extends Singleton implements Client {
13 13
 
14
-	public function get_data( $video_urls ) {
14
+	public function get_data($video_urls) {
15 15
 
16 16
 		$videos_data = array();
17 17
 
18
-		foreach ( $video_urls as $video_url ) {
19
-			$data = wp_remote_get( $video_url );
20
-			if ( is_wp_error( $data ) ) {
18
+		foreach ($video_urls as $video_url) {
19
+			$data = wp_remote_get($video_url);
20
+			if (is_wp_error($data)) {
21 21
 				continue;
22 22
 			}
23
-			$json_body = wp_remote_retrieve_body( $data );
23
+			$json_body = wp_remote_retrieve_body($data);
24 24
 
25
-			$video_data = json_decode( $json_body, true );
26
-			if ( ! $video_data ) {
25
+			$video_data = json_decode($json_body, true);
26
+			if ( ! $video_data) {
27 27
 				continue;
28 28
 			}
29 29
 			$video_data['id'] = $video_url;
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 
35 35
 	}
36 36
 
37
-	public function get_video_ids( $video_urls ) {
37
+	public function get_video_ids($video_urls) {
38 38
 
39 39
 		return array_filter(
40 40
 			$video_urls,
41
-			function ( $item ) {
42
-				return strpos( $item, 'https://cdn.jwplayer.com/v2/media/', 0 ) !== false;
41
+			function($item) {
42
+				return strpos($item, 'https://cdn.jwplayer.com/v2/media/', 0) !== false;
43 43
 			}
44 44
 		);
45 45
 
Please login to merge, or discard this patch.
src/wordlift/videoobject/provider/client/class-client-factory.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@
 block discarded – undo
9 9
  */
10 10
 class Client_Factory {
11 11
 
12
-	const YOUTUBE = 'youtube';
12
+    const YOUTUBE = 'youtube';
13 13
 
14
-	const VIMEO = 'vimeo';
14
+    const VIMEO = 'vimeo';
15 15
 
16
-	const JWPLAYER = 'jwplayer';
16
+    const JWPLAYER = 'jwplayer';
17 17
 
18
-	public static function get_client( $config ) {
19
-		if ( self::YOUTUBE === $config ) {
20
-			return Youtube_Client::get_instance();
21
-		} elseif ( self::VIMEO === $config ) {
22
-			return Vimeo_Client::get_instance();
23
-		} elseif ( self::JWPLAYER === $config ) {
24
-			return Jw_Player_Client::get_instance();
25
-		}
18
+    public static function get_client( $config ) {
19
+        if ( self::YOUTUBE === $config ) {
20
+            return Youtube_Client::get_instance();
21
+        } elseif ( self::VIMEO === $config ) {
22
+            return Vimeo_Client::get_instance();
23
+        } elseif ( self::JWPLAYER === $config ) {
24
+            return Jw_Player_Client::get_instance();
25
+        }
26 26
 
27
-	}
27
+    }
28 28
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@
 block discarded – undo
15 15
 
16 16
 	const JWPLAYER = 'jwplayer';
17 17
 
18
-	public static function get_client( $config ) {
19
-		if ( self::YOUTUBE === $config ) {
18
+	public static function get_client($config) {
19
+		if (self::YOUTUBE === $config) {
20 20
 			return Youtube_Client::get_instance();
21
-		} elseif ( self::VIMEO === $config ) {
21
+		} elseif (self::VIMEO === $config) {
22 22
 			return Vimeo_Client::get_instance();
23
-		} elseif ( self::JWPLAYER === $config ) {
23
+		} elseif (self::JWPLAYER === $config) {
24 24
 			return Jw_Player_Client::get_instance();
25 25
 		}
26 26
 
Please login to merge, or discard this patch.
src/wordlift/videoobject/provider/client/class-youtube-client.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -11,75 +11,75 @@
 block discarded – undo
11 11
  */
12 12
 class Youtube_Client extends Singleton implements Client {
13 13
 
14
-	const YOUTUBE_REGEX = '/(?:https?:\/\/)?(?:youtu\.be\/|(?:www\.|m\.)?youtube\.com\/(?:watch|v|embed)(?:\.php)?(?:\?.*v=|\/))([a-zA-Z0-9\_-]+)/m';
14
+    const YOUTUBE_REGEX = '/(?:https?:\/\/)?(?:youtu\.be\/|(?:www\.|m\.)?youtube\.com\/(?:watch|v|embed)(?:\.php)?(?:\?.*v=|\/))([a-zA-Z0-9\_-]+)/m';
15 15
 
16
-	public static $requests_sent = 0;
16
+    public static $requests_sent = 0;
17 17
 
18
-	public static function get_api_key_option_name() {
19
-		return '__wl_video_object_youtube_api_key';
20
-	}
18
+    public static function get_api_key_option_name() {
19
+        return '__wl_video_object_youtube_api_key';
20
+    }
21 21
 
22
-	public static function get_api_key() {
23
-		return get_option( self::get_api_key_option_name(), false );
24
-	}
22
+    public static function get_api_key() {
23
+        return get_option( self::get_api_key_option_name(), false );
24
+    }
25 25
 
26
-	public function get_api_url() {
27
-		return 'https://www.googleapis.com/youtube/v3/videos';
28
-	}
26
+    public function get_api_url() {
27
+        return 'https://www.googleapis.com/youtube/v3/videos';
28
+    }
29 29
 
30
-	public function get_data( $video_urls ) {
31
-		$video_ids = $this->get_video_ids_as_string( $video_urls );
32
-		$url       = add_query_arg(
33
-			array(
34
-				'part' => 'snippet,contentDetails,statistics,liveStreamingDetails',
35
-				'id'   => $video_ids,
36
-				'key'  => $this->get_api_key(),
37
-			),
38
-			$this->get_api_url()
39
-		);
30
+    public function get_data( $video_urls ) {
31
+        $video_ids = $this->get_video_ids_as_string( $video_urls );
32
+        $url       = add_query_arg(
33
+            array(
34
+                'part' => 'snippet,contentDetails,statistics,liveStreamingDetails',
35
+                'id'   => $video_ids,
36
+                'key'  => $this->get_api_key(),
37
+            ),
38
+            $this->get_api_url()
39
+        );
40 40
 
41
-		$response = wp_remote_get( $url );
41
+        $response = wp_remote_get( $url );
42 42
 
43
-		++ self::$requests_sent;
43
+        ++ self::$requests_sent;
44 44
 
45
-		return wp_remote_retrieve_body( $response );
46
-	}
45
+        return wp_remote_retrieve_body( $response );
46
+    }
47 47
 
48
-	private function get_video_ids_as_string( $video_urls ) {
49
-		// validate the urls.
50
-		$video_urls = array_filter(
51
-			$video_urls,
52
-			function ( $url ) {
53
-				return filter_var( $url, FILTER_VALIDATE_URL );
54
-			}
55
-		);
48
+    private function get_video_ids_as_string( $video_urls ) {
49
+        // validate the urls.
50
+        $video_urls = array_filter(
51
+            $video_urls,
52
+            function ( $url ) {
53
+                return filter_var( $url, FILTER_VALIDATE_URL );
54
+            }
55
+        );
56 56
 
57
-		// extract the video ids.
58
-		return join( ',', $this->get_video_ids( $video_urls ) );
59
-	}
57
+        // extract the video ids.
58
+        return join( ',', $this->get_video_ids( $video_urls ) );
59
+    }
60 60
 
61
-	public function get_video_ids( $video_urls ) {
61
+    public function get_video_ids( $video_urls ) {
62 62
 
63
-		$regex = self::YOUTUBE_REGEX;
63
+        $regex = self::YOUTUBE_REGEX;
64 64
 
65
-		$video_ids = array_map(
66
-			function ( $url ) use ( $regex ) {
67
-				$matches = array();
68
-				preg_match( $regex, $url, $matches );
65
+        $video_ids = array_map(
66
+            function ( $url ) use ( $regex ) {
67
+                $matches = array();
68
+                preg_match( $regex, $url, $matches );
69 69
 
70
-				// Return video id or return false.
71
-				if ( isset( $matches[1] ) && is_string( $matches[1] ) ) {
72
-					  return $matches[1];
73
-				}
70
+                // Return video id or return false.
71
+                if ( isset( $matches[1] ) && is_string( $matches[1] ) ) {
72
+                        return $matches[1];
73
+                }
74 74
 
75
-				return false;
75
+                return false;
76 76
 
77
-			},
78
-			$video_urls
79
-		);
77
+            },
78
+            $video_urls
79
+        );
80 80
 
81
-		return array_values( array_filter( $video_ids ) );
81
+        return array_values( array_filter( $video_ids ) );
82 82
 
83
-	}
83
+    }
84 84
 
85 85
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 
22 22
 	public static function get_api_key() {
23
-		return get_option( self::get_api_key_option_name(), false );
23
+		return get_option(self::get_api_key_option_name(), false);
24 24
 	}
25 25
 
26 26
 	public function get_api_url() {
27 27
 		return 'https://www.googleapis.com/youtube/v3/videos';
28 28
 	}
29 29
 
30
-	public function get_data( $video_urls ) {
31
-		$video_ids = $this->get_video_ids_as_string( $video_urls );
30
+	public function get_data($video_urls) {
31
+		$video_ids = $this->get_video_ids_as_string($video_urls);
32 32
 		$url       = add_query_arg(
33 33
 			array(
34 34
 				'part' => 'snippet,contentDetails,statistics,liveStreamingDetails',
@@ -38,37 +38,35 @@  discard block
 block discarded – undo
38 38
 			$this->get_api_url()
39 39
 		);
40 40
 
41
-		$response = wp_remote_get( $url );
41
+		$response = wp_remote_get($url);++ self::$requests_sent;
42 42
 
43
-		++ self::$requests_sent;
44
-
45
-		return wp_remote_retrieve_body( $response );
43
+		return wp_remote_retrieve_body($response);
46 44
 	}
47 45
 
48
-	private function get_video_ids_as_string( $video_urls ) {
46
+	private function get_video_ids_as_string($video_urls) {
49 47
 		// validate the urls.
50 48
 		$video_urls = array_filter(
51 49
 			$video_urls,
52
-			function ( $url ) {
53
-				return filter_var( $url, FILTER_VALIDATE_URL );
50
+			function($url) {
51
+				return filter_var($url, FILTER_VALIDATE_URL);
54 52
 			}
55 53
 		);
56 54
 
57 55
 		// extract the video ids.
58
-		return join( ',', $this->get_video_ids( $video_urls ) );
56
+		return join(',', $this->get_video_ids($video_urls));
59 57
 	}
60 58
 
61
-	public function get_video_ids( $video_urls ) {
59
+	public function get_video_ids($video_urls) {
62 60
 
63 61
 		$regex = self::YOUTUBE_REGEX;
64 62
 
65 63
 		$video_ids = array_map(
66
-			function ( $url ) use ( $regex ) {
64
+			function($url) use ($regex) {
67 65
 				$matches = array();
68
-				preg_match( $regex, $url, $matches );
66
+				preg_match($regex, $url, $matches);
69 67
 
70 68
 				// Return video id or return false.
71
-				if ( isset( $matches[1] ) && is_string( $matches[1] ) ) {
69
+				if (isset($matches[1]) && is_string($matches[1])) {
72 70
 					  return $matches[1];
73 71
 				}
74 72
 
@@ -78,7 +76,7 @@  discard block
 block discarded – undo
78 76
 			$video_urls
79 77
 		);
80 78
 
81
-		return array_values( array_filter( $video_ids ) );
79
+		return array_values(array_filter($video_ids));
82 80
 
83 81
 	}
84 82
 
Please login to merge, or discard this patch.
src/wordlift/videoobject/provider/client/class-vimeo-client.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -11,83 +11,83 @@
 block discarded – undo
11 11
  */
12 12
 class Vimeo_Client extends Singleton implements Client {
13 13
 
14
-	public static $requests_sent = 0;
14
+    public static $requests_sent = 0;
15 15
 
16
-	const VIMEO_URL_REGEX = '/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/';
16
+    const VIMEO_URL_REGEX = '/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/';
17 17
 
18
-	public function get_data( $video_urls ) {
18
+    public function get_data( $video_urls ) {
19 19
 
20
-		$vimeo_ids = $this->get_video_ids( $video_urls );
20
+        $vimeo_ids = $this->get_video_ids( $video_urls );
21 21
 
22
-		$vimeo_api_ids = array_map(
23
-			function ( $item ) {
24
-				return '/videos/' . $item;
25
-			},
26
-			$vimeo_ids
27
-		);
22
+        $vimeo_api_ids = array_map(
23
+            function ( $item ) {
24
+                return '/videos/' . $item;
25
+            },
26
+            $vimeo_ids
27
+        );
28 28
 
29
-		$ids = join( ',', $vimeo_api_ids );
29
+        $ids = join( ',', $vimeo_api_ids );
30 30
 
31
-		if ( ! $ids ) {
32
-			return array();
33
-		}
31
+        if ( ! $ids ) {
32
+            return array();
33
+        }
34 34
 
35
-		$api_url = $this->get_api_url() . '/videos/';
36
-		$api_url = add_query_arg(
37
-			array(
38
-				'uris'   => $ids,
39
-				'fields' => 'name,description,link,uri,duration,release_time,pictures,stats',
40
-			),
41
-			$api_url
42
-		);
35
+        $api_url = $this->get_api_url() . '/videos/';
36
+        $api_url = add_query_arg(
37
+            array(
38
+                'uris'   => $ids,
39
+                'fields' => 'name,description,link,uri,duration,release_time,pictures,stats',
40
+            ),
41
+            $api_url
42
+        );
43 43
 
44
-		$response = wp_remote_get(
45
-			$api_url,
46
-			array(
47
-				'headers' => array(
48
-					'Authorization' => 'bearer ' . $this->get_api_key(),
49
-				),
50
-			)
51
-		);
44
+        $response = wp_remote_get(
45
+            $api_url,
46
+            array(
47
+                'headers' => array(
48
+                    'Authorization' => 'bearer ' . $this->get_api_key(),
49
+                ),
50
+            )
51
+        );
52 52
 
53
-		++ self::$requests_sent;
53
+        ++ self::$requests_sent;
54 54
 
55
-		return wp_remote_retrieve_body( $response );
56
-	}
55
+        return wp_remote_retrieve_body( $response );
56
+    }
57 57
 
58
-	public static function get_api_key() {
59
-		return get_option( self::get_api_key_option_name(), false );
60
-	}
58
+    public static function get_api_key() {
59
+        return get_option( self::get_api_key_option_name(), false );
60
+    }
61 61
 
62
-	public static function get_api_key_option_name() {
63
-		return '_wl_videoobject_vimeo_api_key';
64
-	}
62
+    public static function get_api_key_option_name() {
63
+        return '_wl_videoobject_vimeo_api_key';
64
+    }
65 65
 
66
-	public function get_api_url() {
67
-		return 'https://api.vimeo.com';
68
-	}
66
+    public function get_api_url() {
67
+        return 'https://api.vimeo.com';
68
+    }
69 69
 
70
-	public function get_video_ids( $video_urls ) {
70
+    public function get_video_ids( $video_urls ) {
71 71
 
72
-		$that = $this;
72
+        $that = $this;
73 73
 
74
-		return array_filter(
75
-			array_map(
76
-				function ( $video_url ) use ( $that ) {
77
-					if ( ! $video_url ) {
78
-						  return false;
79
-					}
80
-					preg_match( $that::VIMEO_URL_REGEX, $video_url, $matches );
74
+        return array_filter(
75
+            array_map(
76
+                function ( $video_url ) use ( $that ) {
77
+                    if ( ! $video_url ) {
78
+                            return false;
79
+                    }
80
+                    preg_match( $that::VIMEO_URL_REGEX, $video_url, $matches );
81 81
 
82
-					if ( ! array_key_exists( 3, $matches ) ) {
83
-						return false;
84
-					}
82
+                    if ( ! array_key_exists( 3, $matches ) ) {
83
+                        return false;
84
+                    }
85 85
 
86
-					return $matches[3];
86
+                    return $matches[3];
87 87
 
88
-				},
89
-				$video_urls
90
-			)
91
-		);
92
-	}
88
+                },
89
+                $video_urls
90
+            )
91
+        );
92
+    }
93 93
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 
16 16
 	const VIMEO_URL_REGEX = '/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/';
17 17
 
18
-	public function get_data( $video_urls ) {
18
+	public function get_data($video_urls) {
19 19
 
20
-		$vimeo_ids = $this->get_video_ids( $video_urls );
20
+		$vimeo_ids = $this->get_video_ids($video_urls);
21 21
 
22 22
 		$vimeo_api_ids = array_map(
23
-			function ( $item ) {
24
-				return '/videos/' . $item;
23
+			function($item) {
24
+				return '/videos/'.$item;
25 25
 			},
26 26
 			$vimeo_ids
27 27
 		);
28 28
 
29
-		$ids = join( ',', $vimeo_api_ids );
29
+		$ids = join(',', $vimeo_api_ids);
30 30
 
31
-		if ( ! $ids ) {
31
+		if ( ! $ids) {
32 32
 			return array();
33 33
 		}
34 34
 
35
-		$api_url = $this->get_api_url() . '/videos/';
35
+		$api_url = $this->get_api_url().'/videos/';
36 36
 		$api_url = add_query_arg(
37 37
 			array(
38 38
 				'uris'   => $ids,
@@ -45,18 +45,16 @@  discard block
 block discarded – undo
45 45
 			$api_url,
46 46
 			array(
47 47
 				'headers' => array(
48
-					'Authorization' => 'bearer ' . $this->get_api_key(),
48
+					'Authorization' => 'bearer '.$this->get_api_key(),
49 49
 				),
50 50
 			)
51
-		);
52
-
53
-		++ self::$requests_sent;
51
+		);++ self::$requests_sent;
54 52
 
55
-		return wp_remote_retrieve_body( $response );
53
+		return wp_remote_retrieve_body($response);
56 54
 	}
57 55
 
58 56
 	public static function get_api_key() {
59
-		return get_option( self::get_api_key_option_name(), false );
57
+		return get_option(self::get_api_key_option_name(), false);
60 58
 	}
61 59
 
62 60
 	public static function get_api_key_option_name() {
@@ -67,19 +65,19 @@  discard block
 block discarded – undo
67 65
 		return 'https://api.vimeo.com';
68 66
 	}
69 67
 
70
-	public function get_video_ids( $video_urls ) {
68
+	public function get_video_ids($video_urls) {
71 69
 
72 70
 		$that = $this;
73 71
 
74 72
 		return array_filter(
75 73
 			array_map(
76
-				function ( $video_url ) use ( $that ) {
77
-					if ( ! $video_url ) {
74
+				function($video_url) use ($that) {
75
+					if ( ! $video_url) {
78 76
 						  return false;
79 77
 					}
80
-					preg_match( $that::VIMEO_URL_REGEX, $video_url, $matches );
78
+					preg_match($that::VIMEO_URL_REGEX, $video_url, $matches);
81 79
 
82
-					if ( ! array_key_exists( 3, $matches ) ) {
80
+					if ( ! array_key_exists(3, $matches)) {
83 81
 						return false;
84 82
 					}
85 83
 
Please login to merge, or discard this patch.
src/wordlift/videoobject/provider/client/class-client.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,39 +7,39 @@
 block discarded – undo
7 7
  * This acts as interface for api clients
8 8
  */
9 9
 interface Client {
10
-	/**
11
-	 *
12
-	 * @param $video_urls array<string> Array of urls.
13
-	 *
14
-	 * Response body or false if the request cant be made or failed.
15
-	 * @return string | false
16
-	 */
17
-	public function get_data( $video_urls );
10
+    /**
11
+     *
12
+     * @param $video_urls array<string> Array of urls.
13
+     *
14
+     * Response body or false if the request cant be made or failed.
15
+     * @return string | false
16
+     */
17
+    public function get_data( $video_urls );
18 18
 
19
-	/**
20
-	 * @return string
21
-	 */
22
-	public static function get_api_key();
23
-	/**
24
-	 * Returns the option where the api key is stored.
25
-	 *
26
-	 * @return string
27
-	 */
28
-	public static function get_api_key_option_name();
19
+    /**
20
+     * @return string
21
+     */
22
+    public static function get_api_key();
23
+    /**
24
+     * Returns the option where the api key is stored.
25
+     *
26
+     * @return string
27
+     */
28
+    public static function get_api_key_option_name();
29 29
 
30
-	/**
31
-	 * The api base url.
32
-	 *
33
-	 * @return string
34
-	 */
35
-	public function get_api_url();
30
+    /**
31
+     * The api base url.
32
+     *
33
+     * @return string
34
+     */
35
+    public function get_api_url();
36 36
 
37
-	/**
38
-	 * Get video ids from URLs.
39
-	 *
40
-	 * @param $video_urls array<string>
41
-	 * @return array<string>
42
-	 */
43
-	public function get_video_ids( $video_urls  );
37
+    /**
38
+     * Get video ids from URLs.
39
+     *
40
+     * @param $video_urls array<string>
41
+     * @return array<string>
42
+     */
43
+    public function get_video_ids( $video_urls  );
44 44
 
45 45
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	 * Response body or false if the request cant be made or failed.
15 15
 	 * @return string | false
16 16
 	 */
17
-	public function get_data( $video_urls );
17
+	public function get_data($video_urls);
18 18
 
19 19
 	/**
20 20
 	 * @return string
@@ -40,6 +40,6 @@  discard block
 block discarded – undo
40 40
 	 * @param $video_urls array<string>
41 41
 	 * @return array<string>
42 42
 	 */
43
-	public function get_video_ids( $video_urls  );
43
+	public function get_video_ids($video_urls);
44 44
 
45 45
 }
Please login to merge, or discard this patch.
src/wordlift/videoobject/jsonld/class-jsonld.php 2 patches
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -11,175 +11,175 @@
 block discarded – undo
11 11
 use Wordlift\Videoobject\Data\Video_Storage\Storage;
12 12
 
13 13
 class Jsonld {
14
-	/**
15
-	 * @var Storage
16
-	 */
17
-	private $video_storage;
18
-
19
-	/**
20
-	 * Jsonld constructor.
21
-	 *
22
-	 * @param $video_storage Storage
23
-	 */
24
-	public function __construct( $video_storage ) {
25
-		add_action( 'wl_post_jsonld', array( $this, 'wl_post_jsonld' ), 10, 2 );
26
-		add_action( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 2 );
27
-		$this->video_storage = $video_storage;
28
-	}
29
-
30
-	public function wl_after_get_jsonld( $jsonld, $post_id ) {
31
-		if ( 0 === count( $jsonld ) ) {
32
-			return $jsonld;
33
-		}
34
-		$current_item = $jsonld[0];
35
-
36
-		if ( ! is_array( $current_item ) || ! array_key_exists( '@type', $current_item ) ) {
37
-			// Cant determine type return early.
38
-			return $jsonld;
39
-		}
40
-
41
-		$type = $current_item['@type'];
42
-		if ( is_string( $type ) ) {
43
-			$type = array( $type );
44
-		}
45
-		// If its a article or descendant of article, then dont add the
46
-		// videoobject in this hook, they will be already added to video property.
47
-		if ( array_intersect( Jsonld_Article_Wrapper::$article_types, $type ) ) {
48
-			return $jsonld;
49
-		}
50
-
51
-		$videos_jsonld = $this->get_videos_jsonld( $post_id );
52
-		if ( 0 === count( $videos_jsonld ) ) {
53
-			return $jsonld;
54
-		}
55
-
56
-		// check if we have @id in jsonld for first item.
57
-		$id = array_key_exists( '@id', $current_item ) ? $current_item['@id'] : '';
58
-
59
-		foreach ( $videos_jsonld as &$video_jsonld ) {
60
-			if ( ! $id ) {
61
-				continue;
62
-			}
63
-			if ( ! array_key_exists( 'mentions', $video_jsonld ) ) {
64
-				$video_jsonld['mentions'] = array( '@id' => $id );
65
-			} else {
66
-				$video_jsonld['mentions'] = array_merge( $video_jsonld['mentions'], array( '@id' => $id ) );
67
-			}
68
-		}
69
-
70
-		return array_merge( $jsonld, $videos_jsonld );
71
-	}
72
-
73
-	/**
74
-	 * @param $existing_video_data string | array associative or sequential array.
75
-	 * @param $new_video_data array Sequential array.
76
-	 *
77
-	 * @return array
78
-	 */
79
-	private function merge_video_data( $existing_video_data, $new_video_data ) {
80
-		if ( ! is_array( $existing_video_data ) ) {
81
-			$new_video_data[] = $existing_video_data;
82
-
83
-			return $new_video_data;
84
-		}
85
-
86
-		if ( $this->is_associative_array( $existing_video_data ) ) {
87
-			$new_video_data[] = $existing_video_data;
88
-
89
-			return $new_video_data;
90
-		}
91
-
92
-		return array_merge( $existing_video_data, $new_video_data );
93
-	}
94
-
95
-	public function wl_post_jsonld( $jsonld, $post_id ) {
96
-
97
-		$video_jsonld = $this->get_videos_jsonld( $post_id );
98
-		if ( count( $video_jsonld ) === 0 ) {
99
-			return $jsonld;
100
-		}
101
-		// Before adding the video jsonld check if the key
102
-		// is present and additional data might be present,
103
-		// if not present just add the data and return early.
104
-		if ( ! array_key_exists( 'video', $jsonld ) ) {
105
-			$jsonld['video'] = $video_jsonld;
106
-
107
-			return $jsonld;
108
-		}
109
-
110
-		// since key exists, we need to merge the data based on type.
111
-		$previous_video_data = $jsonld['video'];
112
-		$jsonld['video']     = $this->merge_video_data( $previous_video_data, $video_jsonld );
113
-
114
-		return $jsonld;
115
-	}
116
-
117
-	/**
118
-	 * @param $post_id int Post id.
119
-	 *
120
-	 * @return array
121
-	 */
122
-	public function get_videos_jsonld( $post_id ) {
123
-
124
-		$videos = $this->video_storage->get_all_videos( $post_id );
125
-
126
-		$jsonld = array();
127
-
128
-		foreach ( $videos as $video ) {
129
-			/**
130
-			 * @var $video Video
131
-			 */
132
-			$description = $video->description;
133
-			if ( ! $video->description ) {
134
-				// If description is empty then use the video title as description
135
-				$description = $video->name;
136
-			}
137
-			$single_jsonld = array(
138
-				'@context'     => 'http://schema.org',
139
-				'@type'        => 'VideoObject',
140
-				'name'         => $video->name,
141
-				'description'  => $description,
142
-				'contentUrl'   => $video->content_url,
143
-				'uploadDate'   => $video->upload_date,
144
-				'thumbnailUrl' => $video->thumbnail_urls,
145
-				'duration'     => $video->duration,
146
-			);
147
-
148
-			if ( $video->embed_url ) {
149
-				$single_jsonld['embedUrl'] = $video->embed_url;
150
-			}
151
-
152
-			if ( $video->views ) {
153
-				$single_jsonld['interactionStatistic'] = array(
154
-					'@type'                => 'InteractionCounter',
155
-					'interactionType'      => array(
156
-						'@type' => 'http://schema.org/WatchAction',
157
-					),
158
-					'userInteractionCount' => $video->views,
159
-				);
160
-			}
161
-
162
-			if ( $video->is_live_video ) {
163
-				$single_jsonld['publication'] = array(
164
-					'@type'           => 'BroadcastEvent',
165
-					'isLiveBroadcast' => true,
166
-					'startDate'       => $video->live_video_start_date,
167
-					'endDate'         => $video->live_video_end_date,
168
-				);
169
-			}
170
-
171
-			$jsonld[] = $single_jsonld;
172
-		}
173
-
174
-		return $jsonld;
175
-	}
176
-
177
-	private function is_associative_array( $arr ) {
178
-		if ( array() === $arr ) {
179
-			return false;
180
-		}
181
-
182
-		return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
183
-	}
14
+    /**
15
+     * @var Storage
16
+     */
17
+    private $video_storage;
18
+
19
+    /**
20
+     * Jsonld constructor.
21
+     *
22
+     * @param $video_storage Storage
23
+     */
24
+    public function __construct( $video_storage ) {
25
+        add_action( 'wl_post_jsonld', array( $this, 'wl_post_jsonld' ), 10, 2 );
26
+        add_action( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 2 );
27
+        $this->video_storage = $video_storage;
28
+    }
29
+
30
+    public function wl_after_get_jsonld( $jsonld, $post_id ) {
31
+        if ( 0 === count( $jsonld ) ) {
32
+            return $jsonld;
33
+        }
34
+        $current_item = $jsonld[0];
35
+
36
+        if ( ! is_array( $current_item ) || ! array_key_exists( '@type', $current_item ) ) {
37
+            // Cant determine type return early.
38
+            return $jsonld;
39
+        }
40
+
41
+        $type = $current_item['@type'];
42
+        if ( is_string( $type ) ) {
43
+            $type = array( $type );
44
+        }
45
+        // If its a article or descendant of article, then dont add the
46
+        // videoobject in this hook, they will be already added to video property.
47
+        if ( array_intersect( Jsonld_Article_Wrapper::$article_types, $type ) ) {
48
+            return $jsonld;
49
+        }
50
+
51
+        $videos_jsonld = $this->get_videos_jsonld( $post_id );
52
+        if ( 0 === count( $videos_jsonld ) ) {
53
+            return $jsonld;
54
+        }
55
+
56
+        // check if we have @id in jsonld for first item.
57
+        $id = array_key_exists( '@id', $current_item ) ? $current_item['@id'] : '';
58
+
59
+        foreach ( $videos_jsonld as &$video_jsonld ) {
60
+            if ( ! $id ) {
61
+                continue;
62
+            }
63
+            if ( ! array_key_exists( 'mentions', $video_jsonld ) ) {
64
+                $video_jsonld['mentions'] = array( '@id' => $id );
65
+            } else {
66
+                $video_jsonld['mentions'] = array_merge( $video_jsonld['mentions'], array( '@id' => $id ) );
67
+            }
68
+        }
69
+
70
+        return array_merge( $jsonld, $videos_jsonld );
71
+    }
72
+
73
+    /**
74
+     * @param $existing_video_data string | array associative or sequential array.
75
+     * @param $new_video_data array Sequential array.
76
+     *
77
+     * @return array
78
+     */
79
+    private function merge_video_data( $existing_video_data, $new_video_data ) {
80
+        if ( ! is_array( $existing_video_data ) ) {
81
+            $new_video_data[] = $existing_video_data;
82
+
83
+            return $new_video_data;
84
+        }
85
+
86
+        if ( $this->is_associative_array( $existing_video_data ) ) {
87
+            $new_video_data[] = $existing_video_data;
88
+
89
+            return $new_video_data;
90
+        }
91
+
92
+        return array_merge( $existing_video_data, $new_video_data );
93
+    }
94
+
95
+    public function wl_post_jsonld( $jsonld, $post_id ) {
96
+
97
+        $video_jsonld = $this->get_videos_jsonld( $post_id );
98
+        if ( count( $video_jsonld ) === 0 ) {
99
+            return $jsonld;
100
+        }
101
+        // Before adding the video jsonld check if the key
102
+        // is present and additional data might be present,
103
+        // if not present just add the data and return early.
104
+        if ( ! array_key_exists( 'video', $jsonld ) ) {
105
+            $jsonld['video'] = $video_jsonld;
106
+
107
+            return $jsonld;
108
+        }
109
+
110
+        // since key exists, we need to merge the data based on type.
111
+        $previous_video_data = $jsonld['video'];
112
+        $jsonld['video']     = $this->merge_video_data( $previous_video_data, $video_jsonld );
113
+
114
+        return $jsonld;
115
+    }
116
+
117
+    /**
118
+     * @param $post_id int Post id.
119
+     *
120
+     * @return array
121
+     */
122
+    public function get_videos_jsonld( $post_id ) {
123
+
124
+        $videos = $this->video_storage->get_all_videos( $post_id );
125
+
126
+        $jsonld = array();
127
+
128
+        foreach ( $videos as $video ) {
129
+            /**
130
+             * @var $video Video
131
+             */
132
+            $description = $video->description;
133
+            if ( ! $video->description ) {
134
+                // If description is empty then use the video title as description
135
+                $description = $video->name;
136
+            }
137
+            $single_jsonld = array(
138
+                '@context'     => 'http://schema.org',
139
+                '@type'        => 'VideoObject',
140
+                'name'         => $video->name,
141
+                'description'  => $description,
142
+                'contentUrl'   => $video->content_url,
143
+                'uploadDate'   => $video->upload_date,
144
+                'thumbnailUrl' => $video->thumbnail_urls,
145
+                'duration'     => $video->duration,
146
+            );
147
+
148
+            if ( $video->embed_url ) {
149
+                $single_jsonld['embedUrl'] = $video->embed_url;
150
+            }
151
+
152
+            if ( $video->views ) {
153
+                $single_jsonld['interactionStatistic'] = array(
154
+                    '@type'                => 'InteractionCounter',
155
+                    'interactionType'      => array(
156
+                        '@type' => 'http://schema.org/WatchAction',
157
+                    ),
158
+                    'userInteractionCount' => $video->views,
159
+                );
160
+            }
161
+
162
+            if ( $video->is_live_video ) {
163
+                $single_jsonld['publication'] = array(
164
+                    '@type'           => 'BroadcastEvent',
165
+                    'isLiveBroadcast' => true,
166
+                    'startDate'       => $video->live_video_start_date,
167
+                    'endDate'         => $video->live_video_end_date,
168
+                );
169
+            }
170
+
171
+            $jsonld[] = $single_jsonld;
172
+        }
173
+
174
+        return $jsonld;
175
+    }
176
+
177
+    private function is_associative_array( $arr ) {
178
+        if ( array() === $arr ) {
179
+            return false;
180
+        }
181
+
182
+        return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
183
+    }
184 184
 
185 185
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -21,53 +21,53 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param $video_storage Storage
23 23
 	 */
24
-	public function __construct( $video_storage ) {
25
-		add_action( 'wl_post_jsonld', array( $this, 'wl_post_jsonld' ), 10, 2 );
26
-		add_action( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 2 );
24
+	public function __construct($video_storage) {
25
+		add_action('wl_post_jsonld', array($this, 'wl_post_jsonld'), 10, 2);
26
+		add_action('wl_after_get_jsonld', array($this, 'wl_after_get_jsonld'), 10, 2);
27 27
 		$this->video_storage = $video_storage;
28 28
 	}
29 29
 
30
-	public function wl_after_get_jsonld( $jsonld, $post_id ) {
31
-		if ( 0 === count( $jsonld ) ) {
30
+	public function wl_after_get_jsonld($jsonld, $post_id) {
31
+		if (0 === count($jsonld)) {
32 32
 			return $jsonld;
33 33
 		}
34 34
 		$current_item = $jsonld[0];
35 35
 
36
-		if ( ! is_array( $current_item ) || ! array_key_exists( '@type', $current_item ) ) {
36
+		if ( ! is_array($current_item) || ! array_key_exists('@type', $current_item)) {
37 37
 			// Cant determine type return early.
38 38
 			return $jsonld;
39 39
 		}
40 40
 
41 41
 		$type = $current_item['@type'];
42
-		if ( is_string( $type ) ) {
43
-			$type = array( $type );
42
+		if (is_string($type)) {
43
+			$type = array($type);
44 44
 		}
45 45
 		// If its a article or descendant of article, then dont add the
46 46
 		// videoobject in this hook, they will be already added to video property.
47
-		if ( array_intersect( Jsonld_Article_Wrapper::$article_types, $type ) ) {
47
+		if (array_intersect(Jsonld_Article_Wrapper::$article_types, $type)) {
48 48
 			return $jsonld;
49 49
 		}
50 50
 
51
-		$videos_jsonld = $this->get_videos_jsonld( $post_id );
52
-		if ( 0 === count( $videos_jsonld ) ) {
51
+		$videos_jsonld = $this->get_videos_jsonld($post_id);
52
+		if (0 === count($videos_jsonld)) {
53 53
 			return $jsonld;
54 54
 		}
55 55
 
56 56
 		// check if we have @id in jsonld for first item.
57
-		$id = array_key_exists( '@id', $current_item ) ? $current_item['@id'] : '';
57
+		$id = array_key_exists('@id', $current_item) ? $current_item['@id'] : '';
58 58
 
59
-		foreach ( $videos_jsonld as &$video_jsonld ) {
60
-			if ( ! $id ) {
59
+		foreach ($videos_jsonld as &$video_jsonld) {
60
+			if ( ! $id) {
61 61
 				continue;
62 62
 			}
63
-			if ( ! array_key_exists( 'mentions', $video_jsonld ) ) {
64
-				$video_jsonld['mentions'] = array( '@id' => $id );
63
+			if ( ! array_key_exists('mentions', $video_jsonld)) {
64
+				$video_jsonld['mentions'] = array('@id' => $id);
65 65
 			} else {
66
-				$video_jsonld['mentions'] = array_merge( $video_jsonld['mentions'], array( '@id' => $id ) );
66
+				$video_jsonld['mentions'] = array_merge($video_jsonld['mentions'], array('@id' => $id));
67 67
 			}
68 68
 		}
69 69
 
70
-		return array_merge( $jsonld, $videos_jsonld );
70
+		return array_merge($jsonld, $videos_jsonld);
71 71
 	}
72 72
 
73 73
 	/**
@@ -76,32 +76,32 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return array
78 78
 	 */
79
-	private function merge_video_data( $existing_video_data, $new_video_data ) {
80
-		if ( ! is_array( $existing_video_data ) ) {
79
+	private function merge_video_data($existing_video_data, $new_video_data) {
80
+		if ( ! is_array($existing_video_data)) {
81 81
 			$new_video_data[] = $existing_video_data;
82 82
 
83 83
 			return $new_video_data;
84 84
 		}
85 85
 
86
-		if ( $this->is_associative_array( $existing_video_data ) ) {
86
+		if ($this->is_associative_array($existing_video_data)) {
87 87
 			$new_video_data[] = $existing_video_data;
88 88
 
89 89
 			return $new_video_data;
90 90
 		}
91 91
 
92
-		return array_merge( $existing_video_data, $new_video_data );
92
+		return array_merge($existing_video_data, $new_video_data);
93 93
 	}
94 94
 
95
-	public function wl_post_jsonld( $jsonld, $post_id ) {
95
+	public function wl_post_jsonld($jsonld, $post_id) {
96 96
 
97
-		$video_jsonld = $this->get_videos_jsonld( $post_id );
98
-		if ( count( $video_jsonld ) === 0 ) {
97
+		$video_jsonld = $this->get_videos_jsonld($post_id);
98
+		if (count($video_jsonld) === 0) {
99 99
 			return $jsonld;
100 100
 		}
101 101
 		// Before adding the video jsonld check if the key
102 102
 		// is present and additional data might be present,
103 103
 		// if not present just add the data and return early.
104
-		if ( ! array_key_exists( 'video', $jsonld ) ) {
104
+		if ( ! array_key_exists('video', $jsonld)) {
105 105
 			$jsonld['video'] = $video_jsonld;
106 106
 
107 107
 			return $jsonld;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
 		// since key exists, we need to merge the data based on type.
111 111
 		$previous_video_data = $jsonld['video'];
112
-		$jsonld['video']     = $this->merge_video_data( $previous_video_data, $video_jsonld );
112
+		$jsonld['video']     = $this->merge_video_data($previous_video_data, $video_jsonld);
113 113
 
114 114
 		return $jsonld;
115 115
 	}
@@ -119,18 +119,18 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return array
121 121
 	 */
122
-	public function get_videos_jsonld( $post_id ) {
122
+	public function get_videos_jsonld($post_id) {
123 123
 
124
-		$videos = $this->video_storage->get_all_videos( $post_id );
124
+		$videos = $this->video_storage->get_all_videos($post_id);
125 125
 
126 126
 		$jsonld = array();
127 127
 
128
-		foreach ( $videos as $video ) {
128
+		foreach ($videos as $video) {
129 129
 			/**
130 130
 			 * @var $video Video
131 131
 			 */
132 132
 			$description = $video->description;
133
-			if ( ! $video->description ) {
133
+			if ( ! $video->description) {
134 134
 				// If description is empty then use the video title as description
135 135
 				$description = $video->name;
136 136
 			}
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 				'duration'     => $video->duration,
146 146
 			);
147 147
 
148
-			if ( $video->embed_url ) {
148
+			if ($video->embed_url) {
149 149
 				$single_jsonld['embedUrl'] = $video->embed_url;
150 150
 			}
151 151
 
152
-			if ( $video->views ) {
152
+			if ($video->views) {
153 153
 				$single_jsonld['interactionStatistic'] = array(
154 154
 					'@type'                => 'InteractionCounter',
155 155
 					'interactionType'      => array(
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 				);
160 160
 			}
161 161
 
162
-			if ( $video->is_live_video ) {
162
+			if ($video->is_live_video) {
163 163
 				$single_jsonld['publication'] = array(
164 164
 					'@type'           => 'BroadcastEvent',
165 165
 					'isLiveBroadcast' => true,
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 		return $jsonld;
175 175
 	}
176 176
 
177
-	private function is_associative_array( $arr ) {
178
-		if ( array() === $arr ) {
177
+	private function is_associative_array($arr) {
178
+		if (array() === $arr) {
179 179
 			return false;
180 180
 		}
181 181
 
182
-		return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
182
+		return array_keys($arr) !== range(0, count($arr) - 1);
183 183
 	}
184 184
 
185 185
 }
Please login to merge, or discard this patch.
src/wordlift/videoobject/class-loader.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@
 block discarded – undo
25 25
 
26 26
 	public function init_all_dependencies() {
27 27
 		$video_storage = Video_Storage_Factory::get_storage();
28
-		new Jsonld( $video_storage );
28
+		new Jsonld($video_storage);
29 29
 
30
-		$sitemap_cache = new Ttl_Cache( 'wl_video_sitemap', 86400 );
30
+		$sitemap_cache = new Ttl_Cache('wl_video_sitemap', 86400);
31 31
 
32 32
 		$video_processor = new Video_Processor();
33 33
 		// Hook in to save_post to save the videos
34
-		$post_filter = new Post_Filter( $video_processor );
34
+		$post_filter = new Post_Filter($video_processor);
35 35
 		$post_filter->init();
36 36
 		// Add entry to wordlift admin tabs
37 37
 		$settings_tab = new Settings_Tab();
38 38
 		$settings_tab->init();
39 39
 
40
-		$video_sitemap = new Video_Sitemap( $sitemap_cache );
40
+		$video_sitemap = new Video_Sitemap($sitemap_cache);
41 41
 		$video_sitemap->init();
42 42
 
43
-		$background_process_data_source = new Videos_Data_Source( '__wl_videoobject_import_state' );
44
-		$background_process             = new Videoobject_Background_Process( $video_processor, $background_process_data_source );
43
+		$background_process_data_source = new Videos_Data_Source('__wl_videoobject_import_state');
44
+		$background_process             = new Videoobject_Background_Process($video_processor, $background_process_data_source);
45 45
 
46
-		$rest_controller = new Rest_Controller( $background_process );
46
+		$rest_controller = new Rest_Controller($background_process);
47 47
 		$rest_controller->register_all_routes();
48 48
 
49 49
 		$post_edit_screen = new Post_Edit_Screen();
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -24,60 +24,60 @@
 block discarded – undo
24 24
  */
25 25
 class Loader extends Default_Loader {
26 26
 
27
-	public function init_all_dependencies() {
28
-		$video_storage = Video_Storage_Factory::get_storage();
29
-		new Jsonld( $video_storage );
30
-
31
-		$sitemap_cache = new Ttl_Cache( 'wl_video_sitemap', 86400 );
32
-
33
-		$video_processor = new Video_Processor();
34
-		// Hook in to save_post to save the videos
35
-		$post_filter = new Post_Filter( $video_processor );
36
-		$post_filter->init();
37
-		// Add entry to wordlift admin tabs
38
-		$settings_tab = new Settings_Tab();
39
-		$settings_tab->init();
40
-
41
-		$video_sitemap = new Video_Sitemap( $sitemap_cache );
42
-		$video_sitemap->init();
43
-
44
-		$background_process_data_source = new Videos_Data_Source( '__wl_videoobject_import_state' );
45
-		$background_process             = new Videoobject_Background_Process( $video_processor, $background_process_data_source );
46
-
47
-		$rest_controller = new Rest_Controller( $background_process );
48
-		$rest_controller->register_all_routes();
49
-
50
-		$post_edit_screen = new Post_Edit_Screen();
51
-		$post_edit_screen->init();
52
-
53
-		new Import_Videos_Page();
54
-
55
-		/**
56
-		 * @since 3.32.0
57
-		 * Allow videoobject to capture embed shortcode.
58
-		 */
59
-		$embed_shortcode_capture = new Embed_Shortcode_Capture();
60
-		$embed_shortcode_capture->init();
61
-
62
-		/**
63
-		 * @since 3.32.0
64
-		 * Get videos from jw player.
65
-		 */
66
-		$jw_player_capture_videos = new Jw_Player_Capture();
67
-		$jw_player_capture_videos->init();
68
-
69
-		/**
70
-		 * Validate API Key for Youtube, Vimeo.
71
-		 */
72
-		new Video_Key_Validation_Service();
73
-
74
-	}
75
-
76
-	public function get_feature_slug() {
77
-		return 'videoobject';
78
-	}
79
-
80
-	public function get_feature_default_value() {
81
-		return false;
82
-	}
27
+    public function init_all_dependencies() {
28
+        $video_storage = Video_Storage_Factory::get_storage();
29
+        new Jsonld( $video_storage );
30
+
31
+        $sitemap_cache = new Ttl_Cache( 'wl_video_sitemap', 86400 );
32
+
33
+        $video_processor = new Video_Processor();
34
+        // Hook in to save_post to save the videos
35
+        $post_filter = new Post_Filter( $video_processor );
36
+        $post_filter->init();
37
+        // Add entry to wordlift admin tabs
38
+        $settings_tab = new Settings_Tab();
39
+        $settings_tab->init();
40
+
41
+        $video_sitemap = new Video_Sitemap( $sitemap_cache );
42
+        $video_sitemap->init();
43
+
44
+        $background_process_data_source = new Videos_Data_Source( '__wl_videoobject_import_state' );
45
+        $background_process             = new Videoobject_Background_Process( $video_processor, $background_process_data_source );
46
+
47
+        $rest_controller = new Rest_Controller( $background_process );
48
+        $rest_controller->register_all_routes();
49
+
50
+        $post_edit_screen = new Post_Edit_Screen();
51
+        $post_edit_screen->init();
52
+
53
+        new Import_Videos_Page();
54
+
55
+        /**
56
+         * @since 3.32.0
57
+         * Allow videoobject to capture embed shortcode.
58
+         */
59
+        $embed_shortcode_capture = new Embed_Shortcode_Capture();
60
+        $embed_shortcode_capture->init();
61
+
62
+        /**
63
+         * @since 3.32.0
64
+         * Get videos from jw player.
65
+         */
66
+        $jw_player_capture_videos = new Jw_Player_Capture();
67
+        $jw_player_capture_videos->init();
68
+
69
+        /**
70
+         * Validate API Key for Youtube, Vimeo.
71
+         */
72
+        new Video_Key_Validation_Service();
73
+
74
+    }
75
+
76
+    public function get_feature_slug() {
77
+        return 'videoobject';
78
+    }
79
+
80
+    public function get_feature_default_value() {
81
+        return false;
82
+    }
83 83
 }
Please login to merge, or discard this patch.
src/wordlift/videoobject/background-process/class-videos-data-source.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -6,74 +6,74 @@
 block discarded – undo
6 6
 
7 7
 class Videos_Data_Source extends Data_Source {
8 8
 
9
-	/**
10
-	 * @var \Wordlift_Log_Service
11
-	 */
12
-	private $log;
9
+    /**
10
+     * @var \Wordlift_Log_Service
11
+     */
12
+    private $log;
13 13
 
14
-	public function __construct( $state_storage_key ) {
15
-		parent::__construct( $state_storage_key );
16
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
17
-	}
14
+    public function __construct( $state_storage_key ) {
15
+        parent::__construct( $state_storage_key );
16
+        $this->log = \Wordlift_Log_Service::get_logger( get_class() );
17
+    }
18 18
 
19
-	public function next() {
20
-		$this->log->debug( 'Received video data source index as ' . $this->get_state()->index );
21
-		$this->log->debug( 'Count set to ' . $this->get_batch_size() );
19
+    public function next() {
20
+        $this->log->debug( 'Received video data source index as ' . $this->get_state()->index );
21
+        $this->log->debug( 'Count set to ' . $this->get_batch_size() );
22 22
 
23
-		return get_posts(
24
-			array(
25
-				'fields'      => 'ids',
26
-				'post_status' => 'any',
27
-				'numberposts' => $this->get_batch_size(),
28
-				'offset'      => $this->get_state()->index,
29
-				/**
30
-				* @return array<string> An array of supported post types for the video import procedure.
31
-				* @since 3.31.4
32
-				* Filter name : wl_videoobject_procedure_post_types
33
-				*/
34
-			'post_type'       => array_unique(
35
-				apply_filters(
36
-					'wl_videoobject_procedure_post_types',
37
-					array(
38
-						'post',
39
-						'page',
40
-					)
41
-				)
42
-			),
43
-			)
44
-		);
45
-	}
23
+        return get_posts(
24
+            array(
25
+                'fields'      => 'ids',
26
+                'post_status' => 'any',
27
+                'numberposts' => $this->get_batch_size(),
28
+                'offset'      => $this->get_state()->index,
29
+                /**
30
+                 * @return array<string> An array of supported post types for the video import procedure.
31
+                 * @since 3.31.4
32
+                 * Filter name : wl_videoobject_procedure_post_types
33
+                 */
34
+            'post_type'       => array_unique(
35
+                apply_filters(
36
+                    'wl_videoobject_procedure_post_types',
37
+                    array(
38
+                        'post',
39
+                        'page',
40
+                    )
41
+                )
42
+            ),
43
+            )
44
+        );
45
+    }
46 46
 
47
-	public function count() {
48
-		return count(
49
-			get_posts(
50
-				array(
51
-					'fields'      => 'ids',
52
-					'numberposts' => - 1,
53
-					'post_status' => 'any',
54
-					/**
55
-					* @return array<string> An array of supported post types for the video import procedure.
56
-					* @since 3.31.4
57
-					* Filter name : wl_videoobject_procedure_post_types
58
-					*/
59
-					'post_type'   => array_unique(
60
-						apply_filters(
61
-							'wl_videoobject_procedure_post_types',
62
-							array(
63
-								'post',
64
-								'page',
65
-							)
66
-						)
67
-					),
68
-				)
69
-			)
70
-		);
47
+    public function count() {
48
+        return count(
49
+            get_posts(
50
+                array(
51
+                    'fields'      => 'ids',
52
+                    'numberposts' => - 1,
53
+                    'post_status' => 'any',
54
+                    /**
55
+                     * @return array<string> An array of supported post types for the video import procedure.
56
+                     * @since 3.31.4
57
+                     * Filter name : wl_videoobject_procedure_post_types
58
+                     */
59
+                    'post_type'   => array_unique(
60
+                        apply_filters(
61
+                            'wl_videoobject_procedure_post_types',
62
+                            array(
63
+                                'post',
64
+                                'page',
65
+                            )
66
+                        )
67
+                    ),
68
+                )
69
+            )
70
+        );
71 71
 
72
-	}
72
+    }
73 73
 
74
-	public function get_batch_size() {
75
-		// For now use only 5 in order to prevent exceeding api limit.
76
-		return 5;
77
-	}
74
+    public function get_batch_size() {
75
+        // For now use only 5 in order to prevent exceeding api limit.
76
+        return 5;
77
+    }
78 78
 
79 79
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 	 */
12 12
 	private $log;
13 13
 
14
-	public function __construct( $state_storage_key ) {
15
-		parent::__construct( $state_storage_key );
16
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
14
+	public function __construct($state_storage_key) {
15
+		parent::__construct($state_storage_key);
16
+		$this->log = \Wordlift_Log_Service::get_logger(get_class());
17 17
 	}
18 18
 
19 19
 	public function next() {
20
-		$this->log->debug( 'Received video data source index as ' . $this->get_state()->index );
21
-		$this->log->debug( 'Count set to ' . $this->get_batch_size() );
20
+		$this->log->debug('Received video data source index as '.$this->get_state()->index);
21
+		$this->log->debug('Count set to '.$this->get_batch_size());
22 22
 
23 23
 		return get_posts(
24 24
 			array(
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 			get_posts(
50 50
 				array(
51 51
 					'fields'      => 'ids',
52
-					'numberposts' => - 1,
52
+					'numberposts' => -1,
53 53
 					'post_status' => 'any',
54 54
 					/**
55 55
 					* @return array<string> An array of supported post types for the video import procedure.
Please login to merge, or discard this patch.
src/wordlift/videoobject/filters/class-post-filter.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -10,32 +10,32 @@
 block discarded – undo
10 10
  */
11 11
 class Post_Filter {
12 12
 
13
-	/**
14
-	 * @var Video_Processor
15
-	 */
16
-	private $video_processor;
13
+    /**
14
+     * @var Video_Processor
15
+     */
16
+    private $video_processor;
17 17
 
18
-	public function __construct( $video_processor ) {
19
-		$this->video_processor = $video_processor;
20
-	}
18
+    public function __construct( $video_processor ) {
19
+        $this->video_processor = $video_processor;
20
+    }
21 21
 
22
-	public function init() {
23
-		add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
24
-	}
22
+    public function init() {
23
+        add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
24
+    }
25 25
 
26
-	/**
27
-	 * @param $post_id int
28
-	 * @param $post \WP_Post
29
-	 * @param $update bool
30
-	 */
31
-	public function save_post( $post_id, $post ) {
26
+    /**
27
+     * @param $post_id int
28
+     * @param $post \WP_Post
29
+     * @param $update bool
30
+     */
31
+    public function save_post( $post_id, $post ) {
32 32
 
33
-		if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
34
-			return;
35
-		}
33
+        if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
34
+            return;
35
+        }
36 36
 
37
-		$this->video_processor->process_video_urls( $post, $post_id );
37
+        $this->video_processor->process_video_urls( $post, $post_id );
38 38
 
39
-	}
39
+    }
40 40
 
41 41
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	private $video_processor;
17 17
 
18
-	public function __construct( $video_processor ) {
18
+	public function __construct($video_processor) {
19 19
 		$this->video_processor = $video_processor;
20 20
 	}
21 21
 
22 22
 	public function init() {
23
-		add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
23
+		add_action('save_post', array($this, 'save_post'), 10, 2);
24 24
 	}
25 25
 
26 26
 	/**
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 	 * @param $post \WP_Post
29 29
 	 * @param $update bool
30 30
 	 */
31
-	public function save_post( $post_id, $post ) {
31
+	public function save_post($post_id, $post) {
32 32
 
33
-		if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
33
+		if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
34 34
 			return;
35 35
 		}
36 36
 
37
-		$this->video_processor->process_video_urls( $post, $post_id );
37
+		$this->video_processor->process_video_urls($post, $post_id);
38 38
 
39 39
 	}
40 40
 
Please login to merge, or discard this patch.