-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoik-batch.php
95 lines (84 loc) · 2.72 KB
/
oik-batch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php // (C) Copyright Bobbing Wide 2013-2023
/*
Plugin Name: oik-batch
Plugin URI: https://www.oik-plugins.com/oik-plugins/oik-batch
Description: Batch interface to WordPress - no need to activate
Version: 1.1.2
Author: bobbingwide
Author URI: https://www.bobbingwide.com/about-bobbing-wide
License: GPL2
Copyright 2013 - 2023 Bobbing Wide (email : herb@bobbingwide.com )
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2,
as published by the Free Software Foundation.
You may NOT assume that you can use any other version of the GPL.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The license for this software can likely be found here:
http://www.gnu.org/licenses/gpl-2.0.html
*/
/**
* Load a library file
*
* @param string $lib - the library file name e.g. oik-cli
*/
if ( !function_exists( "oik_batch_load_lib" ) ) {
function oik_batch_load_lib( $lib ) {
$dir = dirname( __FILE__ );
$lib_file = "$dir/libs/$lib.php";
if ( file_exists( $lib_file ) ) {
require_once( $lib_file );
} else {
echo "Missing shared library file: $lib_file" . PHP_EOL;
}
}
}
/**
* Bootstrap logic for oik-batch
*
*
* This checks if we're running as "CLI" - command line interface
* - If we are then we prepare the batch environment
* - then, if this file is the first file then we run the routine specified on the command line.
*
*/
function oik_batch_loaded() {
if ( PHP_SAPI == "cli" ) {
if ( defined( 'WP_CLI' ) && WP_CLI ) {
// This is WP-CLI
} else {
oik_batch_load_lib( "oik-cli" );
oik_batch_debug();
//oik_batch_trace( true );
oik_batch_define_constants();
oik_batch_load_oik_boot();
oik_batch_simulate_wp_settings();
oik_batch_load_wordpress_files();
echo PHP_SAPI;
echo PHP_EOL;
$included_files = get_included_files();
if ( $included_files[0] == __FILE__) {
oik_batch_run();
}// else {
// wp-batch has been loaded by another PHP routine so that routine is in charge.
// }
echo "End cli:" . __FUNCTION__ . PHP_EOL;
}
} else {
//echo PHP_SAPI;
//echo PHP_EOL;
if ( function_exists( "bw_trace2" ) ) {
bw_trace2( PHP_SAPI, "oik-batch loaded in WordPress environment?" );
}
if ( function_exists( "add_action" ) ) {
// if ( bw_is_wordpress() ) {
oik_batch_load_lib( "oik-cli" );
oik_batch_load_oik_boot();
add_action( "admin_notices", "oik_batch_activation" );
add_action( "oik_admin_menu", "oik_batch_admin_menu" );
}
}
}
oik_batch_loaded();