Completed
Pull Request — master (#1641)
by Naveen
01:35
created
src/wordlift/api/class-default-api-service.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -7,152 +7,152 @@
 block discarded – undo
7 7
 
8 8
 class Default_Api_Service implements Api_Service, Api_Service_Ext {
9 9
 
10
-	/**
11
-	 * @var string
12
-	 */
13
-	private $wordlift_key;
14
-	/**
15
-	 * @var int
16
-	 */
17
-	private $timeout;
18
-
19
-	/**
20
-	 * @var string
21
-	 */
22
-	private $user_agent;
23
-
24
-	/**
25
-	 * @var array
26
-	 */
27
-	private $headers;
28
-	/**
29
-	 * @var string
30
-	 */
31
-	private $base_url;
32
-
33
-	/**
34
-	 * @var \Wordlift_Log_Service
35
-	 */
36
-	private $log;
37
-
38
-	/**
39
-	 * Default_Api_Service constructor.
40
-	 *
41
-	 * @param string $base_url
42
-	 * @param int    $timeout
43
-	 * @param string $user_agent
44
-	 * @param string $wordlift_key
45
-	 */
46
-	protected function __construct( $base_url, $timeout, $user_agent, $wordlift_key ) {
47
-
48
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
49
-
50
-		$this->base_url     = untrailingslashit( $base_url );
51
-		$this->timeout      = $timeout;
52
-		$this->user_agent   = $user_agent;
53
-		$this->wordlift_key = $wordlift_key;
54
-
55
-		$this->headers = array(
56
-			'Content-Type'  => 'application/json',
57
-			'Authorization' => "Key $wordlift_key",
58
-			'Expect'        => '',
59
-		);
60
-
61
-		self::$instance = $this;
62
-	}
63
-
64
-	private static $instance;
65
-
66
-	/**
67
-	 * @return Default_Api_Service
68
-	 */
69
-	public static function get_instance() {
70
-		if ( ! isset( self::$instance ) ) {
71
-			self::$instance = new self(
72
-				apply_filters( 'wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ),
73
-				60,
74
-				User_Agent::get_user_agent(),
75
-				Wordlift_Configuration_Service::get_instance()->get_key()
76
-			);
77
-		}
78
-
79
-		return self::$instance;
80
-	}
81
-
82
-	public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
83
-
84
-		// Get the timeout for this request.
85
-		$request_timeout = isset( $timeout ) ? $timeout : $this->timeout;
86
-
87
-		// Set the time limit if lesser than our request timeout.
88
-		$max_execution_time = ini_get( 'max_execution_time' );
89
-		if ( ! ( defined( 'WP_CLI' ) && WP_CLI )
90
-			 && ( 0 !== intval( $max_execution_time ) )
91
-			 && ( $max_execution_time < $request_timeout ) ) {
92
-			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
93
-			@set_time_limit( $request_timeout );
94
-		}
95
-
96
-		$request_url = $this->base_url . $path;
97
-		// Create the request args in the following order:
98
-		// 1. use `$args` as base if provided.
99
-		// 2. set the custom timeout if provided.
100
-		// 3. set the custom user-agent if provided.
101
-		// 4. merge the API headers to the provided headers.
102
-		// 5. add the body.
103
-		//
104
-		// In this way the user can fully control the request if wanted (using `$args`) and we can add our defaults.
105
-		$request_args = apply_filters(
106
-			'wl_api_service__request',
107
-			$args + array(
108
-				'method'     => $method,
109
-				'timeout'    => $request_timeout,
110
-				'user-agent' => isset( $user_agent ) ? $user_agent : $this->user_agent,
111
-				'headers'    => $headers + $this->headers + Api_Headers_Service::get_instance()->get_wp_headers(),
112
-				'body'       => $body,
113
-			)
114
-		);
115
-
116
-		/**
117
-		 * Allow 3rd parties to process the response.
118
-		 */
119
-		$response = apply_filters(
120
-			'wl_api_service__response',
121
-			wp_remote_request( $request_url, $request_args ),
122
-			$request_url,
123
-			$request_args
124
-		);
125
-
126
-		if ( defined( 'WL_DEBUG' ) && WL_DEBUG ) {
127
-			$this->log->trace(
128
-				"=== REQUEST  ===========================\n"
129
-				. "=== URL: $request_url ===========================\n"
130
-				// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
131
-				. var_export( $request_args, true )
132
-				. "=== RESPONSE ===========================\n"
133
-				// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
134
-				. var_export( $response, true )
135
-			);
136
-		}
137
-
138
-		return new Response( $response );
139
-	}
140
-
141
-	public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
142
-
143
-		return $this->request( 'GET', $path, $headers, $body, $timeout, $user_agent, $args );
144
-	}
145
-
146
-	public function get_base_url() {
147
-		return $this->base_url;
148
-	}
149
-
150
-	/**
151
-	 * @return Me_Response
152
-	 * @throws Exception when an error occurs.
153
-	 */
154
-	public function me() {
155
-		return json_decode( $this->get( '/me' )->get_body() );
156
-	}
10
+    /**
11
+     * @var string
12
+     */
13
+    private $wordlift_key;
14
+    /**
15
+     * @var int
16
+     */
17
+    private $timeout;
18
+
19
+    /**
20
+     * @var string
21
+     */
22
+    private $user_agent;
23
+
24
+    /**
25
+     * @var array
26
+     */
27
+    private $headers;
28
+    /**
29
+     * @var string
30
+     */
31
+    private $base_url;
32
+
33
+    /**
34
+     * @var \Wordlift_Log_Service
35
+     */
36
+    private $log;
37
+
38
+    /**
39
+     * Default_Api_Service constructor.
40
+     *
41
+     * @param string $base_url
42
+     * @param int    $timeout
43
+     * @param string $user_agent
44
+     * @param string $wordlift_key
45
+     */
46
+    protected function __construct( $base_url, $timeout, $user_agent, $wordlift_key ) {
47
+
48
+        $this->log = \Wordlift_Log_Service::get_logger( get_class() );
49
+
50
+        $this->base_url     = untrailingslashit( $base_url );
51
+        $this->timeout      = $timeout;
52
+        $this->user_agent   = $user_agent;
53
+        $this->wordlift_key = $wordlift_key;
54
+
55
+        $this->headers = array(
56
+            'Content-Type'  => 'application/json',
57
+            'Authorization' => "Key $wordlift_key",
58
+            'Expect'        => '',
59
+        );
60
+
61
+        self::$instance = $this;
62
+    }
63
+
64
+    private static $instance;
65
+
66
+    /**
67
+     * @return Default_Api_Service
68
+     */
69
+    public static function get_instance() {
70
+        if ( ! isset( self::$instance ) ) {
71
+            self::$instance = new self(
72
+                apply_filters( 'wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ),
73
+                60,
74
+                User_Agent::get_user_agent(),
75
+                Wordlift_Configuration_Service::get_instance()->get_key()
76
+            );
77
+        }
78
+
79
+        return self::$instance;
80
+    }
81
+
82
+    public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
83
+
84
+        // Get the timeout for this request.
85
+        $request_timeout = isset( $timeout ) ? $timeout : $this->timeout;
86
+
87
+        // Set the time limit if lesser than our request timeout.
88
+        $max_execution_time = ini_get( 'max_execution_time' );
89
+        if ( ! ( defined( 'WP_CLI' ) && WP_CLI )
90
+             && ( 0 !== intval( $max_execution_time ) )
91
+             && ( $max_execution_time < $request_timeout ) ) {
92
+            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
93
+            @set_time_limit( $request_timeout );
94
+        }
95
+
96
+        $request_url = $this->base_url . $path;
97
+        // Create the request args in the following order:
98
+        // 1. use `$args` as base if provided.
99
+        // 2. set the custom timeout if provided.
100
+        // 3. set the custom user-agent if provided.
101
+        // 4. merge the API headers to the provided headers.
102
+        // 5. add the body.
103
+        //
104
+        // In this way the user can fully control the request if wanted (using `$args`) and we can add our defaults.
105
+        $request_args = apply_filters(
106
+            'wl_api_service__request',
107
+            $args + array(
108
+                'method'     => $method,
109
+                'timeout'    => $request_timeout,
110
+                'user-agent' => isset( $user_agent ) ? $user_agent : $this->user_agent,
111
+                'headers'    => $headers + $this->headers + Api_Headers_Service::get_instance()->get_wp_headers(),
112
+                'body'       => $body,
113
+            )
114
+        );
115
+
116
+        /**
117
+         * Allow 3rd parties to process the response.
118
+         */
119
+        $response = apply_filters(
120
+            'wl_api_service__response',
121
+            wp_remote_request( $request_url, $request_args ),
122
+            $request_url,
123
+            $request_args
124
+        );
125
+
126
+        if ( defined( 'WL_DEBUG' ) && WL_DEBUG ) {
127
+            $this->log->trace(
128
+                "=== REQUEST  ===========================\n"
129
+                . "=== URL: $request_url ===========================\n"
130
+                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
131
+                . var_export( $request_args, true )
132
+                . "=== RESPONSE ===========================\n"
133
+                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
134
+                . var_export( $response, true )
135
+            );
136
+        }
137
+
138
+        return new Response( $response );
139
+    }
140
+
141
+    public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
142
+
143
+        return $this->request( 'GET', $path, $headers, $body, $timeout, $user_agent, $args );
144
+    }
145
+
146
+    public function get_base_url() {
147
+        return $this->base_url;
148
+    }
149
+
150
+    /**
151
+     * @return Me_Response
152
+     * @throws Exception when an error occurs.
153
+     */
154
+    public function me() {
155
+        return json_decode( $this->get( '/me' )->get_body() );
156
+    }
157 157
 
158 158
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 	 * @param string $user_agent
44 44
 	 * @param string $wordlift_key
45 45
 	 */
46
-	protected function __construct( $base_url, $timeout, $user_agent, $wordlift_key ) {
46
+	protected function __construct($base_url, $timeout, $user_agent, $wordlift_key) {
47 47
 
48
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
48
+		$this->log = \Wordlift_Log_Service::get_logger(get_class());
49 49
 
50
-		$this->base_url     = untrailingslashit( $base_url );
50
+		$this->base_url     = untrailingslashit($base_url);
51 51
 		$this->timeout      = $timeout;
52 52
 		$this->user_agent   = $user_agent;
53 53
 		$this->wordlift_key = $wordlift_key;
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 * @return Default_Api_Service
68 68
 	 */
69 69
 	public static function get_instance() {
70
-		if ( ! isset( self::$instance ) ) {
70
+		if ( ! isset(self::$instance)) {
71 71
 			self::$instance = new self(
72
-				apply_filters( 'wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ),
72
+				apply_filters('wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE),
73 73
 				60,
74 74
 				User_Agent::get_user_agent(),
75 75
 				Wordlift_Configuration_Service::get_instance()->get_key()
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
 		return self::$instance;
80 80
 	}
81 81
 
82
-	public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
82
+	public function request($method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()) {
83 83
 
84 84
 		// Get the timeout for this request.
85
-		$request_timeout = isset( $timeout ) ? $timeout : $this->timeout;
85
+		$request_timeout = isset($timeout) ? $timeout : $this->timeout;
86 86
 
87 87
 		// Set the time limit if lesser than our request timeout.
88
-		$max_execution_time = ini_get( 'max_execution_time' );
89
-		if ( ! ( defined( 'WP_CLI' ) && WP_CLI )
90
-			 && ( 0 !== intval( $max_execution_time ) )
91
-			 && ( $max_execution_time < $request_timeout ) ) {
88
+		$max_execution_time = ini_get('max_execution_time');
89
+		if ( ! (defined('WP_CLI') && WP_CLI)
90
+			 && (0 !== intval($max_execution_time))
91
+			 && ($max_execution_time < $request_timeout)) {
92 92
 			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
93
-			@set_time_limit( $request_timeout );
93
+			@set_time_limit($request_timeout);
94 94
 		}
95 95
 
96
-		$request_url = $this->base_url . $path;
96
+		$request_url = $this->base_url.$path;
97 97
 		// Create the request args in the following order:
98 98
 		// 1. use `$args` as base if provided.
99 99
 		// 2. set the custom timeout if provided.
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			$args + array(
108 108
 				'method'     => $method,
109 109
 				'timeout'    => $request_timeout,
110
-				'user-agent' => isset( $user_agent ) ? $user_agent : $this->user_agent,
110
+				'user-agent' => isset($user_agent) ? $user_agent : $this->user_agent,
111 111
 				'headers'    => $headers + $this->headers + Api_Headers_Service::get_instance()->get_wp_headers(),
112 112
 				'body'       => $body,
113 113
 			)
@@ -118,29 +118,29 @@  discard block
 block discarded – undo
118 118
 		 */
119 119
 		$response = apply_filters(
120 120
 			'wl_api_service__response',
121
-			wp_remote_request( $request_url, $request_args ),
121
+			wp_remote_request($request_url, $request_args),
122 122
 			$request_url,
123 123
 			$request_args
124 124
 		);
125 125
 
126
-		if ( defined( 'WL_DEBUG' ) && WL_DEBUG ) {
126
+		if (defined('WL_DEBUG') && WL_DEBUG) {
127 127
 			$this->log->trace(
128 128
 				"=== REQUEST  ===========================\n"
129 129
 				. "=== URL: $request_url ===========================\n"
130 130
 				// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
131
-				. var_export( $request_args, true )
131
+				. var_export($request_args, true)
132 132
 				. "=== RESPONSE ===========================\n"
133 133
 				// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
134
-				. var_export( $response, true )
134
+				. var_export($response, true)
135 135
 			);
136 136
 		}
137 137
 
138
-		return new Response( $response );
138
+		return new Response($response);
139 139
 	}
140 140
 
141
-	public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ) {
141
+	public function get($path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()) {
142 142
 
143
-		return $this->request( 'GET', $path, $headers, $body, $timeout, $user_agent, $args );
143
+		return $this->request('GET', $path, $headers, $body, $timeout, $user_agent, $args);
144 144
 	}
145 145
 
146 146
 	public function get_base_url() {
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @throws Exception when an error occurs.
153 153
 	 */
154 154
 	public function me() {
155
-		return json_decode( $this->get( '/me' )->get_body() );
155
+		return json_decode($this->get('/me')->get_body());
156 156
 	}
157 157
 
158 158
 }
Please login to merge, or discard this patch.
src/wordlift/api/class-api-headers-service.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,33 +4,33 @@
 block discarded – undo
4 4
 
5 5
 class Api_Headers_Service {
6 6
 
7
-	private static $instance = null;
8
-
9
-	protected function __construct() {
10
-
11
-	}
12
-
13
-	/**
14
-	 * This function is used to append WordPress endpoint data to every request made.
15
-	 *
16
-	 * @return array
17
-	 */
18
-	public function get_wp_headers() {
19
-		return array(
20
-			'X-Wordlift-Plugin-Wp-Admin' => untrailingslashit( get_admin_url() ),
21
-			'X-Wordlift-Plugin-Wp-Json'  => untrailingslashit( get_rest_url() ),
22
-		);
23
-	}
24
-
25
-	/**
26
-	 * @return Api_Headers_Service
27
-	 */
28
-	public static function get_instance() {
29
-		if ( null === self::$instance ) {
30
-			self::$instance = new Api_Headers_Service();
31
-		}
32
-
33
-		return self::$instance;
34
-	}
7
+    private static $instance = null;
8
+
9
+    protected function __construct() {
10
+
11
+    }
12
+
13
+    /**
14
+     * This function is used to append WordPress endpoint data to every request made.
15
+     *
16
+     * @return array
17
+     */
18
+    public function get_wp_headers() {
19
+        return array(
20
+            'X-Wordlift-Plugin-Wp-Admin' => untrailingslashit( get_admin_url() ),
21
+            'X-Wordlift-Plugin-Wp-Json'  => untrailingslashit( get_rest_url() ),
22
+        );
23
+    }
24
+
25
+    /**
26
+     * @return Api_Headers_Service
27
+     */
28
+    public static function get_instance() {
29
+        if ( null === self::$instance ) {
30
+            self::$instance = new Api_Headers_Service();
31
+        }
32
+
33
+        return self::$instance;
34
+    }
35 35
 
36 36
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 */
18 18
 	public function get_wp_headers() {
19 19
 		return array(
20
-			'X-Wordlift-Plugin-Wp-Admin' => untrailingslashit( get_admin_url() ),
21
-			'X-Wordlift-Plugin-Wp-Json'  => untrailingslashit( get_rest_url() ),
20
+			'X-Wordlift-Plugin-Wp-Admin' => untrailingslashit(get_admin_url()),
21
+			'X-Wordlift-Plugin-Wp-Json'  => untrailingslashit(get_rest_url()),
22 22
 		);
23 23
 	}
24 24
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @return Api_Headers_Service
27 27
 	 */
28 28
 	public static function get_instance() {
29
-		if ( null === self::$instance ) {
29
+		if (null === self::$instance) {
30 30
 			self::$instance = new Api_Headers_Service();
31 31
 		}
32 32
 
Please login to merge, or discard this patch.
src/wordlift/videoobject/pages/class-import-videos-page.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -4,50 +4,50 @@  discard block
 block discarded – undo
4 4
 
5 5
 class Import_Videos_Page {
6 6
 
7
-	/**
8
-	 * Sync_Page constructor.
9
-	 */
10
-	public function __construct() {
7
+    /**
8
+     * Sync_Page constructor.
9
+     */
10
+    public function __construct() {
11 11
 
12
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
12
+        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
13 13
 
14
-	}
14
+    }
15 15
 
16
-	public function admin_menu() {
16
+    public function admin_menu() {
17 17
 
18
-		add_submenu_page(
19
-			'wl_admin_menu',
20
-			__( 'Import all videos', 'wordlift' ),
21
-			__( 'Import all videos', 'wordlift' ),
22
-			'manage_options',
23
-			'wl_videos_import',
24
-			array(
25
-				$this,
26
-				'render',
27
-			)
28
-		);
18
+        add_submenu_page(
19
+            'wl_admin_menu',
20
+            __( 'Import all videos', 'wordlift' ),
21
+            __( 'Import all videos', 'wordlift' ),
22
+            'manage_options',
23
+            'wl_videos_import',
24
+            array(
25
+                $this,
26
+                'render',
27
+            )
28
+        );
29 29
 
30
-	}
30
+    }
31 31
 
32
-	public function render() {
32
+    public function render() {
33 33
 
34
-		wp_enqueue_script(
35
-			'wl-videos-sync-page',
36
-			plugin_dir_url( __FILE__ ) . 'assets/videoobject-import-page.js',
37
-			array( 'wp-api' ),
38
-			WORDLIFT_VERSION,
39
-			false
40
-		);
41
-		wp_localize_script(
42
-			'wl-videos-sync-page',
43
-			'_wlVideoObjectImportSettings',
44
-			array(
45
-				'restUrl' => get_rest_url(),
46
-				'nonce'   => wp_create_nonce( 'wp_rest' ),
47
-			)
48
-		)
34
+        wp_enqueue_script(
35
+            'wl-videos-sync-page',
36
+            plugin_dir_url( __FILE__ ) . 'assets/videoobject-import-page.js',
37
+            array( 'wp-api' ),
38
+            WORDLIFT_VERSION,
39
+            false
40
+        );
41
+        wp_localize_script(
42
+            'wl-videos-sync-page',
43
+            '_wlVideoObjectImportSettings',
44
+            array(
45
+                'restUrl' => get_rest_url(),
46
+                'nonce'   => wp_create_nonce( 'wp_rest' ),
47
+            )
48
+        )
49 49
 
50
-		?>
50
+        ?>
51 51
 		<div class="wrap">
52 52
 			<h2><?php esc_html_e( 'Import all videos', 'wordlift' ); ?></h2>
53 53
 
@@ -58,17 +58,17 @@  discard block
 block discarded – undo
58 58
 
59 59
 			<button id="wl-start-btn" type="button" class="button button-large button-primary">
60 60
 			<?php
61
-				esc_html_e( 'Start', 'wordlift' );
62
-			?>
61
+                esc_html_e( 'Start', 'wordlift' );
62
+            ?>
63 63
 				</button>
64 64
 			<button id="wl-stop-btn" type="button" class="button button-large button-primary hidden">
65 65
 			<?php
66
-				esc_html_e( 'Stop', 'wordlift' );
67
-			?>
66
+                esc_html_e( 'Stop', 'wordlift' );
67
+            ?>
68 68
 				</button>
69 69
 
70 70
 		</div>
71 71
 		<?php
72
-	}
72
+    }
73 73
 
74 74
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	 */
10 10
 	public function __construct() {
11 11
 
12
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
12
+		add_action('admin_menu', array($this, 'admin_menu'));
13 13
 
14 14
 	}
15 15
 
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 
18 18
 		add_submenu_page(
19 19
 			'wl_admin_menu',
20
-			__( 'Import all videos', 'wordlift' ),
21
-			__( 'Import all videos', 'wordlift' ),
20
+			__('Import all videos', 'wordlift'),
21
+			__('Import all videos', 'wordlift'),
22 22
 			'manage_options',
23 23
 			'wl_videos_import',
24 24
 			array(
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 
34 34
 		wp_enqueue_script(
35 35
 			'wl-videos-sync-page',
36
-			plugin_dir_url( __FILE__ ) . 'assets/videoobject-import-page.js',
37
-			array( 'wp-api' ),
36
+			plugin_dir_url(__FILE__).'assets/videoobject-import-page.js',
37
+			array('wp-api'),
38 38
 			WORDLIFT_VERSION,
39 39
 			false
40 40
 		);
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 			'_wlVideoObjectImportSettings',
44 44
 			array(
45 45
 				'restUrl' => get_rest_url(),
46
-				'nonce'   => wp_create_nonce( 'wp_rest' ),
46
+				'nonce'   => wp_create_nonce('wp_rest'),
47 47
 			)
48 48
 		)
49 49
 
50 50
 		?>
51 51
 		<div class="wrap">
52
-			<h2><?php esc_html_e( 'Import all videos', 'wordlift' ); ?></h2>
52
+			<h2><?php esc_html_e('Import all videos', 'wordlift'); ?></h2>
53 53
 
54 54
 			<div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;">
55 55
 				<div class="wl-task__progress__bar"
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 
59 59
 			<button id="wl-start-btn" type="button" class="button button-large button-primary">
60 60
 			<?php
61
-				esc_html_e( 'Start', 'wordlift' );
61
+				esc_html_e('Start', 'wordlift');
62 62
 			?>
63 63
 				</button>
64 64
 			<button id="wl-stop-btn" type="button" class="button button-large button-primary hidden">
65 65
 			<?php
66
-				esc_html_e( 'Stop', 'wordlift' );
66
+				esc_html_e('Stop', 'wordlift');
67 67
 			?>
68 68
 				</button>
69 69
 
Please login to merge, or discard this patch.
src/wordlift/videoobject/parser/class-parser-factory.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,31 +8,31 @@
 block discarded – undo
8 8
  */
9 9
 class Parser_Factory {
10 10
 
11
-	const BLOCK_EDITOR = 'block-editor';
12
-
13
-	const CLASSIC_EDITOR = 'classic-editor';
14
-
15
-	/**
16
-	 * @param $parser_config
17
-	 *
18
-	 * @return Parser
19
-	 */
20
-	public static function get_parser( $parser_config ) {
21
-		if ( self::BLOCK_EDITOR === $parser_config ) {
22
-			return new Block_Editor_Parser();
23
-		} elseif ( self::CLASSIC_EDITOR === $parser_config ) {
24
-			return new Classic_Editor_Parser();
25
-		}
26
-
27
-	}
28
-
29
-	public static function get_parser_from_content( $post_content ) {
30
-		if ( function_exists( 'has_blocks' )
31
-			 && function_exists( 'parse_blocks' ) && has_blocks( $post_content ) ) {
32
-			return self::get_parser( self::BLOCK_EDITOR );
33
-		} else {
34
-			return self::get_parser( self::CLASSIC_EDITOR );
35
-		}
36
-	}
11
+    const BLOCK_EDITOR = 'block-editor';
12
+
13
+    const CLASSIC_EDITOR = 'classic-editor';
14
+
15
+    /**
16
+     * @param $parser_config
17
+     *
18
+     * @return Parser
19
+     */
20
+    public static function get_parser( $parser_config ) {
21
+        if ( self::BLOCK_EDITOR === $parser_config ) {
22
+            return new Block_Editor_Parser();
23
+        } elseif ( self::CLASSIC_EDITOR === $parser_config ) {
24
+            return new Classic_Editor_Parser();
25
+        }
26
+
27
+    }
28
+
29
+    public static function get_parser_from_content( $post_content ) {
30
+        if ( function_exists( 'has_blocks' )
31
+             && function_exists( 'parse_blocks' ) && has_blocks( $post_content ) ) {
32
+            return self::get_parser( self::BLOCK_EDITOR );
33
+        } else {
34
+            return self::get_parser( self::CLASSIC_EDITOR );
35
+        }
36
+    }
37 37
 
38 38
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,21 +17,21 @@
 block discarded – undo
17 17
 	 *
18 18
 	 * @return Parser
19 19
 	 */
20
-	public static function get_parser( $parser_config ) {
21
-		if ( self::BLOCK_EDITOR === $parser_config ) {
20
+	public static function get_parser($parser_config) {
21
+		if (self::BLOCK_EDITOR === $parser_config) {
22 22
 			return new Block_Editor_Parser();
23
-		} elseif ( self::CLASSIC_EDITOR === $parser_config ) {
23
+		} elseif (self::CLASSIC_EDITOR === $parser_config) {
24 24
 			return new Classic_Editor_Parser();
25 25
 		}
26 26
 
27 27
 	}
28 28
 
29
-	public static function get_parser_from_content( $post_content ) {
30
-		if ( function_exists( 'has_blocks' )
31
-			 && function_exists( 'parse_blocks' ) && has_blocks( $post_content ) ) {
32
-			return self::get_parser( self::BLOCK_EDITOR );
29
+	public static function get_parser_from_content($post_content) {
30
+		if (function_exists('has_blocks')
31
+			 && function_exists('parse_blocks') && has_blocks($post_content)) {
32
+			return self::get_parser(self::BLOCK_EDITOR);
33 33
 		} else {
34
-			return self::get_parser( self::CLASSIC_EDITOR );
34
+			return self::get_parser(self::CLASSIC_EDITOR);
35 35
 		}
36 36
 	}
37 37
 
Please login to merge, or discard this patch.
src/wordlift/videoobject/parser/class-block-editor-parser.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,32 +11,32 @@
 block discarded – undo
11 11
  */
12 12
 class Block_Editor_Parser implements Parser {
13 13
 
14
-	public function get_videos( $post_id ) {
15
-		$post         = get_post( $post_id );
16
-		$content      = $post->post_content;
17
-		$video_blocks = array_filter( parse_blocks( $content ), array( $this, 'filter_blocks' ) );
18
-		return array_map( array( $this, 'block_to_video' ), $video_blocks );
19
-	}
14
+    public function get_videos( $post_id ) {
15
+        $post         = get_post( $post_id );
16
+        $content      = $post->post_content;
17
+        $video_blocks = array_filter( parse_blocks( $content ), array( $this, 'filter_blocks' ) );
18
+        return array_map( array( $this, 'block_to_video' ), $video_blocks );
19
+    }
20 20
 
21
-	/**
22
-	 * @param $block
23
-	 *
24
-	 * @return Embedded_Video
25
-	 */
26
-	public function block_to_video( $block ) {
27
-		return Embedded_Video_Factory::get_embedded_video( $block['attrs']['url'] );
28
-	}
21
+    /**
22
+     * @param $block
23
+     *
24
+     * @return Embedded_Video
25
+     */
26
+    public function block_to_video( $block ) {
27
+        return Embedded_Video_Factory::get_embedded_video( $block['attrs']['url'] );
28
+    }
29 29
 
30
-	public function filter_blocks( $block ) {
31
-		return array_key_exists( 'blockName', $block )
32
-			   && ( 'core/embed' === $block['blockName'] || 'core-embed/youtube' === $block['blockName']
33
-					|| 'core-embed/vimeo' === $block['blockName'] )
34
-			   // Check if attributes present
35
-			   && array_key_exists( 'attrs', $block )
36
-			   && is_array( $block['attrs'] )
37
-			   // check if valid url present.
38
-			   && array_key_exists( 'url', $block['attrs'] )
39
-			   && is_string( $block['attrs']['url'] );
40
-	}
30
+    public function filter_blocks( $block ) {
31
+        return array_key_exists( 'blockName', $block )
32
+               && ( 'core/embed' === $block['blockName'] || 'core-embed/youtube' === $block['blockName']
33
+                    || 'core-embed/vimeo' === $block['blockName'] )
34
+                // Check if attributes present
35
+               && array_key_exists( 'attrs', $block )
36
+               && is_array( $block['attrs'] )
37
+                // check if valid url present.
38
+               && array_key_exists( 'url', $block['attrs'] )
39
+               && is_string( $block['attrs']['url'] );
40
+    }
41 41
 
42 42
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class Block_Editor_Parser implements Parser {
13 13
 
14
-	public function get_videos( $post_id ) {
15
-		$post         = get_post( $post_id );
14
+	public function get_videos($post_id) {
15
+		$post         = get_post($post_id);
16 16
 		$content      = $post->post_content;
17
-		$video_blocks = array_filter( parse_blocks( $content ), array( $this, 'filter_blocks' ) );
18
-		return array_map( array( $this, 'block_to_video' ), $video_blocks );
17
+		$video_blocks = array_filter(parse_blocks($content), array($this, 'filter_blocks'));
18
+		return array_map(array($this, 'block_to_video'), $video_blocks);
19 19
 	}
20 20
 
21 21
 	/**
@@ -23,20 +23,20 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @return Embedded_Video
25 25
 	 */
26
-	public function block_to_video( $block ) {
27
-		return Embedded_Video_Factory::get_embedded_video( $block['attrs']['url'] );
26
+	public function block_to_video($block) {
27
+		return Embedded_Video_Factory::get_embedded_video($block['attrs']['url']);
28 28
 	}
29 29
 
30
-	public function filter_blocks( $block ) {
31
-		return array_key_exists( 'blockName', $block )
32
-			   && ( 'core/embed' === $block['blockName'] || 'core-embed/youtube' === $block['blockName']
33
-					|| 'core-embed/vimeo' === $block['blockName'] )
30
+	public function filter_blocks($block) {
31
+		return array_key_exists('blockName', $block)
32
+			   && ('core/embed' === $block['blockName'] || 'core-embed/youtube' === $block['blockName']
33
+					|| 'core-embed/vimeo' === $block['blockName'])
34 34
 			   // Check if attributes present
35
-			   && array_key_exists( 'attrs', $block )
36
-			   && is_array( $block['attrs'] )
35
+			   && array_key_exists('attrs', $block)
36
+			   && is_array($block['attrs'])
37 37
 			   // check if valid url present.
38
-			   && array_key_exists( 'url', $block['attrs'] )
39
-			   && is_string( $block['attrs']['url'] );
38
+			   && array_key_exists('url', $block['attrs'])
39
+			   && is_string($block['attrs']['url']);
40 40
 	}
41 41
 
42 42
 }
Please login to merge, or discard this patch.
src/wordlift/videoobject/parser/class-classic-editor-parser.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -7,45 +7,45 @@
 block discarded – undo
7 7
 
8 8
 class Classic_Editor_Parser implements Parser {
9 9
 
10
-	public function get_videos( $post_id ) {
11
-
12
-		$post = get_post( $post_id );
13
-
14
-		$content = $post->post_content;
15
-
16
-		$line_matches      = array();
17
-		$paragraph_matches = array();
18
-
19
-		/**
20
-		 * This replicates the wp autoembed function, instead of replacing we capture
21
-		 * all the urls.
22
-		 */
23
-		if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
24
-			// Find URLs on their own line.
25
-			preg_match_all( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', $content, $line_matches, PREG_SET_ORDER );
26
-			// Find URLs in their own paragraph.
27
-			preg_match_all( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', $content, $paragraph_matches, PREG_SET_ORDER );
28
-		}
29
-
30
-		$regex_matches = array_merge( $line_matches, $paragraph_matches );
31
-		$matches       = array_map( array( $this, 'get_url_from_match' ), $regex_matches );
32
-
33
-		$matches = array_values( array_unique( array_filter( $matches ) ) );
34
-
35
-		return array_map( array( $this, 'url_to_embedded_video_object' ), $matches );
36
-	}
37
-
38
-	/**
39
-	 * @param $url
40
-	 *
41
-	 * @return Embedded_Video
42
-	 */
43
-	private static function url_to_embedded_video_object( $url ) {
44
-		return Embedded_Video_Factory::get_embedded_video( trim( $url ) );
45
-	}
46
-
47
-	public static function get_url_from_match( $match ) {
48
-		return array_key_exists( 0, $match ) ? $match[0] : false;
49
-	}
10
+    public function get_videos( $post_id ) {
11
+
12
+        $post = get_post( $post_id );
13
+
14
+        $content = $post->post_content;
15
+
16
+        $line_matches      = array();
17
+        $paragraph_matches = array();
18
+
19
+        /**
20
+         * This replicates the wp autoembed function, instead of replacing we capture
21
+         * all the urls.
22
+         */
23
+        if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
24
+            // Find URLs on their own line.
25
+            preg_match_all( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', $content, $line_matches, PREG_SET_ORDER );
26
+            // Find URLs in their own paragraph.
27
+            preg_match_all( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', $content, $paragraph_matches, PREG_SET_ORDER );
28
+        }
29
+
30
+        $regex_matches = array_merge( $line_matches, $paragraph_matches );
31
+        $matches       = array_map( array( $this, 'get_url_from_match' ), $regex_matches );
32
+
33
+        $matches = array_values( array_unique( array_filter( $matches ) ) );
34
+
35
+        return array_map( array( $this, 'url_to_embedded_video_object' ), $matches );
36
+    }
37
+
38
+    /**
39
+     * @param $url
40
+     *
41
+     * @return Embedded_Video
42
+     */
43
+    private static function url_to_embedded_video_object( $url ) {
44
+        return Embedded_Video_Factory::get_embedded_video( trim( $url ) );
45
+    }
46
+
47
+    public static function get_url_from_match( $match ) {
48
+        return array_key_exists( 0, $match ) ? $match[0] : false;
49
+    }
50 50
 
51 51
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 class Classic_Editor_Parser implements Parser {
9 9
 
10
-	public function get_videos( $post_id ) {
10
+	public function get_videos($post_id) {
11 11
 
12
-		$post = get_post( $post_id );
12
+		$post = get_post($post_id);
13 13
 
14 14
 		$content = $post->post_content;
15 15
 
@@ -20,19 +20,19 @@  discard block
 block discarded – undo
20 20
 		 * This replicates the wp autoembed function, instead of replacing we capture
21 21
 		 * all the urls.
22 22
 		 */
23
-		if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
23
+		if (preg_match('#(^|\s|>)https?://#i', $content)) {
24 24
 			// Find URLs on their own line.
25
-			preg_match_all( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', $content, $line_matches, PREG_SET_ORDER );
25
+			preg_match_all('|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', $content, $line_matches, PREG_SET_ORDER);
26 26
 			// Find URLs in their own paragraph.
27
-			preg_match_all( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', $content, $paragraph_matches, PREG_SET_ORDER );
27
+			preg_match_all('|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', $content, $paragraph_matches, PREG_SET_ORDER);
28 28
 		}
29 29
 
30
-		$regex_matches = array_merge( $line_matches, $paragraph_matches );
31
-		$matches       = array_map( array( $this, 'get_url_from_match' ), $regex_matches );
30
+		$regex_matches = array_merge($line_matches, $paragraph_matches);
31
+		$matches       = array_map(array($this, 'get_url_from_match'), $regex_matches);
32 32
 
33
-		$matches = array_values( array_unique( array_filter( $matches ) ) );
33
+		$matches = array_values(array_unique(array_filter($matches)));
34 34
 
35
-		return array_map( array( $this, 'url_to_embedded_video_object' ), $matches );
35
+		return array_map(array($this, 'url_to_embedded_video_object'), $matches);
36 36
 	}
37 37
 
38 38
 	/**
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return Embedded_Video
42 42
 	 */
43
-	private static function url_to_embedded_video_object( $url ) {
44
-		return Embedded_Video_Factory::get_embedded_video( trim( $url ) );
43
+	private static function url_to_embedded_video_object($url) {
44
+		return Embedded_Video_Factory::get_embedded_video(trim($url));
45 45
 	}
46 46
 
47
-	public static function get_url_from_match( $match ) {
48
-		return array_key_exists( 0, $match ) ? $match[0] : false;
47
+	public static function get_url_from_match($match) {
48
+		return array_key_exists(0, $match) ? $match[0] : false;
49 49
 	}
50 50
 
51 51
 }
Please login to merge, or discard this patch.
wordlift/videoobject/data/embedded-video/class-embedded-video-factory.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
  */
9 9
 class Embedded_Video_Factory {
10 10
 
11
-	public static function get_embedded_video( $video_url ) {
12
-		return new Default_Embedded_Video( $video_url );
13
-	}
11
+    public static function get_embedded_video( $video_url ) {
12
+        return new Default_Embedded_Video( $video_url );
13
+    }
14 14
 
15 15
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
  */
9 9
 class Embedded_Video_Factory {
10 10
 
11
-	public static function get_embedded_video( $video_url ) {
12
-		return new Default_Embedded_Video( $video_url );
11
+	public static function get_embedded_video($video_url) {
12
+		return new Default_Embedded_Video($video_url);
13 13
 	}
14 14
 
15 15
 }
Please login to merge, or discard this patch.
src/wordlift/videoobject/data/embedded-video/class-embedded-video.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
  */
13 13
 interface Embedded_Video {
14 14
 
15
-	public function get_api_provider();
15
+    public function get_api_provider();
16 16
 
17
-	public function get_url();
17
+    public function get_url();
18 18
 
19 19
 }
Please login to merge, or discard this patch.
src/wordlift/videoobject/data/video-storage/class-video-storage-factory.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
10 10
 
11 11
 class Video_Storage_Factory {
12 12
 
13
-	public static function get_storage() {
14
-		return new Meta_Storage();
15
-	}
13
+    public static function get_storage() {
14
+        return new Meta_Storage();
15
+    }
16 16
 
17 17
 }
Please login to merge, or discard this patch.