|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file handles the admin area and functions |
|
4
|
|
|
* |
|
5
|
|
|
* You can use it to make changes to the |
|
6
|
|
|
* dashboard. Updates to this page are coming soon. |
|
7
|
|
|
* The file is called by functions.php. |
|
8
|
|
|
* |
|
9
|
|
|
* Adapted from Bones, developed by Eddie Machado. |
|
10
|
|
|
* URL: http://themble.com/bones/ |
|
11
|
|
|
* |
|
12
|
|
|
* Special Thanks for code & inspiration to: |
|
13
|
|
|
* |
|
14
|
|
|
* @jackmcconnell - http://www.voltronik.co.uk/ |
|
15
|
|
|
* Digging into WP - http://digwp.com/2010/10/customize-wordpress-dashboard/ |
|
16
|
|
|
* |
|
17
|
|
|
* @package WordPress |
|
18
|
|
|
* @subpackage Strip |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
/************* DASHBOARD WIDGETS *****************/ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Disable default dashboard widgets. |
|
25
|
|
|
*/ |
|
26
|
|
|
function disable_default_dashboard_widgets() { |
|
27
|
|
|
global $wp_meta_boxes; |
|
28
|
|
|
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity'] ); // Activity Widget. |
|
29
|
|
|
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments'] ); // Comments Widget. |
|
30
|
|
|
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links'] ); // Incoming Links Widget. |
|
31
|
|
|
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'] ); // Plugins Widget. |
|
32
|
|
|
|
|
33
|
|
|
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] ); // Quick Press Widget. |
|
34
|
|
|
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts'] ); // Recent Drafts Widget. |
|
35
|
|
|
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] ); // WordPress related feed. |
|
36
|
|
|
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'] ); // |
|
37
|
|
|
|
|
38
|
|
|
// remove plugin dashboard boxes |
|
39
|
|
|
unset( $wp_meta_boxes['dashboard']['normal']['core']['yoast_db_widget'] ); // Yoast's SEO Plugin Widget. |
|
40
|
|
|
unset( $wp_meta_boxes['dashboard']['normal']['core']['rg_forms_dashboard'] ); // Gravity Forms Plugin Widget. |
|
41
|
|
|
unset( $wp_meta_boxes['dashboard']['normal']['core']['bbp-dashboard-right-now'] ); // bbPress Plugin Widget. |
|
42
|
|
|
|
|
43
|
|
|
/* |
|
44
|
|
|
Have more plugin widgets you'd like to remove? |
|
45
|
|
|
share them with us so we can get a list of |
|
46
|
|
|
the most commonly used. :D |
|
47
|
|
|
https://github.com/eddiemachado/bones/issues |
|
48
|
|
|
*/ |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/* |
|
52
|
|
|
Now let's talk about adding your own custom Dashboard widget. |
|
53
|
|
|
Sometimes you want to show clients feeds relative to their |
|
54
|
|
|
site's content. Here is an example Dashboard Widget that displays recent |
|
55
|
|
|
entries from an RSS Feed. |
|
56
|
|
|
For more information on creating Dashboard Widgets, view: |
|
57
|
|
|
http://digwp.com/2010/10/customize-wordpress-dashboard/ |
|
58
|
|
|
*/ |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* RSS Dasboars Widget |
|
62
|
|
|
*/ |
|
63
|
|
|
function strip_rss_dashboard_widget() { |
|
64
|
|
|
if ( function_exists( 'fetch_feed' ) ) { |
|
65
|
|
|
$feed = fetch_feed( 'https://silent-comics.tumblr.com/rss/' );// specify the source feed. |
|
66
|
|
|
if ( is_wp_error( $feed ) ) { |
|
|
|
|
|
|
67
|
|
|
return; |
|
68
|
|
|
} |
|
69
|
|
|
$limit = $feed->get_item_quantity( 7 ); // specify number of items. |
|
70
|
|
|
$items = $feed->get_items( 0, $limit ); // create an array of items. |
|
71
|
|
|
} |
|
72
|
|
|
if ( 0 ) { echo '<div>The RSS Feed is either empty or unavailable.</div>'; // fallback message. |
|
73
|
|
|
return; |
|
74
|
|
|
} |
|
75
|
|
|
foreach ( $items as $item ) { ?> |
|
76
|
|
|
|
|
77
|
|
|
<h4 style="margin-bottom: 1em; max-width: 384px;"> |
|
78
|
|
|
<a href="<?php echo esc_url( $item->get_permalink() ); ?>" title="" target="_blank"> |
|
|
|
|
|
|
79
|
|
|
<?php echo esc_attr( $item->get_title() ); ?> |
|
|
|
|
|
|
80
|
|
|
<br> |
|
81
|
|
|
</a> |
|
82
|
|
|
</h4> |
|
83
|
|
|
|
|
84
|
|
|
<?php echo esc_html( mysql2date( __( 'j F Y @ g:i a', 'strip' ), $item->get_date( 'Y-m-d H:i:s' ) ) ); ?> |
|
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
<p style="margin-top: 1.2em; |
|
87
|
|
|
#strip_rss_dashboard_widget .postbox.postbox-container { width: 12px; }"> |
|
88
|
|
|
<?php echo wp_kses_post( substr( $item->get_description(), 0, 742 ) ); ?> |
|
|
|
|
|
|
89
|
|
|
</p> |
|
90
|
|
|
<?php |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Calling all custom dashboard widgets. |
|
96
|
|
|
*/ |
|
97
|
|
|
function strip_custom_dashboard_widgets() { |
|
98
|
|
|
wp_add_dashboard_widget( 'strip_rss_dashboard_widget', __( 'SILENT COMICS on tumblr', 'strip' ), 'strip_rss_dashboard_widget' ); |
|
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Be sure to drop any other created Dashboard Widgets. |
|
101
|
|
|
* in this function and they will all load. |
|
102
|
|
|
*/ |
|
103
|
|
|
} |
|
104
|
|
|
// removing the dashboard widgets. |
|
105
|
|
|
add_action( 'wp_dashboard_setup', 'disable_default_dashboard_widgets' ); |
|
|
|
|
|
|
106
|
|
|
// adding any custom widgets. |
|
107
|
|
|
add_action( 'wp_dashboard_setup', 'strip_custom_dashboard_widgets' ); |
|
108
|
|
|
|
|
109
|
|
|
|
|
110
|
|
|
/************* CUSTOM LOGIN PAGE *****************/ |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Calling your own login css so you can style it. |
|
114
|
|
|
* Updated to proper 'enqueue' method. |
|
115
|
|
|
* See http://codex.wordpress.org/Plugin_API/Action_Reference/login_enqueue_scripts. |
|
116
|
|
|
*/ |
|
117
|
|
|
function strip_login_css() { |
|
118
|
|
|
wp_enqueue_style( 'strip_login_css', get_template_directory_uri() . '/assets/css/login.css', false ); |
|
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
// Enqueue custom font to the login form. |
|
121
|
|
|
wp_enqueue_style( 'strip_inconsolata_css', get_template_directory_uri() . '/assets/fonts/inconsolata.css', array(), null ); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Changing the logo link from wordpress.org to your site. |
|
126
|
|
|
* |
|
127
|
|
|
* @return custom link. |
|
|
|
|
|
|
128
|
|
|
*/ |
|
129
|
|
|
function strip_login_url() { |
|
130
|
|
|
return home_url(); } |
|
|
|
|
|
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Changing the alt text on the logo to show your site name. |
|
134
|
|
|
* |
|
135
|
|
|
* @return blog title. |
|
|
|
|
|
|
136
|
|
|
*/ |
|
137
|
|
|
function strip_login_title() { |
|
138
|
|
|
return get_option( 'blogname' ); } |
|
|
|
|
|
|
139
|
|
|
|
|
140
|
|
|
// calling only on the login page. |
|
141
|
|
|
add_action( 'login_enqueue_scripts', 'strip_login_css', 10 ); |
|
142
|
|
|
add_filter( 'login_headerurl', 'strip_login_url' ); |
|
|
|
|
|
|
143
|
|
|
add_filter( 'login_headertitle', 'strip_login_title' ); |
|
144
|
|
|
|
|
145
|
|
|
/************* CUSTOMIZE ADMIN *******************/ |
|
146
|
|
|
|
|
147
|
|
|
/* |
|
148
|
|
|
I don't really recommend editing the admin too much |
|
149
|
|
|
as things may get funky if WordPress updates. Here |
|
150
|
|
|
are a few funtions which you can choose to use if |
|
151
|
|
|
you like. |
|
152
|
|
|
*/ |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Custom Backend Footer. |
|
156
|
|
|
*/ |
|
157
|
|
|
function strip_custom_admin_footer() { |
|
158
|
|
|
?> |
|
159
|
|
|
<span id="footer-thankyou"><a href="<?php echo esc_url( __( 'http://silent-comics.com/', 'strip' ) ); ?>"><?php printf( esc_html__( 'Developed by %s', 'strip' ), 'Silent Comics' ); ?></a> |
|
|
|
|
|
|
160
|
|
|
<span class="sep"> | </span> |
|
161
|
|
|
<a href="<?php echo esc_url( __( 'https://github.com/SilentComics/Strip/', 'strip' ) ); ?>"><?php printf( esc_html__( 'Contribute on %s', 'strip' ), 'GitHub' ); ?></a> |
|
162
|
|
|
<?php } |
|
163
|
|
|
|
|
164
|
|
|
// adding it to the admin area. |
|
165
|
|
|
add_filter( 'admin_footer_text', 'strip_custom_admin_footer' ); |
|
166
|
|
|
|