Ejemplo n.º 1
0
 /**
  * Load 'plugin' file if the options checkbox is set on
  *
  * The file extension of the plugin is ".php"
  * This function implements a simple "load module" until such a time as 
  * either a) modules are implemented, b) the logic is replaced with library logic
  * 
  * @param string $set the option set
  * @param string $option the option within the set
  * @param string $plugin null for the default file extension
  */
 function bw_load_plugin($set = "bw_buttons", $option = "oik-button-shortcodes", $plugin = NULL)
 {
     $checkbox = bobbcomp::bw_get_option($option, $set);
     bw_trace2($checkbox, "checkbox", true, BW_TRACE_DEBUG);
     if ($checkbox == "on") {
         if ($plugin == NULL) {
             $plugin = $option . ".php";
         }
         bw_trace2($plugin, "plugin", false, BW_TRACE_DEBUG);
         oik_require($plugin);
     }
 }
Ejemplo n.º 2
0
 /**
  * Return the themes server if the requested theme is one of ours
  *
  * Note: $bw_registered_themes is an array of filenames
  * we create $bw_theme_slugs as an array of "slug" => array( 'basename' => "theme name", 'file'=> 'server'=>, 'apikey'=> )
  * $bw_themes (stored in WordPress options) also contains 'server' and 'apikey'
  * 
  * @param string $slug theme name
  * @return array 
  */
 static function oik_query_themes_server($slug)
 {
     global $bw_registered_themes, $bw_theme_slugs;
     if (!isset($bw_theme_slugs)) {
         $bw_theme_slugs = array();
         if (count($bw_registered_themes)) {
             foreach ($bw_registered_themes as $key => $value) {
                 $file = bw_array_get($value, "file", null);
                 // The next 2 lines are equivalent to $bw_slug = bw_last_path( $file );
                 $pathinfo = pathinfo($file, PATHINFO_DIRNAME);
                 $bw_slug = basename($pathinfo);
                 $value['basename'] = $bw_slug;
                 $bw_theme_slugs[$bw_slug] = $value;
             }
         }
         bw_trace2($bw_theme_slugs);
     }
     $theme_settings = bobbcomp::bw_get_option($slug, "bw_themes");
     bw_trace2($theme_settings);
     /* return the saved settings, with any registered defaults, otherwise just get the registered settings */
     if ($theme_settings) {
         $server = bw_array_get($theme_settings, "server", null);
         $apikey = bw_array_get($theme_settings, "apikey", null);
         if (!$server || !$apikey) {
             $value = bw_array_get($bw_theme_slugs, $slug, null);
         }
         if (!$server) {
             $server = bobbcomp::bw_array_get_dcb($value, "server", null, "oik_update::oik_get_themes_server");
             bw_trace2($server, $slug, false);
         }
         if (!$apikey) {
             $theme_settings['apikey'] = bw_array_get($value, "apikey", null);
         }
     } else {
         $theme_settings = bw_array_get($bw_theme_slugs, $slug, null);
         if ($theme_settings) {
             $server = bobbcomp::bw_array_get_dcb($theme_settings, "server", null, "oik_update::oik_get_themes_server");
         }
         // apikey doesn't default here
     }
     if ($theme_settings) {
         $theme_settings['server'] = $server;
         bw_trace2($server, "server", false, BW_TRACE_INFO);
     }
     return $theme_settings;
 }