@@ -23,19 +23,19 @@ discard block |
||
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,13 +44,13 @@ discard block |
||
44 | 44 | protected function generateInstructions() |
45 | 45 | { |
46 | 46 | $instructions = array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
47 | - $fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) { |
|
48 | - return $this->validate( $field['condition'] ) |
|
49 | - ? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL |
|
47 | + $fields = array_reduce( $metabox[ 'fields' ], function( $html, $field ) use( $metabox ) { |
|
48 | + return $this->validate( $field[ 'condition' ] ) |
|
49 | + ? $html . $this->filter( 'instruction', "PostMeta::get('{$field[ 'slug' ]}');", $field, $metabox ) . PHP_EOL |
|
50 | 50 | : $html; |
51 | 51 | }); |
52 | 52 | return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
53 | - $metabox['title'], |
|
53 | + $metabox[ 'title' ], |
|
54 | 54 | $fields |
55 | 55 | ); |
56 | 56 | }); |
@@ -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 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | { |
76 | 76 | return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) { |
77 | 77 | return $this->show( false, $metabox ); |
78 | - })) > 0 ); |
|
78 | + }) ) > 0 ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -107,5 +107,5 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * @return void |
109 | 109 | */ |
110 | - abstract protected function normalize( array $metaboxes, array $defaults = [] ); |
|
110 | + abstract protected function normalize( array $metaboxes, array $defaults = [ ] ); |
|
111 | 111 | } |
@@ -22,7 +22,9 @@ discard block |
||
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 |
||
43 | 45 | */ |
44 | 46 | protected function generateInstructions() |
45 | 47 | { |
46 | - $instructions = array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
|
47 | - $fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) { |
|
48 | + $instructions = array_reduce( $this->getInstructions(), function( $html, $metabox ) |
|
49 | + { |
|
50 | + $fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) |
|
51 | + { |
|
48 | 52 | return $this->validate( $field['condition'] ) |
49 | 53 | ? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL |
50 | 54 | : $html; |
@@ -62,7 +66,8 @@ discard block |
||
62 | 66 | */ |
63 | 67 | protected function getInstructions() |
64 | 68 | { |
65 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
69 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
70 | + { |
|
66 | 71 | return $this->validate( $metabox['condition'] ) |
67 | 72 | && $this->hasPostType( $metabox ); |
68 | 73 | }); |
@@ -73,7 +78,8 @@ discard block |
||
73 | 78 | */ |
74 | 79 | protected function showInstructions() |
75 | 80 | { |
76 | - return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) { |
|
81 | + return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) |
|
82 | + { |
|
77 | 83 | return $this->show( false, $metabox ); |
78 | 84 | })) > 0 ); |
79 | 85 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | public function __construct() |
19 | 19 | { |
20 | - $this->options = get_option( Settings::id(), [] ); |
|
20 | + $this->options = get_option( Settings::id(), [ ] ); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | { |
29 | 29 | $args = array_pad( $args, 2, null ); |
30 | 30 | $group = $this->$group; |
31 | - if( is_object( $group )) { |
|
31 | + if( is_object( $group ) ) { |
|
32 | 32 | return $group; |
33 | 33 | } |
34 | - return $this->get( $group, $args[0], $args[1] ); |
|
34 | + return $this->get( $group, $args[ 0 ], $args[ 1 ] ); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | if( $group == 'all' ) { |
44 | 44 | return (object) $this->options; |
45 | 45 | } |
46 | - if( empty( $group )) { |
|
46 | + if( empty( $group ) ) { |
|
47 | 47 | $group = $this->getDefaultGroup(); |
48 | 48 | } |
49 | - return isset( $this->options[$group] ) |
|
50 | - ? $this->options[$group] |
|
49 | + return isset( $this->options[ $group ] ) |
|
50 | + ? $this->options[ $group ] |
|
51 | 51 | : null; |
52 | 52 | } |
53 | 53 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | if( func_num_args() < 1 ) { |
63 | 63 | return $this->all; |
64 | 64 | } |
65 | - if( is_string( $group )) { |
|
65 | + if( is_string( $group ) ) { |
|
66 | 66 | $group = $this->$group; |
67 | 67 | } |
68 | - if( !is_array( $group )) { |
|
68 | + if( !is_array( $group ) ) { |
|
69 | 69 | return $fallback; |
70 | 70 | } |
71 | - if( is_null( $key )) { |
|
71 | + if( is_null( $key ) ) { |
|
72 | 72 | return $group; |
73 | 73 | } |
74 | 74 | return $this->getValue( $group, $key, $fallback ); |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function getValue( array $group, $key, $fallback ) |
91 | 91 | { |
92 | - if( !array_key_exists( $key, $group )) { |
|
92 | + if( !array_key_exists( $key, $group ) ) { |
|
93 | 93 | return $fallback; |
94 | 94 | } |
95 | - return empty( $group[$key] ) && !is_null( $fallback ) |
|
95 | + return empty( $group[ $key ] ) && !is_null( $fallback ) |
|
96 | 96 | ? $fallback |
97 | - : $group[$key]; |
|
97 | + : $group[ $key ]; |
|
98 | 98 | } |
99 | 99 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | { |
17 | 17 | public function __construct() |
18 | 18 | { |
19 | - $this->options = get_option( Archive::id(), [] ); |
|
19 | + $this->options = get_option( Archive::id(), [ ] ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -4,7 +4,7 @@ |
||
4 | 4 | <a href="<?= $thickbox_url; ?>" id="set-post-thumbnail" class="thickbox"><?= $thumbnail; ?></a> |
5 | 5 | </p> |
6 | 6 | |
7 | -<?php if( get_post( $image_id )) : ?> |
|
7 | +<?php if( get_post( $image_id ) ) : ?> |
|
8 | 8 | |
9 | 9 | <p class="hide-if-no-js howto" id="set-post-thumbnail-desc"><?= $edit_image; ?></p> |
10 | 10 | <p class="hide-if-no-js"> |
@@ -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 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public function getCurrentScreen() |
64 | 64 | { |
65 | 65 | global $current_screen, $pagenow; |
66 | - if( isset( $current_screen )) { |
|
66 | + if( isset( $current_screen ) ) { |
|
67 | 67 | $current_screen->pagenow = $pagenow; |
68 | 68 | return $current_screen; |
69 | 69 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function startsWith( $needle, $haystack ) |
83 | 83 | { |
84 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
84 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |