Passed
Push — develop ( fd393c...93d897 )
by Paul
03:06
created
src/MetaBox/Instruction.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 	{
23 23
 		$instructions = array_reduce( $this->getInstructionGroups(), function( $html, $metabox ) {
24 24
 			$fields = $this->getInstructionFields( $metabox );
25
-			if( empty( $fields )) {
25
+			if( empty( $fields ) ) {
26 26
 				return $html;
27 27
 			}
28 28
 			return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>',
29
-				$metabox['title'],
29
+				$metabox[ 'title' ],
30 30
 				$fields
31 31
 			);
32 32
 		});
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	protected function getInstructionFields( $metabox )
40 40
 	{
41
-		$skipFields = ['custom_html', 'divider', 'heading'];
42
-		return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox, $skipFields ) {
43
-			return $this->validate( $field['condition'] ) && !in_array( $field['type'], $skipFields )
44
-				? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL
41
+		$skipFields = [ 'custom_html', 'divider', 'heading' ];
42
+		return array_reduce( $metabox[ 'fields' ], function( $html, $field ) use( $metabox, $skipFields ) {
43
+			return $this->validate( $field[ 'condition' ] ) && !in_array( $field[ 'type' ], $skipFields )
44
+				? $html . $this->filter( 'instruction', "PostMeta::get('{$field[ 'slug' ]}');", $field, $metabox ) . PHP_EOL
45 45
 				: $html;
46 46
 		});
47 47
 	}
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	protected function getInstructionGroups()
53 53
 	{
54 54
 		return array_filter( $this->metaboxes, function( $metabox ) {
55
-			return $this->validate( $metabox['condition'] )
55
+			return $this->validate( $metabox[ 'condition' ] )
56 56
 				&& $this->hasPostType( $metabox );
57 57
 		});
58 58
 	}
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 		return [
67 67
 			'infodiv' => [
68 68
 				'context' => 'side',
69
-				'fields' => [[
69
+				'fields' => [ [
70 70
 					'slug' => '',
71 71
 					'std' => $this->generateInstructions(),
72 72
 					'type' => 'custom_html',
73
-				]],
73
+				] ],
74 74
 				'post_types' => $this->getPostTypes(),
75 75
 				'priority' => 'low',
76 76
 				'title' => __( 'How to use in your theme', 'pollux' ),
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	{
86 86
 		return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) {
87 87
 			return $this->show( false, $metabox );
88
-		})) > 0 );
88
+		}) ) > 0 );
89 89
 	}
90 90
 
91 91
 	/**
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	protected function generateInstructions()
22 22
 	{
23
-		$instructions = array_reduce( $this->getInstructionGroups(), function( $html, $metabox ) {
23
+		$instructions = array_reduce( $this->getInstructionGroups(), function( $html, $metabox )
24
+		{
24 25
 			$fields = $this->getInstructionFields( $metabox );
25 26
 			if( empty( $fields )) {
26 27
 				return $html;
@@ -39,7 +40,8 @@  discard block
 block discarded – undo
39 40
 	protected function getInstructionFields( $metabox )
40 41
 	{
41 42
 		$skipFields = ['custom_html', 'divider', 'heading'];
42
-		return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox, $skipFields ) {
43
+		return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox, $skipFields )
44
+		{
43 45
 			return $this->validate( $field['condition'] ) && !in_array( $field['type'], $skipFields )
44 46
 				? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL
45 47
 				: $html;
@@ -51,7 +53,8 @@  discard block
 block discarded – undo
51 53
 	 */
52 54
 	protected function getInstructionGroups()
53 55
 	{
54
-		return array_filter( $this->metaboxes, function( $metabox ) {
56
+		return array_filter( $this->metaboxes, function( $metabox )
57
+		{
55 58
 			return $this->validate( $metabox['condition'] )
56 59
 				&& $this->hasPostType( $metabox );
57 60
 		});
@@ -62,7 +65,9 @@  discard block
 block discarded – undo
62 65
 	 */
63 66
 	protected function initInstructions()
64 67
 	{
65
-		if( !$this->showInstructions() )return;
68
+		if( !$this->showInstructions() ) {
69
+			return;
70
+		}
66 71
 		return [
67 72
 			'infodiv' => [
68 73
 				'context' => 'side',
@@ -83,7 +88,8 @@  discard block
 block discarded – undo
83 88
 	 */
84 89
 	protected function showInstructions()
85 90
 	{
86
-		return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) {
91
+		return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox )
92
+		{
87 93
 			return $this->show( false, $metabox );
88 94
 		})) > 0 );
89 95
 	}
Please login to merge, or discard this patch.