Passed
Push — develop ( 87abfc...84da8f )
by Paul
02:47
created
src/Settings/RWMetaBox.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 		parent::__construct( $metabox );
16 16
 		$this->meta_box = static::normalize( $this->meta_box );
17 17
 
18
-		remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] );
19
-		remove_action( 'save_post_post', [$this, 'save_post'] );
18
+		remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] );
19
+		remove_action( 'save_post_post', [ $this, 'save_post' ] );
20 20
 
21
-		add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] );
22
-		add_filter( 'rwmb_field_meta',      [$this, '_get_field_meta'], 10, 3 );
21
+		add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] );
22
+		add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 );
23 23
 	}
24 24
 
25 25
 	/**
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function _get_field_meta( $meta, array $field, $saved )
32 32
 	{
33
-		if( !$this->is_edit_screen() || !empty(( new Helper )->toArray( $meta )) || empty( $field['slug'] )) {
33
+		if( !$this->is_edit_screen() || !empty( ( new Helper )->toArray( $meta ) ) || empty( $field[ 'slug' ] ) ) {
34 34
 			return $meta;
35 35
 		}
36
-		$meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved
37
-			? ( new SiteMeta )->get( $this->meta_box['slug'], $field['slug'], $meta )
38
-			: $field['std']
39
-		));
36
+		$meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved
37
+			? ( new SiteMeta )->get( $this->meta_box[ 'slug' ], $field[ 'slug' ], $meta )
38
+			: $field[ 'std' ]
39
+		) );
40 40
 		return $this->_normalize_field_meta( $meta, $field );
41 41
 	}
42 42
 
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function _normalize_field_meta( $meta, array $field )
48 48
 	{
49
-		if( !empty( $meta ) && is_array( $meta )) {
49
+		if( !empty( $meta ) && is_array( $meta ) ) {
50 50
 			return $meta;
51 51
 		}
52
-		if( $field['clone'] ) {
53
-			return [''];
52
+		if( $field[ 'clone' ] ) {
53
+			return [ '' ];
54 54
 		}
55
-		if( $field['multiple'] ) {
56
-			return [];
55
+		if( $field[ 'multiple' ] ) {
56
+			return [ ];
57 57
 		}
58 58
 		return $meta;
59 59
 	}
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 	public function add_meta_boxes()
66 66
 	{
67 67
 		add_meta_box(
68
-			$this->meta_box['id'],
69
-			$this->meta_box['title'],
70
-			[$this, 'show'],
68
+			$this->meta_box[ 'id' ],
69
+			$this->meta_box[ 'title' ],
70
+			[ $this, 'show' ],
71 71
 			null,
72
-			$this->meta_box['context'],
73
-			$this->meta_box['priority']
72
+			$this->meta_box[ 'context' ],
73
+			$this->meta_box[ 'priority' ]
74 74
 		);
75 75
 	}
76 76
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function is_edit_screen( $screen = null )
81 81
 	{
82
-		return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID ));
82
+		return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID ) );
83 83
 	}
84 84
 
85 85
 	/**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	public function is_saved()
89 89
 	{
90 90
 		foreach( array_column( $this->fields, 'slug' ) as $field ) {
91
-			if( !is_null(( new SiteMeta )->get( $this->meta_box['slug'], $field, null ))) {
91
+			if( !is_null( ( new SiteMeta )->get( $this->meta_box[ 'slug' ], $field, null ) ) ) {
92 92
 				return true;
93 93
 			}
94 94
 		}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public static function normalize( $metabox )
103 103
 	{
104
-		unset( $metabox['post_types'] );
105
-		return wp_parse_args( $metabox, ['slug' => ''] );
104
+		unset( $metabox[ 'post_types' ] );
105
+		return wp_parse_args( $metabox, [ 'slug' => '' ] );
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.
src/MetaBox/Instruction.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @var array
17 17
 	 */
18
-	public $metaboxes = [];
18
+	public $metaboxes = [ ];
19 19
 
20 20
 	/**
21 21
 	 * @return void
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
 	protected function addInstructions()
24 24
 	{
25 25
 		if( !$this->showInstructions() )return;
26
-		$this->normalize([
26
+		$this->normalize( [
27 27
 			'infodiv' => [
28 28
 				'context' => 'side',
29
-				'fields' => [[
29
+				'fields' => [ [
30 30
 					'slug' => '',
31 31
 					'std' => $this->generateInstructions(),
32 32
 					'type' => 'custom_html',
33
-				]],
33
+				] ],
34 34
 				'post_types' => $this->getPostTypes(),
35 35
 				'priority' => 'low',
36 36
 				'title' => __( 'How to use in your theme', 'pollux' ),
37 37
 			],
38
-		]);
38
+		] );
39 39
 	}
40 40
 
41 41
 	/**
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
 	protected function generateInstructions()
45 45
 	{
46 46
 		return array_reduce( $this->getInstructions(), function( $html, $metabox ) {
47
-			$fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) {
48
-				if( !$this->validate( $field['condition'] )) {
47
+			$fields = array_reduce( $metabox[ 'fields' ], function( $html, $field ) use( $metabox ) {
48
+				if( !$this->validate( $field[ 'condition' ] ) ) {
49 49
 					return $html;
50 50
 				}
51
-				$hook = sprintf( 'pollux/%s/instruction', strtolower(( new Helper )->getClassname( $this )));
52
-				return $html . apply_filters( $hook, "PostMeta::get('{$field['slug']}');", $field['slug'], $metabox['slug'] ) . PHP_EOL;
51
+				$hook = sprintf( 'pollux/%s/instruction', strtolower( ( new Helper )->getClassname( $this ) ) );
52
+				return $html . apply_filters( $hook, "PostMeta::get('{$field[ 'slug' ]}');", $field[ 'slug' ], $metabox[ 'slug' ] ) . PHP_EOL;
53 53
 			});
54 54
 			return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>',
55
-				$metabox['title'],
55
+				$metabox[ 'title' ],
56 56
 				$fields
57 57
 			);
58 58
 		});
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	protected function getInstructions()
65 65
 	{
66 66
 		return array_filter( $this->metaboxes, function( $metabox ) {
67
-			return $this->validate( $metabox['condition'] )
67
+			return $this->validate( $metabox[ 'condition' ] )
68 68
 				&& $this->hasPostType( $metabox );
69 69
 		});
70 70
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	{
77 77
 		return count( array_filter( $this->metaboxes, function( $metabox ) {
78 78
 			return $this->show( false, $metabox );
79
-		})) > 0;
79
+		}) ) > 0;
80 80
 	}
81 81
 
82 82
 	/**
@@ -103,5 +103,5 @@  discard block
 block discarded – undo
103 103
 	/**
104 104
 	 * @return void
105 105
 	 */
106
-	abstract protected function normalize( array $metaboxes, array $defaults = [] );
106
+	abstract protected function normalize( array $metaboxes, array $defaults = [ ] );
107 107
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	protected function addInstructions()
24 24
 	{
25
-		if( !$this->showInstructions() )return;
25
+		if( !$this->showInstructions() ) {
26
+			return;
27
+		}
26 28
 		$this->normalize([
27 29
 			'infodiv' => [
28 30
 				'context' => 'side',
@@ -43,8 +45,10 @@  discard block
 block discarded – undo
43 45
 	 */
44 46
 	protected function generateInstructions()
45 47
 	{
46
-		return array_reduce( $this->getInstructions(), function( $html, $metabox ) {
47
-			$fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) {
48
+		return array_reduce( $this->getInstructions(), function( $html, $metabox )
49
+		{
50
+			$fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox )
51
+			{
48 52
 				if( !$this->validate( $field['condition'] )) {
49 53
 					return $html;
50 54
 				}
@@ -63,7 +67,8 @@  discard block
 block discarded – undo
63 67
 	 */
64 68
 	protected function getInstructions()
65 69
 	{
66
-		return array_filter( $this->metaboxes, function( $metabox ) {
70
+		return array_filter( $this->metaboxes, function( $metabox )
71
+		{
67 72
 			return $this->validate( $metabox['condition'] )
68 73
 				&& $this->hasPostType( $metabox );
69 74
 		});
@@ -74,7 +79,8 @@  discard block
 block discarded – undo
74 79
 	 */
75 80
 	protected function showInstructions()
76 81
 	{
77
-		return count( array_filter( $this->metaboxes, function( $metabox ) {
82
+		return count( array_filter( $this->metaboxes, function( $metabox )
83
+		{
78 84
 			return $this->show( false, $metabox );
79 85
 		})) > 0;
80 86
 	}
Please login to merge, or discard this patch.