@@ -22,11 +22,11 @@ discard block |
||
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,9 +38,9 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected function getInstructionFields( $metabox ) |
40 | 40 | { |
41 | - return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) { |
|
42 | - return $this->validate( $field['condition'] ) && !in_array( $field['type'], ['divider', 'heading'] ) |
|
43 | - ? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL |
|
41 | + return array_reduce( $metabox[ 'fields' ], function( $html, $field ) use( $metabox ) { |
|
42 | + return $this->validate( $field[ 'condition' ] ) && !in_array( $field[ 'type' ], [ 'divider', 'heading' ] ) |
|
43 | + ? $html . $this->filter( 'instruction', "PostMeta::get('{$field[ 'slug' ]}');", $field, $metabox ) . PHP_EOL |
|
44 | 44 | : $html; |
45 | 45 | }); |
46 | 46 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | protected function getInstructionGroups() |
52 | 52 | { |
53 | 53 | return array_filter( $this->metaboxes, function( $metabox ) { |
54 | - return $this->validate( $metabox['condition'] ) |
|
54 | + return $this->validate( $metabox[ 'condition' ] ) |
|
55 | 55 | && $this->hasPostType( $metabox ); |
56 | 56 | }); |
57 | 57 | } |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | return [ |
66 | 66 | 'infodiv' => [ |
67 | 67 | 'context' => 'side', |
68 | - 'fields' => [[ |
|
68 | + 'fields' => [ [ |
|
69 | 69 | 'slug' => '', |
70 | 70 | 'std' => $this->generateInstructions(), |
71 | 71 | 'type' => 'custom_html', |
72 | - ]], |
|
72 | + ] ], |
|
73 | 73 | 'post_types' => $this->getPostTypes(), |
74 | 74 | 'priority' => 'low', |
75 | 75 | 'title' => __( 'How to use in your theme', 'pollux' ), |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) { |
86 | 86 | return $this->show( false, $metabox ); |
87 | - })) > 0 ); |
|
87 | + }) ) > 0 ); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -20,7 +20,8 @@ discard block |
||
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; |
@@ -38,7 +39,8 @@ discard block |
||
38 | 39 | */ |
39 | 40 | protected function getInstructionFields( $metabox ) |
40 | 41 | { |
41 | - return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) { |
|
42 | + return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) |
|
43 | + { |
|
42 | 44 | return $this->validate( $field['condition'] ) && !in_array( $field['type'], ['divider', 'heading'] ) |
43 | 45 | ? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL |
44 | 46 | : $html; |
@@ -50,7 +52,8 @@ discard block |
||
50 | 52 | */ |
51 | 53 | protected function getInstructionGroups() |
52 | 54 | { |
53 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
55 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
56 | + { |
|
54 | 57 | return $this->validate( $metabox['condition'] ) |
55 | 58 | && $this->hasPostType( $metabox ); |
56 | 59 | }); |
@@ -61,7 +64,9 @@ discard block |
||
61 | 64 | */ |
62 | 65 | protected function initInstructions() |
63 | 66 | { |
64 | - if( !$this->showInstructions() )return; |
|
67 | + if( !$this->showInstructions() ) { |
|
68 | + return; |
|
69 | + } |
|
65 | 70 | return [ |
66 | 71 | 'infodiv' => [ |
67 | 72 | 'context' => 'side', |
@@ -82,7 +87,8 @@ discard block |
||
82 | 87 | */ |
83 | 88 | protected function showInstructions() |
84 | 89 | { |
85 | - return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) { |
|
90 | + return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) |
|
91 | + { |
|
86 | 92 | return $this->show( false, $metabox ); |
87 | 93 | })) > 0 ); |
88 | 94 | } |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected function normalizeCondition( $conditions ) |
45 | 45 | { |
46 | - if( !is_array( $conditions )) { |
|
47 | - $conditions = []; |
|
46 | + if( !is_array( $conditions ) ) { |
|
47 | + $conditions = [ ]; |
|
48 | 48 | } |
49 | - if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) { |
|
49 | + if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) { |
|
50 | 50 | foreach( $conditions as $key ) { |
51 | - $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
51 | + $conditions[ str_replace( '!', '', $key ) ] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
52 | 52 | } |
53 | 53 | $conditions = array_filter( $conditions, function( $key ) { |
54 | 54 | return !is_numeric( $key ); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | return array_intersect_key( |
58 | 58 | $conditions, |
59 | - array_flip( $this->filter( 'conditions', static::conditions() )) |
|
59 | + array_flip( $this->filter( 'conditions', static::conditions() ) ) |
|
60 | 60 | ); |
61 | 61 | } |
62 | 62 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function validateIsFrontPage( $value ) |
104 | 104 | { |
105 | - return $value == ( $this->getPostId() == get_option( 'page_on_front' )); |
|
105 | + return $value == ( $this->getPostId() == get_option( 'page_on_front' ) ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function validateIsHome( $value ) |
113 | 113 | { |
114 | - return $value == ( $this->getPostId() == get_option( 'page_for_posts' )); |
|
114 | + return $value == ( $this->getPostId() == get_option( 'page_for_posts' ) ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | { |
123 | 123 | return ( new Helper )->endsWith( |
124 | 124 | $value, |
125 | - basename( get_page_template_slug( $this->getPostId() )) |
|
125 | + basename( get_page_template_slug( $this->getPostId() ) ) |
|
126 | 126 | ); |
127 | 127 | } |
128 | 128 |