These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Load Email Log plugin. |
||
4 | * |
||
5 | * We need this load code in a separate file since it requires namespace |
||
6 | * and using namespace in PHP 5.2 will generate a fatal error. |
||
7 | * |
||
8 | * @since 2.0 |
||
9 | */ |
||
10 | |||
11 | /** |
||
12 | * Load Email Log plugin. |
||
13 | * |
||
14 | * @since 2.0 |
||
15 | * |
||
16 | * @param string $plugin_file Main plugin file. |
||
17 | */ |
||
18 | function load_email_log( $plugin_file ) { |
||
19 | global $email_log; |
||
20 | |||
21 | $plugin_dir = plugin_dir_path( $plugin_file ); |
||
22 | |||
23 | // setup autoloader. |
||
24 | require_once 'include/EmailLogAutoloader.php'; |
||
25 | |||
26 | $loader = new \EmailLog\EmailLogAutoloader(); |
||
27 | $loader->add_namespace( 'EmailLog', $plugin_dir . 'include' ); |
||
28 | |||
29 | if ( file_exists( $plugin_dir . 'tests/' ) ) { |
||
30 | // if tests are present, then add them. |
||
31 | $loader->add_namespace( 'EmailLog', $plugin_dir . 'tests/wp-tests' ); |
||
32 | } |
||
33 | |||
34 | $loader->add_file( $plugin_dir . 'include/Util/helper.php' ); |
||
35 | $loader->add_file( $plugin_dir . 'include/Addon/addon-helper.php' ); |
||
36 | |||
37 | $loader->register(); |
||
38 | |||
39 | $email_log = new \EmailLog\Core\EmailLog( $plugin_file, $loader, new \EmailLog\Core\DB\TableManager() ); |
||
40 | |||
41 | if ( \EmailLog\Util\is_admin_non_ajax_request() ) { |
||
42 | // Loading licenser in frontend or ajax request is resulting in huge performance issues. |
||
43 | $email_log->set_licenser( new \EmailLog\Addon\License\Licenser() ); |
||
44 | |||
45 | $email_log->add_loadie( new \EmailLog\Addon\DependencyEnforcer() ); |
||
46 | $email_log->add_loadie( new \EmailLog\Core\Request\OverridePluginAPI() ); |
||
47 | } |
||
48 | |||
49 | $email_log->add_loadie( new \EmailLog\Core\EmailLogger() ); |
||
50 | $email_log->add_loadie( new \EmailLog\Core\UI\UILoader() ); |
||
51 | $email_log->add_loadie( new \EmailLog\Core\UI\Setting\EmailLogSetting() ); |
||
0 ignored issues
–
show
|
|||
52 | |||
53 | $email_log->add_loadie( new \EmailLog\Core\Request\NonceChecker() ); |
||
54 | $email_log->add_loadie( new \EmailLog\Core\Request\LogListAction() ); |
||
55 | $email_log->add_loadie( new \EmailLog\Core\Request\OverridePluginAPI() ); |
||
56 | |||
57 | // `register_activation_hook` can't be called from inside any hook. |
||
58 | register_activation_hook( $plugin_file, array( $email_log->table_manager, 'on_activate' ) ); |
||
59 | |||
60 | // Ideally the plugin should be loaded in a later event like `init` or `wp_loaded`. |
||
61 | // But some plugins like EDD are sending emails in `init` event itself, |
||
62 | // which won't be logged if the plugin is loaded in `wp_loaded` or `init`. |
||
63 | add_action( 'plugins_loaded', array( $email_log, 'load' ), 101 ); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Return the global instance of Email Log plugin. |
||
68 | * Eventually the EmailLog class might become singleton. |
||
69 | * |
||
70 | * @since 2.0 |
||
71 | * |
||
72 | * @global \EmailLog\Core\EmailLog $email_log |
||
73 | * @return \EmailLog\Core\EmailLog |
||
74 | */ |
||
75 | function email_log() { |
||
76 | global $email_log; |
||
77 | |||
78 | return $email_log; |
||
79 | } |
||
80 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: