Passed
Push — develop ( 39ebd6...fc1005 )
by Paul
02:53
created
src/PostType/Archive.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -154,6 +154,7 @@
 block discarded – undo
154 154
 	}
155 155
 
156 156
 	/**
157
+	 * @param integer $imageId
157 158
 	 * @return void
158 159
 	 * @callback add_meta_box
159 160
 	 */
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 	public static $current;
18 18
 
19
-	public $hooks = [];
19
+	public $hooks = [ ];
20 20
 
21 21
 	/**
22 22
 	 * {@inheritdoc}
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 	{
26 26
 		parent::init();
27 27
 
28
-		add_action( 'wp_ajax_pollux/archives/featured/html', [$this, 'getFeaturedImageHtml'] );
29
-		add_action( 'pollux/archives/init',                  [$this, 'registerFeaturedImageMetaBox'] );
30
-		add_action( 'pollux/archives/editor',                [$this, 'renderEditor'], 10, 2 );
31
-		add_action( 'wp_ajax_pollux/archives/featured',      [$this, 'setFeaturedImage'] );
32
-		add_filter( 'pollux/archives/metabox/submit',        [$this, 'filterSubmitMetaBox'] );
33
-		add_filter( 'pollux/archives/show/instructions',     '__return_true' );
28
+		add_action( 'wp_ajax_pollux/archives/featured/html', [ $this, 'getFeaturedImageHtml' ] );
29
+		add_action( 'pollux/archives/init', [ $this, 'registerFeaturedImageMetaBox' ] );
30
+		add_action( 'pollux/archives/editor', [ $this, 'renderEditor' ], 10, 2 );
31
+		add_action( 'wp_ajax_pollux/archives/featured', [ $this, 'setFeaturedImage' ] );
32
+		add_filter( 'pollux/archives/metabox/submit', [ $this, 'filterSubmitMetaBox' ] );
33
+		add_filter( 'pollux/archives/show/instructions', '__return_true' );
34 34
 	}
35 35
 
36 36
 	/**
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 	public function addPage()
41 41
 	{
42 42
 		foreach( $this->getPostTypesWithArchive() as $type => $page ) {
43
-			$labels = get_post_type_labels( get_post_type_object( $type ));
44
-			$this->hooks[$type] = call_user_func_array( 'add_submenu_page', $this->filter( 'page', [
43
+			$labels = get_post_type_labels( get_post_type_object( $type ) );
44
+			$this->hooks[ $type ] = call_user_func_array( 'add_submenu_page', $this->filter( 'page', [
45 45
 				$page,
46 46
 				sprintf( _x( '%s Archive', 'post archive', 'pollux' ), $labels->singular_name ),
47 47
 				sprintf( _x( '%s Archive', 'post archive', 'pollux' ), $labels->singular_name ),
48 48
 				'edit_theme_options',
49 49
 				sprintf( '%s_archive', $type ),
50
-				[$this, 'renderPage'],
51
-			]));
50
+				[ $this, 'renderPage' ],
51
+			] ) );
52 52
 		}
53 53
 	}
54 54
 
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 	public function filterBeforeInstructions()
60 60
 	{
61 61
 		return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>',
62
-			array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) {
63
-				return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL;
62
+			array_reduce( [ 'title', 'content', 'featured' ], function( $instructions, $id ) {
63
+				return $instructions . $this->filterInstruction( null, [ 'slug' => $id ], [ 'slug' => $this->getPostType() ] ) . PHP_EOL;
64 64
 			})
65 65
 		);
66 66
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function filterInstruction( $instruction, array $field, array $metabox )
74 74
 	{
75
-		return sprintf( "ArchiveMeta::%s('%s');", $metabox['slug'], $field['slug'] );
75
+		return sprintf( "ArchiveMeta::%s('%s');", $metabox[ 'slug' ], $field[ 'slug' ] );
76 76
 	}
77 77
 
78 78
 	/**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function filterSubmitMetaBox( array $args )
83 83
 	{
84
-		$args[1] = __( 'Save Archive', 'pollux' );
84
+		$args[ 1 ] = __( 'Save Archive', 'pollux' );
85 85
 		return $args;
86 86
 	}
87 87
 
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function getFeaturedImageHtml()
94 94
 	{
95
-		check_ajax_referer( sprintf( '%s-options', static::id() ));
95
+		check_ajax_referer( sprintf( '%s-options', static::id() ) );
96 96
 		static::$current = filter_input( INPUT_POST, 'post_type' );
97 97
 		ob_start();
98
-		$this->renderFeaturedImageMetaBox( intval( filter_input( INPUT_POST, 'thumbnail_id' )));
98
+		$this->renderFeaturedImageMetaBox( intval( filter_input( INPUT_POST, 'thumbnail_id' ) ) );
99 99
 		wp_send_json_success( ob_get_clean() );
100 100
 	}
101 101
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	public function register()
118 118
 	{
119 119
 		$screenId = ( new Helper )->getCurrentScreen()->id;
120
-		if( in_array( $screenId, $this->hooks )) {
120
+		if( in_array( $screenId, $this->hooks ) ) {
121 121
 			$this->hook = $screenId;
122 122
 		}
123 123
 		parent::register();
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function registerFeaturedImageMetaBox()
131 131
 	{
132
-		if( !current_user_can( 'upload_files' ))return;
133
-		add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' );
132
+		if( !current_user_can( 'upload_files' ) )return;
133
+		add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [ $this, 'renderFeaturedImageMetaBox' ], null, 'side', 'low' );
134 134
 	}
135 135
 
136 136
 	/**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 				'resize' => false,
151 151
 				'wp_autoresize_on' => true,
152 152
 			],
153
-		]);
153
+		] );
154 154
 	}
155 155
 
156 156
 	/**
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function renderFeaturedImageMetaBox( $imageId = null )
161 161
 	{
162
-		if( !is_numeric( $imageId )) {
162
+		if( !is_numeric( $imageId ) ) {
163 163
 			$imageId = ArchiveMeta::get( 'featured', -1, $this->getPostType() );
164 164
 		}
165
-		$imageSize = isset( wp_get_additional_image_sizes()['post-thumbnail'] )
165
+		$imageSize = isset( wp_get_additional_image_sizes()[ 'post-thumbnail' ] )
166 166
 			? 'post-thumbnail'
167
-			: [266, 266];
167
+			: [ 266, 266 ];
168 168
 		$thumbnail = get_post( $imageId )
169 169
 			? wp_get_attachment_image( $imageId, $imageSize )
170 170
 			: __( 'Set Featured Image', 'pollux' );
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 			'post_type' => $this->getPostType(),
177 177
 			'remove_image' => __( 'Remove featured image', 'pollux' ),
178 178
 			'thumbnail' => $thumbnail,
179
-		]);
179
+		] );
180 180
 	}
181 181
 
182 182
 	/**
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	public function renderPage()
187 187
 	{
188 188
 		$type = $this->getPostType();
189
-		if( empty( $type ))return;
190
-		$labels = get_post_type_labels( get_post_type_object( $type ));
189
+		if( empty( $type ) )return;
190
+		$labels = get_post_type_labels( get_post_type_object( $type ) );
191 191
 		$this->render( 'archive/index', [
192 192
 			'columns' => get_current_screen()->get_columns(),
193 193
 			'content' => ArchiveMeta::get( 'content', '', $type ),
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			'id' => static::id(),
196 196
 			'post_type' => $type,
197 197
 			'title' => ArchiveMeta::get( 'title', '', $type ),
198
-		]);
198
+		] );
199 199
 	}
200 200
 
201 201
 	/**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 */
204 204
 	protected function getDefaults()
205 205
 	{
206
-		return [];
206
+		return [ ];
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	protected function getPostType()
213 213
 	{
214 214
 		$type = array_search( $this->hook, $this->hooks );
215
-		if( !empty( $type ) && is_string( $type )) {
215
+		if( !empty( $type ) && is_string( $type ) ) {
216 216
 			static::$current = $type;
217 217
 		}
218 218
 		return static::$current;
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	{
226 226
 		$types = array_map( function( $value ) {
227 227
 			return sprintf( 'edit.php?post_type=%s', $value );
228
-		}, get_post_types( ['has_archive' => 1] ));
229
-		return array_merge( $types, ['post' => 'edit.php'] );
228
+		}, get_post_types( [ 'has_archive' => 1 ] ) );
229
+		return array_merge( $types, [ 'post' => 'edit.php' ] );
230 230
 	}
231 231
 
232 232
 	/**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 	/**
13 13
 	 * @var string
14 14
 	 */
15
-	CONST ID = 'archives';
15
+	const ID = 'archives';
16 16
 
17 17
 	public static $current;
18 18
 
Please login to merge, or discard this patch.