-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcli.php
More file actions
68 lines (64 loc) · 1.72 KB
/
Copy pathcli.php
File metadata and controls
68 lines (64 loc) · 1.72 KB
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
<?php
class ONPAGE_CLI
{
function __construct()
{
op_ignore_user_scopes(true);
}
public function import($args, $assoc_args)
{
global $_GLOBALS;
if (isset($assoc_args['halp'])) {
echo "Use --force to force import\n";
echo "Use --force-slug-regen to trigger slug regeneration\n";
echo "Use --regen-snapshot to regenerate the snapshot before importing\n";
echo "Use --timing to show timing info\n";
return;
}
if (@$assoc_args['timing']) {
print_r($_GLOBALS);
$_GLOBALS['op_enable_timing_log'] = true;
}
op_record("Beginning import...");
$t1 = microtime(true);
op_import_snapshot(
(bool) @$assoc_args['force-slug-regen'],
(string) @$assoc_args['file_name'],
isset($assoc_args['force']),
isset($assoc_args['regen-snapshot'])
);
$t2 = microtime(true);
print_r([
// 'log' => op_record('finish'),
'c_count' => OpLib\Term::localized()->count(),
'p_count' => OpLib\Post::localized()->count(),
'time' => $t2 - $t1,
]);
}
public function reset($args, $assoc_args)
{
op_record("Deletion of all your On Page data is about to begin...");
sleep(3);
op_record("Deletion started");
op_reset_data();
op_record("Deletion completed");
}
public function update($args, $assoc_args)
{
op_record("Updating plugin...");
op_upgrade();
op_record("Update completed");
}
public function listmedia($args, $assoc_args)
{
print_r(op_list_files());
}
public function cleanmeta($args, $assoc_args)
{
op_record("Deleting orphaned meta...");
print_r(op_delete_orphan_meta());
}
}
add_action('cli_init', function () {
WP_CLI::add_command('onpage', 'ONPAGE_CLI');
});