@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function init() |
25 | 25 | { |
26 | - if( !$this->app->config['disable_posts'] )return; |
|
27 | - |
|
28 | - add_action( 'init', [$this, 'disable'] ); |
|
29 | - add_action( 'wp_dashboard_setup', [$this, 'modifyDashboardWidgets'] ); |
|
30 | - add_action( 'admin_bar_menu', [$this, 'removeFromAdminBar'], 999 ); |
|
31 | - add_action( 'admin_menu', [$this, 'removeFromAdminMenu'] ); |
|
32 | - add_action( 'wp_dashboard_setup', [$this, 'unregisterDashboardWidgets'] ); |
|
33 | - add_action( 'widgets_init', [$this, 'unregisterWidgets'], 1 ); |
|
34 | - add_filter( 'posts_results', [$this, 'filterPostQuery'] ); |
|
35 | - add_filter( 'pre_get_posts', [$this, 'filterSearchQuery'] ); |
|
26 | + if( !$this->app->config[ 'disable_posts' ] )return; |
|
27 | + |
|
28 | + add_action( 'init', [ $this, 'disable' ] ); |
|
29 | + add_action( 'wp_dashboard_setup', [ $this, 'modifyDashboardWidgets' ] ); |
|
30 | + add_action( 'admin_bar_menu', [ $this, 'removeFromAdminBar' ], 999 ); |
|
31 | + add_action( 'admin_menu', [ $this, 'removeFromAdminMenu' ] ); |
|
32 | + add_action( 'wp_dashboard_setup', [ $this, 'unregisterDashboardWidgets' ] ); |
|
33 | + add_action( 'widgets_init', [ $this, 'unregisterWidgets' ], 1 ); |
|
34 | + add_filter( 'posts_results', [ $this, 'filterPostQuery' ] ); |
|
35 | + add_filter( 'pre_get_posts', [ $this, 'filterSearchQuery' ] ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function disable() |
43 | 43 | { |
44 | - if( !in_array(( new Helper )->getCurrentScreen()->pagenow, [ |
|
44 | + if( !in_array( ( new Helper )->getCurrentScreen()->pagenow, [ |
|
45 | 45 | 'edit.php', 'edit-tags.php', 'post-new.php', |
46 | - ]))return; |
|
46 | + ] ) )return; |
|
47 | 47 | |
48 | 48 | if( !filter_input_array( INPUT_GET, [ |
49 | 49 | 'post_type' => FILTER_DEFAULT, |
50 | 50 | 'taxonomy' => FILTER_DEFAULT, |
51 | - ])) { |
|
51 | + ] ) ) { |
|
52 | 52 | wp_safe_redirect( get_admin_url(), 301 ); |
53 | 53 | exit; |
54 | 54 | } |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * @return array |
67 | 67 | * @filter posts_results |
68 | 68 | */ |
69 | - public function filterPostQuery( $posts = [] ) |
|
69 | + public function filterPostQuery( $posts = [ ] ) |
|
70 | 70 | { |
71 | 71 | global $wp_query; |
72 | 72 | return $this->isAdmin() || strpos( $wp_query->request, "wp_posts.post_type = 'post'" ) === false |
73 | 73 | ? $posts |
74 | - : []; |
|
74 | + : [ ]; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | if( $this->isAdmin() || !$query->is_main_query() || !is_search() ) { |
84 | 84 | return $query; |
85 | 85 | } |
86 | - $post_types = get_post_types( ['exclude_from_search' => false ] ); |
|
87 | - unset( $post_types['post'] ); |
|
86 | + $post_types = get_post_types( [ 'exclude_from_search' => false ] ); |
|
87 | + unset( $post_types[ 'post' ] ); |
|
88 | 88 | $query->set( 'post_type', array_values( $post_types ) ); |
89 | 89 | return $query; |
90 | 90 | } |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function modifyDashboardWidgets() |
97 | 97 | { |
98 | - if( !is_blog_admin() || !current_user_can( 'edit_posts' ))return; |
|
98 | + if( !is_blog_admin() || !current_user_can( 'edit_posts' ) )return; |
|
99 | 99 | |
100 | 100 | global $wp_meta_boxes; |
101 | - $widgets = &$wp_meta_boxes['dashboard']['normal']['core']; |
|
102 | - if( !isset( $widgets['dashboard_right_now']['callback'] ))return; |
|
103 | - $widgets['dashboard_right_now']['callback'] = function() { |
|
101 | + $widgets = &$wp_meta_boxes[ 'dashboard' ][ 'normal' ][ 'core' ]; |
|
102 | + if( !isset( $widgets[ 'dashboard_right_now' ][ 'callback' ] ) )return; |
|
103 | + $widgets[ 'dashboard_right_now' ][ 'callback' ] = function() { |
|
104 | 104 | ob_start(); |
105 | 105 | wp_dashboard_right_now(); |
106 | 106 | echo preg_replace( '/<li class="post-count">(.*?)<\/li>/', '', ob_get_clean() ); |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function init() |
25 | 25 | { |
26 | - if( !$this->app->config['disable_posts'] )return; |
|
26 | + if( !$this->app->config['disable_posts'] ) { |
|
27 | + return; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | add_action( 'init', [$this, 'disable'] ); |
29 | 31 | add_action( 'wp_dashboard_setup', [$this, 'modifyDashboardWidgets'] ); |
@@ -43,7 +45,9 @@ discard block |
||
43 | 45 | { |
44 | 46 | if( !in_array(( new Helper )->getCurrentScreen()->pagenow, [ |
45 | 47 | 'edit.php', 'edit-tags.php', 'post-new.php', |
46 | - ]))return; |
|
48 | + ])) { |
|
49 | + return; |
|
50 | + } |
|
47 | 51 | |
48 | 52 | if( !filter_input_array( INPUT_GET, [ |
49 | 53 | 'post_type' => FILTER_DEFAULT, |
@@ -95,12 +99,17 @@ discard block |
||
95 | 99 | */ |
96 | 100 | public function modifyDashboardWidgets() |
97 | 101 | { |
98 | - if( !is_blog_admin() || !current_user_can( 'edit_posts' ))return; |
|
102 | + if( !is_blog_admin() || !current_user_can( 'edit_posts' )) { |
|
103 | + return; |
|
104 | + } |
|
99 | 105 | |
100 | 106 | global $wp_meta_boxes; |
101 | 107 | $widgets = &$wp_meta_boxes['dashboard']['normal']['core']; |
102 | - if( !isset( $widgets['dashboard_right_now']['callback'] ))return; |
|
103 | - $widgets['dashboard_right_now']['callback'] = function() { |
|
108 | + if( !isset( $widgets['dashboard_right_now']['callback'] )) { |
|
109 | + return; |
|
110 | + } |
|
111 | + $widgets['dashboard_right_now']['callback'] = function() |
|
112 | + { |
|
104 | 113 | ob_start(); |
105 | 114 | wp_dashboard_right_now(); |
106 | 115 | echo preg_replace( '/<li class="post-count">(.*?)<\/li>/', '', ob_get_clean() ); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function filterWordPressFooter( $text ) |
28 | 28 | { |
29 | - if( $this->app->config['remove_wordpress_footer'] )return; |
|
29 | + if( $this->app->config[ 'remove_wordpress_footer' ] )return; |
|
30 | 30 | return $text; |
31 | 31 | } |
32 | 32 | |
@@ -43,17 +43,17 @@ discard block |
||
43 | 43 | |
44 | 44 | wp_enqueue_style( 'pollux/main.css', |
45 | 45 | $this->app->url( 'assets/main.css' ), |
46 | - apply_filters( 'pollux/enqueue/css/deps', [] ), |
|
46 | + apply_filters( 'pollux/enqueue/css/deps', [ ] ), |
|
47 | 47 | $this->app->version |
48 | 48 | ); |
49 | 49 | wp_enqueue_script( 'pollux/main.js', |
50 | 50 | $this->app->url( 'assets/main.js' ), |
51 | - apply_filters( 'pollux/enqueue/js/deps', [] ), |
|
51 | + apply_filters( 'pollux/enqueue/js/deps', [ ] ), |
|
52 | 52 | $this->app->version |
53 | 53 | ); |
54 | 54 | wp_localize_script( 'pollux/main.js', |
55 | 55 | apply_filters( 'pollux/enqueue/js/localize/name', $this->app->id ), |
56 | - apply_filters( 'pollux/enqueue/js/localize/variables', [] ) |
|
56 | + apply_filters( 'pollux/enqueue/js/localize/variables', [ ] ) |
|
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function removeDashboardWidgets() |
65 | 65 | { |
66 | - if( !$this->app->config['remove_dashboard_widgets'] )return; |
|
66 | + if( !$this->app->config[ 'remove_dashboard_widgets' ] )return; |
|
67 | 67 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
68 | 68 | 'dashboard_quick_press', |
69 | - ]); |
|
69 | + ] ); |
|
70 | 70 | foreach( $widgets as $widget ) { |
71 | 71 | remove_meta_box( $widget, 'dashboard', 'normal' ); |
72 | 72 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function removeWordPressMenu() |
80 | 80 | { |
81 | - if( !$this->app->config['remove_wordpress_menu'] )return; |
|
81 | + if( !$this->app->config[ 'remove_wordpress_menu' ] )return; |
|
82 | 82 | global $wp_admin_bar; |
83 | 83 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
84 | 84 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function registerArchiveAssets( WP_Screen $screen ) |
90 | 90 | { |
91 | - if(( new Helper )->endsWith( '_archive', $screen->id ) && $screen->pagenow == 'edit.php' ) { |
|
91 | + if( ( new Helper )->endsWith( '_archive', $screen->id ) && $screen->pagenow == 'edit.php' ) { |
|
92 | 92 | wp_enqueue_script( 'common' ); |
93 | 93 | wp_enqueue_script( 'editor-expand' ); |
94 | 94 | wp_enqueue_script( 'post' ); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function registerSettingsAssets( WP_Screen $screen ) |
107 | 107 | { |
108 | - if( $screen->id == sprintf( 'toplevel_page_%s', Settings::id() )) { |
|
108 | + if( $screen->id == sprintf( 'toplevel_page_%s', Settings::id() ) ) { |
|
109 | 109 | wp_enqueue_script( 'common' ); |
110 | 110 | wp_enqueue_script( 'postbox' ); |
111 | 111 | wp_enqueue_script( 'wp-lists' ); |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function filterWordPressFooter( $text ) |
28 | 28 | { |
29 | - if( $this->app->config['remove_wordpress_footer'] )return; |
|
29 | + if( $this->app->config['remove_wordpress_footer'] ) { |
|
30 | + return; |
|
31 | + } |
|
30 | 32 | return $text; |
31 | 33 | } |
32 | 34 | |
@@ -63,7 +65,9 @@ discard block |
||
63 | 65 | */ |
64 | 66 | public function removeDashboardWidgets() |
65 | 67 | { |
66 | - if( !$this->app->config['remove_dashboard_widgets'] )return; |
|
68 | + if( !$this->app->config['remove_dashboard_widgets'] ) { |
|
69 | + return; |
|
70 | + } |
|
67 | 71 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
68 | 72 | 'dashboard_quick_press', |
69 | 73 | ]); |
@@ -78,7 +82,9 @@ discard block |
||
78 | 82 | */ |
79 | 83 | public function removeWordPressMenu() |
80 | 84 | { |
81 | - if( !$this->app->config['remove_wordpress_menu'] )return; |
|
85 | + if( !$this->app->config['remove_wordpress_menu'] ) { |
|
86 | + return; |
|
87 | + } |
|
82 | 88 | global $wp_admin_bar; |
83 | 89 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
84 | 90 | } |