These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Debug Bar Cron, a WordPress plugin. |
||
4 | * |
||
5 | * @package WordPress\Plugins\Debug Bar Cron |
||
6 | * @author Zack Tollman, Helen Hou-Sandi, Juliette Reinders Folmer |
||
7 | * @link https://github.com/tollmanz/debug-bar-cron |
||
8 | * @version 0.1.2 |
||
9 | * @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher |
||
10 | * |
||
11 | * @wordpress-plugin |
||
12 | * Plugin Name: Debug Bar Cron |
||
13 | * Plugin URI: http://wordpress.org/extend/plugins/debug-bar-cron/ |
||
14 | * Description: Debug Bar Cron adds information about WP scheduled events to the Debug Bar. |
||
15 | * Version: 0.1.2 |
||
16 | * Author: Zack Tollman, Helen Hou-Sandi |
||
17 | * Author URI: http://github.com/tollmanz/ |
||
18 | * Depends: Debug Bar |
||
19 | * Text Domain: debug-bar-cron |
||
20 | * Domain Path: /languages/ |
||
21 | */ |
||
22 | |||
23 | // Avoid direct calls to this file. |
||
24 | if ( ! function_exists( 'add_action' ) ) { |
||
25 | header( 'Status: 403 Forbidden' ); |
||
26 | header( 'HTTP/1.1 403 Forbidden' ); |
||
27 | exit(); |
||
28 | } |
||
29 | |||
30 | if ( ! function_exists( 'debug_bar_cron_has_parent_plugin' ) ) { |
||
31 | /** |
||
32 | * Show admin notice & de-activate if debug-bar plugin not active. |
||
33 | */ |
||
34 | function debug_bar_cron_has_parent_plugin() { |
||
35 | $file = plugin_basename( __FILE__ ); |
||
36 | |||
37 | if ( is_admin() && ( ! class_exists( 'Debug_Bar' ) && current_user_can( 'activate_plugins' ) ) && is_plugin_active( $file ) ) { |
||
38 | add_action( 'admin_notices', create_function( null, 'echo \'<div class="error"><p>\', sprintf( __( \'Activation failed: Debug Bar must be activated to use the <strong>Debug Bar Cron</strong> Plugin. %sVisit your plugins page to install & activate.\', \'debug-bar-cron\' ), \'<a href="\' . esc_url( admin_url( \'plugin-install.php?tab=search&s=debug+bar\' ) ) . \'">\' ), \'</a></p></div>\';' ) ); |
||
0 ignored issues
–
show
introduced
by
![]() The use of
create_function is highly discouraged, better use a closure.
// Instead of
$function = create_function('$a, $b', 'return $a + $b');
// Better use
$function = function($a, $b) { return $a + $b; }
![]() |
|||
39 | |||
40 | deactivate_plugins( $file, false, is_network_admin() ); |
||
41 | |||
42 | // Add to recently active plugins list. |
||
43 | if ( ! is_network_admin() ) { |
||
44 | $insert = array( |
||
45 | $file => time(), |
||
46 | ); |
||
47 | |||
48 | update_option( 'recently_activated', ( $insert + (array) get_option( 'recently_activated' ) ) ); |
||
49 | } else { |
||
50 | update_site_option( 'recently_activated', ( $insert + (array) get_site_option( 'recently_activated' ) ) ); |
||
0 ignored issues
–
show
The variable
$insert seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?
This error can happen if you refactor code and forget to move the variable initialization. Let’s take a look at a simple example: function someFunction() {
$x = 5;
echo $x;
}
The above code is perfectly fine. Now imagine that we re-order the statements: function someFunction() {
echo $x;
$x = 5;
}
In that case, ![]() |
|||
51 | } |
||
52 | |||
53 | // Prevent trying again on page reload. |
||
54 | if ( isset( $_GET['activate'] ) ) { |
||
0 ignored issues
–
show
|
|||
55 | unset( $_GET['activate'] ); |
||
0 ignored issues
–
show
|
|||
56 | } |
||
57 | } |
||
58 | } |
||
59 | add_action( 'admin_init', 'debug_bar_cron_has_parent_plugin' ); |
||
60 | } |
||
61 | |||
62 | |||
63 | if ( ! function_exists( 'zt_add_debug_bar_cron_panel' ) ) { |
||
64 | /** |
||
65 | * Adds panel, as defined in the included class, to Debug Bar. |
||
66 | * |
||
67 | * @param array $panels Existing debug bar panels. |
||
68 | * |
||
69 | * @return array |
||
70 | */ |
||
71 | function zt_add_debug_bar_cron_panel( $panels ) { |
||
72 | if ( ! class_exists( 'ZT_Debug_Bar_Cron' ) ) { |
||
73 | require_once 'class-zt-debug-bar-cron.php'; |
||
74 | $panels[] = new ZT_Debug_Bar_Cron(); |
||
75 | } |
||
76 | return $panels; |
||
77 | } |
||
78 | add_filter( 'debug_bar_panels', 'zt_add_debug_bar_cron_panel' ); |
||
79 | } |
||
80 |