@@ -31,7 +31,8 @@ |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | private function __clone() |
34 | - {} |
|
34 | + { |
|
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Get or create the singleton alias loader instance. |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function getInstance( array $aliases = [] ) |
42 | 42 | { |
43 | - if( is_null( static::$instance )) { |
|
44 | - return static::$instance = new static( $aliases ); |
|
43 | + if( is_null( static::$instance ) ) { |
|
44 | + return static::$instance = new static($aliases); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $aliases = array_merge( static::$instance->aliases, $aliases ); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function load( $alias ) |
62 | 62 | { |
63 | - if( isset( $this->aliases[$alias] )) { |
|
63 | + if( isset($this->aliases[$alias]) ) { |
|
64 | 64 | return class_alias( $this->aliases[$alias], $alias ); |
65 | 65 | } |
66 | 66 | } |
@@ -12,7 +12,9 @@ |
||
12 | 12 | */ |
13 | 13 | public function get( $metaKey, array $args = [] ) |
14 | 14 | { |
15 | - if( empty( $metaKey ))return; |
|
15 | + if( empty( $metaKey )) { |
|
16 | + return; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $args = $this->normalize( $args ); |
18 | 20 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
@@ -18,16 +18,16 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function get( $metaKey, array $args = [] ) |
20 | 20 | { |
21 | - if( empty( $metaKey ))return; |
|
21 | + if( empty($metaKey) )return; |
|
22 | 22 | |
23 | 23 | $args = $this->normalize( $args ); |
24 | 24 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
25 | 25 | $metaValue = get_post_meta( $args['id'], $metaKey, $args['single'] ); |
26 | 26 | |
27 | - if( is_string( $metaValue )) { |
|
27 | + if( is_string( $metaValue ) ) { |
|
28 | 28 | $metaValue = trim( $metaValue ); |
29 | 29 | } |
30 | - return empty( $metaValue ) |
|
30 | + return empty($metaValue) |
|
31 | 31 | ? $args['fallback'] |
32 | 32 | : $metaValue; |
33 | 33 | } |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | */ |
40 | 40 | protected function buildMetaKey( $metaKey, $prefix ) |
41 | 41 | { |
42 | - return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix )) |
|
42 | + return (substr( $metaKey, 0, 1 ) == '_' && !empty($prefix)) |
|
43 | 43 | ? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey ) |
44 | - : $prefix . $metaKey; |
|
44 | + : $prefix.$metaKey; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -55,6 +55,6 @@ discard block |
||
55 | 55 | 'single' => true, |
56 | 56 | 'prefix' => Application::prefix(), |
57 | 57 | ]; |
58 | - return shortcode_atts( $defaults, array_change_key_case( $args )); |
|
58 | + return shortcode_atts( $defaults, array_change_key_case( $args ) ); |
|
59 | 59 | } |
60 | 60 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if( !function_exists( 'pollux_app' )) { |
|
3 | +if( !function_exists( 'pollux_app' ) ) { |
|
4 | 4 | function pollux_app() { |
5 | 5 | return GeminiLabs\Pollux\Application::getInstance(); |
6 | 6 | } |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if( !function_exists( 'pollux_app' )) { |
4 | - function pollux_app() { |
|
4 | + function pollux_app() |
|
5 | + { |
|
5 | 6 | return GeminiLabs\Pollux\Application::getInstance(); |
6 | 7 | } |
7 | 8 | } |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function init() |
39 | 39 | { |
40 | - if( $this->app->config->disable_config )return; |
|
40 | + if( $this->app->config->disable_config ) { |
|
41 | + return; |
|
42 | + } |
|
41 | 43 | |
42 | 44 | add_action( 'admin_menu', [$this, 'registerPage'] ); |
43 | 45 | add_action( 'admin_menu', [$this, 'registerSetting'] ); |
@@ -107,7 +109,9 @@ discard block |
||
107 | 109 | { |
108 | 110 | if( filter_input( INPUT_GET, 'page' ) !== $this->app->id |
109 | 111 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
110 | - )return; |
|
112 | + ) { |
|
113 | + return; |
|
114 | + } |
|
111 | 115 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) { |
112 | 116 | delete_option( static::id() ); |
113 | 117 | $this->app->make( ConfigManager::class )->compile( true ); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public static function id() |
26 | 26 | { |
27 | - return Application::PREFIX . static::ID; |
|
27 | + return Application::PREFIX.static::ID; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function __construct( Application $app ) |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | { |
40 | 40 | if( $this->app->config->disable_config )return; |
41 | 41 | |
42 | - add_action( 'admin_menu', [$this, 'registerPage'] ); |
|
43 | - add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
42 | + add_action( 'admin_menu', [$this, 'registerPage'] ); |
|
43 | + add_action( 'admin_menu', [$this, 'registerSetting'] ); |
|
44 | 44 | add_action( 'current_screen', [$this, 'resetPage'] ); |
45 | 45 | } |
46 | 46 | |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | 'config' => $this->app->make( ConfigManager::class ), |
95 | 95 | 'heading' => __( 'Pollux Settings', 'pollux' ), |
96 | 96 | 'id' => static::id(), |
97 | - 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'options-general.php' ))), |
|
97 | + 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'options-general.php' ) ) ), |
|
98 | 98 | 'has_meta_box' => $this->app->gatekeeper->hasDependency( 'meta-box/meta-box.php' ), |
99 | - ]); |
|
99 | + ] ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -108,16 +108,16 @@ discard block |
||
108 | 108 | if( filter_input( INPUT_GET, 'page' ) !== $this->app->id |
109 | 109 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
110 | 110 | )return; |
111 | - if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) { |
|
111 | + if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() ) ) { |
|
112 | 112 | delete_option( static::id() ); |
113 | 113 | $this->app->make( ConfigManager::class )->compile( true ); |
114 | 114 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
115 | 115 | } |
116 | 116 | else { |
117 | - add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' )); |
|
117 | + add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ) ); |
|
118 | 118 | } |
119 | 119 | set_transient( 'settings_errors', get_settings_errors(), 30 ); |
120 | - wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() )); |
|
120 | + wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() ) ); |
|
121 | 121 | exit; |
122 | 122 | } |
123 | 123 | } |
@@ -4,8 +4,8 @@ |
||
4 | 4 | * Compatibility with Give WP plugin |
5 | 5 | */ |
6 | 6 | add_filter( 'give_load_admin_scripts', function( $is_admin_page, $hook ) { |
7 | - $needle = sprintf( '_page_%s', filter_input( INPUT_GET, 'page' )); |
|
8 | - return substr( $hook, - strlen( $needle )) !== $needle |
|
7 | + $needle = sprintf( '_page_%s', filter_input( INPUT_GET, 'page' ) ); |
|
8 | + return substr( $hook, - strlen( $needle ) ) !== $needle |
|
9 | 9 | ? $is_admin_page |
10 | 10 | : true; |
11 | 11 | }, 10, 2 ); |
@@ -40,7 +40,9 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function filterWordPressFooter( $text ) |
42 | 42 | { |
43 | - if( $this->app->config->remove_wordpress_footer )return; |
|
43 | + if( $this->app->config->remove_wordpress_footer ) { |
|
44 | + return; |
|
45 | + } |
|
44 | 46 | return $text; |
45 | 47 | } |
46 | 48 | |
@@ -79,7 +81,9 @@ discard block |
||
79 | 81 | */ |
80 | 82 | public function removeDashboardWidgets() |
81 | 83 | { |
82 | - if( !$this->app->config->remove_dashboard_widgets )return; |
|
84 | + if( !$this->app->config->remove_dashboard_widgets ) { |
|
85 | + return; |
|
86 | + } |
|
83 | 87 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
84 | 88 | 'dashboard_primary', |
85 | 89 | 'dashboard_quick_press', |
@@ -95,7 +99,9 @@ discard block |
||
95 | 99 | */ |
96 | 100 | public function removeWordPressMenu() |
97 | 101 | { |
98 | - if( !$this->app->config->remove_wordpress_menu )return; |
|
102 | + if( !$this->app->config->remove_wordpress_menu ) { |
|
103 | + return; |
|
104 | + } |
|
99 | 105 | global $wp_admin_bar; |
100 | 106 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
101 | 107 | } |
@@ -122,7 +128,9 @@ discard block |
||
122 | 128 | */ |
123 | 129 | protected function registerCodemirrorAssets( WP_Screen $screen ) |
124 | 130 | { |
125 | - if( $screen->id != 'settings_page_pollux' || $screen->pagenow != 'options-general.php' )return; |
|
131 | + if( $screen->id != 'settings_page_pollux' || $screen->pagenow != 'options-general.php' ) { |
|
132 | + return; |
|
133 | + } |
|
126 | 134 | wp_enqueue_style( 'pollux/codemirror.css', |
127 | 135 | $this->app->url( 'assets/codemirror.css' ), |
128 | 136 | [], |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function filterPluginLinks( array $links ) |
29 | 29 | { |
30 | - $settings_url = admin_url( sprintf( 'options-general.php?page=%s', $this->app->id )); |
|
30 | + $settings_url = admin_url( sprintf( 'options-general.php?page=%s', $this->app->id ) ); |
|
31 | 31 | $links[] = $this->app->config->disable_config |
32 | - ? sprintf( '<span class="network_only">%s</span>', __( 'Settings Disabled', 'pollux' )) |
|
33 | - : sprintf( '<a href="%s">%s</a>', $settings_url, __( 'Settings', 'pollux' )); |
|
32 | + ? sprintf( '<span class="network_only">%s</span>', __( 'Settings Disabled', 'pollux' ) ) |
|
33 | + : sprintf( '<a href="%s">%s</a>', $settings_url, __( 'Settings', 'pollux' ) ); |
|
34 | 34 | return $links; |
35 | 35 | } |
36 | 36 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
84 | 84 | 'dashboard_primary', |
85 | 85 | 'dashboard_quick_press', |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | foreach( $widgets as $widget ) { |
88 | 88 | remove_meta_box( $widget, 'dashboard', 'normal' ); |
89 | 89 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function registerSettingsAssets( WP_Screen $screen ) |
154 | 154 | { |
155 | - if( $screen->id == sprintf( 'toplevel_page_%s', Settings::id() )) { |
|
155 | + if( $screen->id == sprintf( 'toplevel_page_%s', Settings::id() ) ) { |
|
156 | 156 | wp_enqueue_script( 'common' ); |
157 | 157 | wp_enqueue_script( 'postbox' ); |
158 | 158 | wp_enqueue_script( 'wp-lists' ); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $this->versions = wp_parse_args( $versions, array( |
31 | 31 | 'php' => static::MIN_PHP_VERSION, |
32 | 32 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
33 | - )); |
|
33 | + ) ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | if( $this->isValid() ) { |
42 | 42 | return true; |
43 | 43 | } |
44 | - add_action( 'activated_plugin', array( $this, 'deactivate' )); |
|
45 | - add_action( 'admin_notices', array( $this, 'deactivate' )); |
|
44 | + add_action( 'activated_plugin', array( $this, 'deactivate' ) ); |
|
45 | + add_action( 'admin_notices', array( $this, 'deactivate' ) ); |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | filter_input( INPUT_GET, 'plugin_status' ), |
138 | 138 | filter_input( INPUT_GET, 'paged' ), |
139 | 139 | filter_input( INPUT_GET, 's' ) |
140 | - ))); |
|
140 | + ) ) ); |
|
141 | 141 | exit; |
142 | 142 | } |
143 | 143 | } |
@@ -77,7 +77,9 @@ |
||
77 | 77 | */ |
78 | 78 | public function deactivate( $plugin ) |
79 | 79 | { |
80 | - if( $this->isValid() )return; |
|
80 | + if( $this->isValid() ) { |
|
81 | + return; |
|
82 | + } |
|
81 | 83 | $pluginSlug = plugin_basename( $this->file ); |
82 | 84 | if( $plugin == $pluginSlug ) { |
83 | 85 | $this->redirect(); //exit |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $args = array_pad( $args, 2, null ); |
32 | 32 | $group = $this->$group; |
33 | - if( is_object( $group )) { |
|
33 | + if( is_object( $group ) ) { |
|
34 | 34 | return $group; |
35 | 35 | } |
36 | 36 | return $this->get( $group, $args[0], $args[1] ); |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | public function __get( $group ) |
44 | 44 | { |
45 | 45 | if( $group == 'all' ) { |
46 | - return (object) $this->options; |
|
46 | + return (object)$this->options; |
|
47 | 47 | } |
48 | - if( empty( $group )) { |
|
48 | + if( empty($group) ) { |
|
49 | 49 | $group = $this->getDefaultGroup(); |
50 | 50 | } |
51 | - if( is_array( $group )) { |
|
51 | + if( is_array( $group ) ) { |
|
52 | 52 | $group = reset( $group ); |
53 | 53 | } |
54 | - return isset( $this->options[$group] ) |
|
54 | + return isset($this->options[$group]) |
|
55 | 55 | ? $this->options[$group] |
56 | 56 | : null; |
57 | 57 | } |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | if( func_num_args() < 1 ) { |
68 | 68 | return $this->all; |
69 | 69 | } |
70 | - if( is_string( $group )) { |
|
70 | + if( is_string( $group ) ) { |
|
71 | 71 | $group = $this->$group; |
72 | 72 | } |
73 | - if( !is_array( $group )) { |
|
73 | + if( !is_array( $group ) ) { |
|
74 | 74 | return $fallback; |
75 | 75 | } |
76 | - if( is_null( $key )) { |
|
76 | + if( is_null( $key ) ) { |
|
77 | 77 | return $group; |
78 | 78 | } |
79 | 79 | return $this->getValue( $group, $key, $fallback ); |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | */ |
95 | 95 | protected function getValue( array $group, $key, $fallback ) |
96 | 96 | { |
97 | - if( !array_key_exists( $key, $group )) { |
|
97 | + if( !array_key_exists( $key, $group ) ) { |
|
98 | 98 | return $fallback; |
99 | 99 | } |
100 | - return empty( $group[$key] ) && !is_null( $fallback ) |
|
100 | + return empty($group[$key]) && !is_null( $fallback ) |
|
101 | 101 | ? $fallback |
102 | 102 | : $group[$key]; |
103 | 103 | } |
@@ -22,15 +22,15 @@ 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 | - return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
|
28 | + return $html.sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
|
29 | 29 | $metabox['title'], |
30 | 30 | $fields |
31 | 31 | ); |
32 | 32 | }); |
33 | - return $this->filter( 'before/instructions', '' ) . $instructions . $this->filter( 'after/instructions', '' ); |
|
33 | + return $this->filter( 'before/instructions', '' ).$instructions.$this->filter( 'after/instructions', '' ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | protected function getInstructionFields( $metabox ) |
40 | 40 | { |
41 | 41 | $skipFields = ['custom_html', 'divider', 'heading', 'taxonomy']; |
42 | - return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox, $skipFields ) { |
|
42 | + return array_reduce( $metabox['fields'], function( $html, $field ) use($metabox, $skipFields) { |
|
43 | 43 | return $this->validate( $field['condition'] ) && !in_array( $field['type'], $skipFields ) |
44 | - ? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL |
|
44 | + ? $html.$this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ).PHP_EOL |
|
45 | 45 | : $html; |
46 | 46 | }); |
47 | 47 | } |
@@ -85,7 +85,7 @@ discard block |
||
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 | /** |
@@ -62,7 +62,9 @@ |
||
62 | 62 | */ |
63 | 63 | protected function initInstructions() |
64 | 64 | { |
65 | - if( !$this->showInstructions() )return; |
|
65 | + if( !$this->showInstructions() ) { |
|
66 | + return; |
|
67 | + } |
|
66 | 68 | return [ |
67 | 69 | 'infodiv' => [ |
68 | 70 | 'context' => 'side', |