@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function buildClassName( $name, $path = '' ) |
15 | 15 | { |
16 | - $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ))); |
|
16 | + $className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ) ) ); |
|
17 | 17 | $className = implode( '', $className ); |
18 | 18 | return !empty( $path ) |
19 | - ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className )) |
|
19 | + ? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ) ) |
|
20 | 20 | : $className; |
21 | 21 | } |
22 | 22 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function buildMethodName( $name, $prefix = 'get' ) |
29 | 29 | { |
30 | - return lcfirst( $this->buildClassName( $prefix . '-' . $name )); |
|
30 | + return lcfirst( $this->buildClassName( $prefix . '-' . $name ) ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getClassname( $fromClass ) |
38 | 38 | { |
39 | - $paths = explode( '\\', get_class( $fromClass )); |
|
39 | + $paths = explode( '\\', get_class( $fromClass ) ); |
|
40 | 40 | return end( $paths ); |
41 | 41 | } |
42 | 42 |
@@ -37,18 +37,18 @@ discard block |
||
37 | 37 | protected function normalizeCondition( $conditions ) |
38 | 38 | { |
39 | 39 | $conditions = ( new Helper )->toArray( $conditions ); |
40 | - if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) { |
|
40 | + if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) { |
|
41 | 41 | foreach( $conditions as $key ) { |
42 | - $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
42 | + $conditions[ str_replace( '!', '', $key ) ] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
|
43 | 43 | } |
44 | 44 | $conditions = array_filter( $conditions, function( $key ) { |
45 | 45 | return !is_numeric( $key ); |
46 | 46 | }, ARRAY_FILTER_USE_KEY ); |
47 | 47 | } |
48 | - $hook = sprintf( 'pollux/%s/conditions', strtolower(( new Helper )->getClassname( $this ))); |
|
48 | + $hook = sprintf( 'pollux/%s/conditions', strtolower( ( new Helper )->getClassname( $this ) ) ); |
|
49 | 49 | return array_intersect_key( |
50 | 50 | $conditions, |
51 | - array_flip( apply_filters( $hook, static::$conditions )) |
|
51 | + array_flip( apply_filters( $hook, static::$conditions ) ) |
|
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | protected function validateIsFrontPage( $value ) |
96 | 96 | { |
97 | - return $value == ( $this->getPostId() == get_option( 'page_on_front' )); |
|
97 | + return $value == ( $this->getPostId() == get_option( 'page_on_front' ) ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function validateIsHome( $value ) |
105 | 105 | { |
106 | - return $value == ( $this->getPostId() == get_option( 'page_for_posts' )); |
|
106 | + return $value == ( $this->getPostId() == get_option( 'page_for_posts' ) ); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function validateIsPageTemplate( $value ) |
114 | 114 | { |
115 | - return basename( get_page_template_slug( $this->getPostId() )) == $value; |
|
115 | + return basename( get_page_template_slug( $this->getPostId() ) ) == $value; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @var array |
17 | 17 | */ |
18 | - public $metaboxes = []; |
|
18 | + public $metaboxes = [ ]; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @return void |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | { |
25 | 25 | if( !count( array_filter( $this->metaboxes, function( $metabox ) { |
26 | 26 | return $this->show( false, $metabox ); |
27 | - })))return; |
|
28 | - $this->metaboxes[] = [ |
|
27 | + }) ) )return; |
|
28 | + $this->metaboxes[ ] = [ |
|
29 | 29 | 'id' => 'infodiv', |
30 | 30 | 'post_types' => $this->getPostTypes(), |
31 | 31 | 'title' => __( 'How to use in your theme', 'pollux' ), |
32 | 32 | 'context' => 'side', |
33 | 33 | 'priority' => 'low', |
34 | - 'fields' => [[ |
|
34 | + 'fields' => [ [ |
|
35 | 35 | 'slug' => '', |
36 | 36 | 'std' => $this->generateInstructions(), |
37 | 37 | 'type' => 'custom_html', |
38 | - ]], |
|
38 | + ] ], |
|
39 | 39 | ]; |
40 | 40 | } |
41 | 41 | |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | protected function generateInstructions() |
46 | 46 | { |
47 | 47 | return array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
48 | - $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
49 | - $hook = sprintf( 'pollux/%s/instruction', strtolower(( new Helper )->getClassname( $this ))); |
|
50 | - error_log( print_r( $hook, 1 )); |
|
51 | - return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL; |
|
48 | + $fields = array_reduce( array_column( $metabox[ 'fields' ], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
49 | + $hook = sprintf( 'pollux/%s/instruction', strtolower( ( new Helper )->getClassname( $this ) ) ); |
|
50 | + error_log( print_r( $hook, 1 ) ); |
|
51 | + return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox[ 'slug' ] ) . PHP_EOL; |
|
52 | 52 | }); |
53 | 53 | return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
54 | - $metabox['title'], |
|
54 | + $metabox[ 'title' ], |
|
55 | 55 | $fields |
56 | 56 | ); |
57 | 57 | }); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | protected function getInstructions() |
64 | 64 | { |
65 | 65 | return array_filter( $this->metaboxes, function( $metabox ) { |
66 | - return $this->validate( $metabox['condition'] ) |
|
66 | + return $this->validate( $metabox[ 'condition' ] ) |
|
67 | 67 | && $this->hasPostType( $metabox ); |
68 | 68 | }); |
69 | 69 | } |
@@ -22,9 +22,12 @@ discard block |
||
22 | 22 | */ |
23 | 23 | protected function addInstructions() |
24 | 24 | { |
25 | - if( !count( array_filter( $this->metaboxes, function( $metabox ) { |
|
25 | + if( !count( array_filter( $this->metaboxes, function( $metabox ) |
|
26 | + { |
|
26 | 27 | return $this->show( false, $metabox ); |
27 | - })))return; |
|
28 | + }))) { |
|
29 | + return; |
|
30 | + } |
|
28 | 31 | $this->metaboxes[] = [ |
29 | 32 | 'id' => 'infodiv', |
30 | 33 | 'post_types' => $this->getPostTypes(), |
@@ -44,8 +47,10 @@ discard block |
||
44 | 47 | */ |
45 | 48 | protected function generateInstructions() |
46 | 49 | { |
47 | - return array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
|
48 | - $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
50 | + return array_reduce( $this->getInstructions(), function( $html, $metabox ) |
|
51 | + { |
|
52 | + $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) |
|
53 | + { |
|
49 | 54 | $hook = sprintf( 'pollux/%s/instruction', strtolower(( new Helper )->getClassname( $this ))); |
50 | 55 | error_log( print_r( $hook, 1 )); |
51 | 56 | return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL; |
@@ -62,7 +67,8 @@ discard block |
||
62 | 67 | */ |
63 | 68 | protected function getInstructions() |
64 | 69 | { |
65 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
70 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
71 | + { |
|
66 | 72 | return $this->validate( $metabox['condition'] ) |
67 | 73 | && $this->hasPostType( $metabox ); |
68 | 74 | }); |