Example #1
0
/**
 * Return the single instance of the Git class
 *
 */
function git()
{
    if (!class_exists("Git")) {
        oik_require("includes/class-git.php", "oik-batch");
    }
    $git = Git::instance();
    return $git;
}
 /** 
  * Autoload a class if we know how to
  * 
  * The fact that we have gotten here means that the class is not already loaded so we need to load it.
  * @TODO We should also know which pre-requisite classes to load. Does spl_autoload_register() handle this?
  * 
  * What if we can't?
  */
 function autoload($class)
 {
     $class_file = $this->locate_class($class);
     if ($class_file) {
         $file = $this->file($class_file);
         oik_require($file, $class_file->plugin);
     }
 }
Example #3
0
/**
 * Return an array of sites
 *
 * @return array array of site's blognames indexed by ID  
 */
function oik_ms_site_list()
{
    oik_require("shortcodes/oik-blogs.php", "oik-ms");
    $blogs = bw_get_blog_list();
    $site_select = array();
    foreach ($blogs as $blog) {
        $bloginfo = bw_get_bloginfo($blog);
        $site_select[$blog] = $bloginfo->blogname;
    }
    return $site_select;
}
Example #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);
     }
 }
Example #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");
    }
}
Example #6
0
 /**
  * Return the singular instance of the OIK_libs class
  *
  * @return object the OIK_libs class
  */
 function oik_libs()
 {
     if (!class_exists("OIK_libs")) {
         oik_require("includes/class-oik-libs.php", "oik-lib");
         oik_require("includes/class-oik-lib.php", "oik-lib");
     }
     if (class_exists("OIK_libs")) {
         $oik_libs = OIK_libs::instance();
     } else {
         die;
     }
     return $oik_libs;
 }
Example #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);
         }
     }
 }
/**
 * Function to invoke when oik-widget-cache is loaded
 *
 * Load the oik_widget_cache class and instantiate it
 * 
 */
function oik_widget_cache_loaded()
{
    oik_require("class-oik-widget-cache.php", "oik-widget-cache");
    oik_widget_cache::instance();
}
 function start_report()
 {
     oik_require("shortcodes/oik-list.php");
     $this->uo = bw_sl($this->atts);
 }
Example #10
0
<?php

// (C) Copyright Bobbingwide 2015, 2016
/**
 * Syntax: oikwp vt-stats.php process
 * 
 * 
 */
ini_set('memory_limit', '1572M');
$plugin = "wp-top12";
oik_require("class-vt-stats.php", $plugin);
oik_require("class-vt-row-basic.php", $plugin);
oik_require("class-object-sorter.php", $plugin);
oik_require("class-object.php", $plugin);
oik_require("class-object-grouper.php", $plugin);
oik_require("class-CSV-merger.php", $plugin);
//query_my_plugins();
//downloads();
$stats = new VT_stats();
$stats->from_date("2015-10-01");
//$stats->from_date( "2015-12-29" );
$stats->populate();
$stats->count_things();
Example #11
0
/**
 * Ensure the shared library files are up to date
 *
 * @param string $plugin
 */
function dolibs($plugin)
{
    setcd("wp-content", "plugins/{$plugin}");
    if (is_dir("libs")) {
        setcd("wp-content", "plugins/{$plugin}/libs");
        docontinue("in libs dir plugins/{$plugin}/libs");
        oik_require("libs/oik-libs.php", "oik-libs");
        oik_libs_compare($plugin);
    }
    cd2plugins();
}
/**
 * Display some usage notes for the oik-nivo-slider with an example
 */
function oik_nivo_slider_usage()
{
    p("These options for the jQuery Nivo slider control the default behaviour for each instance of the slider.");
    oik_require("nivo.inc", "oik-nivo-slider");
    oik_require("includes/oik-sc-help.inc");
    bw_flush();
    nivo__example();
    sediv("cleared");
}
Example #13
0
/**
 * 
 * Implement "oik_admin_menu" action for oik-ms
 *
 * Set the plugin server. Not necessary for a plugin on WordPress.org
 * Load the oik-ms admin logic
 */
function oik_ms_admin_menu()
{
    oik_register_plugin_server(__FILE__);
    oik_require("admin/oik-ms.php", "oik-ms");
    oik_ms_lazy_admin_menu();
}
Example #14
0
/**
 * Produce a hex dump of the generated HTML
 * 
 * @param string $content
 */
function trac_29608_dump($content)
{
    oik_require("includes/hexdump.php", "trac29608");
    $dump = hexdump($content);
    stag("code");
    e($dump);
    etag("code");
}
Example #15
0
 function bw_wp_error($code, $text = null, $data = null)
 {
     oik_require("includes/bw_error.inc");
     return bw_lazy_wp_error($code, $text, $data);
 }
Example #16
0
<?php

// (C) Copyright Bobbing Wide 2015
oik_require("class-CSV-merger.php", "play");
$merger = new CSV_merger();
$fred = array("a" => "fred", "b" => "blogs");
$hilma = array("a" => "hilma", "b" => "blogs2");
$merger->append($fred);
$merger->append($hilma);
$merger->report();
Example #17
0
<?php

// (C) Copyright Bobbing Wide 2012-2015
if (!defined("OIK_SC_HELP_INCLUDED")) {
    define("OIK_SC_HELP_INCLUDED", "2.6");
    /**
     * Shortcode help 
     * 
     * Library: oik-sc-help
     * Provides: oik-sc-help
     * Depends: on the oik plugin @TODO
     *
     * Implements low level functions for displaying shortcode help.
     * This currently include the help functions for some base shortcodes
     *
     */
    oik_require("includes/oik-sc-help.inc");
}
/* end !defined */
Example #18
0
 * 
 * 
 */
ini_set('memory_limit', '1024M');
//require_once( ABSPATH . "wp-admin/includes/plugin-install.php" );
//oik_require( "includes/oik-remote.inc" );
//oik_require( "class-wp-org-downloads.php", "play" );
$plugin = "wp-top12";
oik_require("class-vt-stats.php", $plugin);
oik_require("class-vt-stats-top12.php", $plugin);
oik_require("class-vt-row.php", $plugin);
oik_require("class-object-sorter.php", $plugin);
oik_require("class-object.php", $plugin);
oik_require("class-object-grouper.php", $plugin);
oik_require("class-CSV-merger.php", $plugin);
oik_require("class-group-summary.php", $plugin);
//query_my_plugins();
//downloads();
//	 "statusquo", 					"jetpack", "jetpack-again",
// $files = array( "jetpackx3", "jetpack-opcache", "vanilla", "jp382", "jp382-5" );
//$files = array( "vanilla", "jp382-5", "noedd", "no-eddjp", "minus10" );
$files = array("nofooter", "minus10", "noedd", "vanilla", "awj", "cf7");
$files = array("vanilla-essence", "akismet", "cf7", "ai1seo", "wpseo", "jetpack", "xml", "nextgen", "importer", "woocommerce", "analytics");
$files = array("client", "server");
$files = array("vanilla7", "vanilla71", "vanilla72", "awj7");
$files = array("vanilla7", "sfence", "cfence", "sfence2", "cfence2", "sfence3", "cfence3");
$files = array("vanilla", "vanilla02", "vanilla03", "vanilla-essence", "vanilla7", "vanilla71", "vanilla72", "vanilla43", "vanilla431", "vanilla432", "vanilla433", "vanilla434", "vanilla435", "vanilla436", "vanilla76", "vanilla4361");
$files = array("vanilla7", "vanilla76", "vanilla4361", "vanilla4362");
$files = array("vanilla7", "ssuper", "csuper", "ssuper2", "csuper2", "scacheuk7", "scache7com", "scache71com", "ccache71com");
$files = array("vanilla", "vanilla5", "akismet", "sitemaps", "importer");
/*
Example #19
0
/**
 * Lazy load the oik-lib options page
 *
 */
function oik_lib_options_add_page()
{
    oik_require("admin/oik-lib.php", "oik-lib");
    oik_lib_admin_do_page();
}
Example #20
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);
     }
 }
Example #21
0
//$enddate = strtotime( "2016-07-27" );
//$startdate = strtotime( "2015-06-01" );
//$enddate = strtotime( "2015-07-0" );
//echo "start: $startdate" ;
//echo "end: $enddate";
for ($thisdate = $startdate; $thisdate <= $enddate; $thisdate += 86400) {
    $dates[] = date("md", $thisdate);
}
echo " Start:" . reset($dates) . PHP_EOL;
echo "End: " . end($dates) . PHP_EOL;
/** 
 * Fetch and save the bwtrace.vt.mmdd file for each of the selected hosts
 */
if (true) {
    foreach ($dates as $date) {
        foreach ($hosts as $host) {
            $content = get_vt($host, $date);
            save_vt($host, $date, $content);
        }
    }
}
/**
 * Process each of the files from the hosts
 */
oik_require("vt.php", "play");
ini_set('memory_limit', '2048M');
foreach ($dates as $date) {
    foreach ($hosts as $host) {
        process_file("vt2016/{$host}/{$date}.vt");
    }
}
 /** 
  * Load the schunted codes
  *
  */
 function load_items()
 {
     oik_require("admin/class-schunter-codes.php", "schunter");
     oik_require("admin/class-schunter-code.php", "schunter");
     $this->codes = new Schunter_codes();
     $this->codes->fetch();
     $this->items = $this->codes->codes;
     $this->total_items = count($this->items);
     $atts = array();
     $atts = $this->determine_pagination($atts);
     $this->sort_items();
     $this->select_items($atts);
     $this->record_pagination($atts);
 }
 /**
  * Load the help for the shortcode
  *
  * @TODO - Only load oik_sc-help.inc once
  */
 function help()
 {
     oik_require("includes/oik-sc-help.inc");
     $this->help = _bw_lazy_sc_help($this->code);
 }
Example #24
0
/**
 * Run a script in batch
 *
 * @TODO Check these comments
 * If the file name given is in the form of a plugin file name e.g. plugin/plugin.php
 * then we can invoke it using oik_path() 
 * If it's just a simple name then we assume it's in the ??? folder and we need to append .php 
 * and invoke it using oik_path()
 * If it's a fully specified file name that exists then we call it directly.
 *
 * The script can be run by simply loading the file
 * and/or it can implement an action hook for "run_$script"
 *
 * @param string $script the file to load and run
 *
 */
function oik_batch_run_script($script)
{
    if (file_exists($script)) {
        oik_require("oik-login.inc", "oik-batch");
        require_once $script;
        echo "Script required once: {$script}" . PHP_EOL;
        do_action("run_{$script}");
        echo "Did: run_{$script}" . PHP_EOL;
    } else {
        $script_parts = pathinfo($script);
        print_r($script_parts);
        $dirname = bw_array_get($script_parts, "dirname", null);
        if ($dirname == ".") {
            $dirname = "oik-wp";
            // @TODO - make it choose the current directory
            $dirname = "oik-batch";
            // @TODO - make it choose the current directory
        }
        $filename = bw_array_get($script_parts, "filename", null);
        $extension = bw_array_get($script_parts, "extension", ".php");
        $required_file = WP_PLUGIN_DIR . "/{$dirname}/{$filename}{$extension}";
        echo $required_file . PHP_EOL;
        if (file_exists($required_file)) {
            require_once $required_file;
        } else {
            echo "Cannot find script to run: {$required_file}" . PHP_EOL;
        }
        // Should this call do_action( "run_$??? " ). If so, what's $???
        // How does WP-cli work?
    }
}
Example #25
0
 function _bw_get_themes()
 {
     static $themes = null;
     if (!$themes) {
         $theme_slugs = bw_get_theme_slugs();
         oik_require("admin/oik-depends.inc");
         $themes = bw_get_all_theme_names($theme_slugs);
     }
     return $themes;
 }
Example #26
0
function schunter_admin_menu()
{
    //	if ( is_admin() ) {
    oik_require("admin/schunter.php", "schunter");
    schunter_admin();
    //	}
}
Example #27
0
 * but it's more likely that they should be directed to
 * another site specifically configured with a defined set of plugins.
 * 
 * e.g. To measure the performance of the 12 plugins of Christmas we start with Akismet
 * and either add the others one by one, or replace them with the others, or both.
 *
 *
 * The transactions should be representative of real transactions
 * and performed against a real website configuration.
 * 
 * To do this on a copy of oik-plugins.com means that we'll have the background overhead of the oik plugins.
 * How we measure this extra overhead is an interesting question.
 *
 * 
 */
oik_require("includes/oik-remote.inc");
$driver = new VT_driver();
$driver->loop();
/**
 
function vt_driver() {
	$file = file( "oik-plugins.com/1221.vt" );
	$file = file( "gt100.csv" );
	$total = count( $file );
	$count = 0;
	for ( $loop = 1; $loop<=2; $loop++ ) {
	foreach ( $file as $line ) {
		$vt = str_getcsv( $line );
		if ( 0 !== strpos( $vt[0], "/wp-admin" ) ) {
			$timestart = microtime( true );
			echo $loop .  "." . $count++ . '/' .  $total . " " . $vt[0] . PHP_EOL;
Example #28
0
 /**
  * Search posts and postmeta for possible shortcodes
  *
  * Note: We don't see posts which are not publicly searchable, so we don't see "revisions".  
  * This is not considered to be a problem right now. 
  * To fix this we can temporarily hack with the registered post types so that the query finds more things
  *
  */
 function schunt_posts()
 {
     oik_require("includes/bw_posts.inc");
     $posts_per_page = $this->options->posts_per_page;
     $page = 0;
     $date_query = array("after" => $this->options->last_date, "column" => "post_modified_gmt");
     $args = array("post_type" => "any", "orderby" => "modified", "order" => "ASC", "post_status" => "any", "posts_per_page" => $posts_per_page, "numberposts" => -1, "cache_results" => false, "date_query" => $date_query);
     $posts = bw_get_posts($args);
     $todo = count($posts);
     echo "Processing posts: {$todo}" . PHP_EOL;
     while (count($posts) > 0) {
         foreach ($posts as $post) {
             $this->schunt_post($post);
             $this->schunt_postmeta($post);
             $this->done($post);
             unset($post);
         }
         $page++;
         $args['paged'] = $page;
         unset($posts);
         $posts = bw_get_posts($args);
     }
     return $todo;
 }