Completed
Pull Request — master (#51)
by Bui Quang
02:21
created
src/Admin/Notice.php 3 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -10,88 +10,88 @@
 block discarded – undo
10 10
 
11 11
 final class Notice 
12 12
 {
13
-    use Singleton;
13
+	use Singleton;
14 14
 
15
-    /**
16
-     * @traitDoc
17
-     */
18
-    public function initializes() 
19
-    {   
20
-        //
21
-    }
15
+	/**
16
+	 * @traitDoc
17
+	 */
18
+	public function initializes() 
19
+	{   
20
+		//
21
+	}
22 22
 
23
-    /**
24
-     * Type of notice, it can be 'success', 'error', 'warning', 'info'.
25
-     */
26
-    private $type;
23
+	/**
24
+	 * Type of notice, it can be 'success', 'error', 'warning', 'info'.
25
+	 */
26
+	private $type;
27 27
         
28
-    /**
29
-     * Message of the notice
30
-     */
31
-    private $message;
28
+	/**
29
+	 * Message of the notice
30
+	 */
31
+	private $message;
32 32
     
33
-    /**
34
-     * Add new notice to the admin dashboard.
35
-     *
36
-     * @param string $noticeMessage
37
-     * @param string $noticeType
38
-     * @since 1.0.0
39
-     * @return void
40
-     */
41
-    public function add($noticeMessage, $noticeType = 'info') 
42
-    {
43
-        $this->message = $noticeMessage;
44
-        $this->type = $noticeType;
33
+	/**
34
+	 * Add new notice to the admin dashboard.
35
+	 *
36
+	 * @param string $noticeMessage
37
+	 * @param string $noticeType
38
+	 * @since 1.0.0
39
+	 * @return void
40
+	 */
41
+	public function add($noticeMessage, $noticeType = 'info') 
42
+	{
43
+		$this->message = $noticeMessage;
44
+		$this->type = $noticeType;
45 45
         
46
-        \add_action( 'admin_notices', [$this, 'display']);
47
-    }
46
+		\add_action( 'admin_notices', [$this, 'display']);
47
+	}
48 48
     
49
-    /**
50
-     * Display notice template to the admin dashboard.
51
-     * 
52
-     * @since 1.0.0
53
-     * @return VA\Templater
54
-     */
55
-    public function display() 
56
-    {
57
-        if(!$this->message) return;
49
+	/**
50
+	 * Display notice template to the admin dashboard.
51
+	 * 
52
+	 * @since 1.0.0
53
+	 * @return VA\Templater
54
+	 */
55
+	public function display() 
56
+	{
57
+		if(!$this->message) return;
58 58
         
59
-        echo \wpdfi()->templater->render('admin/notice', [
60
-            'classes'   => $this->get_classes(),
61
-            'message'   => __($this->message, 'wpdfi')
62
-        ]);
63
-    }
59
+		echo \wpdfi()->templater->render('admin/notice', [
60
+			'classes'   => $this->get_classes(),
61
+			'message'   => __($this->message, 'wpdfi')
62
+		]);
63
+	}
64 64
     
65
-    /**
66
-     * Get all the classes of the notice
67
-     * 
68
-     * @since 1.0.0
69
-     * @return string
70
-     */
71
-    private function get_classes() 
72
-    {
73
-        return "notice notice-{$this->get_type()} is-dismissible";
74
-    }
65
+	/**
66
+	 * Get all the classes of the notice
67
+	 * 
68
+	 * @since 1.0.0
69
+	 * @return string
70
+	 */
71
+	private function get_classes() 
72
+	{
73
+		return "notice notice-{$this->get_type()} is-dismissible";
74
+	}
75 75
     
76
-    /**
77
-     * Get the type of the notice
78
-     *
79
-     * @since 1.0.0
80
-     * @return string
81
-     */ 
82
-    private function get_type()
83
-    {
84
-        return $this->type ? $this->type : $this->get_default_type();
85
-    }
76
+	/**
77
+	 * Get the type of the notice
78
+	 *
79
+	 * @since 1.0.0
80
+	 * @return string
81
+	 */ 
82
+	private function get_type()
83
+	{
84
+		return $this->type ? $this->type : $this->get_default_type();
85
+	}
86 86
     
87
-    /**
88
-     * Get default type of the notice
89
-     *
90
-     * @since 1.0.0
91
-     * @return string
92
-     */
93
-    private function get_default_type()
94
-    {
95
-        return 'info';
96
-    }
87
+	/**
88
+	 * Get default type of the notice
89
+	 *
90
+	 * @since 1.0.0
91
+	 * @return string
92
+	 */
93
+	private function get_default_type()
94
+	{
95
+		return 'info';
96
+	}
97 97
 }
98 98
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $this->message = $noticeMessage;
44 44
         $this->type = $noticeType;
45 45
         
46
-        \add_action( 'admin_notices', [$this, 'display']);
46
+        \add_action('admin_notices', [$this, 'display']);
47 47
     }
48 48
     
49 49
     /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function display() 
56 56
     {
57
-        if(!$this->message) return;
57
+        if (!$this->message) return;
58 58
         
59 59
         echo \wpdfi()->templater->render('admin/notice', [
60 60
             'classes'   => $this->get_classes(),
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@
 block discarded – undo
54 54
      */
55 55
     public function display() 
56 56
     {
57
-        if(!$this->message) return;
57
+        if(!$this->message) {
58
+        	return;
59
+        }
58 60
         
59 61
         echo \wpdfi()->templater->render('admin/notice', [
60 62
             'classes'   => $this->get_classes(),
Please login to merge, or discard this patch.
src/Admin.php 3 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 		\wp_enqueue_media();
44 44
 	}
45 45
 
46
-    /**
47
-     * Add new setting menu
48
-     *
49
-     * @since 1.0.0
50
-     * @return void
51
-     */
46
+	/**
47
+	 * Add new setting menu
48
+	 *
49
+	 * @since 1.0.0
50
+	 * @return void
51
+	 */
52 52
 	public function setting_menu() {
53 53
 		\add_options_page( 'WPDFI', 'WPDFI', 'manage_options', 'wpdfi-settings.php', [$this, 'render_layout']);
54 54
 	}
@@ -141,28 +141,28 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function update_settings() {
143 143
 		if(isset($_GET['page']) and $_GET['page'] == 'wpdfi-settings.php' and isset($_POST['_wpnonce'])) {
144
-            $nonce = $_POST['_wpnonce'];
145
-            if ( ! \wp_verify_nonce( $nonce, 'wpdfi-settings-page' ) ) {
146
-                // This nonce is not valid.
147
-                return;
148
-            } else {
149
-            	// Dont need to store wp_nonce value
150
-                unset($_POST['_wpnonce']);
151
-                unset($_POST['_wp_http_referer']);
144
+			$nonce = $_POST['_wpnonce'];
145
+			if ( ! \wp_verify_nonce( $nonce, 'wpdfi-settings-page' ) ) {
146
+				// This nonce is not valid.
147
+				return;
148
+			} else {
149
+				// Dont need to store wp_nonce value
150
+				unset($_POST['_wpnonce']);
151
+				unset($_POST['_wp_http_referer']);
152 152
                 
153
-                $options = $this->_get_options();
154
-                foreach($_POST as $key => $value) {
155
-                	$options[$key] = $value;
156
-                }
153
+				$options = $this->_get_options();
154
+				foreach($_POST as $key => $value) {
155
+					$options[$key] = $value;
156
+				}
157 157
 
158
-                if($this->_update_options($options)) {
159
-                	\wpdfi()->admin_notice->add('Settings Saved.', 'success');
160
-                } else {
161
-                	\wpdfi()->admin_notice->add('Your options are still the same.', 'warning');
162
-                }
158
+				if($this->_update_options($options)) {
159
+					\wpdfi()->admin_notice->add('Settings Saved.', 'success');
160
+				} else {
161
+					\wpdfi()->admin_notice->add('Your options are still the same.', 'warning');
162
+				}
163 163
                 
164
-            }   
165
-        }
164
+			}   
165
+		}
166 166
 	}	
167 167
 
168 168
 	/**
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 	 * @return void
29 29
 	 */
30 30
 	public function hooks() {
31
-		\add_action( 'admin_enqueue_scripts', [$this, 'wpdfi_enqueue_scripts']);
32
-		\add_action( 'admin_menu', [$this, 'setting_menu'] );
33
-		\add_action( 'init', [$this, 'update_settings']);	
31
+		\add_action('admin_enqueue_scripts', [$this, 'wpdfi_enqueue_scripts']);
32
+		\add_action('admin_menu', [$this, 'setting_menu']);
33
+		\add_action('init', [$this, 'update_settings']);	
34 34
 	}
35 35
 
36 36
 	/**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @return void
51 51
      */
52 52
 	public function setting_menu() {
53
-		\add_options_page( 'WPDFI', 'WPDFI', 'manage_options', 'wpdfi-settings.php', [$this, 'render_layout']);
53
+		\add_options_page('WPDFI', 'WPDFI', 'manage_options', 'wpdfi-settings.php', [$this, 'render_layout']);
54 54
 	}
55 55
 
56 56
 	/**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	public function render_layout() {
63 63
 		global $pagenow;
64 64
 		// Exit if this is not options and WP Default Thumbnail settings page
65
-		if($pagenow != 'options-general.php' or $_GET['page'] != 'wpdfi-settings.php') return;
65
+		if ($pagenow != 'options-general.php' or $_GET['page'] != 'wpdfi-settings.php') return;
66 66
 		
67 67
 		echo \wpdfi()->layout->get_admin_layout(
68 68
 			$this->_get_tabs(), $this->_get_current_tab(), $this->_get_options(), $this->_get_layout_name()
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 	 * @return void
141 141
 	 */
142 142
 	public function update_settings() {
143
-		if(isset($_GET['page']) and $_GET['page'] == 'wpdfi-settings.php' and isset($_POST['_wpnonce'])) {
143
+		if (isset($_GET['page']) and $_GET['page'] == 'wpdfi-settings.php' and isset($_POST['_wpnonce'])) {
144 144
             $nonce = $_POST['_wpnonce'];
145
-            if ( ! \wp_verify_nonce( $nonce, 'wpdfi-settings-page' ) ) {
145
+            if (!\wp_verify_nonce($nonce, 'wpdfi-settings-page')) {
146 146
                 // This nonce is not valid.
147 147
                 return;
148 148
             } else {
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
                 unset($_POST['_wp_http_referer']);
152 152
                 
153 153
                 $options = $this->_get_options();
154
-                foreach($_POST as $key => $value) {
154
+                foreach ($_POST as $key => $value) {
155 155
                 	$options[$key] = $value;
156 156
                 }
157 157
 
158
-                if($this->_update_options($options)) {
158
+                if ($this->_update_options($options)) {
159 159
                 	\wpdfi()->admin_notice->add('Settings Saved.', 'success');
160 160
                 } else {
161 161
                 	\wpdfi()->admin_notice->add('Your options are still the same.', 'warning');
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @return mixed(string/array)
175 175
 	 */
176 176
 	public function get_option($option_key, $option_detail = null) {
177
-		if($option_detail) return $this->_get_options()[$option_key][$option_detail];
177
+		if ($option_detail) return $this->_get_options()[$option_key][$option_detail];
178 178
 		return $this->_get_options()[$option_key];
179 179
 	}
180 180
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,9 @@  discard block
 block discarded – undo
62 62
 	public function render_layout() {
63 63
 		global $pagenow;
64 64
 		// Exit if this is not options and WP Default Thumbnail settings page
65
-		if($pagenow != 'options-general.php' or $_GET['page'] != 'wpdfi-settings.php') return;
65
+		if($pagenow != 'options-general.php' or $_GET['page'] != 'wpdfi-settings.php') {
66
+			return;
67
+		}
66 68
 		
67 69
 		echo \wpdfi()->layout->get_admin_layout(
68 70
 			$this->_get_tabs(), $this->_get_current_tab(), $this->_get_options(), $this->_get_layout_name()
@@ -174,7 +176,9 @@  discard block
 block discarded – undo
174 176
 	 * @return mixed(string/array)
175 177
 	 */
176 178
 	public function get_option($option_key, $option_detail = null) {
177
-		if($option_detail) return $this->_get_options()[$option_key][$option_detail];
179
+		if($option_detail) {
180
+			return $this->_get_options()[$option_key][$option_detail];
181
+		}
178 182
 		return $this->_get_options()[$option_key];
179 183
 	}
180 184
 
Please login to merge, or discard this patch.
wpdfi.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
  * @return WPDFI  Singleton instance of plugin class.
117 117
  */
118 118
 function wpdfi() {
119
-    return WPDFI::instance();
119
+	return WPDFI::instance();
120 120
 }
121 121
 
122 122
 add_action('plugins_loaded', [wpdfi(), 'hooks']);
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@  discard block
 block discarded – undo
8 8
  * License: GNUv3
9 9
  * Text Domain: wpdfi
10 10
  */
11
-define('WPDFI_PLUGIN', __FILE__ );
12
-define('WPDFI_PLUGIN_BASENAME', plugin_basename( WPDFI_PLUGIN ) );
13
-define('WPDFI_URL_BASE', plugin_dir_url( WPDFI_PLUGIN) );
14
-define('WPDFI_DIR_BASE', plugin_dir_path( WPDFI_PLUGIN ) );
15
-define('WPDFI_ASSETS', WPDFI_URL_BASE . '/assets/' );
16
-define('WPDFI_TEMPLATES_PATH', WPDFI_DIR_BASE.  '/templates/');
11
+define('WPDFI_PLUGIN', __FILE__);
12
+define('WPDFI_PLUGIN_BASENAME', plugin_basename(WPDFI_PLUGIN));
13
+define('WPDFI_URL_BASE', plugin_dir_url(WPDFI_PLUGIN));
14
+define('WPDFI_DIR_BASE', plugin_dir_path(WPDFI_PLUGIN));
15
+define('WPDFI_ASSETS', WPDFI_URL_BASE.'/assets/');
16
+define('WPDFI_TEMPLATES_PATH', WPDFI_DIR_BASE.'/templates/');
17 17
 
18
-require_once WPDFI_DIR_BASE . '/vendor/autoload.php';
18
+require_once WPDFI_DIR_BASE.'/vendor/autoload.php';
19 19
 
20 20
 use WPDFI\Traits\HasModule;
21 21
 use WPDFI\Traits\Singleton;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	public function hooks() 
53 53
 	{
54 54
 
55
-		add_action( 'init', [$this, 'init']);
55
+		add_action('init', [$this, 'init']);
56 56
 
57 57
 		/* Load all module hooks */
58 58
 		$this->moduleHooks();
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	public function install() {
69 69
 
70 70
 		$options = get_option('wpdfi-settings');
71
-		if(!$options['options']['status_for_update']) {
71
+		if (!$options['options']['status_for_update']) {
72 72
 			$options['options']['status_for_update'] = 'publish';
73 73
 			update_option('wpdfi-settings', $options);
74 74
 		}
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function init() 
85 85
 	{
86
-		load_plugin_textdomain('wpdfi', false, WPDFI_DIR_BASE . '/lang/');
86
+		load_plugin_textdomain('wpdfi', false, WPDFI_DIR_BASE.'/lang/');
87 87
 	}
88 88
 	
89 89
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 			'admin'		=> Admin::instance()
102 102
 		];
103 103
 			
104
-		foreach($modules as $moduleName => $moduleHandle) {
104
+		foreach ($modules as $moduleName => $moduleHandle) {
105 105
 			$this->module($moduleName, $moduleHandle);
106 106
 		}
107 107
 		
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 /* All uninstall actions of this plugin come here */
3 3
 
4 4
 
5
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
5
+if (!defined('WP_UNINSTALL_PLUGIN')) {
6 6
 	exit();
7 7
 }
8 8
 
Please login to merge, or discard this patch.