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 | * |
||||||||
13 | * @package WordPress |
||||||||
14 | * @subpackage Strip |
||||||||
15 | */ |
||||||||
16 | |||||||||
17 | /************* DASHBOARD WIDGETS *****************/ |
||||||||
18 | |||||||||
19 | /** |
||||||||
20 | * Disable default dashboard widgets. |
||||||||
21 | */ |
||||||||
22 | function disable_default_dashboard_widgets() { |
||||||||
23 | global $wp_meta_boxes; |
||||||||
24 | unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity'] ); // Activity Widget. |
||||||||
25 | unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments'] ); // Comments Widget. |
||||||||
26 | unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links'] ); // Incoming Links Widget. |
||||||||
27 | unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'] ); // Plugins Widget. |
||||||||
28 | |||||||||
29 | unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] ); // Quick Press Widget. |
||||||||
30 | unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts'] ); // Recent Drafts Widget. |
||||||||
31 | unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] ); // WordPress related feed. |
||||||||
32 | unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'] ); // |
||||||||
33 | |||||||||
34 | // remove plugin dashboard boxes |
||||||||
35 | unset( $wp_meta_boxes['dashboard']['normal']['core']['yoast_db_widget'] ); // Yoast's SEO Plugin Widget. |
||||||||
36 | unset( $wp_meta_boxes['dashboard']['normal']['core']['rg_forms_dashboard'] ); // Gravity Forms Plugin Widget. |
||||||||
37 | unset( $wp_meta_boxes['dashboard']['normal']['core']['bbp-dashboard-right-now'] ); // bbPress Plugin Widget. |
||||||||
38 | |||||||||
39 | /* |
||||||||
40 | Have more plugin widgets you'd like to remove? |
||||||||
41 | share them with us so we can get a list of |
||||||||
42 | the most commonly used. :D |
||||||||
43 | https://github.com/eddiemachado/bones/issues |
||||||||
44 | */ |
||||||||
45 | } |
||||||||
46 | |||||||||
47 | /* |
||||||||
48 | Now let's talk about adding your own custom Dashboard widget. |
||||||||
49 | Sometimes you want to show clients feeds relative to their |
||||||||
50 | site's content. Here is an example Dashboard Widget that displays recent |
||||||||
51 | entries from an RSS Feed. |
||||||||
52 | For more information on creating Dashboard Widgets, view: |
||||||||
53 | http://digwp.com/2010/10/customize-wordpress-dashboard/ |
||||||||
54 | */ |
||||||||
55 | |||||||||
56 | /** |
||||||||
57 | * RSS Dasboard Widget |
||||||||
58 | */ |
||||||||
59 | function strip_rss_dashboard_widget() { |
||||||||
60 | // Get RSS Feed(s) |
||||||||
61 | include_once(ABSPATH . WPINC . '/feed.php'); |
||||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||||
62 | |||||||||
63 | // My feeds list (add your own RSS feeds urls) |
||||||||
64 | $my_feeds = array( |
||||||||
65 | 'https://silentcomics.com/feed.xml' |
||||||||
66 | ); |
||||||||
67 | |||||||||
68 | // Loop through Feeds |
||||||||
69 | foreach ( $my_feeds as $feed) : |
||||||||
70 | |||||||||
71 | // Get a SimplePie feed object from the specified feed source. |
||||||||
72 | $rss = fetch_feed( $feed ); |
||||||||
0 ignored issues
–
show
The function
fetch_feed was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
73 | if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly |
||||||||
0 ignored issues
–
show
The function
is_wp_error was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
74 | // Figure out how many total items there are, and choose a limit |
||||||||
75 | $maxitems = $rss->get_item_quantity( 3 ); |
||||||||
76 | |||||||||
77 | // Build an array of all the items, starting with element 0 (first element). |
||||||||
78 | $rss_items = $rss->get_items( 0, $maxitems ); |
||||||||
79 | |||||||||
80 | // Get RSS title |
||||||||
81 | $rss_title = '<a href="'.$rss->get_permalink().'" target="_blank">'.strtoupper( $rss->get_title() ).'</a>'; |
||||||||
82 | endif; |
||||||||
83 | |||||||||
84 | // Display the container |
||||||||
85 | echo '<div class="rss-widget">'; |
||||||||
86 | echo '<strong>'.$rss_title.'</strong>'; |
||||||||
87 | echo '<hr style="border: 0; background-color: #DFDFDF; height: 1px;">'; |
||||||||
88 | |||||||||
89 | // Starts items listing within <ul> tag |
||||||||
90 | echo '<ul>'; |
||||||||
91 | |||||||||
92 | // Check items |
||||||||
93 | if ( $maxitems == 0 ) { |
||||||||
94 | echo '<li>'.__( 'No item', 'strip').'.</li>'; |
||||||||
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
95 | } { |
||||||||
96 | // Loop through each feed item and display each item as a hyperlink. |
||||||||
97 | foreach ( $rss_items as $item ) : |
||||||||
98 | // Uncomment line below to display non human date |
||||||||
99 | //$item_date = $item->get_date( get_option('date_format').' @ '.get_option('time_format') ); |
||||||||
100 | |||||||||
101 | // Get human date (comment if you want to use non human date) |
||||||||
102 | $item_date = human_time_diff( $item->get_date('U'), current_time('timestamp')).' '.__( 'ago', 'strip' ); |
||||||||
0 ignored issues
–
show
The function
current_time was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
human_time_diff was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
103 | |||||||||
104 | // Start displaying item content within a <li> tag |
||||||||
105 | echo '<li>'; |
||||||||
106 | // create item link |
||||||||
107 | echo '<a href="'.esc_url( $item->get_permalink() ).'" title="'.$item_date.'">'; |
||||||||
0 ignored issues
–
show
The function
esc_url was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
108 | // Get item title |
||||||||
109 | echo esc_html( $item->get_title() ); |
||||||||
0 ignored issues
–
show
The function
esc_html was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
110 | echo '</a>'; |
||||||||
111 | // Display date |
||||||||
112 | echo ' <span class="rss-date">'.$item_date.'</span><br />'; |
||||||||
113 | // Get item content |
||||||||
114 | $content = $item->get_content(); |
||||||||
115 | // Shorten content |
||||||||
116 | $content = wp_html_excerpt($content, 120) . ' [...]'; |
||||||||
0 ignored issues
–
show
The function
wp_html_excerpt was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
117 | // Display content |
||||||||
118 | echo $content; |
||||||||
119 | // End <li> tag |
||||||||
120 | echo '</li>'; |
||||||||
121 | endforeach; |
||||||||
122 | } |
||||||||
123 | // End <ul> tag |
||||||||
124 | echo '</ul></div>'; |
||||||||
125 | |||||||||
126 | endforeach; // End foreach feed |
||||||||
127 | } |
||||||||
128 | |||||||||
129 | /** |
||||||||
130 | * Calling all custom dashboard widgets. |
||||||||
131 | */ |
||||||||
132 | function strip_custom_dashboard_widgets() { |
||||||||
133 | wp_add_dashboard_widget( 'strip_rss_dashboard_widget', __( 'SILENT COMICS blog', 'strip' ), 'strip_rss_dashboard_widget' ); |
||||||||
0 ignored issues
–
show
The function
wp_add_dashboard_widget was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
134 | /** |
||||||||
135 | * Be sure to drop any other created Dashboard Widgets. |
||||||||
136 | * in this function and they will all load. |
||||||||
137 | */ |
||||||||
138 | } |
||||||||
139 | // removing the dashboard widgets. |
||||||||
140 | add_action( 'wp_dashboard_setup', 'disable_default_dashboard_widgets' ); |
||||||||
0 ignored issues
–
show
The function
add_action was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
141 | // adding any custom widgets. |
||||||||
142 | add_action( 'wp_dashboard_setup', 'strip_custom_dashboard_widgets' ); |
||||||||
143 | |||||||||
144 | |||||||||
145 | /************* CUSTOM LOGIN PAGE *****************/ |
||||||||
146 | |||||||||
147 | /** |
||||||||
148 | * Calling your own login css so you can style it. |
||||||||
149 | * Updated to proper 'enqueue' method. |
||||||||
150 | * See http://codex.wordpress.org/Plugin_API/Action_Reference/login_enqueue_scripts. |
||||||||
151 | */ |
||||||||
152 | function strip_login_css() { |
||||||||
153 | wp_enqueue_style( 'strip_login_css', get_template_directory_uri() . '/assets/css/login.css', false ); |
||||||||
0 ignored issues
–
show
The function
get_template_directory_uri was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
wp_enqueue_style was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
154 | |||||||||
155 | // Enqueue custom font to the login form. |
||||||||
156 | wp_enqueue_style( 'strip_inconsolata_css', get_template_directory_uri() . '/assets/fonts/inconsolata.css', array(), null ); |
||||||||
157 | } |
||||||||
158 | |||||||||
159 | /** |
||||||||
160 | * Changing the logo link from wordpress.org to your site. |
||||||||
161 | * |
||||||||
162 | * @return custom link. |
||||||||
0 ignored issues
–
show
The type
custom was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||||
163 | */ |
||||||||
164 | function strip_login_url() { |
||||||||
165 | return home_url(); } |
||||||||
0 ignored issues
–
show
The function
home_url was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
166 | |||||||||
167 | /** |
||||||||
168 | * Changing the alt text on the logo to show your site name. |
||||||||
169 | * |
||||||||
170 | * @return blog title. |
||||||||
0 ignored issues
–
show
The type
blog was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||||
171 | */ |
||||||||
172 | function strip_login_title() { |
||||||||
173 | return get_option( 'blogname' ); } |
||||||||
0 ignored issues
–
show
The function
get_option was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
174 | |||||||||
175 | // calling only on the login page. |
||||||||
176 | add_action( 'login_enqueue_scripts', 'strip_login_css', 10 ); |
||||||||
177 | add_filter( 'login_headerurl', 'strip_login_url' ); |
||||||||
0 ignored issues
–
show
The function
add_filter was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
178 | add_filter( 'login_headertext', 'strip_login_title' ); |
||||||||
179 | |||||||||
180 | /************* CUSTOMIZE ADMIN *******************/ |
||||||||
181 | |||||||||
182 | /* |
||||||||
183 | I don't really recommend editing the admin too much |
||||||||
184 | as things may get funky if WordPress updates. Here |
||||||||
185 | are a few funtions which you can choose to use if |
||||||||
186 | you like. |
||||||||
187 | */ |
||||||||
188 | |||||||||
189 | /** |
||||||||
190 | * Custom Backend Footer. |
||||||||
191 | */ |
||||||||
192 | function strip_custom_admin_footer() { |
||||||||
193 | ?> |
||||||||
194 | <span id="footer-thankyou"><a href="<?php echo esc_url( __( 'https://silent-comics.com/', 'strip' ) ); ?>"><?php printf( esc_html__( 'Developed by %s', 'strip' ), 'Silent Comics' ); ?></a> |
||||||||
0 ignored issues
–
show
The function
esc_html__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
esc_url was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
195 | <span class="sep"> | </span> |
||||||||
196 | <a href="<?php echo esc_url( __( 'https://github.com/SilentComics/Strip/', 'strip' ) ); ?>"><?php printf( esc_html__( 'Contribute on %s', 'strip' ), 'GitHub' ); ?></a> |
||||||||
197 | <?php } |
||||||||
198 | |||||||||
199 | // adding it to the admin area. |
||||||||
200 | add_filter( 'admin_footer_text', 'strip_custom_admin_footer' ); |
||||||||
201 |