Jelajahi Sumber

code reuse. moving generic function from plugin to function/plugins.php

tokul 20 tahun lalu
induk
melakukan
5e13f2f9f3
2 mengubah file dengan 20 tambahan dan 13 penghapusan
  1. 20 0
      functions/plugin.php
  2. 0 13
      plugins/info/functions.php

+ 20 - 0
functions/plugin.php

@@ -189,6 +189,26 @@ function boolean_hook_function($name,$parm=NULL,$priority=0,$tie=false) {
 function soupNazi(){
     return !checkForJavascript();
 }
+
+/**
+ * Check if plugin is enabled
+ * @param string $plugin_name plugin name
+ * @since 1.5.1
+ * @return boolean
+ */
+function is_plugin_enabled($plugin_name) {
+  global $plugins;
+
+  if (! isset($plugins) || ! is_array($plugins) || empty($plugins))
+    return false;
+
+  if ( in_array($plugin_name,$plugins) ) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
 /*************************************/
 /*** MAIN PLUGIN LOADING CODE HERE ***/
 /*************************************/

+ 0 - 13
plugins/info/functions.php

@@ -59,17 +59,4 @@ function print_response($response) {
     }
 }
 
-/**
- * Check if plugin is enabled
- * @param string $plugin_name plugin name
- * @return boolean
- */
-function is_plugin_enabled($plugin_name) {
-  global $plugins;
-  if ( in_array($plugin_name,$plugins) ) {
-    return true;
-  } else {
-    return false;
-  }
-}
 ?>