[WordPress] プラグインがアクティブかどうか調べる

アクティブなプラグインは get_option(‘active_plugins’) で取得できる。

function is_plugin_active($file) {
	$is_active = false;
	foreach ((array) get_option('active_plugins') as $val) {
		if (preg_match('/'.preg_quote($file, '/').'/i', $val)) {
			$is_active = true;
			break;
		}
	}
	return $is_active;
}

is_plugin_active('hello.php'); とか is_plugin_active('akismet/akismet.php'); とかすれば良いよ。


Posted

in

by

Comments

“[WordPress] プラグインがアクティブかどうか調べる”. への1件のコメント

コメントを残す