Exemple #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();
    }
}
Exemple #2
0
/**
 * Process schunter depending on how invoked
 *
 * short code hunter ( schunter ) is initially designed to be run in a batch mode
 * as we first want to find out how many shortcodes are being used and where they're being used.
 * This will help us to determine whether or not it makes sense to register a subset of shortcodes.
 * Of course, most plugins and themes register all their shortcodes willy-nilly.
 * Some re-education may be needed.
 * 
 * - This code is not yet designed to be run under WP-cli
 * - This code does not have a WordPress front-end or admin back end
 * - It runs under oik-wp.php
 * - When invoked from "oik-wp.php" ( part of oik-batch ) then it will run schunter_run()
 * - The code is dependent upon oik APIs
 * - It has not been tested without the oik base plugin being active
 */
function schunter_loaded()
{
    if (PHP_SAPI == "cli") {
        if ($_SERVER['argv'][0] == "boot-fs.php") {
            // This is WP-CLI
        } else {
            //oik_require_lib( "oik-cli" );
            oik_batch_load_cli_functions();
            if (oik_batch_run_me(__FILE__)) {
                //schunter_run();
                echo "End cli:" . __FUNCTION__ . PHP_EOL;
            }
        }
    } else {
        //echo PHP_SAPI;
        //echo PHP_EOL;
        if (function_exists("bw_trace2")) {
            bw_trace2(PHP_SAPI, "schunter loaded in WordPress environment?");
        }
    }
    if (function_exists("add_action")) {
        // if ( bw_is_wordpress() ) {
        //add_action( "admin_notices", "oik_batch_activation" );
        add_action("admin_menu", "schunter_admin_menu");
        add_filter('set-screen-option', "schunter_set_screen_option", 10, 3);
        add_action("run_schunter.php", "schunter_run");
    }
}
/**
 * Return count of footer widgets required
 */
function gfw_footer_widgets()
{
    $supports = get_theme_support('genesis-footer-widgets');
    $supports = bw_array_get($supports, "0", $supports);
    if (is_array($supports)) {
        $supports = $supports[0];
    }
    bw_trace2($supports, "genesis-footer-widgets supported", false, BW_TRACE_DEBUG);
    return $supports;
}
Exemple #4
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
  */
 function bw_load_plugin($set = "bw_buttons", $option = "oik-button-shortcodes", $plugin = NULL)
 {
     $checkbox = 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);
     }
 }
Exemple #5
0
/**
 * 
 * Implement "admin_head-schunter-options_page_schunter" for oik-clone
 * 
 * When we're trying to display a List Table then hooking into 
 * nav-tabs is too late to load the classes since 
 * WordPress's get_column_headers() function invokes the hook to find the columns to be displayed.
 * and we need to have instantiated the class in order for this hook to have been registered.
 * Therefore, we need to hook into "admin_head" and determine what's actually happening.
 * Actually, we can hook into the specific action for the page.
 * 
 */
function schunter_admin_head()
{
    $tab = bw_array_get($_REQUEST, "tab", null);
    global $list_table;
    switch ($tab) {
        default:
            bw_trace2();
            oik_require_lib("admin/schunter-list.php", "schunter");
            oik_require("includes/oik-list-table.php");
            $list_table = bw_get_list_table("Schunter_List_Table", array("plugin" => "schunter", "tab" => $tab, "page" => "schunter"));
            add_action("schunter_nav_tab_codes", "schunter_nav_tab_codes");
    }
}
 /**
  * Load the OIK_Autoload logic
  * 
  * You might think that the fact that you invoke oik_require_lib( "oik_autoload" ); 
  * would be enough to tell the autoload library that you'll be using autoloading for your classes.
  * But I think it's better to implicitely invoke either oik_require_class() or oik_autoload() to instantiate the
  * autoloading logic when you know that OO code will be used.
  * 
  * Notice we use oik_require_file() to load a class file manually
  */
 function oik_autoload()
 {
     if (!class_exists("OIK_Autoload")) {
         //echo "Loading OIK_Autoload" ;
         oik_require_file("class-oik-autoload.php", "oik-autoload");
     }
     if (class_exists("OIK_Autoload")) {
         $oik_autoload = OIK_Autoload::instance();
     } else {
         bw_trace2("Class OIK_Autoload does not exist");
         die;
     }
     return $oik_autoload;
 }
Exemple #7
0
 /**
  * Compare the library files in two directories
  *
  * This solution is a temporary solution until a better one is found using 
  * - Git submodules 
  * - or Composer packages.
  * 
  * The oik-libs /libs directory is supposed to contain the master
  * The plugin's /libs directory should either be updated from the master
  * OR, if it's newer than the master then we update the master
  *
  * When packaging a plugin we need to ensure that we've got the latest version of the shared library files
  * that we use.
  * 
  * For each file in the plugin's directory we compare it with the master
  *
  * plugin time vs master time | processing
  * ---------------------- | -----------
  * earlier | Copy to plugins dir from master
  * same | OK
  * later | Copy to master dir from plugins dir
  *  		
  * 
  * 
  * Note: We may need to loop through all the plugins a couple of times
  * 
  * master
  *
  * @param string $master_dir - the master directory
  * @param string $plugins_dir - the plugins directory
  *  
  */
 function oik_libs_compare_libs($master_dir, $plugins_dir)
 {
     oik_require("admin/oik-apis.php", "oik-shortcodes");
     $files = _oiksc_get_php_files($plugins_dir, null);
     bw_trace2($files, "files", true);
     foreach ($files as $key => $file) {
         if (substr($file, -1) !== ".") {
             //echo "$key $file" . PHP_EOL;
             $master_file = oik_libs_get_file($file, $master_dir);
             $plugin_file = oik_libs_get_file($file, $plugins_dir);
             oik_libs_compare_file($plugin_file, $master_file);
         }
     }
 }
Exemple #8
0
/** 
 * Implement [bw_blog] shortcode to select the blog to be used in subsequent shortcodes
 *
 * We might eexpect that if the blog was invalid then switch_to_blog() would fail.
 * But it doesn't, so we need to check.
 * 
 * 
 * @param array $atts - expected to either contain "blog" or uses the index 0 values
 * @param string $content - not expected
 * @param string $tag - the shortcode used
 * @return string - nothing is generated directly by this shortcode
 */
function bw_blog($atts = null, $content = null, $tag = null)
{
    if (is_multisite()) {
        $blog = bw_array_get_from($atts, "blog,0", null);
        if ($blog) {
            $details = get_blog_details($blog, false);
            if ($details) {
                switch_to_blog($blog);
            } else {
                e("Invalid blog {$blog}");
            }
        } else {
            restore_current_blog();
        }
    } else {
        bw_trace2("Shortcode not effective in a non-multisite implementation");
    }
    return bw_ret();
}
Exemple #9
0
 /**
 * Return the current theme name
 * 
 * Note: get_current_theme() was deprecated in WP 3.4 but wp_get_theme() is NEW
 * It didn't exist in WP 3.3.1.
 * So we need a wrapper to test the WordPress version
 * 
 
 C:\apache\htdocs\wordpress\wp-content\plugins\oik\bobbfunc.inc(1037:0) 2012-07-18T11:03:12+00:00 617 cf=the_content bw_get_theme(4) current theme WP_Theme Object
 (
    [theme_root:WP_Theme:private] => C:\apache\htdocs\wordpress/wp-content/themes
    [headers:WP_Theme:private] => Array
        (
            [Name] => Twenty Eleven
            [ThemeURI] => http://wordpress.org/extend/themes/twentyeleven
            [Description] => The 2011 theme for WordPress is sophisticated, lightweight, and adaptable. Make it yours with a custom menu, header image, and background -- then go further with available theme options for light or dark color scheme, custom link colors, and three layout choices. Twenty Eleven comes equipped with a Showcase page template that transforms your front page into a showcase to show off your best content, widget support galore (sidebar, three footer areas, and a Showcase page widget area), and a custom "Ephemera" widget to display your Aside, Link, Quote, or Status posts. Included are styles for print and for the admin editor, support for featured images (as custom header images on posts and pages and as large images on featured "sticky" posts), and special styles for six different post formats.
            [Author] => the WordPress team
            [AuthorURI] => http://wordpress.org/
            [Version] => 1.4
            [Template] => 
            [Status] => 
            [Tags] => dark, light, white, black, gray, one-column, two-columns, left-sidebar, right-sidebar, fixed-width, flexible-width, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-image-header, featured-images, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready
            [TextDomain] => twentyeleven
            [DomainPath] => 
        )
 
    [headers_sanitized:WP_Theme:private] => 
    [name_translated:WP_Theme:private] => 
    [errors:WP_Theme:private] => 
    [stylesheet:WP_Theme:private] => twentyeleven
    [template:WP_Theme:private] => twentyeleven
    [parent:WP_Theme:private] => 
    [theme_root_uri:WP_Theme:private] => 
    [textdomain_loaded:WP_Theme:private] => 
    [cache_hash:WP_Theme:private] => a3e6a9c1d55ef4070d99b81dc839928b
 )
 * 
 */
 function bw_get_theme()
 {
     global $wp_version;
     if (version_compare($wp_version, '3.4', "ge")) {
         $theme = wp_get_theme();
         $current_theme = $theme->stylesheet;
     } else {
         $current_theme = get_current_theme();
     }
     bw_trace2($current_theme, "current theme");
     return $current_theme;
 }
Exemple #10
0
/** 
 * Implement [bw_blogs] shortcode to list the blogs on the multisite
 * 
 * @param array $atts - expected to either contain "blogs" or uses the index 0 values
 * @param string $content - content to expand for each blog
 * @param string $tag - the shortcode used
 * @return string - nothing is generated directly by this shortcode
 */
function bw_blogs($atts = null, $content = null, $tag = null)
{
    if (is_multisite()) {
        $blogs = bw_array_get_from($atts, "blogs,0", null);
        if ($blogs) {
            $blogs = bw_as_array($blogs);
        } else {
            $blogs = bw_get_blog_list();
        }
        bw_display_blogs($blogs, $atts, $content);
    } else {
        bw_trace2("bw_blogs shortcode not effective in a non-multisite implementation");
    }
    return bw_ret();
}
 /**
  * Determine if the library has been checked for dependencies
  * 
  * If the library is already loaded then we assume that its dependencies have been checked
  * If the library has already been checked then we don't need to do it again.
  * Each library that's checked is added to the array of checked libraries.
  *
  * @param object $lib 
  * @return object the checked library object or null
  */
 function checked($lib)
 {
     $checked = $this->is_loaded($lib->library, $lib->version);
     $checked = bw_array_get($this->checked_libraries, $lib->library, $checked);
     $this->checked_libraries[$lib->library] = $lib;
     bw_trace2($checked, "checked", true, BW_TRACE_VERBOSE);
     return $checked;
 }
 /**
  * Obtain the plugin slugs
  *
  * The plugins slugs are the array keys from get_plugins() saved in 
  * a transient named 'plugin_slugs' for 24 hours.
  *
  * @return array of plugin slugs 
  */
 function bw_get_plugin_slugs()
 {
     $plugin_slugs = get_transient('plugin_slugs');
     if (false === $plugin_slugs) {
         require_once ABSPATH . "wp-admin/includes/plugin.php";
         $plugins = get_plugins();
         bw_trace2($plugins, "plugins", false, BW_TRACE_DEBUG);
         $plugin_slugs = array_keys($plugins);
         set_transient('plugin_slugs', $plugin_slugs, 86400);
     }
     bw_trace2($plugin_slugs, "plugin_slugs", false, BW_TRACE_DEBUG);
     return $plugin_slugs;
 }
 /**
  * Checks compatible versions
  *
  */
 function compatible_version($current_version, $required_version)
 {
     bw_trace2(null, null, true, BW_TRACE_VERBOSE);
     if ("*" != $required_version) {
         $version_compare = version_compare($current_version, $required_version);
         $acceptable = false;
         bw_trace2($version_compare, "version compare", false, BW_TRACE_VERBOSE);
         switch ($version_compare) {
             case 0:
                 $acceptable = true;
                 break;
             case -1:
                 break;
             default:
                 // Now we have to check semantic versioning
                 // but in the mean time pretend it's acceptable
                 $acceptable = true;
         }
     } else {
         $acceptable = true;
     }
     return $acceptable;
 }
 /**
  * Return the last path for the given file
  * 
  * @param string $file - a fully specified file name ( e.g. __FILE__ )
  * @return string the last part of the file's path
  * e.g. 
  *
  * @link http://www.php.net/manual/en/function.basename.php#72254
  * When using basename() on a path to a directory ('/bar/foo/'), the last path component ('foo') is returned
  */
 static function bw_last_path($file)
 {
     bw_trace2();
     $pathinfo = pathinfo($file, PATHINFO_DIRNAME);
     $last_path = basename($pathinfo);
     return $last_path;
 }
 /**
  * Safer json_decode() 
  * 
  * @param string $json - what we believe to be JSON 
  * @param bool $assoc - set true to convert objects into associative arrays
  */
 static function bw_json_decode($json, $assoc = false)
 {
     $decoded = null;
     if (is_object($json)) {
         bw_trace2(null, null, true, BW_TRACE_ERROR);
     } elseif ($json) {
         $pos = strpos($json, '{');
         if ($pos) {
             $unexpected = substr($json, 0, $pos);
             bw_trace2($unexpected, "Unexpected data", true, BW_TRACE_WARNING);
             $json = substr($json, $pos);
         }
         $decoded = json_decode($json, $assoc);
     }
     return $decoded;
 }
Exemple #16
0
/**
 * Implement "auto_update_theme" for oik-fum
 * 
 * Return true if you want auto updates to be applied to the theme
 * 
 * @param bool $update 
 * @param object $item 
 * @return bool 
 */
function oikf_auto_update_theme($update, $item)
{
    bw_trace2();
    bw_backtrace();
    gob();
}
Exemple #17
0
/**
 * Create a responsive menu without JavaScript
 *
 * Is this sensible?
 * It's not as easy as using the global.js which already exists
 *
 * 
 */
function genesis_hm_wp_nav_menu_items($menu, $args)
{
    bw_trace2();
    if ('primary' === $args->menu->name) {
        $rmi = '<div class="responsive-menu-icon"></div>';
        $menu = $rmi . $menu;
    }
    return $menu;
}
 function oik_require_file($file, $library, $args = null)
 {
     //bw_trace2();
     if (function_exists("oik_libs")) {
         $oik_libs = oik_libs();
         $library_file = $oik_libs->require_file($file, $library, $args);
     } else {
         $library_file = oik_require_lib_fallback($file);
     }
     bw_trace2($library_file, "library_file", true, BW_TRACE_DEBUG);
     return $library_file;
 }
Exemple #19
0
/**
 * See if we can mess up AJAX
 *
 * Here's an example of bw_trace2() that will only log the trace record
 * when tracing at "Debug" level.
 *
 * @param string $ajax_handler 
 * @return string updated AJAX die handler function
 */
function dinlo_die($ajax_handler)
{
    bw_trace2(null, null, true, BW_TRACE_ERROR);
    return "dinlo_not_there";
}
 /**
  * Determine the server that supports this theme
  * @param string $theme - theme name
  * @param WP_theme $theme_object - the WP_theme object
  * @param array $theme_data - oik theme registration information
  * @return 
  */
 function bw_get_theme_server($theme = "oik", $theme_object, $theme_data)
 {
     $server = bw_array_get($theme_data, "server", null);
     if (!$server) {
         if ($theme_object->exists()) {
             $server = $theme_object->get('ThemeServer');
         }
     }
     if (!$server) {
         $server = "&nbsp;";
     }
     bw_trace2($server, "theme-server");
     return $server;
 }
 /**
  * Register a class that can be autoloaded
  *
  * If the $class is numeric we need to extract the name from the array
  */
 function set_class($class, $load)
 {
     bw_trace2($load, $class, false, BW_TRACE_VERBOSE);
     if (is_numeric($class)) {
         $class = $load["class"];
     }
     $this->classes[$class] = $load;
 }
 /**
  * Reduce items to just those that need to be displayed
  */
 function select_items($atts)
 {
     $page = $atts['paged'];
     $posts_per_page = $atts['posts_per_page'];
     $pages = ceil($this->total_items / $posts_per_page);
     $start = ($page - 1) * $posts_per_page;
     $end = min($start + $posts_per_page, $this->total_items) - 1;
     $this->items = array_slice($this->items, $start, 1 + $end - $start);
     bw_trace2($this->items, "selected items");
 }
Exemple #23
0
/** 
* Disable remaining filters for the current filter
*
* We're expanding a shortcode that's being used to compare the results of running
* different filters against the "current" installation.
* The current installation may be WordPress 4.0, 4.1, 4.2 or higher
* Any filters that are run after shortcode expansion could affect our output.
* So we need to disable all the filters that follow.
* We must not disable filters that precede this one
* First we have to find out what this one is
* We can look up the call stack and find a match for the filter function
* in the global filters array.
* 
* 
0. bw_lazy_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik\bwtrace.inc:60 0
1. bw_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\trac29608\trac29608.php:256 0
2. trac_29608_disable_remaining_filters C:\apache\htdocs\wordpress\wp-content\plugins\trac29608\trac29608.php:190 0
3. trac_29608(,,29608) C:\apache\htdocs\wordpress\wp-content\plugins\trac29608\trac29608.php:0 3
4. call_user_func(trac_29608,,,29608) C:\apache\htdocs\wordpress\wp-includes\shortcodes.php:286 4
5. do_shortcode_tag(array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-css\includes\shortcodes-earlier.php:100 1
6. do_shortcode_tag_earlier(array) C:\apache\htdocs\wordpress\wp-content\plugins\oik-css\includes\shortcodes-earlier.php:0 1
7. preg_replace_callback(/\[(\[?)(embed|wp_caption|caption|gallery|playlist|audio|video|purchase_link|download_history|purchase_history|download_checkout|download_cart|edd_login|edd_register|download_discounts|purchase_collection|downloads|edd_price|edd_receipt|edd_profile_editor|dumptag|paragraph|noautop|29608|year|rss|ad|top|login_link|blog_title|xhtml|css|rss_url|rss_title|template_url|search|product|product_page|product_category|product_categories|add_to_cart|add_to_cart_url|products|recent_products|sale_products|best_selling_products|top_rated_products|featured_products|product_attribute|related_products|shop_messages|woocommerce_order_tracking|woocommerce_cart|woocommerce_checkout|woocommerce_my_account|woocommerce_messages|bw_otd|bw_field|bw_fields|bw_new|bw_related|oik_edd_apikey|oikp_download|bw_squeeze|bw_testimonials|oikth_download|bw_mshot|nivo|bugger|fbh|latestnews|getoik|lazy|loikp|TODO|apiref|themeref|smart|lssc|diy|bob|fob|bing|bong|wide|hide|wow|WoW|WOW|oik|loik|OIK|lbw|bw_page|bw_post|bw_plug|bp|lwp|lbp|wpms|lwpms|drupal|ldrupal|artisteer|lartisteer|wp|bw_csv|bw_search|bw_dash|bw_action|bw_rpt|bw_graphviz|bw_crumbs|bw_option|bw_text|bw_css|bw_geshi|bw_background|bw_autop|bw_blog|bw_blogs|bw_popup|bw_more|bw_rwd|bw_codes|bw_code|bw_user|bw_users|bw_wtf|bw_directions|bw|bw_address|bw_mailto|bw_email|bw_geo|bw_telephone|bw_fax|bw_mobile|bw_skype|bw_tel|bw_mob|bw_wpadmin|bw_domain|bw_show_googlemap|bw_contact|bw_company|bw_business|bw_formal|bw_slogan|bw_alt_slogan|bw_admin|bw_twitter|bw_facebook|bw_linkedin|bw_youtube|bw_flickr|bw_picasa|bw_googleplus|bw_google_plus|bw_google\-plus|bw_google|bw_instagram|bw_pinterest|bw_follow_me|clear|bw_logo|bw_qrcode|div|sdiv|ediv|sediv|bw_emergency|bw_abbr|bw_acronym|bw_blockquote|bw_cite|bw_copyright|stag|etag|bw_tree|bw_posts|bw_pages|bw_list|bw_bookmarks|bw_attachments|bw_pdf|bw_images|bw_portfolio|bw_thumbs|bw_button|bw_contact_button|bw_block|bw_eblock|paypal|ngslideshow|gpslides|bwtron|bwtroff|bwtrace|bw_power|bw_editcss|bw_table|bw_parent|bw_iframe|bw_jq|bw_accordion|bw_tabs|bw_login|bw_loginout|bw_register|bw_link|bw_contact_form|bw_countdown|bw_cycle|bw_count|bw_navi|bw_tides|bw_api|api|apis|hooks|codes|file|files|classes|hook|md)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/s,do_shortcode_tag_earlier,[noautop][29608]

  
 global $wp_filter;
 $fields = array();
 $filters = bw_array_get( $wp_filter, "show_user_profile", null );
 foreach ( $filters as $priority => $hooks ) {
   foreach ( $hooks as $key => $hook ) {
     bw_trace2( $hook, "hook", false );
     $function = oiku_get_function_as_string( $hook['function'] ); 
     $fields["$priority $function"] = $hook['function'];
   }
 } 
* 
*/
function trac_29608_disable_remaining_filters()
{
    $cf = current_filter();
    e("Disabling remaining filters after {$cf}");
    //bw_backtrace();
    global $wp_filter;
    $filters = bw_array_get($wp_filter, $cf, null);
    bw_trace2($filters, "filters", null);
    // Make use of TRAC 17817 ! - didn't appear to work
    $current = current($wp_filter[$cf]);
    bw_trace2($current, "current", false);
    $key = key($wp_filter[$cf]);
    bw_trace2($key, "key", false);
    end($wp_filter[$cf]);
    next($wp_filter[$cf]);
    //do_action( $cf, "Disabling filters" );
}
Exemple #24
0
 /**
  * Return dependencies to check as array of library => version
  * 
  * If not already done create the dependency array for the library
  * given a comma separated string, array of library:version or
  * array of library => version
  *
  * Note: We don't expect libraries to just have numeric names.
  * 
  * @return mixed dependency array or null
  */
 function deps()
 {
     if (null === $this->deps) {
         $deps = bw_array_get($this->args, 'deps', null);
         if (!is_array($deps)) {
             if ($deps) {
                 $deps = explode(",", $deps);
             } else {
                 $deps = array();
             }
         }
         bw_trace2($deps, "deps", false, BW_TRACE_DEBUG);
         $deps_array = array();
         if (count($deps)) {
             foreach ($deps as $key => $value) {
                 if (is_numeric($key)) {
                     list($key, $value) = explode(":", $value . ":*");
                 }
                 $deps_array[$key] = $value;
             }
         }
         $this->deps = $deps_array;
     }
     if (count($this->deps)) {
         return $this->deps;
     }
     return null;
 }
Exemple #25
0
/**
 * Format a tide item
 * 
 * Note: We need to cast the item values to string to avoid getting e.g. 
 * `SimpleXMLElement Object ( [0] => 12:46 AM ) `
 * when we just want 12:46 AM
 *
 *
 * @param SimpleXMLElement $item
 */
function us_format_item($item)
{
    bw_trace2($item, "item", false, BW_TRACE_DEBUG);
    sp("item");
    sepan("time", (string) $item->time);
    e("&nbsp;");
    sepan("ft", (string) $item->predictions_in_ft);
    e("&nbsp;");
    if ($item->highlow == 'L') {
        sepan("highlow low", "Low Tide");
    } else {
        sepan("highlow high", "High Tide");
    }
    ep();
}
Exemple #26
0
/**
 * Functions to invoke when loaded
 *
 * Just about everything that needs to be done should be done by the _oik-lib-mu plugin
 * so we don't need to do anything except when being activated / deactivated
 * 
 * Given that we don't do anything much we might as well let ourselves become deactivated. 
 * In which case, we should have / share an option field to record the state of play.
 * One of the values will be "Always load MU libraries"
 *  
 * This can also be used by the _oik-lib-mu plugin to 
 * decide which library files should be loaded, regardless of the state of the plugins which deliver them.
 * 
 * So we only need to do anything when we're processing "admin" stuff
 *
 */
function oik_lib_loaded()
{
    if (oik_lib_boot_oik_lib()) {
        bw_trace2("oik_lib_boot_oik_lib worked", null, false, BW_TRACE_DEBUG);
        add_filter("oik_query_libs", "oik_lib_oik_query_libs", 11);
        add_action("admin_menu", "oik_lib_admin_menu");
        oik_lib_fallback(__DIR__ . "/libs");
        add_action("init", "oik_lib_init");
        add_action("plugins_loaded", "oik_lib_reset_libs");
        add_action("wp_loaded", "oik_lib_wp_loaded");
    } else {
        gob();
    }
}
Exemple #27
0
 /**
  *
  */
 function remote_get($url)
 {
     $this->request = wp_remote_get($url);
     if (is_wp_error($this->request)) {
         bw_trace2($this->request, "request is_wp_error");
         $this->result = null;
     } else {
         bw_trace2($this->request, "request is expected", false);
         $this->result = bw_retrieve_result($this->request);
     }
     bw_trace2($this->result, "result");
     return $this->result;
 }
 /**
  * Check that the plugins that this plugin is dependent upon are active
  *
  * @param string $plugin - name of the plugin being activated
  * @param string $dependencies - list of plugin dependencies - in whatever order you care
  * @param mixed $callback the callback to invoke when the dependency is not satisfied
  * Notes: 
  * The list of plugins could include oik - which should be loaded UNLESS this file is being
  * loaded by some other mechanism.
  */
 function oik_lazy_depends($plugin = null, $dependencies, $callback = "oik_plugin_inactive")
 {
     bw_backtrace(BW_TRACE_DEBUG);
     $names = bw_get_active_plugins();
     bw_trace2($names, "active plugin names", true, BW_TRACE_DEBUG);
     $depends = explode(",", $dependencies);
     foreach ($depends as $dependcolver) {
         list($depend, $version) = explode(":", $dependcolver . ":");
         //bw_trace2( $dependcolver, "dependcolver" );
         //bw_trace2( $depend, "depend" );
         //bw_trace2( $version, "version" );
         $problem = null;
         $active = bw_array_get($names, $depend, null);
         if ($active) {
             $active = oik_check_version($depend, $version);
             if (!$active) {
                 $problem = "version";
             }
         } else {
             $problem = "missing";
         }
         if (!$active) {
             bw_trace2($depend, "{$plugin} is dependent upon {$depend}, which is not active or is the wrong version", true, BW_TRACE_WARNING);
             if (!is_callable($callback)) {
                 $callback = "oik_plugin_inactive";
             }
             call_user_func($callback, $plugin, $dependcolver, $problem);
             //deactivate_plugins( array( $plugin ) );
         }
     }
 }
Exemple #29
0
 function bw_verify_nonce($action, $name)
 {
     $nonce_field = bw_array_get($_REQUEST, $name, null);
     $verified = wp_verify_nonce($nonce_field, $action);
     bw_trace2($verified, "wp_verify_nonce?");
     return $verified;
 }
 * and oik-bwtrace and good old grep.
 */
add_theme_support('html5');
// Remove post info
//remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
// Remove breadcrumbs
//remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
// Remove the entry meta in the entry footer. i.e. Remove the Filed Under:
remove_action('genesis_entry_footer', 'genesis_post_meta');
//bw_disable_filter( 'genesis_edit_post_link',
//remove_action( 'genesis_edit_post_link',
//remove_action( 'genesis_before_post_content', 'genesis_post_info' );
// Remove post info
remove_action('genesis_entry_header', 'genesis_post_info', 12);
//add_action( 'genesis_entry_footer', 'genesis_post_info' );
add_action('genesis_entry_footer', 'genesis_oik_post_info');
// Put the image before the rest of the content.
//add_action( 'genesis_entry_content', 'genesis_image_do_entry_content', 9 );
remove_action('genesis_after_content', 'genesis_get_sidebar');
add_action('genesis_after_content', 'genesis_oik_get_sidebar');
add_filter('genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar');
$parent_id = wp_get_post_parent_id(null);
if ($parent_id) {
    bw_trace2($parent_id);
    $post_type = get_post_type($parent_id);
    if ($post_type === "oik_premiumversion" || $post_type === "oik_themiumversion") {
        remove_action("the_content", "prepend_attachment");
    }
}
//e( $post_type );
genesis();