@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | |
28 | 28 | remove_action( 'welcome_panel', 'wp_welcome_panel' ); |
29 | 29 | |
30 | - add_action( 'init', [$this, 'disable'] ); |
|
31 | - add_action( 'wp_dashboard_setup', [$this, 'modifyDashboardWidgets'] ); |
|
32 | - add_action( 'welcome_panel', [$this, 'modifyWelcomePanel'] ); |
|
33 | - add_action( 'admin_bar_menu', [$this, 'removeFromAdminBar'], 999 ); |
|
34 | - add_action( 'admin_menu', [$this, 'removeFromAdminMenu'] ); |
|
35 | - add_action( 'admin_init', [$this, 'unregisterDashboardWidgets'] ); |
|
36 | - add_action( 'widgets_init', [$this, 'unregisterWidgets'], 1 ); |
|
37 | - add_filter( 'posts_results', [$this, 'filterPostQuery'] ); |
|
38 | - add_filter( 'pre_get_posts', [$this, 'filterSearchQuery'] ); |
|
30 | + add_action( 'init', [ $this, 'disable' ] ); |
|
31 | + add_action( 'wp_dashboard_setup', [ $this, 'modifyDashboardWidgets' ] ); |
|
32 | + add_action( 'welcome_panel', [ $this, 'modifyWelcomePanel' ] ); |
|
33 | + add_action( 'admin_bar_menu', [ $this, 'removeFromAdminBar' ], 999 ); |
|
34 | + add_action( 'admin_menu', [ $this, 'removeFromAdminMenu' ] ); |
|
35 | + add_action( 'admin_init', [ $this, 'unregisterDashboardWidgets' ] ); |
|
36 | + add_action( 'widgets_init', [ $this, 'unregisterWidgets' ], 1 ); |
|
37 | + add_filter( 'posts_results', [ $this, 'filterPostQuery' ] ); |
|
38 | + add_filter( 'pre_get_posts', [ $this, 'filterSearchQuery' ] ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function disable() |
46 | 46 | { |
47 | - if( !in_array(( new Helper )->getCurrentScreen()->pagenow, [ |
|
47 | + if( !in_array( ( new Helper )->getCurrentScreen()->pagenow, [ |
|
48 | 48 | 'edit.php', 'edit-tags.php', 'post-new.php', |
49 | - ]))return; |
|
49 | + ] ) )return; |
|
50 | 50 | |
51 | 51 | if( !filter_input_array( INPUT_GET, [ |
52 | 52 | 'post_type' => FILTER_DEFAULT, |
53 | 53 | 'taxonomy' => FILTER_DEFAULT, |
54 | - ])) { |
|
54 | + ] ) ) { |
|
55 | 55 | wp_safe_redirect( get_admin_url(), 301 ); |
56 | 56 | exit; |
57 | 57 | } |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | * @return array |
70 | 70 | * @filter posts_results |
71 | 71 | */ |
72 | - public function filterPostQuery( $posts = [] ) |
|
72 | + public function filterPostQuery( $posts = [ ] ) |
|
73 | 73 | { |
74 | 74 | global $wp_query; |
75 | 75 | return $this->isAdmin() || strpos( $wp_query->request, "wp_posts.post_type = 'post'" ) === false |
76 | 76 | ? $posts |
77 | - : []; |
|
77 | + : [ ]; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | if( $this->isAdmin() || !$query->is_main_query() || !is_search() ) { |
87 | 87 | return $query; |
88 | 88 | } |
89 | - $post_types = get_post_types( ['exclude_from_search' => false ] ); |
|
90 | - unset( $post_types['post'] ); |
|
89 | + $post_types = get_post_types( [ 'exclude_from_search' => false ] ); |
|
90 | + unset( $post_types[ 'post' ] ); |
|
91 | 91 | $query->set( 'post_type', array_values( $post_types ) ); |
92 | 92 | return $query; |
93 | 93 | } |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function modifyDashboardWidgets() |
100 | 100 | { |
101 | - if( !is_blog_admin() || !current_user_can( 'edit_posts' ))return; |
|
101 | + if( !is_blog_admin() || !current_user_can( 'edit_posts' ) )return; |
|
102 | 102 | |
103 | 103 | global $wp_meta_boxes; |
104 | - $widgets = &$wp_meta_boxes['dashboard']['normal']['core']; |
|
105 | - if( !isset( $widgets['dashboard_right_now']['callback'] ))return; |
|
106 | - $widgets['dashboard_right_now']['callback'] = function() { |
|
104 | + $widgets = &$wp_meta_boxes[ 'dashboard' ][ 'normal' ][ 'core' ]; |
|
105 | + if( !isset( $widgets[ 'dashboard_right_now' ][ 'callback' ] ) )return; |
|
106 | + $widgets[ 'dashboard_right_now' ][ 'callback' ] = function() { |
|
107 | 107 | ob_start(); |
108 | 108 | wp_dashboard_right_now(); |
109 | 109 | 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 | remove_action( 'welcome_panel', 'wp_welcome_panel' ); |
29 | 31 | |
@@ -46,7 +48,9 @@ discard block |
||
46 | 48 | { |
47 | 49 | if( !in_array(( new Helper )->getCurrentScreen()->pagenow, [ |
48 | 50 | 'edit.php', 'edit-tags.php', 'post-new.php', |
49 | - ]))return; |
|
51 | + ])) { |
|
52 | + return; |
|
53 | + } |
|
50 | 54 | |
51 | 55 | if( !filter_input_array( INPUT_GET, [ |
52 | 56 | 'post_type' => FILTER_DEFAULT, |
@@ -98,12 +102,17 @@ discard block |
||
98 | 102 | */ |
99 | 103 | public function modifyDashboardWidgets() |
100 | 104 | { |
101 | - if( !is_blog_admin() || !current_user_can( 'edit_posts' ))return; |
|
105 | + if( !is_blog_admin() || !current_user_can( 'edit_posts' )) { |
|
106 | + return; |
|
107 | + } |
|
102 | 108 | |
103 | 109 | global $wp_meta_boxes; |
104 | 110 | $widgets = &$wp_meta_boxes['dashboard']['normal']['core']; |
105 | - if( !isset( $widgets['dashboard_right_now']['callback'] ))return; |
|
106 | - $widgets['dashboard_right_now']['callback'] = function() { |
|
111 | + if( !isset( $widgets['dashboard_right_now']['callback'] )) { |
|
112 | + return; |
|
113 | + } |
|
114 | + $widgets['dashboard_right_now']['callback'] = function() |
|
115 | + { |
|
107 | 116 | ob_start(); |
108 | 117 | wp_dashboard_right_now(); |
109 | 118 | echo preg_replace( '/<li class="post-count">(.*?)<\/li>/', '', ob_get_clean() ); |