Passed
Push — master ( 95836d...7727ff )
by SILENT
02:05
created

strip_rss_dashboard_widget()   B

Complexity

Conditions 5
Paths 7

Size

Total Lines 27
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 5
eloc 24
nc 7
nop 0
dl 0
loc 27
rs 8.439
c 2
b 0
f 0
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 ) ) {
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

66
		if ( /** @scrutinizer ignore-call */ is_wp_error( $feed ) ) {
Loading history...
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">
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

78
				<a href="<?php echo /** @scrutinizer ignore-call */ esc_url( $item->get_permalink() ); ?>" title="" target="_blank">
Loading history...
79
					<?php echo esc_attr( $item->get_title() ); ?>
0 ignored issues
show
Bug introduced by
The function esc_attr 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 ignore-call  annotation

79
					<?php echo /** @scrutinizer ignore-call */ esc_attr( $item->get_title() ); ?>
Loading history...
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' ) ) ); ?>
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

84
			<?php echo /** @scrutinizer ignore-call */ esc_html( mysql2date( __( 'j F Y @ g:i a', 'strip' ), $item->get_date( 'Y-m-d H:i:s' ) ) ); ?>
Loading history...
Bug introduced by
The function mysql2date 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 ignore-call  annotation

84
			<?php echo esc_html( /** @scrutinizer ignore-call */ mysql2date( __( 'j F Y @ g:i a', 'strip' ), $item->get_date( 'Y-m-d H:i:s' ) ) ); ?>
Loading history...
Bug introduced by
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 ignore-call  annotation

84
			<?php echo esc_html( mysql2date( /** @scrutinizer ignore-call */ __( 'j F Y @ g:i a', 'strip' ), $item->get_date( 'Y-m-d H:i:s' ) ) ); ?>
Loading history...
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 ) ); ?>
0 ignored issues
show
Bug introduced by
The function wp_kses_post 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 ignore-call  annotation

88
			<?php echo /** @scrutinizer ignore-call */ wp_kses_post( substr( $item->get_description(), 0, 742 ) ); ?>
Loading history...
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' );
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

98
	wp_add_dashboard_widget( 'strip_rss_dashboard_widget', /** @scrutinizer ignore-call */ __( 'SILENT COMICS on tumblr', 'strip' ), 'strip_rss_dashboard_widget' );
Loading history...
Bug introduced by
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 ignore-call  annotation

98
	/** @scrutinizer ignore-call */ 
99
 wp_add_dashboard_widget( 'strip_rss_dashboard_widget', __( 'SILENT COMICS on tumblr', 'strip' ), 'strip_rss_dashboard_widget' );
Loading history...
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' );
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

105
/** @scrutinizer ignore-call */ 
106
add_action( 'wp_dashboard_setup', 'disable_default_dashboard_widgets' );
Loading history...
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 );
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

118
	 wp_enqueue_style( 'strip_login_css', /** @scrutinizer ignore-call */ get_template_directory_uri() . '/assets/css/login.css', false );
Loading history...
Bug introduced by
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 ignore-call  annotation

118
	 /** @scrutinizer ignore-call */ 
119
  wp_enqueue_style( 'strip_login_css', get_template_directory_uri() . '/assets/css/login.css', false );
Loading history...
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.
0 ignored issues
show
Bug introduced by
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
128
 */
129
function strip_login_url() {
130
	return home_url(); }
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

130
	return /** @scrutinizer ignore-call */ home_url(); }
Loading history...
131
132
	/**
133
	 * Changing the alt text on the logo to show your site name.
134
	 *
135
	 * @return blog title.
0 ignored issues
show
Bug introduced by
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
136
	 */
137
function strip_login_title() {
138
	return get_option( 'blogname' ); }
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

138
	return /** @scrutinizer ignore-call */ get_option( 'blogname' ); }
Loading history...
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' );
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

142
/** @scrutinizer ignore-call */ 
143
add_filter( 'login_headerurl', 'strip_login_url' );
Loading history...
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>
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

159
	<span id="footer-thankyou"><a href="<?php echo /** @scrutinizer ignore-call */ esc_url( __( 'http://silent-comics.com/', 'strip' ) ); ?>"><?php printf( esc_html__( 'Developed by %s', 'strip' ), 'Silent Comics' ); ?></a>
Loading history...
Bug introduced by
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 ignore-call  annotation

159
	<span id="footer-thankyou"><a href="<?php echo esc_url( __( 'http://silent-comics.com/', 'strip' ) ); ?>"><?php printf( /** @scrutinizer ignore-call */ esc_html__( 'Developed by %s', 'strip' ), 'Silent Comics' ); ?></a>
Loading history...
Bug introduced by
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 ignore-call  annotation

159
	<span id="footer-thankyou"><a href="<?php echo esc_url( /** @scrutinizer ignore-call */ __( 'http://silent-comics.com/', 'strip' ) ); ?>"><?php printf( esc_html__( 'Developed by %s', 'strip' ), 'Silent Comics' ); ?></a>
Loading history...
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