Skip to content

Commit ef5b545

Browse files
committed
easy-plugin-check command added but not working
1 parent ff34ff0 commit ef5b545

File tree

4 files changed

+75
-4
lines changed

4 files changed

+75
-4
lines changed

cbxcareertoolkit.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
*
54
* @link https://codeboxr.com
@@ -10,8 +9,8 @@
109
* Plugin Name: CBX Career Toolkit
1110
* Plugin URI: https://github.com/codeboxrcodehub/cbxcareertoolkit/
1211
* Description: Helper plugin for CBX Career plugins
13-
* Version: 1.0.0
14-
* Requires at least: 3.7
12+
* Version: 1.0.1
13+
* Requires at least: 5.3
1514
* Requires PHP: 8.2
1615
* Author: Codeboxr
1716
* Author URI: https://codeboxr.com
@@ -27,7 +26,7 @@
2726
}
2827

2928
defined( 'CBXCAREER_TOOLKIT_PLUGIN_NAME' ) or define( 'CBXCAREER_TOOLKIT_PLUGIN_NAME', 'cbxcareertoolkit' );
30-
defined( 'CBXCAREER_TOOLKIT_PLUGIN_VERSION' ) or define( 'CBXCAREER_TOOLKIT_PLUGIN_VERSION', '1.0.0' );
29+
defined( 'CBXCAREER_TOOLKIT_PLUGIN_VERSION' ) or define( 'CBXCAREER_TOOLKIT_PLUGIN_VERSION', '1.0.1' );
3130
defined( 'CBXCAREER_TOOLKIT_BASE_NAME' ) or define( 'CBXCAREER_TOOLKIT_BASE_NAME', plugin_basename( __FILE__ ) );
3231
defined( 'CBXCAREER_TOOLKIT_ROOT_PATH' ) or define( 'CBXCAREER_TOOLKIT_ROOT_PATH', plugin_dir_path( __FILE__ ) );
3332
defined( 'CBXCAREER_TOOLKIT_ROOT_URL' ) or define( 'CBXCAREER_TOOLKIT_ROOT_URL', plugin_dir_url( __FILE__ ) );
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
namespace Cbx\Careertoolkit\Factories\Misc;
3+
4+
/**
5+
* Easy plugin checker command command
6+
* Class EasyPluginChecker
7+
* @since 1.0.1
8+
*/
9+
class EasyPluginChecker{
10+
11+
/**
12+
* Register CLI command
13+
* @since 1.0.0
14+
*/
15+
public function wp_cli_register_commands() {
16+
\WP_CLI::add_command( 'easy-plugin-check', [ $this, "run" ] );
17+
} //end method wp_cli_register_commands
18+
19+
/**
20+
* Command activity
21+
*
22+
* @param $args
23+
* @param $assoc_args
24+
*
25+
* @since 1.0.0
26+
*/
27+
public function run( $args, $assoc_args ) {
28+
global $wpdb;
29+
30+
$plugin = $args[0];
31+
$exclude_directories = WP_CLI\Utils\get_flag_value($assoc_args, 'exclude-directories', '');
32+
$format = WP_CLI\Utils\get_flag_value($assoc_args, 'format', 'table'); // Default format is table
33+
$output_file = WP_CLI\Utils\get_flag_value($assoc_args, 'output-file', '');
34+
35+
// Set default output file if not provided
36+
if (empty($output_file)) {
37+
$output_file = ABSPATH . 'plugin-check.log';
38+
}
39+
40+
// Build the command to check the plugin
41+
$command = sprintf(
42+
'wp plugin check %s --exclude-directories=%s --format=%s',
43+
escapeshellarg($plugin),
44+
escapeshellarg($exclude_directories),
45+
escapeshellarg($format)
46+
);
47+
48+
// Execute the command and capture the output
49+
exec($command, $output, $return_var);
50+
51+
if ($return_var !== 0) {
52+
WP_CLI::error('Error running the plugin check command.');
53+
}
54+
55+
// Combine the output into a single string
56+
$output_content = implode("\n", $output);
57+
58+
// Clean the file (truncate) before writing new output
59+
if (file_put_contents($output_file, '') === false) {
60+
WP_CLI::error('Failed to clear the output file.');
61+
}
62+
63+
// Write the output to the file
64+
if (file_put_contents($output_file, $output_content) === false) {
65+
WP_CLI::error('Failed to write output to the file.');
66+
}
67+
68+
WP_CLI::success("Plugin check output written to {$output_file}");
69+
} //end method run
70+
} //end class EasyPluginChecker

includes/Hooks.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Cbx\Careertoolkit\Factories\Resume\DummyResumeGenerate;
66
use Cbx\Careertoolkit\Factories\Job\DummyJobGenerate;
7+
use Cbx\Careertoolkit\Factories\Misc\EasyPluginChecker;
78

89
use Cbx\Careertoolkit\PDUpdater;
910

@@ -18,6 +19,7 @@ public function init_commands() {
1819
if ( class_exists( "WP_CLI" ) ) {
1920
$resume = new DummyResumeGenerate();
2021
$jobs = new DummyJobGenerate();
22+
$epc = new EasyPluginChecker();
2123
}
2224
}//end method init_commands
2325

README.txt renamed to readme.txt

File renamed without changes.

0 commit comments

Comments
 (0)