最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Mu-plugin causes entire site to crash

programmeradmin3浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?

Closed 5 years ago.

Improve this question

I think i'm probably doing something daft here. Every time i try to include this as a mu-plugin it takes down the test site though.

<?php
if( is_plugin_active( '/public_html/wp-content/plugins/wordfence.php' ) ) {
    require_once('wp-load.php');
    $to = ‘[email protected]’;
    $subject = ‘Wordfence is down’;
    $message = ‘Wordfence is not active’;
    $headers = array('Content-Type: text/html; charset=UTF-8');
    wp_mail( $to, $subject, $message, $headers );
}

Any ideas where i'm going wrong would be very much appreciated :)

Closed. This question is off-topic. It is not currently accepting answers.

Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?

Closed 5 years ago.

Improve this question

I think i'm probably doing something daft here. Every time i try to include this as a mu-plugin it takes down the test site though.

<?php
if( is_plugin_active( '/public_html/wp-content/plugins/wordfence.php' ) ) {
    require_once('wp-load.php');
    $to = ‘[email protected]’;
    $subject = ‘Wordfence is down’;
    $message = ‘Wordfence is not active’;
    $headers = array('Content-Type: text/html; charset=UTF-8');
    wp_mail( $to, $subject, $message, $headers );
}

Any ideas where i'm going wrong would be very much appreciated :)

Share Improve this question asked May 20, 2019 at 12:39 Peter KirwanPeter Kirwan 31 bronze badge 2
  • Debugging always needs to be done you. Try to accomplish this systematically. Delete line by line of your snippet until you get the line that's causing the problem. Then check the official docs of the function that's causing the problem and fix it. You might also check/search the WordPress core for similar usages. – norman.lol Commented May 20, 2019 at 13:18
  • Cough curly quotes cough. :) – rudtek Commented May 21, 2019 at 14:28
Add a comment  | 

2 Answers 2

Reset to default 1

is_plugin_active isn't available for mu-plugins to use. The codex says:

NOTE: defined in wp-admin/includes/plugin.php, so this is only available from within the admin pages, and any references to this function must be hooked to admin_init or a later action. If you want to use this function from within a template or a must-use plugin, you will need to manually require plugin.php, an example is below.

And I think there must be better ways to solve this anyway: your code will try and send you an email for every non-static HTTP request to the site, and you probably meant !is_plugin_active or is_plugin_inactive, and in any case these accept relative paths to the plugin files not absolute paths.

It's best to turn on WP_DEBUG to see exactly what problem you're facing. The code above includes fancy quotes like and and doesn't include the full path to wp-load.php.

发布评论

评论列表(0)

  1. 暂无评论