Completed
Pull Request — develop (#1175)
by Naveen
02:51
created
src/admin/class-wordlift-admin-page.php 2 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -18,150 +18,150 @@
 block discarded – undo
18 18
  */
19 19
 abstract class Wordlift_Admin_Page {
20 20
 
21
-	/**
22
-	 * Define the {@link Wordlift_Admin_Page} constructor.
23
-	 *
24
-	 * @since 3.20.0
25
-	 */
26
-	public function __construct() {
27
-
28
-		/**
29
-		 * Filter: wl_feature__enable__screens.
30
-		 *
31
-		 * @param bool whether the screens needed to be registered, defaults to true.
32
-		 *
33
-		 * @return bool
34
-		 * @since 3.27.6
35
-		 */
36
-		if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
37
-			add_action( 'admin_menu', array( $this, 'admin_menu' ), 10, 0 );
38
-		}
39
-
40
-	}
41
-
42
-	/**
43
-	 * Get the parent slug.
44
-	 *
45
-	 * @return string The parent slug (default 'wl_admin_menu').
46
-	 * @since 3.11.0
47
-	 *
48
-	 */
49
-	protected function get_parent_slug() {
50
-
51
-		return 'wl_admin_menu';
52
-	}
53
-
54
-	/**
55
-	 * Get the required capability.
56
-	 *
57
-	 * @return string The capability (default 'manage_options').
58
-	 * @since 3.11.0
59
-	 *
60
-	 */
61
-	protected function get_capability() {
62
-
63
-		return 'manage_options';
64
-	}
65
-
66
-	/**
67
-	 * Get the page title. Will be translated.
68
-	 *
69
-	 * @return string The page title.
70
-	 * @since 3.11.0
71
-	 *
72
-	 */
73
-	abstract function get_page_title();
74
-
75
-	/**
76
-	 * Get the menu title. Will be translated.
77
-	 *
78
-	 * @return string The menu title.
79
-	 * @since 3.11.0
80
-	 *
81
-	 */
82
-	abstract function get_menu_title();
83
-
84
-	/**
85
-	 * Get the menu slug.
86
-	 *
87
-	 * @return string The menu slug.
88
-	 * @since 3.11.0
89
-	 *
90
-	 */
91
-	abstract function get_menu_slug();
92
-
93
-	/**
94
-	 * Get the page url.
95
-	 *
96
-	 * @return string The escaped url of the admin page
97
-	 * @since 3.14.0
98
-	 *
99
-	 */
100
-	function get_url() {
101
-
102
-		// ideally should have used menu_page_url, but it is loaded later than some usages.
103
-		$url = admin_url( 'admin.php?page=' . $this->get_menu_slug() );
104
-
105
-		return esc_url( $url );
106
-	}
107
-
108
-	/**
109
-	 * Get the partial file name, used in the {@link render} function.
110
-	 *
111
-	 * @return string The partial file name.
112
-	 * @since 3.11.0
113
-	 *
114
-	 */
115
-	abstract function get_partial_name();
116
-
117
-	/**
118
-	 * The `admin_menu` callback. Will call {@link add_submenu_page} to add the
119
-	 * page to the admin menu.
120
-	 *
121
-	 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
122
-	 * @since 3.11.0
123
-	 *
124
-	 */
125
-	public function admin_menu() {
126
-		// Add the sub-menu page.
127
-		//
128
-		// See http://codex.wordpress.org/Function_Reference/add_submenu_page
129
-		$page = add_submenu_page(
130
-			$this->get_parent_slug(),
131
-			$this->get_page_title(),
132
-			$this->get_menu_title(),
133
-			$this->get_capability(),                   // The required capability, provided by the calling hook.
134
-			$this->get_menu_slug(),
135
-			array( $this, 'render' )
136
-		);
137
-
138
-		// Set a hook to enqueue scripts only when the settings page is displayed.
139
-		add_action( 'admin_print_scripts-' . $page, array(
140
-			$this,
141
-			'enqueue_scripts',
142
-		) );
143
-
144
-		// Finally return the page hook_suffix.
145
-		return $page;
146
-	}
147
-
148
-	/**
149
-	 * Enqueue scripts for the specific page. Subclasses can override this function
150
-	 * to provide their own styles/scripts.
151
-	 *
152
-	 * @since 3.11.0
153
-	 */
154
-	public function enqueue_scripts() {
155
-	}
156
-
157
-	/**
158
-	 * Render the page.
159
-	 */
160
-	public function render() {
161
-
162
-		// Include the partial.
163
-		include( plugin_dir_path( __FILE__ ) . 'partials/' . $this->get_partial_name() );
164
-
165
-	}
21
+    /**
22
+     * Define the {@link Wordlift_Admin_Page} constructor.
23
+     *
24
+     * @since 3.20.0
25
+     */
26
+    public function __construct() {
27
+
28
+        /**
29
+         * Filter: wl_feature__enable__screens.
30
+         *
31
+         * @param bool whether the screens needed to be registered, defaults to true.
32
+         *
33
+         * @return bool
34
+         * @since 3.27.6
35
+         */
36
+        if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
37
+            add_action( 'admin_menu', array( $this, 'admin_menu' ), 10, 0 );
38
+        }
39
+
40
+    }
41
+
42
+    /**
43
+     * Get the parent slug.
44
+     *
45
+     * @return string The parent slug (default 'wl_admin_menu').
46
+     * @since 3.11.0
47
+     *
48
+     */
49
+    protected function get_parent_slug() {
50
+
51
+        return 'wl_admin_menu';
52
+    }
53
+
54
+    /**
55
+     * Get the required capability.
56
+     *
57
+     * @return string The capability (default 'manage_options').
58
+     * @since 3.11.0
59
+     *
60
+     */
61
+    protected function get_capability() {
62
+
63
+        return 'manage_options';
64
+    }
65
+
66
+    /**
67
+     * Get the page title. Will be translated.
68
+     *
69
+     * @return string The page title.
70
+     * @since 3.11.0
71
+     *
72
+     */
73
+    abstract function get_page_title();
74
+
75
+    /**
76
+     * Get the menu title. Will be translated.
77
+     *
78
+     * @return string The menu title.
79
+     * @since 3.11.0
80
+     *
81
+     */
82
+    abstract function get_menu_title();
83
+
84
+    /**
85
+     * Get the menu slug.
86
+     *
87
+     * @return string The menu slug.
88
+     * @since 3.11.0
89
+     *
90
+     */
91
+    abstract function get_menu_slug();
92
+
93
+    /**
94
+     * Get the page url.
95
+     *
96
+     * @return string The escaped url of the admin page
97
+     * @since 3.14.0
98
+     *
99
+     */
100
+    function get_url() {
101
+
102
+        // ideally should have used menu_page_url, but it is loaded later than some usages.
103
+        $url = admin_url( 'admin.php?page=' . $this->get_menu_slug() );
104
+
105
+        return esc_url( $url );
106
+    }
107
+
108
+    /**
109
+     * Get the partial file name, used in the {@link render} function.
110
+     *
111
+     * @return string The partial file name.
112
+     * @since 3.11.0
113
+     *
114
+     */
115
+    abstract function get_partial_name();
116
+
117
+    /**
118
+     * The `admin_menu` callback. Will call {@link add_submenu_page} to add the
119
+     * page to the admin menu.
120
+     *
121
+     * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
122
+     * @since 3.11.0
123
+     *
124
+     */
125
+    public function admin_menu() {
126
+        // Add the sub-menu page.
127
+        //
128
+        // See http://codex.wordpress.org/Function_Reference/add_submenu_page
129
+        $page = add_submenu_page(
130
+            $this->get_parent_slug(),
131
+            $this->get_page_title(),
132
+            $this->get_menu_title(),
133
+            $this->get_capability(),                   // The required capability, provided by the calling hook.
134
+            $this->get_menu_slug(),
135
+            array( $this, 'render' )
136
+        );
137
+
138
+        // Set a hook to enqueue scripts only when the settings page is displayed.
139
+        add_action( 'admin_print_scripts-' . $page, array(
140
+            $this,
141
+            'enqueue_scripts',
142
+        ) );
143
+
144
+        // Finally return the page hook_suffix.
145
+        return $page;
146
+    }
147
+
148
+    /**
149
+     * Enqueue scripts for the specific page. Subclasses can override this function
150
+     * to provide their own styles/scripts.
151
+     *
152
+     * @since 3.11.0
153
+     */
154
+    public function enqueue_scripts() {
155
+    }
156
+
157
+    /**
158
+     * Render the page.
159
+     */
160
+    public function render() {
161
+
162
+        // Include the partial.
163
+        include( plugin_dir_path( __FILE__ ) . 'partials/' . $this->get_partial_name() );
164
+
165
+    }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 		 * @return bool
34 34
 		 * @since 3.27.6
35 35
 		 */
36
-		if ( apply_filters( 'wl_feature__enable__screens', true ) ) {
37
-			add_action( 'admin_menu', array( $this, 'admin_menu' ), 10, 0 );
36
+		if (apply_filters('wl_feature__enable__screens', true)) {
37
+			add_action('admin_menu', array($this, 'admin_menu'), 10, 0);
38 38
 		}
39 39
 
40 40
 	}
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 	function get_url() {
101 101
 
102 102
 		// ideally should have used menu_page_url, but it is loaded later than some usages.
103
-		$url = admin_url( 'admin.php?page=' . $this->get_menu_slug() );
103
+		$url = admin_url('admin.php?page='.$this->get_menu_slug());
104 104
 
105
-		return esc_url( $url );
105
+		return esc_url($url);
106 106
 	}
107 107
 
108 108
 	/**
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 			$this->get_parent_slug(),
131 131
 			$this->get_page_title(),
132 132
 			$this->get_menu_title(),
133
-			$this->get_capability(),                   // The required capability, provided by the calling hook.
133
+			$this->get_capability(), // The required capability, provided by the calling hook.
134 134
 			$this->get_menu_slug(),
135
-			array( $this, 'render' )
135
+			array($this, 'render')
136 136
 		);
137 137
 
138 138
 		// Set a hook to enqueue scripts only when the settings page is displayed.
139
-		add_action( 'admin_print_scripts-' . $page, array(
139
+		add_action('admin_print_scripts-'.$page, array(
140 140
 			$this,
141 141
 			'enqueue_scripts',
142
-		) );
142
+		));
143 143
 
144 144
 		// Finally return the page hook_suffix.
145 145
 		return $page;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	public function render() {
161 161
 
162 162
 		// Include the partial.
163
-		include( plugin_dir_path( __FILE__ ) . 'partials/' . $this->get_partial_name() );
163
+		include(plugin_dir_path(__FILE__).'partials/'.$this->get_partial_name());
164 164
 
165 165
 	}
166 166
 
Please login to merge, or discard this patch.
src/widgets/wordlift_widget_geo.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -7,57 +7,57 @@  discard block
 block discarded – undo
7 7
  * Class WordLift_Geo_Widget
8 8
  */
9 9
 class WordLift_Geo_Widget extends WP_Widget {
10
-	/**
11
-	 * Sets up the widgets name etc
12
-	 */
13
-	public function __construct() {
14
-		// Initialize the Widget.
15
-		parent::__construct(
16
-			'wl_geo_widget', // Base ID
17
-			__( 'Geo Widget', 'wordlift' ), // Name
18
-			array( 'description' => __( 'Geo Widget description', 'wordlift' ), ) // Args
19
-		);
20
-	}
10
+    /**
11
+     * Sets up the widgets name etc
12
+     */
13
+    public function __construct() {
14
+        // Initialize the Widget.
15
+        parent::__construct(
16
+            'wl_geo_widget', // Base ID
17
+            __( 'Geo Widget', 'wordlift' ), // Name
18
+            array( 'description' => __( 'Geo Widget description', 'wordlift' ), ) // Args
19
+        );
20
+    }
21 21
 
22
-	/**
23
-	 * Outputs the content of the widget
24
-	 *
25
-	 * @param array $args
26
-	 * @param array $instance
27
-	 */
28
-	public function widget( $args, $instance ) {
29
-		// Get the widget's title.
30
-		$title = apply_filters( 'widget_title', $instance['title'] );
22
+    /**
23
+     * Outputs the content of the widget
24
+     *
25
+     * @param array $args
26
+     * @param array $instance
27
+     */
28
+    public function widget( $args, $instance ) {
29
+        // Get the widget's title.
30
+        $title = apply_filters( 'widget_title', $instance['title'] );
31 31
 
32
-		// Print the HTML output.
33
-		echo $args['before_widget'];
34
-		if ( ! empty( $title ) ) {
35
-			echo $args['before_title'] . $title . $args['after_title'];
36
-		}
32
+        // Print the HTML output.
33
+        echo $args['before_widget'];
34
+        if ( ! empty( $title ) ) {
35
+            echo $args['before_title'] . $title . $args['after_title'];
36
+        }
37 37
 
38
-		// Print the geomap shortcode
39
-		// ( global = true - because it is not post-specific)
40
-		echo do_shortcode( '[wl_geomap global=true]' );
38
+        // Print the geomap shortcode
39
+        // ( global = true - because it is not post-specific)
40
+        echo do_shortcode( '[wl_geomap global=true]' );
41 41
 
42
-		echo $args['after_widget'];
43
-	}
42
+        echo $args['after_widget'];
43
+    }
44 44
 
45
-	/**
46
-	 * Ouputs the options form on admin
47
-	 *
48
-	 * @param array $instance The widget options
49
-	 */
50
-	public
51
-	function form(
52
-		$instance
53
-	) {
45
+    /**
46
+     * Ouputs the options form on admin
47
+     *
48
+     * @param array $instance The widget options
49
+     */
50
+    public
51
+    function form(
52
+        $instance
53
+    ) {
54 54
 
55
-		if ( isset( $instance['title'] ) ) {
56
-			$title = $instance['title'];
57
-		} else {
58
-			$title = __( 'New title', 'wordlift' );
59
-		}
60
-		?>
55
+        if ( isset( $instance['title'] ) ) {
56
+            $title = $instance['title'];
57
+        } else {
58
+            $title = __( 'New title', 'wordlift' );
59
+        }
60
+        ?>
61 61
         <p>
62 62
             <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:' ); ?></label>
63 63
             <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>"
@@ -66,26 +66,26 @@  discard block
 block discarded – undo
66 66
         </p>
67 67
 		<?php
68 68
 
69
-	}
69
+    }
70 70
 
71
-	/**
72
-	 * Processing widget options on save
73
-	 *
74
-	 * @param array $new_instance The new options
75
-	 * @param array $old_instance The previous options
76
-	 */
77
-	public
78
-	function update(
79
-		$new_instance, $old_instance
80
-	) {
71
+    /**
72
+     * Processing widget options on save
73
+     *
74
+     * @param array $new_instance The new options
75
+     * @param array $old_instance The previous options
76
+     */
77
+    public
78
+    function update(
79
+        $new_instance, $old_instance
80
+    ) {
81 81
 
82
-		$instance          = array();
83
-		$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
82
+        $instance          = array();
83
+        $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
84 84
 
85
-		return $instance;
86
-	}
85
+        return $instance;
86
+    }
87 87
 }
88 88
 
89 89
 function wl_register_geo_widget() {
90
-	register_widget( 'WordLift_Geo_Widget' );
90
+    register_widget( 'WordLift_Geo_Widget' );
91 91
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 		// Initialize the Widget.
15 15
 		parent::__construct(
16 16
 			'wl_geo_widget', // Base ID
17
-			__( 'Geo Widget', 'wordlift' ), // Name
18
-			array( 'description' => __( 'Geo Widget description', 'wordlift' ), ) // Args
17
+			__('Geo Widget', 'wordlift'), // Name
18
+			array('description' => __('Geo Widget description', 'wordlift'),) // Args
19 19
 		);
20 20
 	}
21 21
 
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
 	 * @param array $args
26 26
 	 * @param array $instance
27 27
 	 */
28
-	public function widget( $args, $instance ) {
28
+	public function widget($args, $instance) {
29 29
 		// Get the widget's title.
30
-		$title = apply_filters( 'widget_title', $instance['title'] );
30
+		$title = apply_filters('widget_title', $instance['title']);
31 31
 
32 32
 		// Print the HTML output.
33 33
 		echo $args['before_widget'];
34
-		if ( ! empty( $title ) ) {
35
-			echo $args['before_title'] . $title . $args['after_title'];
34
+		if ( ! empty($title)) {
35
+			echo $args['before_title'].$title.$args['after_title'];
36 36
 		}
37 37
 
38 38
 		// Print the geomap shortcode
39 39
 		// ( global = true - because it is not post-specific)
40
-		echo do_shortcode( '[wl_geomap global=true]' );
40
+		echo do_shortcode('[wl_geomap global=true]');
41 41
 
42 42
 		echo $args['after_widget'];
43 43
 	}
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
 		$instance
53 53
 	) {
54 54
 
55
-		if ( isset( $instance['title'] ) ) {
55
+		if (isset($instance['title'])) {
56 56
 			$title = $instance['title'];
57 57
 		} else {
58
-			$title = __( 'New title', 'wordlift' );
58
+			$title = __('New title', 'wordlift');
59 59
 		}
60 60
 		?>
61 61
         <p>
62
-            <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:' ); ?></label>
63
-            <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>"
64
-                   name="<?php echo $this->get_field_name( 'title' ); ?>" type="text"
65
-                   value="<?php echo esc_attr( $title ); ?>">
62
+            <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:'); ?></label>
63
+            <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
64
+                   name="<?php echo $this->get_field_name('title'); ?>" type="text"
65
+                   value="<?php echo esc_attr($title); ?>">
66 66
         </p>
67 67
 		<?php
68 68
 
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	) {
81 81
 
82 82
 		$instance          = array();
83
-		$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
83
+		$instance['title'] = ( ! empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';
84 84
 
85 85
 		return $instance;
86 86
 	}
87 87
 }
88 88
 
89 89
 function wl_register_geo_widget() {
90
-	register_widget( 'WordLift_Geo_Widget' );
90
+	register_widget('WordLift_Geo_Widget');
91 91
 }
Please login to merge, or discard this patch.
src/widgets/wordlift_widget_timeline.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -2,50 +2,50 @@
 block discarded – undo
2 2
 
3 3
 class Wordlift_Timeline_Widget extends WP_Widget {
4 4
 
5
-	/**
6
-	 * Sets up the widgets name etc
7
-	 */
8
-	public function __construct() {
9
-		// widget actual processes
10
-		parent::__construct(
11
-			'wl_timeline_widget', // Base ID
12
-			__( 'WordLift Timeline Widget', 'wordlift' ), // Name
13
-			array( 'description' => __( 'Displays entities of type event using an interactive timeline.', 'wordlift' ), ) // Args
14
-		);
15
-	}
5
+    /**
6
+     * Sets up the widgets name etc
7
+     */
8
+    public function __construct() {
9
+        // widget actual processes
10
+        parent::__construct(
11
+            'wl_timeline_widget', // Base ID
12
+            __( 'WordLift Timeline Widget', 'wordlift' ), // Name
13
+            array( 'description' => __( 'Displays entities of type event using an interactive timeline.', 'wordlift' ), ) // Args
14
+        );
15
+    }
16 16
 
17
-	/**
18
-	 * Outputs the content of the widget
19
-	 *
20
-	 * @param array $args
21
-	 * @param array $instance
22
-	 */
23
-	public function widget( $args, $instance ) {
24
-		// outputs the content of the widget	
25
-		echo do_shortcode( '[wl_timeline global=true]' );
26
-	}
17
+    /**
18
+     * Outputs the content of the widget
19
+     *
20
+     * @param array $args
21
+     * @param array $instance
22
+     */
23
+    public function widget( $args, $instance ) {
24
+        // outputs the content of the widget	
25
+        echo do_shortcode( '[wl_timeline global=true]' );
26
+    }
27 27
 
28
-	/**
29
-	 * Outputs the options form on admin
30
-	 *
31
-	 * @param array $instance The widget options
32
-	 */
33
-	public function form( $instance ) {
34
-		// outputs the options form on admin
35
-	}
28
+    /**
29
+     * Outputs the options form on admin
30
+     *
31
+     * @param array $instance The widget options
32
+     */
33
+    public function form( $instance ) {
34
+        // outputs the options form on admin
35
+    }
36 36
 
37
-	/**
38
-	 * Processing widget options on save
39
-	 *
40
-	 * @param array $new_instance The new options
41
-	 * @param array $old_instance The previous options
42
-	 */
43
-	public function update( $new_instance, $old_instance ) {
44
-		// processes widget options to be saved
45
-	}
37
+    /**
38
+     * Processing widget options on save
39
+     *
40
+     * @param array $new_instance The new options
41
+     * @param array $old_instance The previous options
42
+     */
43
+    public function update( $new_instance, $old_instance ) {
44
+        // processes widget options to be saved
45
+    }
46 46
 }
47 47
 
48 48
 function wl_register_timeline_widget() {
49 49
 
50
-	register_widget( 'WordLift_Timeline_Widget' );
50
+    register_widget( 'WordLift_Timeline_Widget' );
51 51
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 		// widget actual processes
10 10
 		parent::__construct(
11 11
 			'wl_timeline_widget', // Base ID
12
-			__( 'WordLift Timeline Widget', 'wordlift' ), // Name
13
-			array( 'description' => __( 'Displays entities of type event using an interactive timeline.', 'wordlift' ), ) // Args
12
+			__('WordLift Timeline Widget', 'wordlift'), // Name
13
+			array('description' => __('Displays entities of type event using an interactive timeline.', 'wordlift'),) // Args
14 14
 		);
15 15
 	}
16 16
 
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
 	 * @param array $args
21 21
 	 * @param array $instance
22 22
 	 */
23
-	public function widget( $args, $instance ) {
23
+	public function widget($args, $instance) {
24 24
 		// outputs the content of the widget	
25
-		echo do_shortcode( '[wl_timeline global=true]' );
25
+		echo do_shortcode('[wl_timeline global=true]');
26 26
 	}
27 27
 
28 28
 	/**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param array $instance The widget options
32 32
 	 */
33
-	public function form( $instance ) {
33
+	public function form($instance) {
34 34
 		// outputs the options form on admin
35 35
 	}
36 36
 
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 	 * @param array $new_instance The new options
41 41
 	 * @param array $old_instance The previous options
42 42
 	 */
43
-	public function update( $new_instance, $old_instance ) {
43
+	public function update($new_instance, $old_instance) {
44 44
 		// processes widget options to be saved
45 45
 	}
46 46
 }
47 47
 
48 48
 function wl_register_timeline_widget() {
49 49
 
50
-	register_widget( 'WordLift_Timeline_Widget' );
50
+	register_widget('WordLift_Timeline_Widget');
51 51
 }
Please login to merge, or discard this patch.
src/widgets/class-wordlift-chord-widget.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -10,54 +10,54 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class Wordlift_Chord_Widget extends WP_Widget {
12 12
 
13
-	/**
14
-	 * Sets up the widgets name etc
15
-	 */
16
-	public function __construct() {
17
-		// widget actual processes.
18
-		parent::__construct(
19
-			'wl_chord_widget', // Base ID.
20
-			__( 'Chord Widget', 'wordlift' ), // Name.
21
-			array(
22
-				'description' => __( 'The Chord Widget depicts the main topics of your blog in concise graph.', 'wordlift' ),
23
-			) // Args.
24
-		);
25
-	}
13
+    /**
14
+     * Sets up the widgets name etc
15
+     */
16
+    public function __construct() {
17
+        // widget actual processes.
18
+        parent::__construct(
19
+            'wl_chord_widget', // Base ID.
20
+            __( 'Chord Widget', 'wordlift' ), // Name.
21
+            array(
22
+                'description' => __( 'The Chord Widget depicts the main topics of your blog in concise graph.', 'wordlift' ),
23
+            ) // Args.
24
+        );
25
+    }
26 26
 
27
-	/**
28
-	 * Outputs the content of the widget
29
-	 *
30
-	 * @param array $args widget args.
31
-	 * @param array $instance widget instance.
32
-	 */
33
-	// @codingStandardsIgnoreLine Generic.CodeAnalysis.UnusedFunctionParameter.Found
34
-	public function widget( $args, $instance ) {
35
-		// outputs the content of the widget.
36
-		echo do_shortcode( '[wl_chord global=true]' );
37
-	}
27
+    /**
28
+     * Outputs the content of the widget
29
+     *
30
+     * @param array $args widget args.
31
+     * @param array $instance widget instance.
32
+     */
33
+    // @codingStandardsIgnoreLine Generic.CodeAnalysis.UnusedFunctionParameter.Found
34
+    public function widget( $args, $instance ) {
35
+        // outputs the content of the widget.
36
+        echo do_shortcode( '[wl_chord global=true]' );
37
+    }
38 38
 
39
-	/**
40
-	 * Outputs the options form on admin
41
-	 *
42
-	 * @param array $instance The widget options.
43
-	 *
44
-	 * @return string|void
45
-	 */
46
-	public function form( $instance ) {
47
-		// outputs the options form on admin.
48
-	}
39
+    /**
40
+     * Outputs the options form on admin
41
+     *
42
+     * @param array $instance The widget options.
43
+     *
44
+     * @return string|void
45
+     */
46
+    public function form( $instance ) {
47
+        // outputs the options form on admin.
48
+    }
49 49
 
50
-	/**
51
-	 * Processing widget options on save
52
-	 *
53
-	 * @param array $new_instance The new options.
54
-	 * @param array $old_instance The previous options.
55
-	 *
56
-	 * @return array|void
57
-	 */
58
-	public function update( $new_instance, $old_instance ) {
59
-		// processes widget options to be saved.
60
-	}
50
+    /**
51
+     * Processing widget options on save
52
+     *
53
+     * @param array $new_instance The new options.
54
+     * @param array $old_instance The previous options.
55
+     *
56
+     * @return array|void
57
+     */
58
+    public function update( $new_instance, $old_instance ) {
59
+        // processes widget options to be saved.
60
+    }
61 61
 }
62 62
 
63 63
 /**
@@ -67,5 +67,5 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function wl_register_chord_widget() {
69 69
 
70
-	register_widget( 'WordLift_Chord_Widget' );
70
+    register_widget( 'WordLift_Chord_Widget' );
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 		// widget actual processes.
18 18
 		parent::__construct(
19 19
 			'wl_chord_widget', // Base ID.
20
-			__( 'Chord Widget', 'wordlift' ), // Name.
20
+			__('Chord Widget', 'wordlift'), // Name.
21 21
 			array(
22
-				'description' => __( 'The Chord Widget depicts the main topics of your blog in concise graph.', 'wordlift' ),
22
+				'description' => __('The Chord Widget depicts the main topics of your blog in concise graph.', 'wordlift'),
23 23
 			) // Args.
24 24
 		);
25 25
 	}
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 	 * @param array $instance widget instance.
32 32
 	 */
33 33
 	// @codingStandardsIgnoreLine Generic.CodeAnalysis.UnusedFunctionParameter.Found
34
-	public function widget( $args, $instance ) {
34
+	public function widget($args, $instance) {
35 35
 		// outputs the content of the widget.
36
-		echo do_shortcode( '[wl_chord global=true]' );
36
+		echo do_shortcode('[wl_chord global=true]');
37 37
 	}
38 38
 
39 39
 	/**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 * @return string|void
45 45
 	 */
46
-	public function form( $instance ) {
46
+	public function form($instance) {
47 47
 		// outputs the options form on admin.
48 48
 	}
49 49
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return array|void
57 57
 	 */
58
-	public function update( $new_instance, $old_instance ) {
58
+	public function update($new_instance, $old_instance) {
59 59
 		// processes widget options to be saved.
60 60
 	}
61 61
 }
@@ -67,5 +67,5 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function wl_register_chord_widget() {
69 69
 
70
-	register_widget( 'WordLift_Chord_Widget' );
70
+	register_widget('WordLift_Chord_Widget');
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift.php 2 patches
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 // If this file is called directly, abort.
49 49
 if ( ! defined( 'WPINC' ) ) {
50
-	die;
50
+    die;
51 51
 }
52 52
 
53 53
 // Include WordLift constants.
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  */
69 69
 function wl_write_log( $log ) {
70 70
 
71
-	Wordlift_Log_Service::get_instance()->debug( $log );
71
+    Wordlift_Log_Service::get_instance()->debug( $log );
72 72
 
73 73
 }
74 74
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function wl_write_log_hide_key( $text ) {
87 87
 
88
-	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
88
+    return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
89 89
 }
90 90
 
91 91
 /**
@@ -93,21 +93,21 @@  discard block
 block discarded – undo
93 93
  * see http://vip.wordpress.com/documentation/register-additional-html-attributes-for-tinymce-and-wp-kses/
94 94
  */
95 95
 function wordlift_allowed_post_tags() {
96
-	global $allowedposttags;
97
-
98
-	$tags           = array( 'span' );
99
-	$new_attributes = array(
100
-		'itemscope' => array(),
101
-		'itemtype'  => array(),
102
-		'itemprop'  => array(),
103
-		'itemid'    => array(),
104
-	);
105
-
106
-	foreach ( $tags as $tag ) {
107
-		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
108
-			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
109
-		}
110
-	}
96
+    global $allowedposttags;
97
+
98
+    $tags           = array( 'span' );
99
+    $new_attributes = array(
100
+        'itemscope' => array(),
101
+        'itemtype'  => array(),
102
+        'itemprop'  => array(),
103
+        'itemid'    => array(),
104
+    );
105
+
106
+    foreach ( $tags as $tag ) {
107
+        if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
108
+            $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
109
+        }
110
+    }
111 111
 }
112 112
 
113 113
 // add allowed post tags.
@@ -118,18 +118,18 @@  discard block
 block discarded – undo
118 118
  */
119 119
 function wordlift_admin_enqueue_scripts() {
120 120
 
121
-	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
122
-	wp_enqueue_script( 'wpdialogs' );
123
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
121
+    // Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
122
+    wp_enqueue_script( 'wpdialogs' );
123
+    wp_enqueue_style( 'wp-jquery-ui-dialog' );
124 124
 
125
-	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
125
+    wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
126 126
 
127
-	wp_enqueue_script( 'jquery-ui-autocomplete' );
127
+    wp_enqueue_script( 'jquery-ui-autocomplete' );
128 128
 
129
-	// Disable auto-save for custom entity posts only
130
-	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
131
-		wp_dequeue_script( 'autosave' );
132
-	}
129
+    // Disable auto-save for custom entity posts only
130
+    if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
131
+        wp_dequeue_script( 'autosave' );
132
+    }
133 133
 
134 134
 }
135 135
 
@@ -145,18 +145,18 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function wordlift_allowed_html( $allowedtags, $context ) {
147 147
 
148
-	if ( 'post' !== $context ) {
149
-		return $allowedtags;
150
-	}
151
-
152
-	return array_merge_recursive( $allowedtags, array(
153
-		'span' => array(
154
-			'itemscope' => true,
155
-			'itemtype'  => true,
156
-			'itemid'    => true,
157
-			'itemprop'  => true,
158
-		),
159
-	) );
148
+    if ( 'post' !== $context ) {
149
+        return $allowedtags;
150
+    }
151
+
152
+    return array_merge_recursive( $allowedtags, array(
153
+        'span' => array(
154
+            'itemscope' => true,
155
+            'itemtype'  => true,
156
+            'itemid'    => true,
157
+            'itemprop'  => true,
158
+        ),
159
+    ) );
160 160
 }
161 161
 
162 162
 add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function wl_get_coordinates( $post_id ) {
172 172
 
173
-	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
174
-	$longitude = wl_schema_get_value( $post_id, 'longitude' );
173
+    $latitude  = wl_schema_get_value( $post_id, 'latitude' );
174
+    $longitude = wl_schema_get_value( $post_id, 'longitude' );
175 175
 
176
-	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific
177
-	// place on the globe:"The zero/zero point of this system is located in the
178
-	// Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
179
-	return array(
180
-		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
181
-		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
182
-	);
176
+    // DO NOT set latitude/longitude to 0/0 as default values. It's a specific
177
+    // place on the globe:"The zero/zero point of this system is located in the
178
+    // Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
179
+    return array(
180
+        'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
181
+        'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
182
+    );
183 183
 }
184 184
 
185 185
 /**
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
  */
194 194
 function wl_get_image_urls( $post_id ) {
195 195
 
196
-	return Wordlift_Storage_Factory::get_instance()
197
-	                               ->post_images()
198
-	                               ->get( $post_id );
196
+    return Wordlift_Storage_Factory::get_instance()
197
+                                    ->post_images()
198
+                                    ->get( $post_id );
199 199
 
200 200
 }
201 201
 
@@ -209,24 +209,24 @@  discard block
 block discarded – undo
209 209
  */
210 210
 function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
211 211
 
212
-	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
212
+    // wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
213 213
 
214
-	$posts = get_posts( array(
215
-		'post_type'      => 'attachment',
216
-		'posts_per_page' => 1,
217
-		'post_status'    => 'any',
218
-		'post_parent'    => $parent_post_id,
219
-		'meta_key'       => 'wl_source_url',
220
-		'meta_value'     => $source_url,
221
-	) );
214
+    $posts = get_posts( array(
215
+        'post_type'      => 'attachment',
216
+        'posts_per_page' => 1,
217
+        'post_status'    => 'any',
218
+        'post_parent'    => $parent_post_id,
219
+        'meta_key'       => 'wl_source_url',
220
+        'meta_value'     => $source_url,
221
+    ) );
222 222
 
223
-	// Return the found post.
224
-	if ( 1 === count( $posts ) ) {
225
-		return $posts[0];
226
-	}
223
+    // Return the found post.
224
+    if ( 1 === count( $posts ) ) {
225
+        return $posts[0];
226
+    }
227 227
 
228
-	// Return null.
229
-	return null;
228
+    // Return null.
229
+    return null;
230 230
 }
231 231
 
232 232
 /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
  */
238 238
 function wl_set_source_url( $post_id, $source_url ) {
239 239
 
240
-	delete_post_meta( $post_id, 'wl_source_url' );
241
-	add_post_meta( $post_id, 'wl_source_url', $source_url );
240
+    delete_post_meta( $post_id, 'wl_source_url' );
241
+    add_post_meta( $post_id, 'wl_source_url', $source_url );
242 242
 }
243 243
 
244 244
 /**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
  */
256 256
 function wl_sanitize_uri_path( $path, $char = '_' ) {
257 257
 
258
-	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
258
+    return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
259 259
 }
260 260
 
261 261
 /**
@@ -267,47 +267,47 @@  discard block
 block discarded – undo
267 267
  */
268 268
 function wl_replace_item_id_with_uri( $content ) {
269 269
 
270
-	$log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' );
271
-	$log->trace( 'Replacing item IDs with URIs...' );
270
+    $log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' );
271
+    $log->trace( 'Replacing item IDs with URIs...' );
272 272
 
273
-	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
274
-	$content = stripslashes( $content );
273
+    // Strip slashes, see https://core.trac.wordpress.org/ticket/21767
274
+    $content = stripslashes( $content );
275 275
 
276
-	// If any match are found.
277
-	$matches = array();
278
-	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
276
+    // If any match are found.
277
+    $matches = array();
278
+    if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
279 279
 
280
-		foreach ( $matches as $match ) {
280
+        foreach ( $matches as $match ) {
281 281
 
282
-			// Get the item ID.
283
-			$item_id = $match[1];
282
+            // Get the item ID.
283
+            $item_id = $match[1];
284 284
 
285
-			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
286
-			$post = Wordlift_Entity_Service::get_instance()
287
-			                               ->get_entity_post_by_uri( $item_id );
285
+            // Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
286
+            $post = Wordlift_Entity_Service::get_instance()
287
+                                            ->get_entity_post_by_uri( $item_id );
288 288
 
289
-			// If no entity is found, continue to the next one.
290
-			if ( null === $post ) {
291
-				continue;
292
-			}
289
+            // If no entity is found, continue to the next one.
290
+            if ( null === $post ) {
291
+                continue;
292
+            }
293 293
 
294
-			// Get the URI for that post.
295
-			$uri = wl_get_entity_uri( $post->ID );
294
+            // Get the URI for that post.
295
+            $uri = wl_get_entity_uri( $post->ID );
296 296
 
297
-			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
297
+            // wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
298 298
 
299
-			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
300
-			if ( $item_id !== $uri ) {
301
-				$uri_e   = esc_html( $uri );
302
-				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
303
-			}
304
-		}
305
-	}
299
+            // If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
300
+            if ( $item_id !== $uri ) {
301
+                $uri_e   = esc_html( $uri );
302
+                $content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
303
+            }
304
+        }
305
+    }
306 306
 
307
-	// Reapply slashes.
308
-	$content = addslashes( $content );
307
+    // Reapply slashes.
308
+    $content = addslashes( $content );
309 309
 
310
-	return $content;
310
+    return $content;
311 311
 }
312 312
 
313 313
 add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
@@ -370,24 +370,24 @@  discard block
 block discarded – undo
370 370
  */
371 371
 function activate_wordlift() {
372 372
 
373
-	$log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
373
+    $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
374 374
 
375
-	$log->info( 'Activating WordLift...' );
375
+    $log->info( 'Activating WordLift...' );
376 376
 
377
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
378
-	Wordlift_Activator::activate();
377
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
378
+    Wordlift_Activator::activate();
379 379
 
380
-	/**
381
-	 * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks.
382
-	 *
383
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue.
384
-	 * @since 3.19.2
385
-	 */
386
-	Wordlift_Http_Api::activate();
380
+    /**
381
+     * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks.
382
+     *
383
+     * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue.
384
+     * @since 3.19.2
385
+     */
386
+    Wordlift_Http_Api::activate();
387 387
 
388
-	// Ensure the post type is registered before flushing the rewrite rules.
389
-	Wordlift_Entity_Post_Type_Service::get_instance()->register();
390
-	flush_rewrite_rules();
388
+    // Ensure the post type is registered before flushing the rewrite rules.
389
+    Wordlift_Entity_Post_Type_Service::get_instance()->register();
390
+    flush_rewrite_rules();
391 391
 }
392 392
 
393 393
 /**
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function deactivate_wordlift() {
398 398
 
399
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
400
-	Wordlift_Deactivator::deactivate();
401
-	Wordlift_Http_Api::deactivate();
402
-	Ttl_Cache_Cleaner::deactivate();
403
-	flush_rewrite_rules();
399
+    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
400
+    Wordlift_Deactivator::deactivate();
401
+    Wordlift_Http_Api::deactivate();
402
+    Ttl_Cache_Cleaner::deactivate();
403
+    flush_rewrite_rules();
404 404
 
405 405
 }
406 406
 
@@ -423,70 +423,70 @@  discard block
 block discarded – undo
423 423
  * @since    1.0.0
424 424
  */
425 425
 function run_wordlift() {
426
-	/**
427
-	 * Filter: wl_feature__enable__widgets.
428
-	 *
429
-	 * @param bool whether the widgets needed to be registered, defaults to true.
430
-	 *
431
-	 * @return bool
432
-	 * @since 3.27.6
433
-	 */
434
-	if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
435
-		add_action( 'widgets_init', 'wl_register_chord_widget' );
436
-		add_filter( 'widget_text', 'do_shortcode' );
437
-		add_action( 'widgets_init', 'wl_register_geo_widget' );
438
-		add_action( 'widgets_init', 'wl_register_timeline_widget' );
439
-		add_filter( 'widget_text', 'do_shortcode' );
440
-	}
441
-	/*
426
+    /**
427
+     * Filter: wl_feature__enable__widgets.
428
+     *
429
+     * @param bool whether the widgets needed to be registered, defaults to true.
430
+     *
431
+     * @return bool
432
+     * @since 3.27.6
433
+     */
434
+    if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
435
+        add_action( 'widgets_init', 'wl_register_chord_widget' );
436
+        add_filter( 'widget_text', 'do_shortcode' );
437
+        add_action( 'widgets_init', 'wl_register_geo_widget' );
438
+        add_action( 'widgets_init', 'wl_register_timeline_widget' );
439
+        add_filter( 'widget_text', 'do_shortcode' );
440
+    }
441
+    /*
442 442
 	 * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http.
443 443
 	 *
444 444
 	 * @since 3.21.2
445 445
 	 */
446
-	wordlift_plugin_autoload_register();
446
+    wordlift_plugin_autoload_register();
447 447
 
448
-	$plugin = new Wordlift();
449
-	$plugin->run();
448
+    $plugin = new Wordlift();
449
+    $plugin->run();
450 450
 
451
-	// Initialize the TTL Cache Cleaner.
452
-	new Ttl_Cache_Cleaner();
451
+    // Initialize the TTL Cache Cleaner.
452
+    new Ttl_Cache_Cleaner();
453 453
 
454
-	// Load the new Post Adapter.
455
-	new Post_Adapter();
454
+    // Load the new Post Adapter.
455
+    new Post_Adapter();
456 456
 
457
-	// Licenses Images.
458
-	$user_agent                   = User_Agent::get_user_agent();
459
-	$wordlift_key                 = Wordlift_Configuration_Service::get_instance()->get_key();
460
-	$api_service                  = new Default_Api_Service( 'https://api.wordlift.io', 60, $user_agent, $wordlift_key );
461
-	$image_license_factory        = new Image_License_Factory();
462
-	$image_license_service        = new Image_License_Service( $api_service, $image_license_factory );
463
-	$image_license_cache          = new Ttl_Cache( 'image-license', 86400 * 30 ); // 30 days.
464
-	$cached_image_license_service = new Cached_Image_License_Service( $image_license_service, $image_license_cache );
457
+    // Licenses Images.
458
+    $user_agent                   = User_Agent::get_user_agent();
459
+    $wordlift_key                 = Wordlift_Configuration_Service::get_instance()->get_key();
460
+    $api_service                  = new Default_Api_Service( 'https://api.wordlift.io', 60, $user_agent, $wordlift_key );
461
+    $image_license_factory        = new Image_License_Factory();
462
+    $image_license_service        = new Image_License_Service( $api_service, $image_license_factory );
463
+    $image_license_cache          = new Ttl_Cache( 'image-license', 86400 * 30 ); // 30 days.
464
+    $cached_image_license_service = new Cached_Image_License_Service( $image_license_service, $image_license_cache );
465 465
 
466
-	$image_license_scheduler       = new Image_License_Scheduler( $image_license_service, $image_license_cache );
467
-	$image_license_cleanup_service = new Image_License_Cleanup_Service();
466
+    $image_license_scheduler       = new Image_License_Scheduler( $image_license_service, $image_license_cache );
467
+    $image_license_cleanup_service = new Image_License_Cleanup_Service();
468 468
 
469
-	// Get the cached data. If we have cached data, we load the notifier.
470
-	$image_license_data = $image_license_cache->get( Cached_Image_License_Service::GET_NON_PUBLIC_DOMAIN_IMAGES );
471
-	if ( null !== $image_license_data ) {
472
-		$image_license_page = new Image_License_Page( $image_license_data, Wordlift::get_instance()->get_version() );
473
-		new Image_License_Notifier( $image_license_data, $image_license_page );
474
-	}
469
+    // Get the cached data. If we have cached data, we load the notifier.
470
+    $image_license_data = $image_license_cache->get( Cached_Image_License_Service::GET_NON_PUBLIC_DOMAIN_IMAGES );
471
+    if ( null !== $image_license_data ) {
472
+        $image_license_page = new Image_License_Page( $image_license_data, Wordlift::get_instance()->get_version() );
473
+        new Image_License_Notifier( $image_license_data, $image_license_page );
474
+    }
475 475
 
476
-	$remove_all_images_task         = new Remove_All_Images_Task( $cached_image_license_service );
477
-	$remove_all_images_task_adapter = new Task_Ajax_Adapter( $remove_all_images_task );
476
+    $remove_all_images_task         = new Remove_All_Images_Task( $cached_image_license_service );
477
+    $remove_all_images_task_adapter = new Task_Ajax_Adapter( $remove_all_images_task );
478 478
 
479
-	$reload_data_task         = new Reload_Data_Task();
480
-	$reload_data_task_adapter = new Task_Ajax_Adapter( $reload_data_task );
479
+    $reload_data_task         = new Reload_Data_Task();
480
+    $reload_data_task_adapter = new Task_Ajax_Adapter( $reload_data_task );
481 481
 
482
-	$add_license_caption_or_remove_task         = new Add_License_Caption_Or_Remove_Task( $cached_image_license_service );
483
-	$add_license_caption_or_remove_task_adapter = new Task_Ajax_Adapter( $add_license_caption_or_remove_task );
482
+    $add_license_caption_or_remove_task         = new Add_License_Caption_Or_Remove_Task( $cached_image_license_service );
483
+    $add_license_caption_or_remove_task_adapter = new Task_Ajax_Adapter( $add_license_caption_or_remove_task );
484 484
 
485
-	$remove_all_images_task_page             = new Remove_All_Images_Page( new Task_Ajax_Adapters_Registry( $remove_all_images_task_adapter ), $plugin->get_version() );
486
-	$reload_data_task_page                   = new Reload_Data_Page( new Task_Ajax_Adapters_Registry( $reload_data_task_adapter ), $plugin->get_version() );
487
-	$add_license_caption_or_remove_task_page = new Add_License_Caption_Or_Remove_Page( new Task_Ajax_Adapters_Registry( $add_license_caption_or_remove_task_adapter ), $plugin->get_version() );
485
+    $remove_all_images_task_page             = new Remove_All_Images_Page( new Task_Ajax_Adapters_Registry( $remove_all_images_task_adapter ), $plugin->get_version() );
486
+    $reload_data_task_page                   = new Reload_Data_Page( new Task_Ajax_Adapters_Registry( $reload_data_task_adapter ), $plugin->get_version() );
487
+    $add_license_caption_or_remove_task_page = new Add_License_Caption_Or_Remove_Page( new Task_Ajax_Adapters_Registry( $add_license_caption_or_remove_task_adapter ), $plugin->get_version() );
488 488
 
489
-	new Wordlift_Products_Navigator_Shortcode_REST();
489
+    new Wordlift_Products_Navigator_Shortcode_REST();
490 490
 
491 491
 }
492 492
 
@@ -500,45 +500,45 @@  discard block
 block discarded – undo
500 500
  */
501 501
 function wordlift_plugin_autoload_register() {
502 502
 
503
-	spl_autoload_register( function ( $class_name ) {
503
+    spl_autoload_register( function ( $class_name ) {
504 504
 
505
-		// Bail out if these are not our classes.
506
-		if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
507
-			return false;
508
-		}
505
+        // Bail out if these are not our classes.
506
+        if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
507
+            return false;
508
+        }
509 509
 
510
-		$class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
510
+        $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
511 511
 
512
-		preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
512
+        preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
513 513
 
514
-		$path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
515
-		$file = 'class-' . $matches[2] . '.php';
514
+        $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
515
+        $file = 'class-' . $matches[2] . '.php';
516 516
 
517
-		$full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file;
517
+        $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file;
518 518
 
519
-		if ( ! file_exists( $full_path ) ) {
520
-			echo( "Class $class_name not found at $full_path." );
519
+        if ( ! file_exists( $full_path ) ) {
520
+            echo( "Class $class_name not found at $full_path." );
521 521
 
522
-			return false;
523
-		}
522
+            return false;
523
+        }
524 524
 
525
-		require_once $full_path;
525
+        require_once $full_path;
526 526
 
527
-		return true;
528
-	} );
527
+        return true;
528
+    } );
529 529
 
530 530
 }
531 531
 
532 532
 function wl_block_categories( $categories, $post ) {
533
-	return array_merge(
534
-		$categories,
535
-		array(
536
-			array(
537
-				'slug'  => 'wordlift',
538
-				'title' => __( 'WordLift', 'wordlift' ),
539
-			),
540
-		)
541
-	);
533
+    return array_merge(
534
+        $categories,
535
+        array(
536
+            array(
537
+                'slug'  => 'wordlift',
538
+                'title' => __( 'WordLift', 'wordlift' ),
539
+            ),
540
+        )
541
+    );
542 542
 }
543 543
 
544 544
 add_filter( 'block_categories', 'wl_block_categories', 10, 2 );
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 use Wordlift\Tasks\Task_Ajax_Adapters_Registry;
47 47
 
48 48
 // If this file is called directly, abort.
49
-if ( ! defined( 'WPINC' ) ) {
49
+if ( ! defined('WPINC')) {
50 50
 	die;
51 51
 }
52 52
 
53 53
 // Include WordLift constants.
54
-require_once( 'wordlift_constants.php' );
54
+require_once('wordlift_constants.php');
55 55
 
56 56
 // Load modules.
57
-require_once( 'modules/core/wordlift_core.php' );
57
+require_once('modules/core/wordlift_core.php');
58 58
 
59 59
 /**
60 60
  * Log to the debug.log file.
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
  * @deprecated use Wordlift_Log_Service::get_instance()->info( $log );
67 67
  *
68 68
  */
69
-function wl_write_log( $log ) {
69
+function wl_write_log($log) {
70 70
 
71
-	Wordlift_Log_Service::get_instance()->debug( $log );
71
+	Wordlift_Log_Service::get_instance()->debug($log);
72 72
 
73 73
 }
74 74
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
  * @since 3.0.0
84 84
  *
85 85
  */
86
-function wl_write_log_hide_key( $text ) {
86
+function wl_write_log_hide_key($text) {
87 87
 
88
-	return str_ireplace( wl_configuration_get_key(), '<hidden>', $text );
88
+	return str_ireplace(wl_configuration_get_key(), '<hidden>', $text);
89 89
 }
90 90
 
91 91
 /**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 function wordlift_allowed_post_tags() {
96 96
 	global $allowedposttags;
97 97
 
98
-	$tags           = array( 'span' );
98
+	$tags           = array('span');
99 99
 	$new_attributes = array(
100 100
 		'itemscope' => array(),
101 101
 		'itemtype'  => array(),
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 		'itemid'    => array(),
104 104
 	);
105 105
 
106
-	foreach ( $tags as $tag ) {
107
-		if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) ) {
108
-			$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
106
+	foreach ($tags as $tag) {
107
+		if (isset($allowedposttags[$tag]) && is_array($allowedposttags[$tag])) {
108
+			$allowedposttags[$tag] = array_merge($allowedposttags[$tag], $new_attributes);
109 109
 		}
110 110
 	}
111 111
 }
112 112
 
113 113
 // add allowed post tags.
114
-add_action( 'init', 'wordlift_allowed_post_tags' );
114
+add_action('init', 'wordlift_allowed_post_tags');
115 115
 
116 116
 /**
117 117
  * Register additional scripts for the admin UI.
@@ -119,21 +119,21 @@  discard block
 block discarded – undo
119 119
 function wordlift_admin_enqueue_scripts() {
120 120
 
121 121
 	// Added for compatibility with WordPress 3.9 (see http://make.wordpress.org/core/2014/04/16/jquery-ui-and-wpdialogs-in-wordpress-3-9/)
122
-	wp_enqueue_script( 'wpdialogs' );
123
-	wp_enqueue_style( 'wp-jquery-ui-dialog' );
122
+	wp_enqueue_script('wpdialogs');
123
+	wp_enqueue_style('wp-jquery-ui-dialog');
124 124
 
125
-	wp_enqueue_style( 'wordlift-reloaded', plugin_dir_url( __FILE__ ) . 'css/wordlift-reloaded.min.css' );
125
+	wp_enqueue_style('wordlift-reloaded', plugin_dir_url(__FILE__).'css/wordlift-reloaded.min.css');
126 126
 
127
-	wp_enqueue_script( 'jquery-ui-autocomplete' );
127
+	wp_enqueue_script('jquery-ui-autocomplete');
128 128
 
129 129
 	// Disable auto-save for custom entity posts only
130
-	if ( Wordlift_Entity_Service::TYPE_NAME === get_post_type() ) {
131
-		wp_dequeue_script( 'autosave' );
130
+	if (Wordlift_Entity_Service::TYPE_NAME === get_post_type()) {
131
+		wp_dequeue_script('autosave');
132 132
 	}
133 133
 
134 134
 }
135 135
 
136
-add_action( 'admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts' );
136
+add_action('admin_enqueue_scripts', 'wordlift_admin_enqueue_scripts');
137 137
 
138 138
 /**
139 139
  * Hooked to *wp_kses_allowed_html* filter, adds microdata attributes.
@@ -143,23 +143,23 @@  discard block
 block discarded – undo
143 143
  *
144 144
  * @return array An array which contains allowed microdata attributes.
145 145
  */
146
-function wordlift_allowed_html( $allowedtags, $context ) {
146
+function wordlift_allowed_html($allowedtags, $context) {
147 147
 
148
-	if ( 'post' !== $context ) {
148
+	if ('post' !== $context) {
149 149
 		return $allowedtags;
150 150
 	}
151 151
 
152
-	return array_merge_recursive( $allowedtags, array(
152
+	return array_merge_recursive($allowedtags, array(
153 153
 		'span' => array(
154 154
 			'itemscope' => true,
155 155
 			'itemtype'  => true,
156 156
 			'itemid'    => true,
157 157
 			'itemprop'  => true,
158 158
 		),
159
-	) );
159
+	));
160 160
 }
161 161
 
162
-add_filter( 'wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2 );
162
+add_filter('wp_kses_allowed_html', 'wordlift_allowed_html', 10, 2);
163 163
 
164 164
 /**
165 165
  * Get the coordinates for the specified post ID.
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
  *
169 169
  * @return array|null An array of coordinates or null.
170 170
  */
171
-function wl_get_coordinates( $post_id ) {
171
+function wl_get_coordinates($post_id) {
172 172
 
173
-	$latitude  = wl_schema_get_value( $post_id, 'latitude' );
174
-	$longitude = wl_schema_get_value( $post_id, 'longitude' );
173
+	$latitude  = wl_schema_get_value($post_id, 'latitude');
174
+	$longitude = wl_schema_get_value($post_id, 'longitude');
175 175
 
176 176
 	// DO NOT set latitude/longitude to 0/0 as default values. It's a specific
177 177
 	// place on the globe:"The zero/zero point of this system is located in the
178 178
 	// Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
179 179
 	return array(
180
-		'latitude'  => isset( $latitude[0] ) && is_numeric( $latitude[0] ) ? $latitude[0] : '',
181
-		'longitude' => isset( $longitude[0] ) && is_numeric( $longitude[0] ) ? $longitude[0] : '',
180
+		'latitude'  => isset($latitude[0]) && is_numeric($latitude[0]) ? $latitude[0] : '',
181
+		'longitude' => isset($longitude[0]) && is_numeric($longitude[0]) ? $longitude[0] : '',
182 182
 	);
183 183
 }
184 184
 
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
  * @deprecated use Wordlift_Storage_Factory::get_instance()->post_images()->get( $post_id )
192 192
  *
193 193
  */
194
-function wl_get_image_urls( $post_id ) {
194
+function wl_get_image_urls($post_id) {
195 195
 
196 196
 	return Wordlift_Storage_Factory::get_instance()
197 197
 	                               ->post_images()
198
-	                               ->get( $post_id );
198
+	                               ->get($post_id);
199 199
 
200 200
 }
201 201
 
@@ -207,21 +207,21 @@  discard block
 block discarded – undo
207 207
  *
208 208
  * @return WP_Post|null A post instance or null if not found.
209 209
  */
210
-function wl_get_attachment_for_source_url( $parent_post_id, $source_url ) {
210
+function wl_get_attachment_for_source_url($parent_post_id, $source_url) {
211 211
 
212 212
 	// wl_write_log( "wl_get_attachment_for_source_url [ parent post id :: $parent_post_id ][ source url :: $source_url ]" );
213 213
 
214
-	$posts = get_posts( array(
214
+	$posts = get_posts(array(
215 215
 		'post_type'      => 'attachment',
216 216
 		'posts_per_page' => 1,
217 217
 		'post_status'    => 'any',
218 218
 		'post_parent'    => $parent_post_id,
219 219
 		'meta_key'       => 'wl_source_url',
220 220
 		'meta_value'     => $source_url,
221
-	) );
221
+	));
222 222
 
223 223
 	// Return the found post.
224
-	if ( 1 === count( $posts ) ) {
224
+	if (1 === count($posts)) {
225 225
 		return $posts[0];
226 226
 	}
227 227
 
@@ -235,10 +235,10 @@  discard block
 block discarded – undo
235 235
  * @param int $post_id The post ID.
236 236
  * @param string $source_url The source URL.
237 237
  */
238
-function wl_set_source_url( $post_id, $source_url ) {
238
+function wl_set_source_url($post_id, $source_url) {
239 239
 
240
-	delete_post_meta( $post_id, 'wl_source_url' );
241
-	add_post_meta( $post_id, 'wl_source_url', $source_url );
240
+	delete_post_meta($post_id, 'wl_source_url');
241
+	add_post_meta($post_id, 'wl_source_url', $source_url);
242 242
 }
243 243
 
244 244
 /**
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
  * @see        https://codex.wordpress.org/Function_Reference/sanitize_title
254 254
  *
255 255
  */
256
-function wl_sanitize_uri_path( $path, $char = '_' ) {
256
+function wl_sanitize_uri_path($path, $char = '_') {
257 257
 
258
-	return Wordlift_Uri_Service::get_instance()->sanitize_path( $path, $char );
258
+	return Wordlift_Uri_Service::get_instance()->sanitize_path($path, $char);
259 259
 }
260 260
 
261 261
 /**
@@ -265,104 +265,104 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return string The updated post content.
267 267
  */
268
-function wl_replace_item_id_with_uri( $content ) {
268
+function wl_replace_item_id_with_uri($content) {
269 269
 
270
-	$log = Wordlift_Log_Service::get_logger( 'wl_replace_item_id_with_uri' );
271
-	$log->trace( 'Replacing item IDs with URIs...' );
270
+	$log = Wordlift_Log_Service::get_logger('wl_replace_item_id_with_uri');
271
+	$log->trace('Replacing item IDs with URIs...');
272 272
 
273 273
 	// Strip slashes, see https://core.trac.wordpress.org/ticket/21767
274
-	$content = stripslashes( $content );
274
+	$content = stripslashes($content);
275 275
 
276 276
 	// If any match are found.
277 277
 	$matches = array();
278
-	if ( 0 < preg_match_all( '/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER ) ) {
278
+	if (0 < preg_match_all('/ itemid="([^"]+)"/i', $content, $matches, PREG_SET_ORDER)) {
279 279
 
280
-		foreach ( $matches as $match ) {
280
+		foreach ($matches as $match) {
281 281
 
282 282
 			// Get the item ID.
283 283
 			$item_id = $match[1];
284 284
 
285 285
 			// Get the post bound to that item ID (looking both in the 'official' URI and in the 'same-as' .
286 286
 			$post = Wordlift_Entity_Service::get_instance()
287
-			                               ->get_entity_post_by_uri( $item_id );
287
+			                               ->get_entity_post_by_uri($item_id);
288 288
 
289 289
 			// If no entity is found, continue to the next one.
290
-			if ( null === $post ) {
290
+			if (null === $post) {
291 291
 				continue;
292 292
 			}
293 293
 
294 294
 			// Get the URI for that post.
295
-			$uri = wl_get_entity_uri( $post->ID );
295
+			$uri = wl_get_entity_uri($post->ID);
296 296
 
297 297
 			// wl_write_log( "wl_replace_item_id_with_uri [ item id :: $item_id ][ uri :: $uri ]" );
298 298
 
299 299
 			// If the item ID and the URI differ, replace the item ID with the URI saved in WordPress.
300
-			if ( $item_id !== $uri ) {
301
-				$uri_e   = esc_html( $uri );
302
-				$content = str_replace( " itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content );
300
+			if ($item_id !== $uri) {
301
+				$uri_e   = esc_html($uri);
302
+				$content = str_replace(" itemid=\"$item_id\"", " itemid=\"$uri_e\"", $content);
303 303
 			}
304 304
 		}
305 305
 	}
306 306
 
307 307
 	// Reapply slashes.
308
-	$content = addslashes( $content );
308
+	$content = addslashes($content);
309 309
 
310 310
 	return $content;
311 311
 }
312 312
 
313
-add_filter( 'content_save_pre', 'wl_replace_item_id_with_uri', 1, 1 );
313
+add_filter('content_save_pre', 'wl_replace_item_id_with_uri', 1, 1);
314 314
 
315
-require_once( 'wordlift_entity_functions.php' );
315
+require_once('wordlift_entity_functions.php');
316 316
 
317 317
 // add editor related methods.
318
-require_once( 'wordlift_editor.php' );
318
+require_once('wordlift_editor.php');
319 319
 
320 320
 // add the WordLift entity custom type.
321
-require_once( 'wordlift_entity_type.php' );
321
+require_once('wordlift_entity_type.php');
322 322
 
323 323
 // add callbacks on post save to notify data changes from wp to redlink triple store
324
-require_once( 'wordlift_to_redlink_data_push_callbacks.php' );
324
+require_once('wordlift_to_redlink_data_push_callbacks.php');
325 325
 
326
-require_once( 'modules/configuration/wordlift_configuration_settings.php' );
326
+require_once('modules/configuration/wordlift_configuration_settings.php');
327 327
 
328 328
 // Load modules
329
-require_once( 'modules/analyzer/wordlift_analyzer.php' );
330
-require_once( 'modules/linked_data/wordlift_linked_data.php' );
331
-require_once( 'modules/prefixes/wordlift_prefixes.php' );
329
+require_once('modules/analyzer/wordlift_analyzer.php');
330
+require_once('modules/linked_data/wordlift_linked_data.php');
331
+require_once('modules/prefixes/wordlift_prefixes.php');
332 332
 
333 333
 // Shortcodes
334 334
 
335
-require_once( 'modules/geo_widget/wordlift_geo_widget.php' );
336
-require_once( 'shortcodes/class-wordlift-shortcode-rest.php' );
337
-require_once( 'shortcodes/wordlift_shortcode_chord.php' );
338
-require_once( 'shortcodes/wordlift_shortcode_geomap.php' );
339
-require_once( 'shortcodes/wordlift_shortcode_field.php' );
340
-require_once( 'shortcodes/wordlift_shortcode_faceted_search.php' );
341
-require_once( 'shortcodes/wordlift_shortcode_navigator.php' );
342
-require_once( 'shortcodes/class-wordlift-products-navigator-shortcode-rest.php' );
335
+require_once('modules/geo_widget/wordlift_geo_widget.php');
336
+require_once('shortcodes/class-wordlift-shortcode-rest.php');
337
+require_once('shortcodes/wordlift_shortcode_chord.php');
338
+require_once('shortcodes/wordlift_shortcode_geomap.php');
339
+require_once('shortcodes/wordlift_shortcode_field.php');
340
+require_once('shortcodes/wordlift_shortcode_faceted_search.php');
341
+require_once('shortcodes/wordlift_shortcode_navigator.php');
342
+require_once('shortcodes/class-wordlift-products-navigator-shortcode-rest.php');
343 343
 
344
-require_once( 'widgets/wordlift_widget_geo.php' );
345
-require_once( 'widgets/class-wordlift-chord-widget.php' );
346
-require_once( 'widgets/wordlift_widget_timeline.php' );
344
+require_once('widgets/wordlift_widget_geo.php');
345
+require_once('widgets/class-wordlift-chord-widget.php');
346
+require_once('widgets/wordlift_widget_timeline.php');
347 347
 
348
-require_once( 'wordlift_redlink.php' );
348
+require_once('wordlift_redlink.php');
349 349
 
350 350
 // Add admin functions.
351 351
 // TODO: find a way to make 'admin' UI tests work.
352 352
 //if ( is_admin() ) {
353 353
 
354
-require_once( 'admin/wordlift_admin.php' );
355
-require_once( 'admin/wordlift_admin_edit_post.php' );
356
-require_once( 'admin/wordlift_admin_save_post.php' );
354
+require_once('admin/wordlift_admin.php');
355
+require_once('admin/wordlift_admin_edit_post.php');
356
+require_once('admin/wordlift_admin_save_post.php');
357 357
 
358 358
 // add the entities meta box.
359
-require_once( 'admin/wordlift_admin_meta_box_entities.php' );
359
+require_once('admin/wordlift_admin_meta_box_entities.php');
360 360
 
361 361
 // add the entity creation AJAX.
362
-require_once( 'admin/wordlift_admin_ajax_related_posts.php' );
362
+require_once('admin/wordlift_admin_ajax_related_posts.php');
363 363
 
364 364
 // Load the wl_chord TinyMCE button and configuration dialog.
365
-require_once( 'admin/wordlift_admin_shortcodes.php' );
365
+require_once('admin/wordlift_admin_shortcodes.php');
366 366
 
367 367
 /**
368 368
  * The code that runs during plugin activation.
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
  */
371 371
 function activate_wordlift() {
372 372
 
373
-	$log = Wordlift_Log_Service::get_logger( 'activate_wordlift' );
373
+	$log = Wordlift_Log_Service::get_logger('activate_wordlift');
374 374
 
375
-	$log->info( 'Activating WordLift...' );
375
+	$log->info('Activating WordLift...');
376 376
 
377
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php';
377
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php';
378 378
 	Wordlift_Activator::activate();
379 379
 
380 380
 	/**
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function deactivate_wordlift() {
398 398
 
399
-	require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php';
399
+	require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php';
400 400
 	Wordlift_Deactivator::deactivate();
401 401
 	Wordlift_Http_Api::deactivate();
402 402
 	Ttl_Cache_Cleaner::deactivate();
@@ -404,14 +404,14 @@  discard block
 block discarded – undo
404 404
 
405 405
 }
406 406
 
407
-register_activation_hook( __FILE__, 'activate_wordlift' );
408
-register_deactivation_hook( __FILE__, 'deactivate_wordlift' );
407
+register_activation_hook(__FILE__, 'activate_wordlift');
408
+register_deactivation_hook(__FILE__, 'deactivate_wordlift');
409 409
 
410 410
 /**
411 411
  * The core plugin class that is used to define internationalization,
412 412
  * admin-specific hooks, and public-facing site hooks.
413 413
  */
414
-require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php';
414
+require plugin_dir_path(__FILE__).'includes/class-wordlift.php';
415 415
 
416 416
 /**
417 417
  * Begins execution of the plugin.
@@ -431,12 +431,12 @@  discard block
 block discarded – undo
431 431
 	 * @return bool
432 432
 	 * @since 3.27.6
433 433
 	 */
434
-	if ( apply_filters( 'wl_feature__enable__widgets', true ) ) {
435
-		add_action( 'widgets_init', 'wl_register_chord_widget' );
436
-		add_filter( 'widget_text', 'do_shortcode' );
437
-		add_action( 'widgets_init', 'wl_register_geo_widget' );
438
-		add_action( 'widgets_init', 'wl_register_timeline_widget' );
439
-		add_filter( 'widget_text', 'do_shortcode' );
434
+	if (apply_filters('wl_feature__enable__widgets', true)) {
435
+		add_action('widgets_init', 'wl_register_chord_widget');
436
+		add_filter('widget_text', 'do_shortcode');
437
+		add_action('widgets_init', 'wl_register_geo_widget');
438
+		add_action('widgets_init', 'wl_register_timeline_widget');
439
+		add_filter('widget_text', 'do_shortcode');
440 440
 	}
441 441
 	/*
442 442
 	 * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http.
@@ -457,34 +457,34 @@  discard block
 block discarded – undo
457 457
 	// Licenses Images.
458 458
 	$user_agent                   = User_Agent::get_user_agent();
459 459
 	$wordlift_key                 = Wordlift_Configuration_Service::get_instance()->get_key();
460
-	$api_service                  = new Default_Api_Service( 'https://api.wordlift.io', 60, $user_agent, $wordlift_key );
460
+	$api_service                  = new Default_Api_Service('https://api.wordlift.io', 60, $user_agent, $wordlift_key);
461 461
 	$image_license_factory        = new Image_License_Factory();
462
-	$image_license_service        = new Image_License_Service( $api_service, $image_license_factory );
463
-	$image_license_cache          = new Ttl_Cache( 'image-license', 86400 * 30 ); // 30 days.
464
-	$cached_image_license_service = new Cached_Image_License_Service( $image_license_service, $image_license_cache );
462
+	$image_license_service        = new Image_License_Service($api_service, $image_license_factory);
463
+	$image_license_cache          = new Ttl_Cache('image-license', 86400 * 30); // 30 days.
464
+	$cached_image_license_service = new Cached_Image_License_Service($image_license_service, $image_license_cache);
465 465
 
466
-	$image_license_scheduler       = new Image_License_Scheduler( $image_license_service, $image_license_cache );
466
+	$image_license_scheduler       = new Image_License_Scheduler($image_license_service, $image_license_cache);
467 467
 	$image_license_cleanup_service = new Image_License_Cleanup_Service();
468 468
 
469 469
 	// Get the cached data. If we have cached data, we load the notifier.
470
-	$image_license_data = $image_license_cache->get( Cached_Image_License_Service::GET_NON_PUBLIC_DOMAIN_IMAGES );
471
-	if ( null !== $image_license_data ) {
472
-		$image_license_page = new Image_License_Page( $image_license_data, Wordlift::get_instance()->get_version() );
473
-		new Image_License_Notifier( $image_license_data, $image_license_page );
470
+	$image_license_data = $image_license_cache->get(Cached_Image_License_Service::GET_NON_PUBLIC_DOMAIN_IMAGES);
471
+	if (null !== $image_license_data) {
472
+		$image_license_page = new Image_License_Page($image_license_data, Wordlift::get_instance()->get_version());
473
+		new Image_License_Notifier($image_license_data, $image_license_page);
474 474
 	}
475 475
 
476
-	$remove_all_images_task         = new Remove_All_Images_Task( $cached_image_license_service );
477
-	$remove_all_images_task_adapter = new Task_Ajax_Adapter( $remove_all_images_task );
476
+	$remove_all_images_task         = new Remove_All_Images_Task($cached_image_license_service);
477
+	$remove_all_images_task_adapter = new Task_Ajax_Adapter($remove_all_images_task);
478 478
 
479 479
 	$reload_data_task         = new Reload_Data_Task();
480
-	$reload_data_task_adapter = new Task_Ajax_Adapter( $reload_data_task );
480
+	$reload_data_task_adapter = new Task_Ajax_Adapter($reload_data_task);
481 481
 
482
-	$add_license_caption_or_remove_task         = new Add_License_Caption_Or_Remove_Task( $cached_image_license_service );
483
-	$add_license_caption_or_remove_task_adapter = new Task_Ajax_Adapter( $add_license_caption_or_remove_task );
482
+	$add_license_caption_or_remove_task         = new Add_License_Caption_Or_Remove_Task($cached_image_license_service);
483
+	$add_license_caption_or_remove_task_adapter = new Task_Ajax_Adapter($add_license_caption_or_remove_task);
484 484
 
485
-	$remove_all_images_task_page             = new Remove_All_Images_Page( new Task_Ajax_Adapters_Registry( $remove_all_images_task_adapter ), $plugin->get_version() );
486
-	$reload_data_task_page                   = new Reload_Data_Page( new Task_Ajax_Adapters_Registry( $reload_data_task_adapter ), $plugin->get_version() );
487
-	$add_license_caption_or_remove_task_page = new Add_License_Caption_Or_Remove_Page( new Task_Ajax_Adapters_Registry( $add_license_caption_or_remove_task_adapter ), $plugin->get_version() );
485
+	$remove_all_images_task_page             = new Remove_All_Images_Page(new Task_Ajax_Adapters_Registry($remove_all_images_task_adapter), $plugin->get_version());
486
+	$reload_data_task_page                   = new Reload_Data_Page(new Task_Ajax_Adapters_Registry($reload_data_task_adapter), $plugin->get_version());
487
+	$add_license_caption_or_remove_task_page = new Add_License_Caption_Or_Remove_Page(new Task_Ajax_Adapters_Registry($add_license_caption_or_remove_task_adapter), $plugin->get_version());
488 488
 
489 489
 	new Wordlift_Products_Navigator_Shortcode_REST();
490 490
 
@@ -500,24 +500,24 @@  discard block
 block discarded – undo
500 500
  */
501 501
 function wordlift_plugin_autoload_register() {
502 502
 
503
-	spl_autoload_register( function ( $class_name ) {
503
+	spl_autoload_register(function($class_name) {
504 504
 
505 505
 		// Bail out if these are not our classes.
506
-		if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) {
506
+		if (0 !== strpos($class_name, 'Wordlift\\')) {
507 507
 			return false;
508 508
 		}
509 509
 
510
-		$class_name_lc = strtolower( str_replace( '_', '-', $class_name ) );
510
+		$class_name_lc = strtolower(str_replace('_', '-', $class_name));
511 511
 
512
-		preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches );
512
+		preg_match('|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches);
513 513
 
514
-		$path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] );
515
-		$file = 'class-' . $matches[2] . '.php';
514
+		$path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]);
515
+		$file = 'class-'.$matches[2].'.php';
516 516
 
517
-		$full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file;
517
+		$full_path = plugin_dir_path(__FILE__).$path.DIRECTORY_SEPARATOR.$file;
518 518
 
519
-		if ( ! file_exists( $full_path ) ) {
520
-			echo( "Class $class_name not found at $full_path." );
519
+		if ( ! file_exists($full_path)) {
520
+			echo("Class $class_name not found at $full_path.");
521 521
 
522 522
 			return false;
523 523
 		}
@@ -529,16 +529,16 @@  discard block
 block discarded – undo
529 529
 
530 530
 }
531 531
 
532
-function wl_block_categories( $categories, $post ) {
532
+function wl_block_categories($categories, $post) {
533 533
 	return array_merge(
534 534
 		$categories,
535 535
 		array(
536 536
 			array(
537 537
 				'slug'  => 'wordlift',
538
-				'title' => __( 'WordLift', 'wordlift' ),
538
+				'title' => __('WordLift', 'wordlift'),
539 539
 			),
540 540
 		)
541 541
 	);
542 542
 }
543 543
 
544
-add_filter( 'block_categories', 'wl_block_categories', 10, 2 );
544
+add_filter('block_categories', 'wl_block_categories', 10, 2);
Please login to merge, or discard this patch.
wordlift/external-plugin-hooks/recipe-maker/class-recipe-maker-warning.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -15,6 +15,9 @@
 block discarded – undo
15 15
 	 */
16 16
 	private $recipe_maker_validation_service;
17 17
 
18
+	/**
19
+	 * @param Recipe_Maker_Validation_Service $recipe_maker_validation_service
20
+	 */
18 21
 	public function __construct( $recipe_maker_validation_service ) {
19 22
 		$this->recipe_maker_validation_service = $recipe_maker_validation_service;
20 23
 		/**
Please login to merge, or discard this patch.
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -10,99 +10,99 @@
 block discarded – undo
10 10
  */
11 11
 class Recipe_Maker_Warning {
12 12
 
13
-	/**
14
-	 * @var Recipe_Maker_Validation_Service
15
-	 */
16
-	private $recipe_maker_validation_service;
17
-
18
-	public function __construct( $recipe_maker_validation_service ) {
19
-		$this->recipe_maker_validation_service = $recipe_maker_validation_service;
20
-		/**
21
-		 * Filter: wl_feature__enable__notices.
22
-		 *
23
-		 * @param bool whether the notices needs to be enabled or not.
24
-		 *
25
-		 * @return bool
26
-		 * @since 3.27.6
27
-		 */
28
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
29
-			add_action( 'admin_notices', array( $this, 'display_image_size_warning' ) );
30
-		}
31
-	}
32
-
33
-	/**
34
-	 * Show the warning after applying the conditions.
35
-	 */
36
-	public function display_image_size_warning() {
37
-
38
-		// Check if we are on the post.
39
-		if ( ! get_post() instanceof \WP_Post ) {
40
-			return false;
41
-		}
42
-		if ( ! $this->recipe_maker_validation_service->is_wp_recipe_maker_available() ) {
43
-			return false;
44
-		}
45
-		$post_id = get_the_ID();
46
-
47
-		// Dont show notification if there is no recipes referred by the post.
48
-		if ( ! $this->recipe_maker_validation_service->is_atleast_once_recipe_present_in_the_post( $post_id ) ) {
49
-			return false;
50
-		}
51
-
52
-		$recipe_with_image_warnings = $this->get_warnings( $post_id );
53
-
54
-		if ( count( $recipe_with_image_warnings ) > 0 ) {
55
-			// Show notification.
56
-			?>
13
+    /**
14
+     * @var Recipe_Maker_Validation_Service
15
+     */
16
+    private $recipe_maker_validation_service;
17
+
18
+    public function __construct( $recipe_maker_validation_service ) {
19
+        $this->recipe_maker_validation_service = $recipe_maker_validation_service;
20
+        /**
21
+         * Filter: wl_feature__enable__notices.
22
+         *
23
+         * @param bool whether the notices needs to be enabled or not.
24
+         *
25
+         * @return bool
26
+         * @since 3.27.6
27
+         */
28
+        if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
29
+            add_action( 'admin_notices', array( $this, 'display_image_size_warning' ) );
30
+        }
31
+    }
32
+
33
+    /**
34
+     * Show the warning after applying the conditions.
35
+     */
36
+    public function display_image_size_warning() {
37
+
38
+        // Check if we are on the post.
39
+        if ( ! get_post() instanceof \WP_Post ) {
40
+            return false;
41
+        }
42
+        if ( ! $this->recipe_maker_validation_service->is_wp_recipe_maker_available() ) {
43
+            return false;
44
+        }
45
+        $post_id = get_the_ID();
46
+
47
+        // Dont show notification if there is no recipes referred by the post.
48
+        if ( ! $this->recipe_maker_validation_service->is_atleast_once_recipe_present_in_the_post( $post_id ) ) {
49
+            return false;
50
+        }
51
+
52
+        $recipe_with_image_warnings = $this->get_warnings( $post_id );
53
+
54
+        if ( count( $recipe_with_image_warnings ) > 0 ) {
55
+            // Show notification.
56
+            ?>
57 57
             <div class="notice notice-warning is-dismissible">
58 58
                 <p><?php echo __( 'The following recipes didnt have minimum image size of 1200 x 1200 px', 'wordlift' ); ?></p>
59 59
                 <ol>
60 60
 					<?php
61
-					foreach ( $recipe_with_image_warnings as $post_id ) {
62
-						echo "<li>" . get_the_title( $post_id ) . "</li>";
63
-					}
64
-					?>
61
+                    foreach ( $recipe_with_image_warnings as $post_id ) {
62
+                        echo "<li>" . get_the_title( $post_id ) . "</li>";
63
+                    }
64
+                    ?>
65 65
                 </ol>
66 66
             </div>
67 67
 			<?php
68
-		}
69
-
70
-	}
71
-
72
-	/**
73
-	 * @param $post_id
74
-	 *
75
-	 * @return array
76
-	 */
77
-	private function get_warnings( $post_id ) {
78
-
79
-		$recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post( $post_id );
80
-
81
-		// Dont show duplicate warnings.
82
-		$recipe_ids = array_unique( $recipe_ids );
83
-
84
-		$recipe_with_image_warnings = array();
85
-
86
-		foreach ( $recipe_ids as $recipe_id ) {
87
-			$recipe     = \WPRM_Recipe_Manager::get_recipe( $recipe_id );
88
-			$image_id   = $recipe->image_id();
89
-			$image_data = wp_get_attachment_image_src( $image_id, array( 1200, 1200 ) );
90
-			if ( ! is_array( $image_data ) ) {
91
-				continue;
92
-			}
93
-			$image_width  = array_key_exists( 1, $image_data ) ? $image_data [1] : false;
94
-			$image_height = array_key_exists( 2, $image_data ) ? $image_data [2] : false;
95
-			if ( ! ( $image_height && $image_width ) ) {
96
-				continue;
97
-			}
98
-
99
-			if ( $image_height < 1200 || $image_width < 1200 ) {
100
-				// Image size not present in 1200 * 1200, show a warning.
101
-				$recipe_with_image_warnings[] = $recipe_id;
102
-			}
103
-		}
104
-
105
-		return $recipe_with_image_warnings;
106
-	}
68
+        }
69
+
70
+    }
71
+
72
+    /**
73
+     * @param $post_id
74
+     *
75
+     * @return array
76
+     */
77
+    private function get_warnings( $post_id ) {
78
+
79
+        $recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post( $post_id );
80
+
81
+        // Dont show duplicate warnings.
82
+        $recipe_ids = array_unique( $recipe_ids );
83
+
84
+        $recipe_with_image_warnings = array();
85
+
86
+        foreach ( $recipe_ids as $recipe_id ) {
87
+            $recipe     = \WPRM_Recipe_Manager::get_recipe( $recipe_id );
88
+            $image_id   = $recipe->image_id();
89
+            $image_data = wp_get_attachment_image_src( $image_id, array( 1200, 1200 ) );
90
+            if ( ! is_array( $image_data ) ) {
91
+                continue;
92
+            }
93
+            $image_width  = array_key_exists( 1, $image_data ) ? $image_data [1] : false;
94
+            $image_height = array_key_exists( 2, $image_data ) ? $image_data [2] : false;
95
+            if ( ! ( $image_height && $image_width ) ) {
96
+                continue;
97
+            }
98
+
99
+            if ( $image_height < 1200 || $image_width < 1200 ) {
100
+                // Image size not present in 1200 * 1200, show a warning.
101
+                $recipe_with_image_warnings[] = $recipe_id;
102
+            }
103
+        }
104
+
105
+        return $recipe_with_image_warnings;
106
+    }
107 107
 
108 108
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	private $recipe_maker_validation_service;
17 17
 
18
-	public function __construct( $recipe_maker_validation_service ) {
18
+	public function __construct($recipe_maker_validation_service) {
19 19
 		$this->recipe_maker_validation_service = $recipe_maker_validation_service;
20 20
 		/**
21 21
 		 * Filter: wl_feature__enable__notices.
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 		 * @return bool
26 26
 		 * @since 3.27.6
27 27
 		 */
28
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
29
-			add_action( 'admin_notices', array( $this, 'display_image_size_warning' ) );
28
+		if (apply_filters('wl_feature__enable__notices', true)) {
29
+			add_action('admin_notices', array($this, 'display_image_size_warning'));
30 30
 		}
31 31
 	}
32 32
 
@@ -36,30 +36,30 @@  discard block
 block discarded – undo
36 36
 	public function display_image_size_warning() {
37 37
 
38 38
 		// Check if we are on the post.
39
-		if ( ! get_post() instanceof \WP_Post ) {
39
+		if ( ! get_post() instanceof \WP_Post) {
40 40
 			return false;
41 41
 		}
42
-		if ( ! $this->recipe_maker_validation_service->is_wp_recipe_maker_available() ) {
42
+		if ( ! $this->recipe_maker_validation_service->is_wp_recipe_maker_available()) {
43 43
 			return false;
44 44
 		}
45 45
 		$post_id = get_the_ID();
46 46
 
47 47
 		// Dont show notification if there is no recipes referred by the post.
48
-		if ( ! $this->recipe_maker_validation_service->is_atleast_once_recipe_present_in_the_post( $post_id ) ) {
48
+		if ( ! $this->recipe_maker_validation_service->is_atleast_once_recipe_present_in_the_post($post_id)) {
49 49
 			return false;
50 50
 		}
51 51
 
52
-		$recipe_with_image_warnings = $this->get_warnings( $post_id );
52
+		$recipe_with_image_warnings = $this->get_warnings($post_id);
53 53
 
54
-		if ( count( $recipe_with_image_warnings ) > 0 ) {
54
+		if (count($recipe_with_image_warnings) > 0) {
55 55
 			// Show notification.
56 56
 			?>
57 57
             <div class="notice notice-warning is-dismissible">
58
-                <p><?php echo __( 'The following recipes didnt have minimum image size of 1200 x 1200 px', 'wordlift' ); ?></p>
58
+                <p><?php echo __('The following recipes didnt have minimum image size of 1200 x 1200 px', 'wordlift'); ?></p>
59 59
                 <ol>
60 60
 					<?php
61
-					foreach ( $recipe_with_image_warnings as $post_id ) {
62
-						echo "<li>" . get_the_title( $post_id ) . "</li>";
61
+					foreach ($recipe_with_image_warnings as $post_id) {
62
+						echo "<li>".get_the_title($post_id)."</li>";
63 63
 					}
64 64
 					?>
65 65
                 </ol>
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return array
76 76
 	 */
77
-	private function get_warnings( $post_id ) {
77
+	private function get_warnings($post_id) {
78 78
 
79
-		$recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post( $post_id );
79
+		$recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post($post_id);
80 80
 
81 81
 		// Dont show duplicate warnings.
82
-		$recipe_ids = array_unique( $recipe_ids );
82
+		$recipe_ids = array_unique($recipe_ids);
83 83
 
84 84
 		$recipe_with_image_warnings = array();
85 85
 
86
-		foreach ( $recipe_ids as $recipe_id ) {
87
-			$recipe     = \WPRM_Recipe_Manager::get_recipe( $recipe_id );
86
+		foreach ($recipe_ids as $recipe_id) {
87
+			$recipe     = \WPRM_Recipe_Manager::get_recipe($recipe_id);
88 88
 			$image_id   = $recipe->image_id();
89
-			$image_data = wp_get_attachment_image_src( $image_id, array( 1200, 1200 ) );
90
-			if ( ! is_array( $image_data ) ) {
89
+			$image_data = wp_get_attachment_image_src($image_id, array(1200, 1200));
90
+			if ( ! is_array($image_data)) {
91 91
 				continue;
92 92
 			}
93
-			$image_width  = array_key_exists( 1, $image_data ) ? $image_data [1] : false;
94
-			$image_height = array_key_exists( 2, $image_data ) ? $image_data [2] : false;
95
-			if ( ! ( $image_height && $image_width ) ) {
93
+			$image_width  = array_key_exists(1, $image_data) ? $image_data [1] : false;
94
+			$image_height = array_key_exists(2, $image_data) ? $image_data [2] : false;
95
+			if ( ! ($image_height && $image_width)) {
96 96
 				continue;
97 97
 			}
98 98
 
99
-			if ( $image_height < 1200 || $image_width < 1200 ) {
99
+			if ($image_height < 1200 || $image_width < 1200) {
100 100
 				// Image size not present in 1200 * 1200, show a warning.
101 101
 				$recipe_with_image_warnings[] = $recipe_id;
102 102
 			}
Please login to merge, or discard this patch.
src/includes/class-wordlift-key-validation-service.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -17,157 +17,157 @@
 block discarded – undo
17 17
  */
18 18
 class Wordlift_Key_Validation_Service {
19 19
 
20
-	/**
21
-	 * A {@link Wordlift_Log_Service} instance.
22
-	 *
23
-	 * @since  3.14.0
24
-	 * @access private
25
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
26
-	 */
27
-	private $log;
28
-
29
-	/**
30
-	 * The {@link Wordlift_Configuration_Service} instance.
31
-	 *
32
-	 * @since  3.14.0
33
-	 * @access private
34
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
35
-	 */
36
-	private $configuration_service;
37
-
38
-	/**
39
-	 * Create a {@link Wordlift_Key_Validation_Service} instance.
40
-	 *
41
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
42
-	 *
43
-	 * @since 3.14.0
44
-	 *
45
-	 */
46
-	public function __construct( $configuration_service ) {
47
-
48
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Key_Validation_Service' );
49
-
50
-		$this->configuration_service = $configuration_service;
51
-		add_action( 'admin_init', array( $this, 'wl_load_plugin' ) );
52
-		/**
53
-		 * Filter: wl_feature__enable__notices.
54
-		 *
55
-		 * @param bool whether the notices needs to be enabled or not.
56
-		 *
57
-		 * @return bool
58
-		 * @since 3.27.6
59
-		 */
60
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
61
-			add_action( 'admin_notices', array( $this, 'wl_key_update_notice' ) );
62
-		}
63
-	}
64
-
65
-	/**
66
-	 * Validate the provided key.
67
-	 *
68
-	 * @param string $key WordLift's key to validate.
69
-	 *
70
-	 * @return WP_Error|array The response or WP_Error on failure.
71
-	 * @since 3.9.0
72
-	 *
73
-	 */
74
-	public function get_account_info( $key ) {
75
-
76
-		$this->log->debug( 'Validating key...' );
77
-
78
-		// Request the account info as a way to validate the key
79
-
80
-		$args = array_merge_recursive(
81
-			unserialize( WL_REDLINK_API_HTTP_OPTIONS ),
82
-			array(
83
-				'headers' => array(
84
-					'Content-Type'    => 'application/json; charset=utf-8',
85
-					'X-Authorization' => $key,
86
-				)
87
-			)
88
-		);
89
-
90
-		return wp_remote_get( $this->configuration_service->get_accounts_info_by_key( $key ), $args );
91
-	}
92
-
93
-	/**
94
-	 * This function is hooked to the `wl_validate_key` AJAX call.
95
-	 *
96
-	 * @since 3.9.0
97
-	 */
98
-	public function validate_key() {
99
-
100
-		// Ensure we don't have garbage before us.
101
-		ob_clean();
102
-
103
-		// Check if we have a key.
104
-		if ( ! isset( $_POST['key'] ) ) {
105
-			wp_send_json_error( 'The key parameter is required.' );
106
-		}
107
-
108
-		$response = $this->get_account_info( $_POST['key'] );
109
-
110
-		// If we got an error, return invalid.
111
-		if ( is_wp_error( $response ) || 2 !== (int) $response['response']['code'] / 100 ) {
112
-			wp_send_json_success( array( 'valid' => false, 'message' => '' ) );
113
-		}
114
-
115
-		$res_body = json_decode( wp_remote_retrieve_body( $response ), true );
116
-
117
-		// The URL stored in WLS. If this is the initial install the URL may be null.
118
-		$url = $res_body['url'];
119
-
120
-		// If the URL isn't set or matches, then it's valid.
121
-		if ( is_null( $url ) || $url === get_option( 'home' ) ) {
122
-			wp_send_json_success( array( 'valid' => true, 'message' => '' ) );
123
-		}
124
-
125
-		// If the URL doesn't match it means that this key has been configured elsewhere already.
126
-		if ( $url !== get_option( 'home' ) ) {
127
-			Wordlift_Configuration_Service::get_instance()->set_key( '' );
128
-			wp_send_json_success( array(
129
-				'valid'   => false,
130
-				'message' => __( 'The key is already used on another site, please contact us at [email protected] to move the key to another site.', 'wordlift' ),
131
-			) );
132
-		}
133
-
134
-		// Set a response with valid set to true or false according to the key validity with message.
135
-		wp_send_json_success( array(
136
-			'valid'   => false,
137
-			'message' => __( 'An error occurred, please contact us at [email protected]', 'wordlift' ),
138
-		) );
139
-	}
140
-
141
-	/**
142
-	 * This function is hooked `admin_init` to check _wl_blog_url.
143
-	 *
144
-	 */
145
-	public function wl_load_plugin() {
146
-
147
-		$wl_blog_url = get_option( '_wl_blog_url' );
148
-		$home_url    = defined( 'WP_HOME' ) ? WP_HOME : get_option( 'home' );
149
-
150
-		if ( ! $wl_blog_url ) {
151
-			update_option( '_wl_blog_url', $home_url, true );
152
-		} else if ( $wl_blog_url !== $home_url ) {
153
-			update_option( '_wl_blog_url', $home_url, true );
154
-			Wordlift_Configuration_Service::get_instance()->set_key( '' );
155
-			set_transient( 'wl-key-error-msg', __( "Your web site URL has changed. To avoid data corruption, WordLift's key has been removed. Please provide a new key in WordLift Settings. If you believe this to be an error, please contact us at [email protected]", 'wordlift' ), 10 );
156
-		}
157
-
158
-	}
159
-
160
-	/**
161
-	 * This function is hooked to the `admin_notices` to show admin notification.
162
-	 *
163
-	 */
164
-	public function wl_key_update_notice() {
165
-		if ( get_transient( 'wl-key-error-msg' ) ) {
166
-			?>
20
+    /**
21
+     * A {@link Wordlift_Log_Service} instance.
22
+     *
23
+     * @since  3.14.0
24
+     * @access private
25
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
26
+     */
27
+    private $log;
28
+
29
+    /**
30
+     * The {@link Wordlift_Configuration_Service} instance.
31
+     *
32
+     * @since  3.14.0
33
+     * @access private
34
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
35
+     */
36
+    private $configuration_service;
37
+
38
+    /**
39
+     * Create a {@link Wordlift_Key_Validation_Service} instance.
40
+     *
41
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
42
+     *
43
+     * @since 3.14.0
44
+     *
45
+     */
46
+    public function __construct( $configuration_service ) {
47
+
48
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Key_Validation_Service' );
49
+
50
+        $this->configuration_service = $configuration_service;
51
+        add_action( 'admin_init', array( $this, 'wl_load_plugin' ) );
52
+        /**
53
+         * Filter: wl_feature__enable__notices.
54
+         *
55
+         * @param bool whether the notices needs to be enabled or not.
56
+         *
57
+         * @return bool
58
+         * @since 3.27.6
59
+         */
60
+        if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
61
+            add_action( 'admin_notices', array( $this, 'wl_key_update_notice' ) );
62
+        }
63
+    }
64
+
65
+    /**
66
+     * Validate the provided key.
67
+     *
68
+     * @param string $key WordLift's key to validate.
69
+     *
70
+     * @return WP_Error|array The response or WP_Error on failure.
71
+     * @since 3.9.0
72
+     *
73
+     */
74
+    public function get_account_info( $key ) {
75
+
76
+        $this->log->debug( 'Validating key...' );
77
+
78
+        // Request the account info as a way to validate the key
79
+
80
+        $args = array_merge_recursive(
81
+            unserialize( WL_REDLINK_API_HTTP_OPTIONS ),
82
+            array(
83
+                'headers' => array(
84
+                    'Content-Type'    => 'application/json; charset=utf-8',
85
+                    'X-Authorization' => $key,
86
+                )
87
+            )
88
+        );
89
+
90
+        return wp_remote_get( $this->configuration_service->get_accounts_info_by_key( $key ), $args );
91
+    }
92
+
93
+    /**
94
+     * This function is hooked to the `wl_validate_key` AJAX call.
95
+     *
96
+     * @since 3.9.0
97
+     */
98
+    public function validate_key() {
99
+
100
+        // Ensure we don't have garbage before us.
101
+        ob_clean();
102
+
103
+        // Check if we have a key.
104
+        if ( ! isset( $_POST['key'] ) ) {
105
+            wp_send_json_error( 'The key parameter is required.' );
106
+        }
107
+
108
+        $response = $this->get_account_info( $_POST['key'] );
109
+
110
+        // If we got an error, return invalid.
111
+        if ( is_wp_error( $response ) || 2 !== (int) $response['response']['code'] / 100 ) {
112
+            wp_send_json_success( array( 'valid' => false, 'message' => '' ) );
113
+        }
114
+
115
+        $res_body = json_decode( wp_remote_retrieve_body( $response ), true );
116
+
117
+        // The URL stored in WLS. If this is the initial install the URL may be null.
118
+        $url = $res_body['url'];
119
+
120
+        // If the URL isn't set or matches, then it's valid.
121
+        if ( is_null( $url ) || $url === get_option( 'home' ) ) {
122
+            wp_send_json_success( array( 'valid' => true, 'message' => '' ) );
123
+        }
124
+
125
+        // If the URL doesn't match it means that this key has been configured elsewhere already.
126
+        if ( $url !== get_option( 'home' ) ) {
127
+            Wordlift_Configuration_Service::get_instance()->set_key( '' );
128
+            wp_send_json_success( array(
129
+                'valid'   => false,
130
+                'message' => __( 'The key is already used on another site, please contact us at [email protected] to move the key to another site.', 'wordlift' ),
131
+            ) );
132
+        }
133
+
134
+        // Set a response with valid set to true or false according to the key validity with message.
135
+        wp_send_json_success( array(
136
+            'valid'   => false,
137
+            'message' => __( 'An error occurred, please contact us at [email protected]', 'wordlift' ),
138
+        ) );
139
+    }
140
+
141
+    /**
142
+     * This function is hooked `admin_init` to check _wl_blog_url.
143
+     *
144
+     */
145
+    public function wl_load_plugin() {
146
+
147
+        $wl_blog_url = get_option( '_wl_blog_url' );
148
+        $home_url    = defined( 'WP_HOME' ) ? WP_HOME : get_option( 'home' );
149
+
150
+        if ( ! $wl_blog_url ) {
151
+            update_option( '_wl_blog_url', $home_url, true );
152
+        } else if ( $wl_blog_url !== $home_url ) {
153
+            update_option( '_wl_blog_url', $home_url, true );
154
+            Wordlift_Configuration_Service::get_instance()->set_key( '' );
155
+            set_transient( 'wl-key-error-msg', __( "Your web site URL has changed. To avoid data corruption, WordLift's key has been removed. Please provide a new key in WordLift Settings. If you believe this to be an error, please contact us at [email protected]", 'wordlift' ), 10 );
156
+        }
157
+
158
+    }
159
+
160
+    /**
161
+     * This function is hooked to the `admin_notices` to show admin notification.
162
+     *
163
+     */
164
+    public function wl_key_update_notice() {
165
+        if ( get_transient( 'wl-key-error-msg' ) ) {
166
+            ?>
167 167
             <div class="updated notice is-dismissible error">
168 168
                 <p><?php _e( get_transient( 'wl-key-error-msg' ), 'wordlift' ); ?></p>
169 169
             </div>
170 170
 			<?php
171
-		}
172
-	}
171
+        }
172
+    }
173 173
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 	 * @since 3.14.0
44 44
 	 *
45 45
 	 */
46
-	public function __construct( $configuration_service ) {
46
+	public function __construct($configuration_service) {
47 47
 
48
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Key_Validation_Service' );
48
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Key_Validation_Service');
49 49
 
50 50
 		$this->configuration_service = $configuration_service;
51
-		add_action( 'admin_init', array( $this, 'wl_load_plugin' ) );
51
+		add_action('admin_init', array($this, 'wl_load_plugin'));
52 52
 		/**
53 53
 		 * Filter: wl_feature__enable__notices.
54 54
 		 *
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 		 * @return bool
58 58
 		 * @since 3.27.6
59 59
 		 */
60
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
61
-			add_action( 'admin_notices', array( $this, 'wl_key_update_notice' ) );
60
+		if (apply_filters('wl_feature__enable__notices', true)) {
61
+			add_action('admin_notices', array($this, 'wl_key_update_notice'));
62 62
 		}
63 63
 	}
64 64
 
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 	 * @since 3.9.0
72 72
 	 *
73 73
 	 */
74
-	public function get_account_info( $key ) {
74
+	public function get_account_info($key) {
75 75
 
76
-		$this->log->debug( 'Validating key...' );
76
+		$this->log->debug('Validating key...');
77 77
 
78 78
 		// Request the account info as a way to validate the key
79 79
 
80 80
 		$args = array_merge_recursive(
81
-			unserialize( WL_REDLINK_API_HTTP_OPTIONS ),
81
+			unserialize(WL_REDLINK_API_HTTP_OPTIONS),
82 82
 			array(
83 83
 				'headers' => array(
84 84
 					'Content-Type'    => 'application/json; charset=utf-8',
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			)
88 88
 		);
89 89
 
90
-		return wp_remote_get( $this->configuration_service->get_accounts_info_by_key( $key ), $args );
90
+		return wp_remote_get($this->configuration_service->get_accounts_info_by_key($key), $args);
91 91
 	}
92 92
 
93 93
 	/**
@@ -101,41 +101,41 @@  discard block
 block discarded – undo
101 101
 		ob_clean();
102 102
 
103 103
 		// Check if we have a key.
104
-		if ( ! isset( $_POST['key'] ) ) {
105
-			wp_send_json_error( 'The key parameter is required.' );
104
+		if ( ! isset($_POST['key'])) {
105
+			wp_send_json_error('The key parameter is required.');
106 106
 		}
107 107
 
108
-		$response = $this->get_account_info( $_POST['key'] );
108
+		$response = $this->get_account_info($_POST['key']);
109 109
 
110 110
 		// If we got an error, return invalid.
111
-		if ( is_wp_error( $response ) || 2 !== (int) $response['response']['code'] / 100 ) {
112
-			wp_send_json_success( array( 'valid' => false, 'message' => '' ) );
111
+		if (is_wp_error($response) || 2 !== (int) $response['response']['code'] / 100) {
112
+			wp_send_json_success(array('valid' => false, 'message' => ''));
113 113
 		}
114 114
 
115
-		$res_body = json_decode( wp_remote_retrieve_body( $response ), true );
115
+		$res_body = json_decode(wp_remote_retrieve_body($response), true);
116 116
 
117 117
 		// The URL stored in WLS. If this is the initial install the URL may be null.
118 118
 		$url = $res_body['url'];
119 119
 
120 120
 		// If the URL isn't set or matches, then it's valid.
121
-		if ( is_null( $url ) || $url === get_option( 'home' ) ) {
122
-			wp_send_json_success( array( 'valid' => true, 'message' => '' ) );
121
+		if (is_null($url) || $url === get_option('home')) {
122
+			wp_send_json_success(array('valid' => true, 'message' => ''));
123 123
 		}
124 124
 
125 125
 		// If the URL doesn't match it means that this key has been configured elsewhere already.
126
-		if ( $url !== get_option( 'home' ) ) {
127
-			Wordlift_Configuration_Service::get_instance()->set_key( '' );
128
-			wp_send_json_success( array(
126
+		if ($url !== get_option('home')) {
127
+			Wordlift_Configuration_Service::get_instance()->set_key('');
128
+			wp_send_json_success(array(
129 129
 				'valid'   => false,
130
-				'message' => __( 'The key is already used on another site, please contact us at [email protected] to move the key to another site.', 'wordlift' ),
131
-			) );
130
+				'message' => __('The key is already used on another site, please contact us at [email protected] to move the key to another site.', 'wordlift'),
131
+			));
132 132
 		}
133 133
 
134 134
 		// Set a response with valid set to true or false according to the key validity with message.
135
-		wp_send_json_success( array(
135
+		wp_send_json_success(array(
136 136
 			'valid'   => false,
137
-			'message' => __( 'An error occurred, please contact us at [email protected]', 'wordlift' ),
138
-		) );
137
+			'message' => __('An error occurred, please contact us at [email protected]', 'wordlift'),
138
+		));
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	public function wl_load_plugin() {
146 146
 
147
-		$wl_blog_url = get_option( '_wl_blog_url' );
148
-		$home_url    = defined( 'WP_HOME' ) ? WP_HOME : get_option( 'home' );
147
+		$wl_blog_url = get_option('_wl_blog_url');
148
+		$home_url    = defined('WP_HOME') ? WP_HOME : get_option('home');
149 149
 
150
-		if ( ! $wl_blog_url ) {
151
-			update_option( '_wl_blog_url', $home_url, true );
152
-		} else if ( $wl_blog_url !== $home_url ) {
153
-			update_option( '_wl_blog_url', $home_url, true );
154
-			Wordlift_Configuration_Service::get_instance()->set_key( '' );
155
-			set_transient( 'wl-key-error-msg', __( "Your web site URL has changed. To avoid data corruption, WordLift's key has been removed. Please provide a new key in WordLift Settings. If you believe this to be an error, please contact us at [email protected]", 'wordlift' ), 10 );
150
+		if ( ! $wl_blog_url) {
151
+			update_option('_wl_blog_url', $home_url, true);
152
+		} else if ($wl_blog_url !== $home_url) {
153
+			update_option('_wl_blog_url', $home_url, true);
154
+			Wordlift_Configuration_Service::get_instance()->set_key('');
155
+			set_transient('wl-key-error-msg', __("Your web site URL has changed. To avoid data corruption, WordLift's key has been removed. Please provide a new key in WordLift Settings. If you believe this to be an error, please contact us at [email protected]", 'wordlift'), 10);
156 156
 		}
157 157
 
158 158
 	}
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 */
164 164
 	public function wl_key_update_notice() {
165
-		if ( get_transient( 'wl-key-error-msg' ) ) {
165
+		if (get_transient('wl-key-error-msg')) {
166 166
 			?>
167 167
             <div class="updated notice is-dismissible error">
168
-                <p><?php _e( get_transient( 'wl-key-error-msg' ), 'wordlift' ); ?></p>
168
+                <p><?php _e(get_transient('wl-key-error-msg'), 'wordlift'); ?></p>
169 169
             </div>
170 170
 			<?php
171 171
 		}
Please login to merge, or discard this patch.
src/admin/class-wordlift-entity-type-settings.php 2 patches
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -30,217 +30,217 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class Wordlift_Admin_Entity_Type_Settings {
32 32
 
33
-	/**
34
-	 * A {@link Wordlift_Log_Service} instance.
35
-	 *
36
-	 * @since  3.14.0
37
-	 * @access private
38
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
39
-	 */
40
-	private $log;
41
-
42
-	/**
43
-	 * Create a {@link Wordlift_Admin_Entity_Type_Settings} instance.
44
-	 *
45
-	 * @since 3.14.0
46
-	 */
47
-	public function __construct() {
48
-
49
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Admin_Entity_Type_Settings' );
50
-
51
-	}
52
-
53
-	/**
54
-	 * Handle menu registration.
55
-	 *
56
-	 * The registration is required, although we do not want to actually to add
57
-	 * an item to the menu, in order to "whitelist" the access to the settings page in
58
-	 * the admin.
59
-	 *
60
-	 * @since 3.11.0
61
-	 */
62
-	public function admin_menu() {
63
-
64
-		/*
33
+    /**
34
+     * A {@link Wordlift_Log_Service} instance.
35
+     *
36
+     * @since  3.14.0
37
+     * @access private
38
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
39
+     */
40
+    private $log;
41
+
42
+    /**
43
+     * Create a {@link Wordlift_Admin_Entity_Type_Settings} instance.
44
+     *
45
+     * @since 3.14.0
46
+     */
47
+    public function __construct() {
48
+
49
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Admin_Entity_Type_Settings' );
50
+
51
+    }
52
+
53
+    /**
54
+     * Handle menu registration.
55
+     *
56
+     * The registration is required, although we do not want to actually to add
57
+     * an item to the menu, in order to "whitelist" the access to the settings page in
58
+     * the admin.
59
+     *
60
+     * @since 3.11.0
61
+     */
62
+    public function admin_menu() {
63
+
64
+        /*
65 65
 		 * Before anything else check if an settings form was submitted.
66 66
 		 * This has to be done before any output happens in order to be able to
67 67
 		 * display proper "die" error messages and redirect.
68 68
 		 */
69
-		if ( isset( $_GET['page'] ) && ( 'wl_entity_type_settings' === $_GET['page'] ) ) {
70
-
71
-			// Validate inputs. Do not return on invalid parameters or capabilities.
72
-			$this->validate_proper_term();
73
-
74
-			// If proper form submission, handle it and redirect back to the settings page.
75
-			if ( isset( $_POST['action'] ) && ( 'wl_edit_entity_type_term' === $_POST['action'] ) ) {
76
-				$this->handle_form_submission();
77
-			}
78
-			/**
79
-			 * Filter: wl_feature__enable__notices.
80
-			 *
81
-			 * @param bool whether the notices needs to be enabled or not.
82
-			 *
83
-			 * @return bool
84
-			 * @since 3.27.6
85
-			 */
86
-			if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
87
-				// Register admin notices handler.
88
-				add_action( 'admin_notices', array( $this, 'admin_notice' ) );
89
-			}
90
-
91
-		}
92
-
93
-		/*
69
+        if ( isset( $_GET['page'] ) && ( 'wl_entity_type_settings' === $_GET['page'] ) ) {
70
+
71
+            // Validate inputs. Do not return on invalid parameters or capabilities.
72
+            $this->validate_proper_term();
73
+
74
+            // If proper form submission, handle it and redirect back to the settings page.
75
+            if ( isset( $_POST['action'] ) && ( 'wl_edit_entity_type_term' === $_POST['action'] ) ) {
76
+                $this->handle_form_submission();
77
+            }
78
+            /**
79
+             * Filter: wl_feature__enable__notices.
80
+             *
81
+             * @param bool whether the notices needs to be enabled or not.
82
+             *
83
+             * @return bool
84
+             * @since 3.27.6
85
+             */
86
+            if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
87
+                // Register admin notices handler.
88
+                add_action( 'admin_notices', array( $this, 'admin_notice' ) );
89
+            }
90
+
91
+        }
92
+
93
+        /*
94 94
 		 * Use a null parent slug to prevent the menu from actually appearing
95 95
 		 * in the admin menu.
96 96
 		 */
97
-		// @todo: use the new {@link Wordlift_Admin_Page}.
98
-		add_submenu_page(
99
-			null,
100
-			__( 'Edit Entity term', 'wordlift' ),
101
-			__( 'Edit Entity term', 'wordlift' ),
102
-			'manage_options',
103
-			'wl_entity_type_settings',
104
-			array( $this, 'render' )
105
-		);
106
-	}
107
-
108
-	/**
109
-	 * Output admin notices if needed, based on the message url parameter.
110
-	 * A value of 1 indicates that a successful save was done.
111
-	 *
112
-	 * @since 3.11.0
113
-	 */
114
-	function admin_notice() {
115
-		if ( isset( $_GET['message'] ) && ( '1' === $_GET['message'] ) ) {
116
-			?>
97
+        // @todo: use the new {@link Wordlift_Admin_Page}.
98
+        add_submenu_page(
99
+            null,
100
+            __( 'Edit Entity term', 'wordlift' ),
101
+            __( 'Edit Entity term', 'wordlift' ),
102
+            'manage_options',
103
+            'wl_entity_type_settings',
104
+            array( $this, 'render' )
105
+        );
106
+    }
107
+
108
+    /**
109
+     * Output admin notices if needed, based on the message url parameter.
110
+     * A value of 1 indicates that a successful save was done.
111
+     *
112
+     * @since 3.11.0
113
+     */
114
+    function admin_notice() {
115
+        if ( isset( $_GET['message'] ) && ( '1' === $_GET['message'] ) ) {
116
+            ?>
117 117
             <div class="notice notice-success is-dismissible">
118 118
                 <p><?php esc_html_e( 'Settings saved', 'wordlift' ) ?></p>
119 119
             </div>
120 120
 			<?php
121
-		}
122
-	}
123
-
124
-	/**
125
-	 * Validate the existence of the entity type indicated by the tag_ID url
126
-	 * parameter before doing any processing. Done before any output to mimic
127
-	 * the way WordPress handles same situation with "normal" term editing screens.
128
-	 *
129
-	 * @since 3.11.0
130
-	 */
131
-	function validate_proper_term() {
132
-
133
-		// Validate capabilities.
134
-		if ( ! current_user_can( 'manage_options' ) ) {
135
-			wp_die(
136
-				'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
137
-				'<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
138
-				403
139
-			);
140
-		}
141
-
142
-		// Get the term id and the actual term.
143
-		$term_id = (int) $_REQUEST['tag_ID'];
144
-
145
-		if ( ! term_exists( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) ) {
146
-			wp_die( __( 'You attempted to edit an entity type term that doesn&#8217;t exist.', 'wordlift' ) );
147
-		}
148
-
149
-	}
150
-
151
-	/**
152
-	 * Handle the form submission of the settings form. On successful
153
-	 * handling redirect tp the setting edit page.
154
-	 *
155
-	 * @since 3.11.0
156
-	 */
157
-	function handle_form_submission() {
158
-
159
-		$term_id = (int) $_POST['tag_ID'];
160
-
161
-		// Check the nonce.
162
-		check_admin_referer( 'update-entity_type_term_' . $term_id );
163
-
164
-		$term = get_term( $term_id, 'wl_entity_type' );
165
-
166
-		$this->set_setting(
167
-			$term_id,
168
-			trim( wp_unslash( $_POST['title'] ) ),
169
-			wp_unslash( $_POST['description'] )
170
-		);
171
-
172
-		// Redirect back to the term settings page and indicate a save was done.
173
-		$url = admin_url( "admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id&message=1" );
174
-
175
-		wp_redirect( $url );
176
-		exit;
177
-
178
-	}
179
-
180
-	/**
181
-	 * Render the settings page for the term.
182
-	 *
183
-	 * Access and parameter validity is assumed to be done earlier.
184
-	 *
185
-	 * @since 3.11.0
186
-	 */
187
-	function render() {
188
-
189
-		// Set variables used by the partial
190
-		$term_id  = absint( $_REQUEST['tag_ID'] );
191
-		$settings = $this->get_setting( $term_id );
192
-
193
-		include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-entity-type-settings.php';
194
-
195
-	}
196
-
197
-	/**
198
-	 * Store the entity type term settings in the DB
199
-	 *
200
-	 * @param integer $term_id The ID of the entity type term
201
-	 * @param string $title The override for the terms title.
202
-	 * @param string $description The override for the terms description.
203
-	 *
204
-	 * @since 3.11.0
205
-	 *
206
-	 */
207
-	function set_setting( $term_id, $title, $description ) {
208
-
209
-		$settings             = get_option( 'wl_entity_type_settings', array() );
210
-		$settings[ $term_id ] = array(
211
-			'title'       => $title,
212
-			'description' => $description,
213
-		);
214
-		update_option( 'wl_entity_type_settings', $settings );
215
-
216
-	}
217
-
218
-	/**
219
-	 * Retrieve the entity type term settings from the DB
220
-	 *
221
-	 * @param integer $term_id The ID of the entity type term
222
-	 *
223
-	 * @return    null|array {
224
-	 *                null is returned when there are no settings otherwise
225
-	 *                an array is returned with following fields
226
-	 *
227
-	 * @type    string    title    The overriding title for the term
228
-	 * @type    string    description    The overriding description for the term
229
-	 *            }
230
-	 * @since 3.11.0
231
-	 *
232
-	 */
233
-	function get_setting( $term_id ) {
234
-
235
-		$settings = get_option( 'wl_entity_type_settings', array() );
236
-
237
-		if ( isset( $settings[ $term_id ] ) ) {
238
-			return $settings[ $term_id ];
239
-		}
240
-
241
-		$this->log->warn( "No settings found for term id $term_id." );
242
-
243
-		return null;
244
-	}
121
+        }
122
+    }
123
+
124
+    /**
125
+     * Validate the existence of the entity type indicated by the tag_ID url
126
+     * parameter before doing any processing. Done before any output to mimic
127
+     * the way WordPress handles same situation with "normal" term editing screens.
128
+     *
129
+     * @since 3.11.0
130
+     */
131
+    function validate_proper_term() {
132
+
133
+        // Validate capabilities.
134
+        if ( ! current_user_can( 'manage_options' ) ) {
135
+            wp_die(
136
+                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
137
+                '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
138
+                403
139
+            );
140
+        }
141
+
142
+        // Get the term id and the actual term.
143
+        $term_id = (int) $_REQUEST['tag_ID'];
144
+
145
+        if ( ! term_exists( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) ) {
146
+            wp_die( __( 'You attempted to edit an entity type term that doesn&#8217;t exist.', 'wordlift' ) );
147
+        }
148
+
149
+    }
150
+
151
+    /**
152
+     * Handle the form submission of the settings form. On successful
153
+     * handling redirect tp the setting edit page.
154
+     *
155
+     * @since 3.11.0
156
+     */
157
+    function handle_form_submission() {
158
+
159
+        $term_id = (int) $_POST['tag_ID'];
160
+
161
+        // Check the nonce.
162
+        check_admin_referer( 'update-entity_type_term_' . $term_id );
163
+
164
+        $term = get_term( $term_id, 'wl_entity_type' );
165
+
166
+        $this->set_setting(
167
+            $term_id,
168
+            trim( wp_unslash( $_POST['title'] ) ),
169
+            wp_unslash( $_POST['description'] )
170
+        );
171
+
172
+        // Redirect back to the term settings page and indicate a save was done.
173
+        $url = admin_url( "admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id&message=1" );
174
+
175
+        wp_redirect( $url );
176
+        exit;
177
+
178
+    }
179
+
180
+    /**
181
+     * Render the settings page for the term.
182
+     *
183
+     * Access and parameter validity is assumed to be done earlier.
184
+     *
185
+     * @since 3.11.0
186
+     */
187
+    function render() {
188
+
189
+        // Set variables used by the partial
190
+        $term_id  = absint( $_REQUEST['tag_ID'] );
191
+        $settings = $this->get_setting( $term_id );
192
+
193
+        include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-entity-type-settings.php';
194
+
195
+    }
196
+
197
+    /**
198
+     * Store the entity type term settings in the DB
199
+     *
200
+     * @param integer $term_id The ID of the entity type term
201
+     * @param string $title The override for the terms title.
202
+     * @param string $description The override for the terms description.
203
+     *
204
+     * @since 3.11.0
205
+     *
206
+     */
207
+    function set_setting( $term_id, $title, $description ) {
208
+
209
+        $settings             = get_option( 'wl_entity_type_settings', array() );
210
+        $settings[ $term_id ] = array(
211
+            'title'       => $title,
212
+            'description' => $description,
213
+        );
214
+        update_option( 'wl_entity_type_settings', $settings );
215
+
216
+    }
217
+
218
+    /**
219
+     * Retrieve the entity type term settings from the DB
220
+     *
221
+     * @param integer $term_id The ID of the entity type term
222
+     *
223
+     * @return    null|array {
224
+     *                null is returned when there are no settings otherwise
225
+     *                an array is returned with following fields
226
+     *
227
+     * @type    string    title    The overriding title for the term
228
+     * @type    string    description    The overriding description for the term
229
+     *            }
230
+     * @since 3.11.0
231
+     *
232
+     */
233
+    function get_setting( $term_id ) {
234
+
235
+        $settings = get_option( 'wl_entity_type_settings', array() );
236
+
237
+        if ( isset( $settings[ $term_id ] ) ) {
238
+            return $settings[ $term_id ];
239
+        }
240
+
241
+        $this->log->warn( "No settings found for term id $term_id." );
242
+
243
+        return null;
244
+    }
245 245
 
246 246
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @since      3.11.0
13 13
  */
14 14
 
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function __construct() {
48 48
 
49
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Admin_Entity_Type_Settings' );
49
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Admin_Entity_Type_Settings');
50 50
 
51 51
 	}
52 52
 
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 		 * This has to be done before any output happens in order to be able to
67 67
 		 * display proper "die" error messages and redirect.
68 68
 		 */
69
-		if ( isset( $_GET['page'] ) && ( 'wl_entity_type_settings' === $_GET['page'] ) ) {
69
+		if (isset($_GET['page']) && ('wl_entity_type_settings' === $_GET['page'])) {
70 70
 
71 71
 			// Validate inputs. Do not return on invalid parameters or capabilities.
72 72
 			$this->validate_proper_term();
73 73
 
74 74
 			// If proper form submission, handle it and redirect back to the settings page.
75
-			if ( isset( $_POST['action'] ) && ( 'wl_edit_entity_type_term' === $_POST['action'] ) ) {
75
+			if (isset($_POST['action']) && ('wl_edit_entity_type_term' === $_POST['action'])) {
76 76
 				$this->handle_form_submission();
77 77
 			}
78 78
 			/**
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 			 * @return bool
84 84
 			 * @since 3.27.6
85 85
 			 */
86
-			if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
86
+			if (apply_filters('wl_feature__enable__notices', true)) {
87 87
 				// Register admin notices handler.
88
-				add_action( 'admin_notices', array( $this, 'admin_notice' ) );
88
+				add_action('admin_notices', array($this, 'admin_notice'));
89 89
 			}
90 90
 
91 91
 		}
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 		// @todo: use the new {@link Wordlift_Admin_Page}.
98 98
 		add_submenu_page(
99 99
 			null,
100
-			__( 'Edit Entity term', 'wordlift' ),
101
-			__( 'Edit Entity term', 'wordlift' ),
100
+			__('Edit Entity term', 'wordlift'),
101
+			__('Edit Entity term', 'wordlift'),
102 102
 			'manage_options',
103 103
 			'wl_entity_type_settings',
104
-			array( $this, 'render' )
104
+			array($this, 'render')
105 105
 		);
106 106
 	}
107 107
 
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 	 * @since 3.11.0
113 113
 	 */
114 114
 	function admin_notice() {
115
-		if ( isset( $_GET['message'] ) && ( '1' === $_GET['message'] ) ) {
115
+		if (isset($_GET['message']) && ('1' === $_GET['message'])) {
116 116
 			?>
117 117
             <div class="notice notice-success is-dismissible">
118
-                <p><?php esc_html_e( 'Settings saved', 'wordlift' ) ?></p>
118
+                <p><?php esc_html_e('Settings saved', 'wordlift') ?></p>
119 119
             </div>
120 120
 			<?php
121 121
 		}
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
 	function validate_proper_term() {
132 132
 
133 133
 		// Validate capabilities.
134
-		if ( ! current_user_can( 'manage_options' ) ) {
134
+		if ( ! current_user_can('manage_options')) {
135 135
 			wp_die(
136
-				'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
137
-				'<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
136
+				'<h1>'.__('Cheatin&#8217; uh?').'</h1>'.
137
+				'<p>'.__('Sorry, you are not allowed to edit this item.').'</p>',
138 138
 				403
139 139
 			);
140 140
 		}
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 		// Get the term id and the actual term.
143 143
 		$term_id = (int) $_REQUEST['tag_ID'];
144 144
 
145
-		if ( ! term_exists( $term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ) ) {
146
-			wp_die( __( 'You attempted to edit an entity type term that doesn&#8217;t exist.', 'wordlift' ) );
145
+		if ( ! term_exists($term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME)) {
146
+			wp_die(__('You attempted to edit an entity type term that doesn&#8217;t exist.', 'wordlift'));
147 147
 		}
148 148
 
149 149
 	}
@@ -159,20 +159,20 @@  discard block
 block discarded – undo
159 159
 		$term_id = (int) $_POST['tag_ID'];
160 160
 
161 161
 		// Check the nonce.
162
-		check_admin_referer( 'update-entity_type_term_' . $term_id );
162
+		check_admin_referer('update-entity_type_term_'.$term_id);
163 163
 
164
-		$term = get_term( $term_id, 'wl_entity_type' );
164
+		$term = get_term($term_id, 'wl_entity_type');
165 165
 
166 166
 		$this->set_setting(
167 167
 			$term_id,
168
-			trim( wp_unslash( $_POST['title'] ) ),
169
-			wp_unslash( $_POST['description'] )
168
+			trim(wp_unslash($_POST['title'])),
169
+			wp_unslash($_POST['description'])
170 170
 		);
171 171
 
172 172
 		// Redirect back to the term settings page and indicate a save was done.
173
-		$url = admin_url( "admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id&message=1" );
173
+		$url = admin_url("admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id&message=1");
174 174
 
175
-		wp_redirect( $url );
175
+		wp_redirect($url);
176 176
 		exit;
177 177
 
178 178
 	}
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
 	function render() {
188 188
 
189 189
 		// Set variables used by the partial
190
-		$term_id  = absint( $_REQUEST['tag_ID'] );
191
-		$settings = $this->get_setting( $term_id );
190
+		$term_id  = absint($_REQUEST['tag_ID']);
191
+		$settings = $this->get_setting($term_id);
192 192
 
193
-		include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-entity-type-settings.php';
193
+		include plugin_dir_path(dirname(__FILE__)).'admin/partials/wordlift-admin-entity-type-settings.php';
194 194
 
195 195
 	}
196 196
 
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 	 * @since 3.11.0
205 205
 	 *
206 206
 	 */
207
-	function set_setting( $term_id, $title, $description ) {
207
+	function set_setting($term_id, $title, $description) {
208 208
 
209
-		$settings             = get_option( 'wl_entity_type_settings', array() );
210
-		$settings[ $term_id ] = array(
209
+		$settings             = get_option('wl_entity_type_settings', array());
210
+		$settings[$term_id] = array(
211 211
 			'title'       => $title,
212 212
 			'description' => $description,
213 213
 		);
214
-		update_option( 'wl_entity_type_settings', $settings );
214
+		update_option('wl_entity_type_settings', $settings);
215 215
 
216 216
 	}
217 217
 
@@ -230,15 +230,15 @@  discard block
 block discarded – undo
230 230
 	 * @since 3.11.0
231 231
 	 *
232 232
 	 */
233
-	function get_setting( $term_id ) {
233
+	function get_setting($term_id) {
234 234
 
235
-		$settings = get_option( 'wl_entity_type_settings', array() );
235
+		$settings = get_option('wl_entity_type_settings', array());
236 236
 
237
-		if ( isset( $settings[ $term_id ] ) ) {
238
-			return $settings[ $term_id ];
237
+		if (isset($settings[$term_id])) {
238
+			return $settings[$term_id];
239 239
 		}
240 240
 
241
-		$this->log->warn( "No settings found for term id $term_id." );
241
+		$this->log->warn("No settings found for term id $term_id.");
242 242
 
243 243
 		return null;
244 244
 	}
Please login to merge, or discard this patch.
src/admin/class-wordlift-notice-service.php 2 patches
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -7,194 +7,194 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Notice_Service {
9 9
 
10
-	/**
11
-	 * The template used to display notices. The <em>notice dismissible</em> style classes make this notice dismissible
12
-	 * on the WordPress UI (via a small X button on the right side of the notice).
13
-	 *
14
-	 * @since 3.2.0
15
-	 */
16
-	const TEMPLATE = '<div class="wl-notice notice is-dismissible %s"><p>%s</p></div>';
17
-
18
-	/**
19
-	 * The standard WordPress <em>update</em> style class.
20
-	 *
21
-	 * @since 3.2.0
22
-	 */
23
-	const UPDATE = 'update';
24
-
25
-	/**
26
-	 * The standard WordPress <em>update-nag</em> style class.
27
-	 *
28
-	 * @since 3.2.0
29
-	 */
30
-	const UPDATE_NAG = 'update-nag';
31
-
32
-	/**
33
-	 * The standard WordPress <em>error</em> style class.
34
-	 *
35
-	 * @since 3.2.0
36
-	 */
37
-	const ERROR = 'error';
38
-
39
-	/**
40
-	 * A custom WordLift css style class used for WordLift suggestions.
41
-	 *
42
-	 * @since 3.3.0
43
-	 */
44
-	const SUGGESTION = 'wl-suggestion';
45
-
46
-	/**
47
-	 * The array of notices.
48
-	 *
49
-	 * @since 3.2.0
50
-	 * @access private
51
-	 * @var array $notices The array of notices.
52
-	 */
53
-	private $notices = array();
54
-
55
-	/**
56
-	 * A singleton instance of the Notice service.
57
-	 *
58
-	 * @since 3.2.0
59
-	 * @access private
60
-	 * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service.
61
-	 */
62
-	private static $instance;
63
-
64
-	/**
65
-	 * Create an instance of the Notice service.
66
-	 *
67
-	 * @since 3.2.0
68
-	 */
69
-	public function __construct() {
70
-		/**
71
-		 * Filter: wl_feature__enable__notices.
72
-		 *
73
-		 * @param bool whether the notices needs to be enabled or not.
74
-		 *
75
-		 * @return bool
76
-		 * @since 3.27.6
77
-		 */
78
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
79
-			// Hook to be called when to display notices.
80
-			add_action( 'admin_notices', array( $this, 'admin_notices' ) );
81
-		}
82
-		self::$instance = $this;
83
-
84
-	}
85
-
86
-	/**
87
-	 * Get the singleton instance of the Notice service.
88
-	 *
89
-	 * @return \Wordlift_Notice_Service The singleton instance of the Notice service.
90
-	 * @since 3.2.0
91
-	 */
92
-	public static function get_instance() {
93
-
94
-		return self::$instance;
95
-	}
96
-
97
-	/**
98
-	 * Add a notice.
99
-	 *
100
-	 * @param string $class The css class.
101
-	 * @param string $message The message.
102
-	 *
103
-	 * @since 3.2.0
104
-	 *
105
-	 */
106
-	public function add( $class, $message ) {
107
-
108
-		$this->notices[] = sprintf( self::TEMPLATE, $class, $this->transform( $message ) );
109
-
110
-	}
111
-
112
-	/**
113
-	 * Add an update notice (message with a white background and a green left border).
114
-	 *
115
-	 * @param string $message The message to display.
116
-	 *
117
-	 * @since 3.2.0
118
-	 *
119
-	 */
120
-	public function add_update( $message ) {
121
-
122
-		$this->add( self::UPDATE, $message );
123
-
124
-	}
125
-
126
-	/**
127
-	 * Add an update nag notice (message with a white background and a yellow left border).
128
-	 *
129
-	 * @param string $message The message to display.
130
-	 *
131
-	 * @since 3.2.0
132
-	 *
133
-	 */
134
-	public function add_update_nag( $message ) {
135
-
136
-		$this->add( self::UPDATE_NAG, $message );
137
-
138
-	}
139
-
140
-	/**
141
-	 * Add an error notice (message with a white background and a red left border).
142
-	 *
143
-	 * @param string $message The message to display.
144
-	 *
145
-	 * @since 3.2.0
146
-	 *
147
-	 */
148
-	public function add_error( $message ) {
149
-
150
-		$this->add( self::ERROR, $message );
151
-
152
-	}
153
-
154
-	/**
155
-	 * Add a suggestion notice (message with a white background and a WordLift brand colored left border).
156
-	 *
157
-	 * @param string $message The message to display.
158
-	 *
159
-	 * @since 3.3.0
160
-	 *
161
-	 */
162
-	public function add_suggestion( $message ) {
163
-
164
-		$this->add( self::SUGGESTION, $message );
165
-
166
-	}
167
-
168
-	/**
169
-	 * Print out the notices when the admin_notices action is called.
170
-	 *
171
-	 * @since 3.2.0
172
-	 */
173
-	public function admin_notices() {
174
-
175
-		foreach ( $this->notices as $notice ) {
176
-			echo( $notice );
177
-		}
178
-
179
-	}
180
-
181
-	/**
182
-	 * Transform message depending on message type. Return a string
183
-	 *
184
-	 * @param string $message The message.
185
-	 *
186
-	 * @since 3.3.0
187
-	 *
188
-	 */
189
-	private function transform( $message ) {
190
-
191
-		switch ( gettype( $message ) ) {
192
-			case 'array':
193
-				return implode( $message, '<br />' );
194
-			default:
195
-				return $message;
196
-		}
197
-
198
-	}
10
+    /**
11
+     * The template used to display notices. The <em>notice dismissible</em> style classes make this notice dismissible
12
+     * on the WordPress UI (via a small X button on the right side of the notice).
13
+     *
14
+     * @since 3.2.0
15
+     */
16
+    const TEMPLATE = '<div class="wl-notice notice is-dismissible %s"><p>%s</p></div>';
17
+
18
+    /**
19
+     * The standard WordPress <em>update</em> style class.
20
+     *
21
+     * @since 3.2.0
22
+     */
23
+    const UPDATE = 'update';
24
+
25
+    /**
26
+     * The standard WordPress <em>update-nag</em> style class.
27
+     *
28
+     * @since 3.2.0
29
+     */
30
+    const UPDATE_NAG = 'update-nag';
31
+
32
+    /**
33
+     * The standard WordPress <em>error</em> style class.
34
+     *
35
+     * @since 3.2.0
36
+     */
37
+    const ERROR = 'error';
38
+
39
+    /**
40
+     * A custom WordLift css style class used for WordLift suggestions.
41
+     *
42
+     * @since 3.3.0
43
+     */
44
+    const SUGGESTION = 'wl-suggestion';
45
+
46
+    /**
47
+     * The array of notices.
48
+     *
49
+     * @since 3.2.0
50
+     * @access private
51
+     * @var array $notices The array of notices.
52
+     */
53
+    private $notices = array();
54
+
55
+    /**
56
+     * A singleton instance of the Notice service.
57
+     *
58
+     * @since 3.2.0
59
+     * @access private
60
+     * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service.
61
+     */
62
+    private static $instance;
63
+
64
+    /**
65
+     * Create an instance of the Notice service.
66
+     *
67
+     * @since 3.2.0
68
+     */
69
+    public function __construct() {
70
+        /**
71
+         * Filter: wl_feature__enable__notices.
72
+         *
73
+         * @param bool whether the notices needs to be enabled or not.
74
+         *
75
+         * @return bool
76
+         * @since 3.27.6
77
+         */
78
+        if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
79
+            // Hook to be called when to display notices.
80
+            add_action( 'admin_notices', array( $this, 'admin_notices' ) );
81
+        }
82
+        self::$instance = $this;
83
+
84
+    }
85
+
86
+    /**
87
+     * Get the singleton instance of the Notice service.
88
+     *
89
+     * @return \Wordlift_Notice_Service The singleton instance of the Notice service.
90
+     * @since 3.2.0
91
+     */
92
+    public static function get_instance() {
93
+
94
+        return self::$instance;
95
+    }
96
+
97
+    /**
98
+     * Add a notice.
99
+     *
100
+     * @param string $class The css class.
101
+     * @param string $message The message.
102
+     *
103
+     * @since 3.2.0
104
+     *
105
+     */
106
+    public function add( $class, $message ) {
107
+
108
+        $this->notices[] = sprintf( self::TEMPLATE, $class, $this->transform( $message ) );
109
+
110
+    }
111
+
112
+    /**
113
+     * Add an update notice (message with a white background and a green left border).
114
+     *
115
+     * @param string $message The message to display.
116
+     *
117
+     * @since 3.2.0
118
+     *
119
+     */
120
+    public function add_update( $message ) {
121
+
122
+        $this->add( self::UPDATE, $message );
123
+
124
+    }
125
+
126
+    /**
127
+     * Add an update nag notice (message with a white background and a yellow left border).
128
+     *
129
+     * @param string $message The message to display.
130
+     *
131
+     * @since 3.2.0
132
+     *
133
+     */
134
+    public function add_update_nag( $message ) {
135
+
136
+        $this->add( self::UPDATE_NAG, $message );
137
+
138
+    }
139
+
140
+    /**
141
+     * Add an error notice (message with a white background and a red left border).
142
+     *
143
+     * @param string $message The message to display.
144
+     *
145
+     * @since 3.2.0
146
+     *
147
+     */
148
+    public function add_error( $message ) {
149
+
150
+        $this->add( self::ERROR, $message );
151
+
152
+    }
153
+
154
+    /**
155
+     * Add a suggestion notice (message with a white background and a WordLift brand colored left border).
156
+     *
157
+     * @param string $message The message to display.
158
+     *
159
+     * @since 3.3.0
160
+     *
161
+     */
162
+    public function add_suggestion( $message ) {
163
+
164
+        $this->add( self::SUGGESTION, $message );
165
+
166
+    }
167
+
168
+    /**
169
+     * Print out the notices when the admin_notices action is called.
170
+     *
171
+     * @since 3.2.0
172
+     */
173
+    public function admin_notices() {
174
+
175
+        foreach ( $this->notices as $notice ) {
176
+            echo( $notice );
177
+        }
178
+
179
+    }
180
+
181
+    /**
182
+     * Transform message depending on message type. Return a string
183
+     *
184
+     * @param string $message The message.
185
+     *
186
+     * @since 3.3.0
187
+     *
188
+     */
189
+    private function transform( $message ) {
190
+
191
+        switch ( gettype( $message ) ) {
192
+            case 'array':
193
+                return implode( $message, '<br />' );
194
+            default:
195
+                return $message;
196
+        }
197
+
198
+    }
199 199
 
200 200
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 		 * @return bool
76 76
 		 * @since 3.27.6
77 77
 		 */
78
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
78
+		if (apply_filters('wl_feature__enable__notices', true)) {
79 79
 			// Hook to be called when to display notices.
80
-			add_action( 'admin_notices', array( $this, 'admin_notices' ) );
80
+			add_action('admin_notices', array($this, 'admin_notices'));
81 81
 		}
82 82
 		self::$instance = $this;
83 83
 
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 	 * @since 3.2.0
104 104
 	 *
105 105
 	 */
106
-	public function add( $class, $message ) {
106
+	public function add($class, $message) {
107 107
 
108
-		$this->notices[] = sprintf( self::TEMPLATE, $class, $this->transform( $message ) );
108
+		$this->notices[] = sprintf(self::TEMPLATE, $class, $this->transform($message));
109 109
 
110 110
 	}
111 111
 
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	 * @since 3.2.0
118 118
 	 *
119 119
 	 */
120
-	public function add_update( $message ) {
120
+	public function add_update($message) {
121 121
 
122
-		$this->add( self::UPDATE, $message );
122
+		$this->add(self::UPDATE, $message);
123 123
 
124 124
 	}
125 125
 
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 	 * @since 3.2.0
132 132
 	 *
133 133
 	 */
134
-	public function add_update_nag( $message ) {
134
+	public function add_update_nag($message) {
135 135
 
136
-		$this->add( self::UPDATE_NAG, $message );
136
+		$this->add(self::UPDATE_NAG, $message);
137 137
 
138 138
 	}
139 139
 
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 * @since 3.2.0
146 146
 	 *
147 147
 	 */
148
-	public function add_error( $message ) {
148
+	public function add_error($message) {
149 149
 
150
-		$this->add( self::ERROR, $message );
150
+		$this->add(self::ERROR, $message);
151 151
 
152 152
 	}
153 153
 
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	 * @since 3.3.0
160 160
 	 *
161 161
 	 */
162
-	public function add_suggestion( $message ) {
162
+	public function add_suggestion($message) {
163 163
 
164
-		$this->add( self::SUGGESTION, $message );
164
+		$this->add(self::SUGGESTION, $message);
165 165
 
166 166
 	}
167 167
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	public function admin_notices() {
174 174
 
175
-		foreach ( $this->notices as $notice ) {
176
-			echo( $notice );
175
+		foreach ($this->notices as $notice) {
176
+			echo($notice);
177 177
 		}
178 178
 
179 179
 	}
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 	 * @since 3.3.0
187 187
 	 *
188 188
 	 */
189
-	private function transform( $message ) {
189
+	private function transform($message) {
190 190
 
191
-		switch ( gettype( $message ) ) {
191
+		switch (gettype($message)) {
192 192
 			case 'array':
193
-				return implode( $message, '<br />' );
193
+				return implode($message, '<br />');
194 194
 			default:
195 195
 				return $message;
196 196
 		}
Please login to merge, or discard this patch.