Esempio n. 1
0
/**
 * Activate / deactivate MU library processing
 *
 * Either copies an MU plugin from the source to the target or removes the MU plugin file from the target
 *
 *
 * Note: WPMU_PLUGIN_DIR may not have been defined if we're invoked from wp-config.php, but ABSPATH should have been.
 *
 * MU plugin files are loaded in ascending alphabetical order.
 * For MU plugin for oik-bwtrace is prefixed with an underscore so that it's loaded very early.
 * The MU plugin for oik-lib is prefixed with two underscores so that it's loaded before oik-bwtrace
 * @TODO Check if this is a good idea or not.
 *
 * @param bool $activate true to activate, false to deactivate
 * @param string $file
 * @param string $plugin
 * @param string $target
 */
function oik_lib_activate_mu($activate = true, $file = "includes/__oik-lib-mu.php", $plugin = "oik-lib", $target = null)
{
    //bw_trace2();
    $source = oik_path($file, $plugin);
    if (defined('WPMU_PLUGIN_DIR')) {
        $mu_target = WPMU_PLUGIN_DIR;
    } else {
        $mu_target = ABSPATH . '/wp-content/mu-plugins';
    }
    //bw_trace2( $mu_target, "target dir" );
    if (is_dir($mu_target)) {
        $mu_target .= '/';
        if ($target) {
            $mu_target .= $target;
        } else {
            $mu_target .= basename($file);
        }
        //bw_trace2( $mu_target, "target file:$activate" );
        if ($activate) {
            if (!file_exists($mu_target)) {
                copy($source, $mu_target);
            }
        } else {
            if (file_exists($mu_target)) {
                unlink($mu_target);
            }
        }
    } else {
        // Do we need to make this ourselves?
        bw_trace2("Not a dir?");
        //gobang();
    }
}
/**
 * Implement "oik_loaded" action for the oik-nivo-slider 
 */
function oik_nivo_add_shortcodes()
{
    bw_add_shortcode("nivo", "bw_nivo_slider", oik_path("nivo.inc", "oik-nivo-slider"), false);
}
Esempio n. 3
0
/**
 * Return the name of the XML file
 *
 * @param string $station The Station ID
 * @return string The XML file name. Now has a longer extension than before.
 */
function us_xml_file($station = "8423745")
{
    $xml = "Annual XML.Annual XML.Annual XML";
    $file = oik_path("xml/{$station}.{$xml}", "us-tides");
    return $file;
}
Esempio n. 4
0
/**
 * Implement "oik_add_shortcodes" action for oik-ms
 */
function oik_ms_init()
{
    bw_add_shortcode("bw_blog", "bw_blog", oik_path("shortcodes/oik-blog.php", "oik-ms"), false);
    bw_add_shortcode("bw_blogs", "bw_blogs", oik_path("shortcodes/oik-blogs.php", "oik-ms"), false);
}
Esempio n. 5
0
/**
 * Implement "oik_loaded" action for oik-video
 */
function bw_video_init()
{
    bw_add_shortcode("bw_video", "bw_video", oik_path("oik-video.inc", "oik-video"), false);
    // We should only do this when it's admin and oik has been loaded
    add_filter("oik_admin_menu", "bwv_admin_menu");
}
Esempio n. 6
0
/**
 * Implement "oik_add_shortcodes" for US-tides
 */
function us_tides_init()
{
    bw_add_shortcode('us_tides', 'us_tides', oik_path("shortcodes/us-tides.php", "us-tides"), false);
}
Esempio n. 7
0
 /**
  * Load a file which could have been relocated from one plugin to another
  * 
  * @param string $include_file - file name within the chosen $pluging e.g. admin/oik-header.inc
  * @param string $to_plugin - the first plugin to try - this is the "to" plugin to where the file has been relocated
  * @param string $from_plugin - this is the original plugin, defaulting to "oik"
  * 
  * Note: we try to be as efficient as possible loading the "new" file 
  * Note: this code does not allow for files to be renamed during relocation
  * This code does REQUIRE the file to exist somewhere! 
  */
 function oik_require2($include_file = "bobbfunc.inc", $to_plugin, $from_plugin = "oik")
 {
     $new_path = oik_path($include_file, $to_plugin);
     if (file_exists($new_path)) {
         require_once $new_path;
     } else {
         oik_require($include_file, $from_plugin);
     }
 }
Esempio n. 8
0
 /**
  * Satisfy pre-requisites for oik-lib shared library processing
  *
  * The "oik-lib" library is dependent upon "oik_boot" and "bwtrace".
  * "oik_boot" for functions such as oik_require() and "bwtrace" for the trace APIs
  *
  * These are shareable shared libraries from the "oik" and "oik-bwtrace" plugins.
  * 
  * If they are not registered by these plugins then we need to load them ourselves.
  * Having loaded these shared libraries we register them so that other plugins can use oik_require_lib()
  *
  * @return bool true if "oik_boot" and "bwtrace" both loaded 
  */
 function oik_lib_boot()
 {
     $loaded = true;
     if (!function_exists("oik_path")) {
         $oik_boot_file = __DIR__ . "/oik_boot.php";
         $loaded = (include_once $oik_boot_file);
     }
     if ($loaded && !function_exists("bw_trace2") && function_exists("oik_require")) {
         $trace_file = oik_path("libs/bwtrace.php", "oik-lib");
         $loaded = (include_once $trace_file);
     }
     if ($loaded) {
         oik_lib_register_default_libs();
     }
     return $loaded;
 }