PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.4.13
CloudSecure WP Security v1.4.13
1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 trunk 0.9.0 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.19 1.3.2 1.3.20 1.3.21 1.3.22 1.3.23 1.3.24 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8
cloudsecure-wp-security / modules / cli / commands / class-cloudsecure-wp-cli-disable-restapi.php
cloudsecure-wp-security / modules / cli / commands Last commit date
class-cloudsecure-wp-cli-disable-restapi.php 2 weeks ago class-cloudsecure-wp-cli-disable.php 10 months ago class-cloudsecure-wp-cli-enable.php 1 month ago class-cloudsecure-wp-cli-list.php 10 months ago class-cloudsecure-wp-cli-status.php 10 months ago
class-cloudsecure-wp-cli-disable-restapi.php
151 lines
1 <?php
2 /**
3 * CloudSecure WP Security CLI Disable REST API Command
4 *
5 * @package CloudSecure_WP_Security
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 if ( ! class_exists( 'WP_CLI' ) ) {
13 return;
14 }
15
16 // ベースクラスを読み込み
17 require_once dirname( __DIR__ ) . '/class-cloudsecure-wp-cli-base.php';
18
19 /**
20 * CloudSecure WP Security Disable REST API Command
21 * REST API無効化機能専用のコマンドクラス
22 */
23 class CloudSecureWP_CLI_Disable_Restapi extends CloudSecureWP_CLI_Base {
24
25 /**
26 * 機能名
27 */
28 private const FEATURE_NAME = 'disable-restapi';
29
30 /**
31 * @var object REST API無効化機能のインスタンス
32 */
33 private $feature_instance;
34
35 public function __construct() {
36 parent::__construct();
37 $this->init_feature_instance();
38 }
39
40 /**
41 * REST API無効化機能のインスタンスを初期化
42 */
43 private function init_feature_instance() {
44 $this->feature_instance = $this->get_feature_instance( self::FEATURE_NAME );
45
46 if ( ! $this->feature_instance ) {
47 WP_CLI::error( 'REST API無効化機能のインスタンスを取得できませんでした。' );
48 }
49 }
50
51 /**
52 * 有効済みプラグインの一覧を取得
53 *
54 * ## DESCRIPTION
55 * REST API無効化機能で除外指定していない有効なプラグインの一覧を取得します。
56 *
57 * ## EXAMPLES
58 * wp cldsec-wp-security disable-restapi list-plugins
59 *
60 * @subcommand list-plugins
61 */
62 public function list_plugins( $args = array(), $assoc_args = array() ) {
63 try {
64 // 機能が存在するかチェック
65 if ( ! $this->feature_instance ) {
66 $this->output_error_response( array( 'message' => 'REST API無効化機能が利用できません。' ) );
67 return;
68 }
69
70 // 有効済みプラグインの一覧を取得
71 if ( ! method_exists( $this->feature_instance, 'get_active_plugin_names' ) ) {
72 $this->output_error_response( array( 'message' => 'get_active_plugin_namesメソッドが見つかりません。' ) );
73 return;
74 }
75
76 $active_plugins = $this->feature_instance->get_active_plugin_names();
77
78 // プラグイン名をカンマ区切りの文字列に変換
79 $plugin_names_string = $this->convert_array_to_string( $active_plugins );
80
81 // 成功レスポンス
82 $response_data = array(
83 'result' => 'success',
84 'data' => array(
85 'active_plugin_names' => $plugin_names_string,
86 ),
87 );
88
89 $this->output_success_response( $response_data );
90
91 } catch ( Exception $e ) {
92 $this->output_error_response(
93 array(
94 'message' => 'コマンド実行中にエラーが発生しました: ' . $e->getMessage(),
95 )
96 );
97 }
98 }
99
100 /**
101 * 有効なテーマの一覧を取得
102 *
103 * ## DESCRIPTION
104 * REST API無効化機能で除外指定していない有効なテーマの一覧を取得します。
105 * 子テーマが有効な場合は親テーマを返します。
106 * 有効なテーマは常に1つだけ返される想定です。
107 *
108 * ## EXAMPLES
109 * wp cldsec-wp-security disable-restapi list-themes
110 *
111 * @subcommand list-themes
112 */
113 public function list_themes( $args = array(), $assoc_args = array() ) {
114 try {
115 // 機能が存在するかチェック
116 if ( ! $this->feature_instance ) {
117 $this->output_error_response( array( 'message' => 'REST API無効化機能が利用できません。' ) );
118 return;
119 }
120
121 // 有効なテーマの一覧を取得
122 if ( ! method_exists( $this->feature_instance, 'get_active_theme_names' ) ) {
123 $this->output_error_response( array( 'message' => 'get_active_theme_namesメソッドが見つかりません。' ) );
124 return;
125 }
126
127 $active_themes = $this->feature_instance->get_active_theme_names();
128
129 // テーマ名をカンマ区切りの文字列に変換
130 $theme_names_string = $this->convert_array_to_string( $active_themes );
131
132 // 成功レスポンス
133 $response_data = array(
134 'result' => 'success',
135 'data' => array(
136 'active_theme_names' => $theme_names_string,
137 ),
138 );
139
140 $this->output_success_response( $response_data );
141
142 } catch ( Exception $e ) {
143 $this->output_error_response(
144 array(
145 'message' => 'コマンド実行中にエラーが発生しました: ' . $e->getMessage(),
146 )
147 );
148 }
149 }
150 }
151