@@ -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 |
@@ -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 | }); |