Completed
Pull Request — develop (#1633)
by Naveen
01:05
created
src/wordlift/task/background/class-abstract-background-task-state.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,32 +4,32 @@
 block discarded – undo
4 4
 
5 5
 abstract class Abstract_Background_Task_State implements Background_Task_State {
6 6
 
7
-	/**
8
-	 * @var Background_Task_State
9
-	 */
10
-	private $state;
11
-
12
-	/**
13
-	 * @var Background_Task
14
-	 */
15
-	private $context;
16
-
17
-	public function __construct( $context, $state ) {
18
-		$this->state   = $state;
19
-		$this->context = $context;
20
-	}
21
-
22
-	public function get_info() {
23
-		$started     = get_option( $this->context->get_option_prefix() . 'started' );
24
-		$offset      = get_option( $this->context->get_option_prefix() . 'offset' );
25
-		$count       = get_option( $this->context->get_option_prefix() . 'count', array( 0 ) );
26
-		$last_update = get_option( $this->context->get_option_prefix() . 'updated' );
27
-
28
-		return new Background_Task_Info( $this->state, $started, $offset, $count, $last_update );
29
-	}
30
-
31
-	public function resume() {
32
-		// do nothing.
33
-	}
7
+    /**
8
+     * @var Background_Task_State
9
+     */
10
+    private $state;
11
+
12
+    /**
13
+     * @var Background_Task
14
+     */
15
+    private $context;
16
+
17
+    public function __construct( $context, $state ) {
18
+        $this->state   = $state;
19
+        $this->context = $context;
20
+    }
21
+
22
+    public function get_info() {
23
+        $started     = get_option( $this->context->get_option_prefix() . 'started' );
24
+        $offset      = get_option( $this->context->get_option_prefix() . 'offset' );
25
+        $count       = get_option( $this->context->get_option_prefix() . 'count', array( 0 ) );
26
+        $last_update = get_option( $this->context->get_option_prefix() . 'updated' );
27
+
28
+        return new Background_Task_Info( $this->state, $started, $offset, $count, $last_update );
29
+    }
30
+
31
+    public function resume() {
32
+        // do nothing.
33
+    }
34 34
 
35 35
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,18 +14,18 @@
 block discarded – undo
14 14
 	 */
15 15
 	private $context;
16 16
 
17
-	public function __construct( $context, $state ) {
17
+	public function __construct($context, $state) {
18 18
 		$this->state   = $state;
19 19
 		$this->context = $context;
20 20
 	}
21 21
 
22 22
 	public function get_info() {
23
-		$started     = get_option( $this->context->get_option_prefix() . 'started' );
24
-		$offset      = get_option( $this->context->get_option_prefix() . 'offset' );
25
-		$count       = get_option( $this->context->get_option_prefix() . 'count', array( 0 ) );
26
-		$last_update = get_option( $this->context->get_option_prefix() . 'updated' );
23
+		$started     = get_option($this->context->get_option_prefix().'started');
24
+		$offset      = get_option($this->context->get_option_prefix().'offset');
25
+		$count       = get_option($this->context->get_option_prefix().'count', array(0));
26
+		$last_update = get_option($this->context->get_option_prefix().'updated');
27 27
 
28
-		return new Background_Task_Info( $this->state, $started, $offset, $count, $last_update );
28
+		return new Background_Task_Info($this->state, $started, $offset, $count, $last_update);
29 29
 	}
30 30
 
31 31
 	public function resume() {
Please login to merge, or discard this patch.
src/wordlift/task/background/class-background-task-state.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,29 +4,29 @@
 block discarded – undo
4 4
 
5 5
 interface Background_Task_State {
6 6
 
7
-	public function enter();
8
-
9
-	public function leave();
10
-
11
-	/**
12
-	 * Task
13
-	 *
14
-	 * Override this method to perform any actions required on each
15
-	 * queue item. Return the modified item for further processing
16
-	 * in the next pass through. Or, return false to remove the
17
-	 * item from the queue.
18
-	 *
19
-	 * @param mixed $item Queue item to iterate over.
20
-	 *
21
-	 * @return mixed
22
-	 */
23
-	public function task( $item );
24
-
25
-	public function get_info();
26
-
27
-	/**
28
-	 * Try to resume an interrupted task.
29
-	 */
30
-	public function resume();
7
+    public function enter();
8
+
9
+    public function leave();
10
+
11
+    /**
12
+     * Task
13
+     *
14
+     * Override this method to perform any actions required on each
15
+     * queue item. Return the modified item for further processing
16
+     * in the next pass through. Or, return false to remove the
17
+     * item from the queue.
18
+     *
19
+     * @param mixed $item Queue item to iterate over.
20
+     *
21
+     * @return mixed
22
+     */
23
+    public function task( $item );
24
+
25
+    public function get_info();
26
+
27
+    /**
28
+     * Try to resume an interrupted task.
29
+     */
30
+    public function resume();
31 31
 
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	 *
21 21
 	 * @return mixed
22 22
 	 */
23
-	public function task( $item );
23
+	public function task($item);
24 24
 
25 25
 	public function get_info();
26 26
 
Please login to merge, or discard this patch.
src/wordlift/scripts/class-scripts-helper.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -19,70 +19,70 @@
 block discarded – undo
19 19
 
20 20
 class Scripts_Helper {
21 21
 
22
-	/**
23
-	 * This function loads the javascript file according to the WordPress version.
24
-	 *
25
-	 * For WordPress < 5.0 it'll load the javascript file using the `.full` suffix i.e. the file that embeds all the
26
-	 * dependencies.
27
-	 *
28
-	 * For WordPress >= 5.0 it'll load the stripped down js.
29
-	 *
30
-	 * @param string $handle The handle name.
31
-	 * @param string $script_name The full script URL without the `.js` extension.
32
-	 * @param array  $dependencies An array of dependencies to be added only in WordPress > 5.0.
33
-	 */
34
-	public static function enqueue_based_on_wordpress_version( $handle, $script_name, $dependencies, $in_footer = false ) {
35
-		global $wp_version;
22
+    /**
23
+     * This function loads the javascript file according to the WordPress version.
24
+     *
25
+     * For WordPress < 5.0 it'll load the javascript file using the `.full` suffix i.e. the file that embeds all the
26
+     * dependencies.
27
+     *
28
+     * For WordPress >= 5.0 it'll load the stripped down js.
29
+     *
30
+     * @param string $handle The handle name.
31
+     * @param string $script_name The full script URL without the `.js` extension.
32
+     * @param array  $dependencies An array of dependencies to be added only in WordPress > 5.0.
33
+     */
34
+    public static function enqueue_based_on_wordpress_version( $handle, $script_name, $dependencies, $in_footer = false ) {
35
+        global $wp_version;
36 36
 
37
-		if ( version_compare( $wp_version, '5.0', '<' ) ) {
38
-			$actual_script_name  = "$script_name.full.js";
39
-			$actual_dependencies = array();
40
-		} else {
41
-			$actual_script_name  = "$script_name.js";
42
-			$actual_dependencies = $dependencies;
43
-		}
37
+        if ( version_compare( $wp_version, '5.0', '<' ) ) {
38
+            $actual_script_name  = "$script_name.full.js";
39
+            $actual_dependencies = array();
40
+        } else {
41
+            $actual_script_name  = "$script_name.js";
42
+            $actual_dependencies = $dependencies;
43
+        }
44 44
 
45
-		$wordlift = \Wordlift::get_instance();
46
-		wp_enqueue_script( $handle, $actual_script_name, $actual_dependencies, $wordlift->get_version(), $in_footer );
45
+        $wordlift = \Wordlift::get_instance();
46
+        wp_enqueue_script( $handle, $actual_script_name, $actual_dependencies, $wordlift->get_version(), $in_footer );
47 47
 
48
-	}
49
-	/**
50
-	 * This function registers the javascript file according to the WordPress version.
51
-	 *
52
-	 * For WordPress < 5.0 it'll register the javascript file using the `.full` suffix i.e. the file that embeds all the
53
-	 * dependencies.
54
-	 *
55
-	 * For WordPress >= 5.0 it'll register the stripped down js.
56
-	 *
57
-	 * @param string $handle The handle name.
58
-	 * @param string $script_name The full script URL without the `.js` extension.
59
-	 * @param array  $dependencies An array of dependencies to be added only in WordPress > 5.0.
60
-	 */
61
-	public static function register_based_on_wordpress_version(
62
-			$handle,
63
-			$script_name,
64
-			$dependencies,
65
-			$action = 'wp_enqueue_scripts',
66
-			$in_footer = false
67
-		) {
68
-		global $wp_version;
48
+    }
49
+    /**
50
+     * This function registers the javascript file according to the WordPress version.
51
+     *
52
+     * For WordPress < 5.0 it'll register the javascript file using the `.full` suffix i.e. the file that embeds all the
53
+     * dependencies.
54
+     *
55
+     * For WordPress >= 5.0 it'll register the stripped down js.
56
+     *
57
+     * @param string $handle The handle name.
58
+     * @param string $script_name The full script URL without the `.js` extension.
59
+     * @param array  $dependencies An array of dependencies to be added only in WordPress > 5.0.
60
+     */
61
+    public static function register_based_on_wordpress_version(
62
+            $handle,
63
+            $script_name,
64
+            $dependencies,
65
+            $action = 'wp_enqueue_scripts',
66
+            $in_footer = false
67
+        ) {
68
+        global $wp_version;
69 69
 
70
-		if ( version_compare( $wp_version, '5.0', '<' ) ) {
71
-			$actual_script_name  = "$script_name.full.js";
72
-			$actual_dependencies = array();
73
-		} else {
74
-			$actual_script_name  = "$script_name.js";
75
-			$actual_dependencies = $dependencies;
76
-		}
70
+        if ( version_compare( $wp_version, '5.0', '<' ) ) {
71
+            $actual_script_name  = "$script_name.full.js";
72
+            $actual_dependencies = array();
73
+        } else {
74
+            $actual_script_name  = "$script_name.js";
75
+            $actual_dependencies = $dependencies;
76
+        }
77 77
 
78
-		$wordlift = \Wordlift::get_instance();
79
-		add_action(
80
-			$action,
81
-			function () use ( $handle, $actual_script_name, $actual_dependencies, $wordlift, $in_footer ) {
82
-				wp_register_script( $handle, $actual_script_name, $actual_dependencies, $wordlift->get_version(), $in_footer );
83
-			}
84
-		);
78
+        $wordlift = \Wordlift::get_instance();
79
+        add_action(
80
+            $action,
81
+            function () use ( $handle, $actual_script_name, $actual_dependencies, $wordlift, $in_footer ) {
82
+                wp_register_script( $handle, $actual_script_name, $actual_dependencies, $wordlift->get_version(), $in_footer );
83
+            }
84
+        );
85 85
 
86
-	}
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 	 * @param string $script_name The full script URL without the `.js` extension.
32 32
 	 * @param array  $dependencies An array of dependencies to be added only in WordPress > 5.0.
33 33
 	 */
34
-	public static function enqueue_based_on_wordpress_version( $handle, $script_name, $dependencies, $in_footer = false ) {
34
+	public static function enqueue_based_on_wordpress_version($handle, $script_name, $dependencies, $in_footer = false) {
35 35
 		global $wp_version;
36 36
 
37
-		if ( version_compare( $wp_version, '5.0', '<' ) ) {
37
+		if (version_compare($wp_version, '5.0', '<')) {
38 38
 			$actual_script_name  = "$script_name.full.js";
39 39
 			$actual_dependencies = array();
40 40
 		} else {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		}
44 44
 
45 45
 		$wordlift = \Wordlift::get_instance();
46
-		wp_enqueue_script( $handle, $actual_script_name, $actual_dependencies, $wordlift->get_version(), $in_footer );
46
+		wp_enqueue_script($handle, $actual_script_name, $actual_dependencies, $wordlift->get_version(), $in_footer);
47 47
 
48 48
 	}
49 49
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		) {
68 68
 		global $wp_version;
69 69
 
70
-		if ( version_compare( $wp_version, '5.0', '<' ) ) {
70
+		if (version_compare($wp_version, '5.0', '<')) {
71 71
 			$actual_script_name  = "$script_name.full.js";
72 72
 			$actual_dependencies = array();
73 73
 		} else {
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 		$wordlift = \Wordlift::get_instance();
79 79
 		add_action(
80 80
 			$action,
81
-			function () use ( $handle, $actual_script_name, $actual_dependencies, $wordlift, $in_footer ) {
82
-				wp_register_script( $handle, $actual_script_name, $actual_dependencies, $wordlift->get_version(), $in_footer );
81
+			function() use ($handle, $actual_script_name, $actual_dependencies, $wordlift, $in_footer) {
82
+				wp_register_script($handle, $actual_script_name, $actual_dependencies, $wordlift->get_version(), $in_footer);
83 83
 			}
84 84
 		);
85 85
 
Please login to merge, or discard this patch.
src/wordlift/templates/class-templates-ajax-endpoint.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@
 block discarded – undo
17 17
  */
18 18
 class Templates_Ajax_Endpoint {
19 19
 
20
-	/**
21
-	 * Templates_Ajax_Endpoint constructor.
22
-	 *
23
-	 * Hook to `wl_templates` Ajax action.
24
-	 */
25
-	public function __construct() {
20
+    /**
21
+     * Templates_Ajax_Endpoint constructor.
22
+     *
23
+     * Hook to `wl_templates` Ajax action.
24
+     */
25
+    public function __construct() {
26 26
 
27
-		add_action( 'wp_ajax_wl_templates', array( $this, 'template' ) );
27
+        add_action( 'wp_ajax_wl_templates', array( $this, 'template' ) );
28 28
 
29
-	}
29
+    }
30 30
 
31
-	/**
32
-	 * Display the requested template. The template is searched in wp-content/wordlift/templates/wordlift-widget-be/
33
-	 *
34
-	 * Non alphanumeric names (including `-`) are considered invalid.
35
-	 */
36
-	public function template() {
31
+    /**
32
+     * Display the requested template. The template is searched in wp-content/wordlift/templates/wordlift-widget-be/
33
+     *
34
+     * Non alphanumeric names (including `-`) are considered invalid.
35
+     */
36
+    public function template() {
37 37
 
38
-		$name = filter_input( INPUT_GET, 'name' );
38
+        $name = filter_input( INPUT_GET, 'name' );
39 39
 
40
-		if ( 1 !== preg_match( '|^[a-z0-9\-]+$|', $name ) ) {
41
-			return wp_send_json_error( 'Invalid name.' );
42
-		}
40
+        if ( 1 !== preg_match( '|^[a-z0-9\-]+$|', $name ) ) {
41
+            return wp_send_json_error( 'Invalid name.' );
42
+        }
43 43
 
44
-		require dirname( dirname( __DIR__ ) ) . "/templates/wordlift-widget-be/$name.html";
44
+        require dirname( dirname( __DIR__ ) ) . "/templates/wordlift-widget-be/$name.html";
45 45
 
46
-		die();
47
-	}
46
+        die();
47
+    }
48 48
 
49 49
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function __construct() {
26 26
 
27
-		add_action( 'wp_ajax_wl_templates', array( $this, 'template' ) );
27
+		add_action('wp_ajax_wl_templates', array($this, 'template'));
28 28
 
29 29
 	}
30 30
 
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function template() {
37 37
 
38
-		$name = filter_input( INPUT_GET, 'name' );
38
+		$name = filter_input(INPUT_GET, 'name');
39 39
 
40
-		if ( 1 !== preg_match( '|^[a-z0-9\-]+$|', $name ) ) {
41
-			return wp_send_json_error( 'Invalid name.' );
40
+		if (1 !== preg_match('|^[a-z0-9\-]+$|', $name)) {
41
+			return wp_send_json_error('Invalid name.');
42 42
 		}
43 43
 
44
-		require dirname( dirname( __DIR__ ) ) . "/templates/wordlift-widget-be/$name.html";
44
+		require dirname(dirname(__DIR__))."/templates/wordlift-widget-be/$name.html";
45 45
 
46 46
 		die();
47 47
 	}
Please login to merge, or discard this patch.
src/wordlift/admin/class-key-validation-notice.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -11,138 +11,138 @@
 block discarded – undo
11 11
  */
12 12
 class Key_Validation_Notice {
13 13
 
14
-	const CACHE_KEY = 'is_key_valid';
14
+    const CACHE_KEY = 'is_key_valid';
15 15
 
16
-	const KEY_VALIDATION_NONCE_ACTION = 'wl_key_validation_notice_nonce';
16
+    const KEY_VALIDATION_NONCE_ACTION = 'wl_key_validation_notice_nonce';
17 17
 
18
-	const KEY_VALIDATION_NONCE_PARAM = '_wl_key_validation_notice_nonce';
18
+    const KEY_VALIDATION_NONCE_PARAM = '_wl_key_validation_notice_nonce';
19 19
 
20
-	const KEY_VALIDATION_NOTICE_PARAM = 'wl_key_validation_notice';
20
+    const KEY_VALIDATION_NOTICE_PARAM = 'wl_key_validation_notice';
21 21
 
22
-	const NOTIFICATION_OPTION_KEY = 'wordlift_key_validation_notification_shown';
22
+    const NOTIFICATION_OPTION_KEY = 'wordlift_key_validation_notification_shown';
23 23
 
24
-	/**
25
-	 * @var \Wordlift_Key_Validation_Service
26
-	 */
27
-	private $key_validation_service;
24
+    /**
25
+     * @var \Wordlift_Key_Validation_Service
26
+     */
27
+    private $key_validation_service;
28 28
 
29
-	/**
30
-	 * @var Ttl_Cache
31
-	 */
32
-	private $ttl_cache_service;
29
+    /**
30
+     * @var Ttl_Cache
31
+     */
32
+    private $ttl_cache_service;
33 33
 
34
-	/**
35
-	 * @var Wordlift_Configuration_Service
36
-	 */
37
-	private $configuration_service;
34
+    /**
35
+     * @var Wordlift_Configuration_Service
36
+     */
37
+    private $configuration_service;
38 38
 
39
-	/**
40
-	 * Key_Validation_Notice constructor.
41
-	 *
42
-	 * @param \Wordlift_Key_Validation_Service $key_validation_service
43
-	 * @param Wordlift_Configuration_Service   $configuration_service
44
-	 */
45
-	public function __construct( $key_validation_service, $configuration_service ) {
39
+    /**
40
+     * Key_Validation_Notice constructor.
41
+     *
42
+     * @param \Wordlift_Key_Validation_Service $key_validation_service
43
+     * @param Wordlift_Configuration_Service   $configuration_service
44
+     */
45
+    public function __construct( $key_validation_service, $configuration_service ) {
46 46
 
47
-		$this->key_validation_service = $key_validation_service;
48
-		$this->configuration_service  = $configuration_service;
47
+        $this->key_validation_service = $key_validation_service;
48
+        $this->configuration_service  = $configuration_service;
49 49
 
50
-		$this->ttl_cache_service = new Ttl_Cache( 'key-validation-notification', 60 * 60 * 8 );
50
+        $this->ttl_cache_service = new Ttl_Cache( 'key-validation-notification', 60 * 60 * 8 );
51 51
 
52
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
53
-			$this->display_key_validation_notice();
54
-		}
52
+        if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
53
+            $this->display_key_validation_notice();
54
+        }
55 55
 
56
-		$that = $this;
57
-		add_action(
58
-			'plugins_loaded',
59
-			function () use ( $that ) {
60
-				$that->notification_close_handler();
61
-			}
62
-		);
63
-	}
56
+        $that = $this;
57
+        add_action(
58
+            'plugins_loaded',
59
+            function () use ( $that ) {
60
+                $that->notification_close_handler();
61
+            }
62
+        );
63
+    }
64 64
 
65
-	public function show_notification() {
66
-		$settings_url = admin_url( 'admin.php?page=wl_configuration_admin_menu' );
67
-		?>
65
+    public function show_notification() {
66
+        $settings_url = admin_url( 'admin.php?page=wl_configuration_admin_menu' );
67
+        ?>
68 68
 		<div class="wl-notice notice is-dismissible error">
69 69
 			<p>
70 70
 				<?php
71
-				/* translators: %s: the link to the WordLift configuration screen. */
72
-				echo wp_kses( sprintf( __( "Your WordLift key is not valid, please update the key in <a href='%s'>WordLift Settings</a> or contact our support at [email protected].", 'wordlift' ), esc_attr( $settings_url ) ), array( 'a' => array( 'href' ) ) );
73
-				?>
71
+                /* translators: %s: the link to the WordLift configuration screen. */
72
+                echo wp_kses( sprintf( __( "Your WordLift key is not valid, please update the key in <a href='%s'>WordLift Settings</a> or contact our support at [email protected].", 'wordlift' ), esc_attr( $settings_url ) ), array( 'a' => array( 'href' ) ) );
73
+                ?>
74 74
 			</p>
75 75
 			<button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span>
76 76
 			</button>
77 77
 		</div>
78 78
 		<?php
79
-	}
79
+    }
80 80
 
81
-	private function is_key_valid() {
81
+    private function is_key_valid() {
82 82
 
83
-		$key = $this->configuration_service->get_key();
83
+        $key = $this->configuration_service->get_key();
84 84
 
85
-		// Check cache if the result is present, if not get the results
86
-		// save it and return the data.
87
-		if ( $this->ttl_cache_service->get( self::CACHE_KEY ) !== null ) {
88
-			return $this->ttl_cache_service->get( self::CACHE_KEY );
89
-		}
85
+        // Check cache if the result is present, if not get the results
86
+        // save it and return the data.
87
+        if ( $this->ttl_cache_service->get( self::CACHE_KEY ) !== null ) {
88
+            return $this->ttl_cache_service->get( self::CACHE_KEY );
89
+        }
90 90
 
91
-		$is_valid = $this->key_validation_service->is_key_valid( $key );
91
+        $is_valid = $this->key_validation_service->is_key_valid( $key );
92 92
 
93
-		// when the cache is set, clear the notification flag.
94
-		delete_option( self::NOTIFICATION_OPTION_KEY );
93
+        // when the cache is set, clear the notification flag.
94
+        delete_option( self::NOTIFICATION_OPTION_KEY );
95 95
 
96
-		$this->ttl_cache_service->put( self::CACHE_KEY, $is_valid );
96
+        $this->ttl_cache_service->put( self::CACHE_KEY, $is_valid );
97 97
 
98
-		return $is_valid;
99
-	}
98
+        return $is_valid;
99
+    }
100 100
 
101
-	private function display_key_validation_notice() {
102
-		$that = $this;
103
-		add_action(
104
-			'admin_notices',
105
-			function () use ( $that ) {
101
+    private function display_key_validation_notice() {
102
+        $that = $this;
103
+        add_action(
104
+            'admin_notices',
105
+            function () use ( $that ) {
106 106
 
107
-				$is_notification_shown = get_option( Key_Validation_Notice::NOTIFICATION_OPTION_KEY, false );
107
+                $is_notification_shown = get_option( Key_Validation_Notice::NOTIFICATION_OPTION_KEY, false );
108 108
 
109
-				$key = $that->configuration_service->get_key();
109
+                $key = $that->configuration_service->get_key();
110 110
 
111
-				if ( ! $key ) {
112
-					// Dont show warning or make API call, return early.
113
-					return;
114
-				}
111
+                if ( ! $key ) {
112
+                    // Dont show warning or make API call, return early.
113
+                    return;
114
+                }
115 115
 
116
-				if ( $that->is_key_valid() ) {
117
-					return;
118
-				}
116
+                if ( $that->is_key_valid() ) {
117
+                    return;
118
+                }
119 119
 
120
-				if ( $is_notification_shown ) {
121
-					return;
122
-				}
120
+                if ( $is_notification_shown ) {
121
+                    return;
122
+                }
123 123
 
124
-				$that->show_notification();
124
+                $that->show_notification();
125 125
 
126
-			}
127
-		);
128
-	}
126
+            }
127
+        );
128
+    }
129 129
 
130
-	public function notification_close_handler() {
131
-		if ( ! isset( $_GET['wl_key_validation_notice'] )
132
-			 || ! isset( $_GET['_wl_key_validation_notice_nonce'] ) ) {
133
-			return false;
134
-		}
135
-		$nonce = sanitize_text_field( wp_unslash( (string) $_GET['_wl_key_validation_notice_nonce'] ) );
136
-		if ( wp_verify_nonce( $nonce, self::KEY_VALIDATION_NONCE_ACTION )
137
-			 && current_user_can( 'manage_options' ) ) {
138
-			// close the notification.
139
-			update_option( self::NOTIFICATION_OPTION_KEY, true );
140
-		}
141
-	}
130
+    public function notification_close_handler() {
131
+        if ( ! isset( $_GET['wl_key_validation_notice'] )
132
+             || ! isset( $_GET['_wl_key_validation_notice_nonce'] ) ) {
133
+            return false;
134
+        }
135
+        $nonce = sanitize_text_field( wp_unslash( (string) $_GET['_wl_key_validation_notice_nonce'] ) );
136
+        if ( wp_verify_nonce( $nonce, self::KEY_VALIDATION_NONCE_ACTION )
137
+             && current_user_can( 'manage_options' ) ) {
138
+            // close the notification.
139
+            update_option( self::NOTIFICATION_OPTION_KEY, true );
140
+        }
141
+    }
142 142
 
143
-	public static function remove_notification_flag() {
144
-		delete_option( self::NOTIFICATION_OPTION_KEY );
145
-	}
143
+    public static function remove_notification_flag() {
144
+        delete_option( self::NOTIFICATION_OPTION_KEY );
145
+    }
146 146
 
147 147
 }
148 148
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -42,34 +42,34 @@  discard block
 block discarded – undo
42 42
 	 * @param \Wordlift_Key_Validation_Service $key_validation_service
43 43
 	 * @param Wordlift_Configuration_Service   $configuration_service
44 44
 	 */
45
-	public function __construct( $key_validation_service, $configuration_service ) {
45
+	public function __construct($key_validation_service, $configuration_service) {
46 46
 
47 47
 		$this->key_validation_service = $key_validation_service;
48 48
 		$this->configuration_service  = $configuration_service;
49 49
 
50
-		$this->ttl_cache_service = new Ttl_Cache( 'key-validation-notification', 60 * 60 * 8 );
50
+		$this->ttl_cache_service = new Ttl_Cache('key-validation-notification', 60 * 60 * 8);
51 51
 
52
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
52
+		if (apply_filters('wl_feature__enable__notices', true)) {
53 53
 			$this->display_key_validation_notice();
54 54
 		}
55 55
 
56 56
 		$that = $this;
57 57
 		add_action(
58 58
 			'plugins_loaded',
59
-			function () use ( $that ) {
59
+			function() use ($that) {
60 60
 				$that->notification_close_handler();
61 61
 			}
62 62
 		);
63 63
 	}
64 64
 
65 65
 	public function show_notification() {
66
-		$settings_url = admin_url( 'admin.php?page=wl_configuration_admin_menu' );
66
+		$settings_url = admin_url('admin.php?page=wl_configuration_admin_menu');
67 67
 		?>
68 68
 		<div class="wl-notice notice is-dismissible error">
69 69
 			<p>
70 70
 				<?php
71 71
 				/* translators: %s: the link to the WordLift configuration screen. */
72
-				echo wp_kses( sprintf( __( "Your WordLift key is not valid, please update the key in <a href='%s'>WordLift Settings</a> or contact our support at [email protected].", 'wordlift' ), esc_attr( $settings_url ) ), array( 'a' => array( 'href' ) ) );
72
+				echo wp_kses(sprintf(__("Your WordLift key is not valid, please update the key in <a href='%s'>WordLift Settings</a> or contact our support at [email protected].", 'wordlift'), esc_attr($settings_url)), array('a' => array('href')));
73 73
 				?>
74 74
 			</p>
75 75
 			<button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span>
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
 
85 85
 		// Check cache if the result is present, if not get the results
86 86
 		// save it and return the data.
87
-		if ( $this->ttl_cache_service->get( self::CACHE_KEY ) !== null ) {
88
-			return $this->ttl_cache_service->get( self::CACHE_KEY );
87
+		if ($this->ttl_cache_service->get(self::CACHE_KEY) !== null) {
88
+			return $this->ttl_cache_service->get(self::CACHE_KEY);
89 89
 		}
90 90
 
91
-		$is_valid = $this->key_validation_service->is_key_valid( $key );
91
+		$is_valid = $this->key_validation_service->is_key_valid($key);
92 92
 
93 93
 		// when the cache is set, clear the notification flag.
94
-		delete_option( self::NOTIFICATION_OPTION_KEY );
94
+		delete_option(self::NOTIFICATION_OPTION_KEY);
95 95
 
96
-		$this->ttl_cache_service->put( self::CACHE_KEY, $is_valid );
96
+		$this->ttl_cache_service->put(self::CACHE_KEY, $is_valid);
97 97
 
98 98
 		return $is_valid;
99 99
 	}
@@ -102,22 +102,22 @@  discard block
 block discarded – undo
102 102
 		$that = $this;
103 103
 		add_action(
104 104
 			'admin_notices',
105
-			function () use ( $that ) {
105
+			function() use ($that) {
106 106
 
107
-				$is_notification_shown = get_option( Key_Validation_Notice::NOTIFICATION_OPTION_KEY, false );
107
+				$is_notification_shown = get_option(Key_Validation_Notice::NOTIFICATION_OPTION_KEY, false);
108 108
 
109 109
 				$key = $that->configuration_service->get_key();
110 110
 
111
-				if ( ! $key ) {
111
+				if ( ! $key) {
112 112
 					// Dont show warning or make API call, return early.
113 113
 					return;
114 114
 				}
115 115
 
116
-				if ( $that->is_key_valid() ) {
116
+				if ($that->is_key_valid()) {
117 117
 					return;
118 118
 				}
119 119
 
120
-				if ( $is_notification_shown ) {
120
+				if ($is_notification_shown) {
121 121
 					return;
122 122
 				}
123 123
 
@@ -128,20 +128,20 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	public function notification_close_handler() {
131
-		if ( ! isset( $_GET['wl_key_validation_notice'] )
132
-			 || ! isset( $_GET['_wl_key_validation_notice_nonce'] ) ) {
131
+		if ( ! isset($_GET['wl_key_validation_notice'])
132
+			 || ! isset($_GET['_wl_key_validation_notice_nonce'])) {
133 133
 			return false;
134 134
 		}
135
-		$nonce = sanitize_text_field( wp_unslash( (string) $_GET['_wl_key_validation_notice_nonce'] ) );
136
-		if ( wp_verify_nonce( $nonce, self::KEY_VALIDATION_NONCE_ACTION )
137
-			 && current_user_can( 'manage_options' ) ) {
135
+		$nonce = sanitize_text_field(wp_unslash((string) $_GET['_wl_key_validation_notice_nonce']));
136
+		if (wp_verify_nonce($nonce, self::KEY_VALIDATION_NONCE_ACTION)
137
+			 && current_user_can('manage_options')) {
138 138
 			// close the notification.
139
-			update_option( self::NOTIFICATION_OPTION_KEY, true );
139
+			update_option(self::NOTIFICATION_OPTION_KEY, true);
140 140
 		}
141 141
 	}
142 142
 
143 143
 	public static function remove_notification_flag() {
144
-		delete_option( self::NOTIFICATION_OPTION_KEY );
144
+		delete_option(self::NOTIFICATION_OPTION_KEY);
145 145
 	}
146 146
 
147 147
 }
Please login to merge, or discard this patch.
src/wordlift/admin/class-top-entities.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -8,23 +8,23 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class Top_Entities {
10 10
 
11
-	const CRON_ACTION = 'wl_admin_dashboard_top_entities';
11
+    const CRON_ACTION = 'wl_admin_dashboard_top_entities';
12 12
 
13
-	/**
14
-	 * Option key where the top entities data is stored.
15
-	 */
16
-	const OPTION_KEY = 'wl_admin_dashboard_top_entities_option';
13
+    /**
14
+     * Option key where the top entities data is stored.
15
+     */
16
+    const OPTION_KEY = 'wl_admin_dashboard_top_entities_option';
17 17
 
18
-	public function __construct() {
19
-		add_action( self::CRON_ACTION, array( $this, 'save_top_entities' ) );
20
-	}
18
+    public function __construct() {
19
+        add_action( self::CRON_ACTION, array( $this, 'save_top_entities' ) );
20
+    }
21 21
 
22
-	public function save_top_entities() {
22
+    public function save_top_entities() {
23 23
 
24
-		global $wpdb;
24
+        global $wpdb;
25 25
 
26
-		$results = $wpdb->get_results(
27
-			"
26
+        $results = $wpdb->get_results(
27
+            "
28 28
 			SELECT p_as_object.ID
29 29
 			    , p_as_object.post_title
30 30
 			    , COALESCE(SUM(CASE WHEN t_as_subject.slug IS NULL THEN 1 END), 0)     entities
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 			ORDER BY total DESC
50 50
 			LIMIT 20
51 51
 		"
52
-		);
52
+        );
53 53
 
54
-		update_option( self::OPTION_KEY, $results );
55
-	}
54
+        update_option( self::OPTION_KEY, $results );
55
+    }
56 56
 
57
-	public static function activate() {
58
-		if ( ! wp_next_scheduled( self::CRON_ACTION ) ) {
59
-			wp_schedule_event( time(), 'daily', self::CRON_ACTION );
60
-		}
61
-	}
57
+    public static function activate() {
58
+        if ( ! wp_next_scheduled( self::CRON_ACTION ) ) {
59
+            wp_schedule_event( time(), 'daily', self::CRON_ACTION );
60
+        }
61
+    }
62 62
 
63
-	public static function deactivate() {
64
-		$timestamp = wp_next_scheduled( self::CRON_ACTION );
65
-		wp_unschedule_event( $timestamp, self::CRON_ACTION );
66
-	}
63
+    public static function deactivate() {
64
+        $timestamp = wp_next_scheduled( self::CRON_ACTION );
65
+        wp_unschedule_event( $timestamp, self::CRON_ACTION );
66
+    }
67 67
 
68 68
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	const OPTION_KEY = 'wl_admin_dashboard_top_entities_option';
17 17
 
18 18
 	public function __construct() {
19
-		add_action( self::CRON_ACTION, array( $this, 'save_top_entities' ) );
19
+		add_action(self::CRON_ACTION, array($this, 'save_top_entities'));
20 20
 	}
21 21
 
22 22
 	public function save_top_entities() {
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
 		"
52 52
 		);
53 53
 
54
-		update_option( self::OPTION_KEY, $results );
54
+		update_option(self::OPTION_KEY, $results);
55 55
 	}
56 56
 
57 57
 	public static function activate() {
58
-		if ( ! wp_next_scheduled( self::CRON_ACTION ) ) {
59
-			wp_schedule_event( time(), 'daily', self::CRON_ACTION );
58
+		if ( ! wp_next_scheduled(self::CRON_ACTION)) {
59
+			wp_schedule_event(time(), 'daily', self::CRON_ACTION);
60 60
 		}
61 61
 	}
62 62
 
63 63
 	public static function deactivate() {
64
-		$timestamp = wp_next_scheduled( self::CRON_ACTION );
65
-		wp_unschedule_event( $timestamp, self::CRON_ACTION );
64
+		$timestamp = wp_next_scheduled(self::CRON_ACTION);
65
+		wp_unschedule_event($timestamp, self::CRON_ACTION);
66 66
 	}
67 67
 
68 68
 }
Please login to merge, or discard this patch.
src/wordlift/admin/class-admin-user-option.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -8,55 +8,55 @@
 block discarded – undo
8 8
  */
9 9
 class Admin_User_Option {
10 10
 
11
-	const WORDLIFT_ADMIN = 'wl_is_wordlift_admin';
12
-
13
-	public static function is_wordlift_admin() {
14
-		return intval( get_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN, true ) ) === 1;
15
-	}
16
-
17
-	public function connect_hook() {
18
-		add_action( 'wordlift_user_settings_page', array( $this, 'render_checkbox' ) );
19
-		add_action( 'edit_user_profile_update', array( $this, 'save_checkbox' ) );
20
-		add_action( 'personal_options_update', array( $this, 'save_checkbox' ) );
21
-	}
22
-
23
-	public function save_checkbox() {
24
-
25
-		if ( ! current_user_can( 'manage_options' ) ) {
26
-			return;
27
-		}
28
-
29
-		if ( ! isset( $_POST[ self::WORDLIFT_ADMIN ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
30
-			delete_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN );
31
-
32
-			return;
33
-		}
34
-		update_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN, 1 );
35
-	}
36
-
37
-	public function render_checkbox() {
38
-		if ( ! current_user_can( 'manage_options' ) ) {
39
-			return;
40
-		}
41
-		$is_checked   = intval( get_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN, true ) ) === 1;
42
-		$allowed_html = array(
43
-			'tr'    => array(),
44
-			'th'    => array(),
45
-			'td'    => array(),
46
-			'input' => array(
47
-				'type'    => array(),
48
-				'name'    => array(),
49
-				'checked' => array(),
50
-			),
51
-		);
52
-		echo wp_kses( $this->get_checkbox( $is_checked ), $allowed_html );
53
-	}
54
-
55
-	public static function get_checkbox( $is_checked ) {
56
-		$checked    = $is_checked ? "checked='checked'" : '';
57
-		$admin_text = __( 'Wordlift Admin', 'wordlift' );
58
-
59
-		return "<tr><th>$admin_text</th><td><input type='checkbox' name='wl_is_wordlift_admin' $checked></td></tr>";
60
-	}
11
+    const WORDLIFT_ADMIN = 'wl_is_wordlift_admin';
12
+
13
+    public static function is_wordlift_admin() {
14
+        return intval( get_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN, true ) ) === 1;
15
+    }
16
+
17
+    public function connect_hook() {
18
+        add_action( 'wordlift_user_settings_page', array( $this, 'render_checkbox' ) );
19
+        add_action( 'edit_user_profile_update', array( $this, 'save_checkbox' ) );
20
+        add_action( 'personal_options_update', array( $this, 'save_checkbox' ) );
21
+    }
22
+
23
+    public function save_checkbox() {
24
+
25
+        if ( ! current_user_can( 'manage_options' ) ) {
26
+            return;
27
+        }
28
+
29
+        if ( ! isset( $_POST[ self::WORDLIFT_ADMIN ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
30
+            delete_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN );
31
+
32
+            return;
33
+        }
34
+        update_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN, 1 );
35
+    }
36
+
37
+    public function render_checkbox() {
38
+        if ( ! current_user_can( 'manage_options' ) ) {
39
+            return;
40
+        }
41
+        $is_checked   = intval( get_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN, true ) ) === 1;
42
+        $allowed_html = array(
43
+            'tr'    => array(),
44
+            'th'    => array(),
45
+            'td'    => array(),
46
+            'input' => array(
47
+                'type'    => array(),
48
+                'name'    => array(),
49
+                'checked' => array(),
50
+            ),
51
+        );
52
+        echo wp_kses( $this->get_checkbox( $is_checked ), $allowed_html );
53
+    }
54
+
55
+    public static function get_checkbox( $is_checked ) {
56
+        $checked    = $is_checked ? "checked='checked'" : '';
57
+        $admin_text = __( 'Wordlift Admin', 'wordlift' );
58
+
59
+        return "<tr><th>$admin_text</th><td><input type='checkbox' name='wl_is_wordlift_admin' $checked></td></tr>";
60
+    }
61 61
 
62 62
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,34 +11,34 @@  discard block
 block discarded – undo
11 11
 	const WORDLIFT_ADMIN = 'wl_is_wordlift_admin';
12 12
 
13 13
 	public static function is_wordlift_admin() {
14
-		return intval( get_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN, true ) ) === 1;
14
+		return intval(get_user_meta(get_current_user_id(), self::WORDLIFT_ADMIN, true)) === 1;
15 15
 	}
16 16
 
17 17
 	public function connect_hook() {
18
-		add_action( 'wordlift_user_settings_page', array( $this, 'render_checkbox' ) );
19
-		add_action( 'edit_user_profile_update', array( $this, 'save_checkbox' ) );
20
-		add_action( 'personal_options_update', array( $this, 'save_checkbox' ) );
18
+		add_action('wordlift_user_settings_page', array($this, 'render_checkbox'));
19
+		add_action('edit_user_profile_update', array($this, 'save_checkbox'));
20
+		add_action('personal_options_update', array($this, 'save_checkbox'));
21 21
 	}
22 22
 
23 23
 	public function save_checkbox() {
24 24
 
25
-		if ( ! current_user_can( 'manage_options' ) ) {
25
+		if ( ! current_user_can('manage_options')) {
26 26
 			return;
27 27
 		}
28 28
 
29
-		if ( ! isset( $_POST[ self::WORDLIFT_ADMIN ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
30
-			delete_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN );
29
+		if ( ! isset($_POST[self::WORDLIFT_ADMIN])) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
30
+			delete_user_meta(get_current_user_id(), self::WORDLIFT_ADMIN);
31 31
 
32 32
 			return;
33 33
 		}
34
-		update_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN, 1 );
34
+		update_user_meta(get_current_user_id(), self::WORDLIFT_ADMIN, 1);
35 35
 	}
36 36
 
37 37
 	public function render_checkbox() {
38
-		if ( ! current_user_can( 'manage_options' ) ) {
38
+		if ( ! current_user_can('manage_options')) {
39 39
 			return;
40 40
 		}
41
-		$is_checked   = intval( get_user_meta( get_current_user_id(), self::WORDLIFT_ADMIN, true ) ) === 1;
41
+		$is_checked   = intval(get_user_meta(get_current_user_id(), self::WORDLIFT_ADMIN, true)) === 1;
42 42
 		$allowed_html = array(
43 43
 			'tr'    => array(),
44 44
 			'th'    => array(),
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 				'checked' => array(),
50 50
 			),
51 51
 		);
52
-		echo wp_kses( $this->get_checkbox( $is_checked ), $allowed_html );
52
+		echo wp_kses($this->get_checkbox($is_checked), $allowed_html);
53 53
 	}
54 54
 
55
-	public static function get_checkbox( $is_checked ) {
55
+	public static function get_checkbox($is_checked) {
56 56
 		$checked    = $is_checked ? "checked='checked'" : '';
57
-		$admin_text = __( 'Wordlift Admin', 'wordlift' );
57
+		$admin_text = __('Wordlift Admin', 'wordlift');
58 58
 
59 59
 		return "<tr><th>$admin_text</th><td><input type='checkbox' name='wl_is_wordlift_admin' $checked></td></tr>";
60 60
 	}
Please login to merge, or discard this patch.
src/wordlift/class-assertions.php 2 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -15,84 +15,84 @@
 block discarded – undo
15 15
 
16 16
 class Assertions {
17 17
 
18
-	/**
19
-	 * Asserts that the provided value is of the specified type.
20
-	 *
21
-	 * @param mixed  $value The value to test.
22
-	 * @param string $type The expected type.
23
-	 *
24
-	 * @throws Exception when an error occurs.
25
-	 */
26
-	public static function assert_of_type( $value, $type ) {
27
-
28
-		// Check for nulls.
29
-		if ( null === $value ) {
30
-			throw new Exception( 'Value can`t be null.' );
31
-		}
32
-
33
-		// Check for type.
34
-		if ( get_class( $value ) !== $type ) {
35
-			throw new Exception( "Value must be a $type." );
36
-		}
37
-
38
-	}
39
-
40
-	/**
41
-	 * @throws Exception when the argument is not a string.
42
-	 */
43
-	public static function is_string( $arg, $message = 'Value must be a string' ) {
44
-		if ( ! is_string( $arg ) ) {
45
-			throw new Exception( $message );
46
-		}
47
-	}
48
-
49
-	/**
50
-	 * @throws Exception when actual doesn't match expected.
51
-	 */
52
-	public static function equals( $actual, $expected, $message = 'Values do not match' ) {
53
-		if ( $actual !== $expected ) {
54
-			throw new Exception( $message );
55
-		}
56
-	}
57
-
58
-	/**
59
-	 * @throws Exception when the value doesn't match the pattern.
60
-	 */
61
-	public static function matches( $value, $pattern, $message = "Value doesn't match" ) {
62
-		if ( 1 !== preg_match( $pattern, $value ) ) {
63
-			throw new Exception( $message );
64
-		}
65
-
66
-	}
67
-
68
-	/**
69
-	 * @throws Exception when the value doesn't start with the provided scope.
70
-	 */
71
-	public static function starts_with( $value, $scope, $message = "Value doesn't start with provided scope" ) {
72
-		if ( 0 !== strpos( $value, $scope ) ) {
73
-			throw new Exception( $message );
74
-		}
75
-	}
76
-
77
-	/**
78
-	 * @throws Exception when the value is not of the specified type.
79
-	 */
80
-	public static function is_a( $value, $type, $message = 'Value is not of the required type' ) {
81
-		if ( ! is_a( $value, $type ) ) {
82
-			throw new Exception( $message );
83
-		}
84
-	}
85
-
86
-	public static function is_set( $value, $message = 'Value is not set' ) {
87
-		if ( ! isset( $value ) ) {
88
-			throw new Exception( $message );
89
-		}
90
-	}
91
-
92
-	public static function not_empty( $value, $message = "Value can't be empty" ) {
93
-		if ( empty( $value ) ) {
94
-			throw new Exception( $message );
95
-		}
96
-	}
18
+    /**
19
+     * Asserts that the provided value is of the specified type.
20
+     *
21
+     * @param mixed  $value The value to test.
22
+     * @param string $type The expected type.
23
+     *
24
+     * @throws Exception when an error occurs.
25
+     */
26
+    public static function assert_of_type( $value, $type ) {
27
+
28
+        // Check for nulls.
29
+        if ( null === $value ) {
30
+            throw new Exception( 'Value can`t be null.' );
31
+        }
32
+
33
+        // Check for type.
34
+        if ( get_class( $value ) !== $type ) {
35
+            throw new Exception( "Value must be a $type." );
36
+        }
37
+
38
+    }
39
+
40
+    /**
41
+     * @throws Exception when the argument is not a string.
42
+     */
43
+    public static function is_string( $arg, $message = 'Value must be a string' ) {
44
+        if ( ! is_string( $arg ) ) {
45
+            throw new Exception( $message );
46
+        }
47
+    }
48
+
49
+    /**
50
+     * @throws Exception when actual doesn't match expected.
51
+     */
52
+    public static function equals( $actual, $expected, $message = 'Values do not match' ) {
53
+        if ( $actual !== $expected ) {
54
+            throw new Exception( $message );
55
+        }
56
+    }
57
+
58
+    /**
59
+     * @throws Exception when the value doesn't match the pattern.
60
+     */
61
+    public static function matches( $value, $pattern, $message = "Value doesn't match" ) {
62
+        if ( 1 !== preg_match( $pattern, $value ) ) {
63
+            throw new Exception( $message );
64
+        }
65
+
66
+    }
67
+
68
+    /**
69
+     * @throws Exception when the value doesn't start with the provided scope.
70
+     */
71
+    public static function starts_with( $value, $scope, $message = "Value doesn't start with provided scope" ) {
72
+        if ( 0 !== strpos( $value, $scope ) ) {
73
+            throw new Exception( $message );
74
+        }
75
+    }
76
+
77
+    /**
78
+     * @throws Exception when the value is not of the specified type.
79
+     */
80
+    public static function is_a( $value, $type, $message = 'Value is not of the required type' ) {
81
+        if ( ! is_a( $value, $type ) ) {
82
+            throw new Exception( $message );
83
+        }
84
+    }
85
+
86
+    public static function is_set( $value, $message = 'Value is not set' ) {
87
+        if ( ! isset( $value ) ) {
88
+            throw new Exception( $message );
89
+        }
90
+    }
91
+
92
+    public static function not_empty( $value, $message = "Value can't be empty" ) {
93
+        if ( empty( $value ) ) {
94
+            throw new Exception( $message );
95
+        }
96
+    }
97 97
 
98 98
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @throws Exception when an error occurs.
25 25
 	 */
26
-	public static function assert_of_type( $value, $type ) {
26
+	public static function assert_of_type($value, $type) {
27 27
 
28 28
 		// Check for nulls.
29
-		if ( null === $value ) {
30
-			throw new Exception( 'Value can`t be null.' );
29
+		if (null === $value) {
30
+			throw new Exception('Value can`t be null.');
31 31
 		}
32 32
 
33 33
 		// Check for type.
34
-		if ( get_class( $value ) !== $type ) {
35
-			throw new Exception( "Value must be a $type." );
34
+		if (get_class($value) !== $type) {
35
+			throw new Exception("Value must be a $type.");
36 36
 		}
37 37
 
38 38
 	}
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 * @throws Exception when the argument is not a string.
42 42
 	 */
43
-	public static function is_string( $arg, $message = 'Value must be a string' ) {
44
-		if ( ! is_string( $arg ) ) {
45
-			throw new Exception( $message );
43
+	public static function is_string($arg, $message = 'Value must be a string') {
44
+		if ( ! is_string($arg)) {
45
+			throw new Exception($message);
46 46
 		}
47 47
 	}
48 48
 
49 49
 	/**
50 50
 	 * @throws Exception when actual doesn't match expected.
51 51
 	 */
52
-	public static function equals( $actual, $expected, $message = 'Values do not match' ) {
53
-		if ( $actual !== $expected ) {
54
-			throw new Exception( $message );
52
+	public static function equals($actual, $expected, $message = 'Values do not match') {
53
+		if ($actual !== $expected) {
54
+			throw new Exception($message);
55 55
 		}
56 56
 	}
57 57
 
58 58
 	/**
59 59
 	 * @throws Exception when the value doesn't match the pattern.
60 60
 	 */
61
-	public static function matches( $value, $pattern, $message = "Value doesn't match" ) {
62
-		if ( 1 !== preg_match( $pattern, $value ) ) {
63
-			throw new Exception( $message );
61
+	public static function matches($value, $pattern, $message = "Value doesn't match") {
62
+		if (1 !== preg_match($pattern, $value)) {
63
+			throw new Exception($message);
64 64
 		}
65 65
 
66 66
 	}
@@ -68,30 +68,30 @@  discard block
 block discarded – undo
68 68
 	/**
69 69
 	 * @throws Exception when the value doesn't start with the provided scope.
70 70
 	 */
71
-	public static function starts_with( $value, $scope, $message = "Value doesn't start with provided scope" ) {
72
-		if ( 0 !== strpos( $value, $scope ) ) {
73
-			throw new Exception( $message );
71
+	public static function starts_with($value, $scope, $message = "Value doesn't start with provided scope") {
72
+		if (0 !== strpos($value, $scope)) {
73
+			throw new Exception($message);
74 74
 		}
75 75
 	}
76 76
 
77 77
 	/**
78 78
 	 * @throws Exception when the value is not of the specified type.
79 79
 	 */
80
-	public static function is_a( $value, $type, $message = 'Value is not of the required type' ) {
81
-		if ( ! is_a( $value, $type ) ) {
82
-			throw new Exception( $message );
80
+	public static function is_a($value, $type, $message = 'Value is not of the required type') {
81
+		if ( ! is_a($value, $type)) {
82
+			throw new Exception($message);
83 83
 		}
84 84
 	}
85 85
 
86
-	public static function is_set( $value, $message = 'Value is not set' ) {
87
-		if ( ! isset( $value ) ) {
88
-			throw new Exception( $message );
86
+	public static function is_set($value, $message = 'Value is not set') {
87
+		if ( ! isset($value)) {
88
+			throw new Exception($message);
89 89
 		}
90 90
 	}
91 91
 
92
-	public static function not_empty( $value, $message = "Value can't be empty" ) {
93
-		if ( empty( $value ) ) {
94
-			throw new Exception( $message );
92
+	public static function not_empty($value, $message = "Value can't be empty") {
93
+		if (empty($value)) {
94
+			throw new Exception($message);
95 95
 		}
96 96
 	}
97 97
 
Please login to merge, or discard this patch.
src/wordlift/mappings/pages/class-admin-mappings-page.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -22,69 +22,69 @@
 block discarded – undo
22 22
  */
23 23
 class Admin_Mappings_Page extends Wordlift_Admin_Page {
24 24
 
25
-	/**
26
-	 * Provides script and js global values used by react component.
27
-	 */
28
-	public static function provide_ui_dependencies() {
29
-		// Create ui settings array to be used by js client.
30
-		$mapping_settings                          = array();
31
-		$mapping_settings['rest_url']              = get_rest_url(
32
-			null,
33
-			WL_REST_ROUTE_DEFAULT_NAMESPACE . Mappings_REST_Controller::MAPPINGS_NAMESPACE
34
-		);
35
-		$mapping_settings['wl_mapping_nonce']      = wp_create_nonce( 'wp_rest' );
36
-		$mapping_settings['wl_edit_mapping_nonce'] = wp_create_nonce( 'wl-edit-mapping-nonce' );
37
-		wp_localize_script( 'wl-mappings-admin', 'wlMappingsConfig', $mapping_settings );
38
-	}
39
-
40
-	/**
41
-	 * {@inheritdoc}
42
-	 */
43
-	public function get_page_title() {
44
-
45
-		return __( 'Mappings', 'wordlift' );
46
-	}
47
-
48
-	/**
49
-	 * {@inheritdoc}
50
-	 */
51
-	public function get_menu_title() {
52
-
53
-		return __( 'Mappings', 'wordlift' );
54
-	}
55
-
56
-	/**
57
-	 * {@inheritdoc}
58
-	 */
59
-	public function get_menu_slug() {
60
-
61
-		return 'wl_mappings_admin';
62
-	}
63
-
64
-	/**
65
-	 * {@inheritdoc}
66
-	 */
67
-	public function get_partial_name() {
68
-
69
-		return 'wordlift-admin-mappings-admin.php';
70
-	}
71
-
72
-	public function enqueue_scripts() {
73
-
74
-		Scripts_Helper::enqueue_based_on_wordpress_version(
75
-			'wl-mappings-admin',
76
-			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/mappings',
77
-			array( 'react', 'react-dom', 'wp-polyfill' ),
78
-			true
79
-		);
80
-
81
-		wp_enqueue_style(
82
-			'wl-mappings-admin',
83
-			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/mappings.css',
84
-			array(),
85
-			WORDLIFT_VERSION
86
-		);
87
-		self::provide_ui_dependencies();
88
-	}
25
+    /**
26
+     * Provides script and js global values used by react component.
27
+     */
28
+    public static function provide_ui_dependencies() {
29
+        // Create ui settings array to be used by js client.
30
+        $mapping_settings                          = array();
31
+        $mapping_settings['rest_url']              = get_rest_url(
32
+            null,
33
+            WL_REST_ROUTE_DEFAULT_NAMESPACE . Mappings_REST_Controller::MAPPINGS_NAMESPACE
34
+        );
35
+        $mapping_settings['wl_mapping_nonce']      = wp_create_nonce( 'wp_rest' );
36
+        $mapping_settings['wl_edit_mapping_nonce'] = wp_create_nonce( 'wl-edit-mapping-nonce' );
37
+        wp_localize_script( 'wl-mappings-admin', 'wlMappingsConfig', $mapping_settings );
38
+    }
39
+
40
+    /**
41
+     * {@inheritdoc}
42
+     */
43
+    public function get_page_title() {
44
+
45
+        return __( 'Mappings', 'wordlift' );
46
+    }
47
+
48
+    /**
49
+     * {@inheritdoc}
50
+     */
51
+    public function get_menu_title() {
52
+
53
+        return __( 'Mappings', 'wordlift' );
54
+    }
55
+
56
+    /**
57
+     * {@inheritdoc}
58
+     */
59
+    public function get_menu_slug() {
60
+
61
+        return 'wl_mappings_admin';
62
+    }
63
+
64
+    /**
65
+     * {@inheritdoc}
66
+     */
67
+    public function get_partial_name() {
68
+
69
+        return 'wordlift-admin-mappings-admin.php';
70
+    }
71
+
72
+    public function enqueue_scripts() {
73
+
74
+        Scripts_Helper::enqueue_based_on_wordpress_version(
75
+            'wl-mappings-admin',
76
+            plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/mappings',
77
+            array( 'react', 'react-dom', 'wp-polyfill' ),
78
+            true
79
+        );
80
+
81
+        wp_enqueue_style(
82
+            'wl-mappings-admin',
83
+            plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/mappings.css',
84
+            array(),
85
+            WORDLIFT_VERSION
86
+        );
87
+        self::provide_ui_dependencies();
88
+    }
89 89
 
90 90
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 		$mapping_settings                          = array();
31 31
 		$mapping_settings['rest_url']              = get_rest_url(
32 32
 			null,
33
-			WL_REST_ROUTE_DEFAULT_NAMESPACE . Mappings_REST_Controller::MAPPINGS_NAMESPACE
33
+			WL_REST_ROUTE_DEFAULT_NAMESPACE.Mappings_REST_Controller::MAPPINGS_NAMESPACE
34 34
 		);
35
-		$mapping_settings['wl_mapping_nonce']      = wp_create_nonce( 'wp_rest' );
36
-		$mapping_settings['wl_edit_mapping_nonce'] = wp_create_nonce( 'wl-edit-mapping-nonce' );
37
-		wp_localize_script( 'wl-mappings-admin', 'wlMappingsConfig', $mapping_settings );
35
+		$mapping_settings['wl_mapping_nonce']      = wp_create_nonce('wp_rest');
36
+		$mapping_settings['wl_edit_mapping_nonce'] = wp_create_nonce('wl-edit-mapping-nonce');
37
+		wp_localize_script('wl-mappings-admin', 'wlMappingsConfig', $mapping_settings);
38 38
 	}
39 39
 
40 40
 	/**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public function get_page_title() {
44 44
 
45
-		return __( 'Mappings', 'wordlift' );
45
+		return __('Mappings', 'wordlift');
46 46
 	}
47 47
 
48 48
 	/**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function get_menu_title() {
52 52
 
53
-		return __( 'Mappings', 'wordlift' );
53
+		return __('Mappings', 'wordlift');
54 54
 	}
55 55
 
56 56
 	/**
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 
74 74
 		Scripts_Helper::enqueue_based_on_wordpress_version(
75 75
 			'wl-mappings-admin',
76
-			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/mappings',
77
-			array( 'react', 'react-dom', 'wp-polyfill' ),
76
+			plugin_dir_url(dirname(dirname(__DIR__))).'js/dist/mappings',
77
+			array('react', 'react-dom', 'wp-polyfill'),
78 78
 			true
79 79
 		);
80 80
 
81 81
 		wp_enqueue_style(
82 82
 			'wl-mappings-admin',
83
-			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/mappings.css',
83
+			plugin_dir_url(dirname(dirname(__DIR__))).'js/dist/mappings.css',
84 84
 			array(),
85 85
 			WORDLIFT_VERSION
86 86
 		);
Please login to merge, or discard this patch.