1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
namespace Undefined\Stash\Admin; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Clean up adminpages |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
function login_redirect($redirect_to, $request, $user) |
|
|
|
|
10
|
|
|
{ |
11
|
|
|
return admin_url('edit.php?post_type=page'); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
add_filter('login_redirect', __NAMESPACE__ . '\\login_redirect', 10, 3); |
15
|
|
|
|
16
|
|
|
function remove_menu() |
17
|
|
|
{ |
18
|
|
|
remove_menu_page('index.php'); //dashboard |
19
|
|
|
remove_menu_page('edit-comments.php'); //comments |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
add_action('admin_menu', __NAMESPACE__ . '\\remove_menu', 99); |
23
|
|
|
|
24
|
|
|
function remove_wp_logo($wp_admin_bar) |
25
|
|
|
{ |
26
|
|
|
$wp_admin_bar->remove_node('wp-logo'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
add_action('admin_bar_menu', __NAMESPACE__ . '\\remove_wp_logo', 999); |
30
|
|
|
|
31
|
|
|
function change_footer_admin() |
32
|
|
|
{ |
33
|
|
|
return ' '; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
add_filter('admin_footer_text', __NAMESPACE__ . '\\change_footer_admin', 9999); |
37
|
|
|
|
38
|
|
|
function change_footer_version() |
39
|
|
|
{ |
40
|
|
|
return ' '; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
add_filter('update_footer', __NAMESPACE__ . '\\change_footer_version', 9999); |
44
|
|
|
|
45
|
|
|
/* |
46
|
|
|
* Change the opacity of WordPress Admin Bar |
47
|
|
|
*/ |
48
|
|
|
function adminbar_opacity() |
49
|
|
|
{ |
50
|
|
|
$adminbar_opacity = '<style type="text/css">#wpadminbar { filter:alpha(opacity=50); opacity:0.5; }</style>'; |
51
|
|
|
echo $adminbar_opacity; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
if (!is_admin()) { |
55
|
|
|
add_action('wp_head', __NAMESPACE__ . '\\adminbar_opacity'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/* |
59
|
|
|
* Redirect Dashboard to pages |
60
|
|
|
*/ |
61
|
|
|
function redirect_from_dashboard() |
62
|
|
|
{ |
63
|
|
|
wp_redirect(admin_url('edit.php?post_type=page')); |
64
|
|
|
exit; |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
add_action('wp_dashboard_setup', __NAMESPACE__ . '\\redirect_from_dashboard'); |
68
|
|
|
|
69
|
|
|
function admin_menu() |
70
|
|
|
{ |
71
|
|
|
global $menu; |
|
|
|
|
72
|
|
|
$url = '/'; |
|
|
|
|
73
|
|
|
$menu[0] = array(__('STASH'), 'read', '#', 'undefined-logo', 'undefined-logo'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
add_action('admin_menu', __NAMESPACE__ . '\\admin_menu'); |
77
|
|
|
|
78
|
|
|
function admin_style() |
79
|
|
|
{ |
80
|
|
|
echo '<link rel="stylesheet" href="' . get_template_directory_uri() . '/dist/css/admin/main.css" type="text/css" media="all" />'; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
add_action('admin_head', __NAMESPACE__ . '\\admin_style'); |
84
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.