file_get_contents

  • WordPressのプラグインSingle Post Templateは、サーバーの環境によりプラグインを有効化した段階でエラーが表示される場合がある。
    他のプラグインとのバッティングの場合もあるが、多くの場合、file_get_contentsが原因。

    また、パソコンからの管理画面ではエラーが表示されなくても、スマートフォンから管理画面を開くとエラーが表示されている場合もある。

    file_get_contentsが理由の場合は以下の方法でWarning(エラー表示)を消すことができる。

    /wp-content/plugins/single-post-template
    内の
    post_templates.php

    を開き、

    if ( ! preg_match( ‘|Single Post Template:(.*)$|mi’, file_get_contents( $full_path ), $header ) )

    の行にあるfile_get_contentsの前にエラー表示抑止のための@を入れる

    if ( ! preg_match( ‘|Single Post Template:(.*)$|mi’, @file_get_contents( $full_path ), $header ) )

    これでエラー表示は出なくなる。