WordPressプラグイン指摘事項修正

This commit is contained in:
2024-07-19 18:42:09 +09:00
parent 1390e315a6
commit 961a591e61
6 changed files with 44 additions and 30 deletions
@@ -3,9 +3,9 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} // Exit if accessed directly } // Exit if accessed directly
if ( ! class_exists( 'cnv_protection_txt' ) ) { if ( ! class_exists( 'conv_protection_txt' ) ) {
class cnv_protection_txt { class conv_protection_txt {
public function __construct() { public function __construct() {
add_action( 'admin_menu', array( $this, 'add_pages' ) ); add_action( 'admin_menu', array( $this, 'add_pages' ) );
@@ -27,17 +27,17 @@ if ( ! class_exists( 'cnv_protection_txt' ) ) {
} }
public function show_text_option_page() { public function show_text_option_page() {
$update_option = filter_input( INPUT_POST, '_cnv_protect_options', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY ); $update_option = filter_input( INPUT_POST, 'conv_protection_options', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
if ( ! empty( $update_option ) ) { if ( ! empty( $update_option ) ) {
check_admin_referer( 'cnv_options' ); check_admin_referer( 'conv_options' );
update_option( '_cnv_protect_options', $update_option ); update_option( 'conv_protection_options', $update_option );
include_once cnv_protection_txt_settings::TEMPLATE_DIR . 'success.php'; include_once conv_protection_txt_settings::TEMPLATE_DIR . 'success.php';
} }
include_once cnv_protection_txt_settings::TEMPLATE_DIR . 'cnv_protection_txt_form.php'; include_once conv_protection_txt_settings::TEMPLATE_DIR . 'conv_protection_txt_form.php';
} }
public function edit_protected_word( $text ) { public function edit_protected_word( $text ) {
$opt = get_option( '_cnv_protect_options' ); $opt = get_option( 'conv_protection_options' );
if ( isset( $opt['flag'] ) && $opt['flag'] == 2 ) { if ( isset( $opt['flag'] ) && $opt['flag'] == 2 ) {
return '%s'; return '%s';
} }
@@ -47,21 +47,21 @@ if ( ! class_exists( 'cnv_protection_txt' ) ) {
//パスワード保護時のメッセージ //パスワード保護時のメッセージ
public function protect_password_form( $form_text ): string { public function protect_password_form( $form_text ): string {
$opt = get_option( '_cnv_protect_options' ); $opt = get_option( 'conv_protection_options' );
if ( isset( $opt['text'] ) && ! empty( $opt['text'] ) ) { if ( isset( $opt['text'] ) && ! empty( $opt['text'] ) ) {
$alert_text = $opt['text']; $alert_text = $opt['text'];
} else { } else {
$alert_text = cnv_protection_txt_settings::ALERT_TEXT; $alert_text = conv_protection_txt_settings::ALERT_TEXT;
} }
if ( isset( $opt['label'] ) && ! empty( $opt['label'] ) ) { if ( isset( $opt['label'] ) && ! empty( $opt['label'] ) ) {
$btn_label = $opt['label'] . ' : '; $btn_label = $opt['label'] . ' : ';
} else { } else {
$btn_label = cnv_protection_txt_settings::BTN_LABEL . ' : '; $btn_label = conv_protection_txt_settings::BTN_LABEL . ' : ';
} }
if ( isset( $opt['btn'] ) && ! empty( $opt['btn'] ) ) { if ( isset( $opt['btn'] ) && ! empty( $opt['btn'] ) ) {
$btn_text = $opt['btn']; $btn_text = $opt['btn'];
} else { } else {
$btn_text = cnv_protection_txt_settings::BTN_TEXT; $btn_text = conv_protection_txt_settings::BTN_TEXT;
} }
return ' return '
@@ -4,9 +4,9 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} // Exit if accessed directly } // Exit if accessed directly
if ( ! class_exists( 'cnv_protection_txt_settings' ) ) { if ( ! class_exists( 'conv_protection_txt_settings' ) ) {
class cnv_protection_txt_settings{ class conv_protection_txt_settings{
const ALERT_TEXT = 'このコンテンツはパスワードで保護されています。閲覧するには以下にパスワードを入力してください。'; const ALERT_TEXT = 'このコンテンツはパスワードで保護されています。閲覧するには以下にパスワードを入力してください。';
const BTN_LABEL = 'パスワード'; const BTN_LABEL = 'パスワード';
+7 -3
View File
@@ -22,7 +22,11 @@ License: GPLv2
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
include_once __DIR__ . '/class/cnv_protection_txt_settings.php'; if ( ! defined( 'ABSPATH' ) ) {
include_once __DIR__ . '/class/class.cnv_protection_txt.php'; exit;
} // Exit if accessed directly
new cnv_protection_txt; include_once __DIR__ . '/class/conv_protection_txt_settings.php';
include_once __DIR__ . '/class/class.conv_protection_txt.php';
new conv_protection_txt;
@@ -1,13 +1,18 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
?>
<div class="wrap"> <div class="wrap">
<h2>限定公開ページテキストカスタマイズ</h2> <h2>限定公開ページテキストカスタマイズ</h2>
<form action="" method="post"> <form action="" method="post">
<?php <?php
wp_nonce_field( 'cnv_options' ); wp_nonce_field( 'conv_options' );
$opt = get_option( '_cnv_protect_options' ); $opt = get_option( 'conv_protection_options' );
$show_radio = $opt['flag'] ?? 1; $show_radio = $opt['flag'] ?? 1;
$show_text = $opt['text'] ?? cnv_protection_txt_settings::ALERT_TEXT; $show_text = $opt['text'] ?? conv_protection_txt_settings::ALERT_TEXT;
$show_label = $opt['label'] ?? cnv_protection_txt_settings::BTN_LABEL; $show_label = $opt['label'] ?? conv_protection_txt_settings::BTN_LABEL;
$show_btn = $opt['btn'] ?? cnv_protection_txt_settings::BTN_TEXT; $show_btn = $opt['btn'] ?? conv_protection_txt_settings::BTN_TEXT;
?> ?>
<table class="form-table"> <table class="form-table">
<tr valign="top"> <tr valign="top">
@@ -15,17 +20,17 @@
<td> <td>
<?php if ( $show_radio == 2 ) : ?> <?php if ( $show_radio == 2 ) : ?>
<label> <label>
<input type="radio" name="_cnv_protect_options[flag]" value="1">表示 <input type="radio" name="conv_protection_options[flag]" value="1">表示
</label> </label>
<label> <label>
<input type="radio" name="_cnv_protect_options[flag]" value="2" checked>非表示 <input type="radio" name="conv_protection_options[flag]" value="2" checked>非表示
</label> </label>
<?php elseif ( $show_radio == 1 ): ?> <?php elseif ( $show_radio == 1 ): ?>
<label> <label>
<input type="radio" name="_cnv_protect_options[flag]" value="1" checked>表示 <input type="radio" name="conv_protection_options[flag]" value="1" checked>表示
</label> </label>
<label> <label>
<input type="radio" name="_cnv_protect_options[flag]" value="2">非表示 <input type="radio" name="conv_protection_options[flag]" value="2">非表示
</label> </label>
<?php endif; ?> <?php endif; ?>
</td> </td>
@@ -33,21 +38,21 @@
<tr valign="top"> <tr valign="top">
<th scope="row">メッセージ</th> <th scope="row">メッセージ</th>
<td> <td>
<textarea name="_cnv_protect_options[text]" rows="4" <textarea name="conv_protection_options[text]" rows="4"
cols="60"><?php echo esc_attr( $show_text ); ?></textarea> cols="60"><?php echo esc_attr( $show_text ); ?></textarea>
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<th scope="row">ボタンラベル</th> <th scope="row">ボタンラベル</th>
<td> <td>
<input type="text" name="_cnv_protect_options[label]" <input type="text" name="conv_protection_options[label]"
value="<?php echo esc_attr( $show_label ); ?>"> value="<?php echo esc_attr( $show_label ); ?>">
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign="top">
<th scope="row">ボタン名</th> <th scope="row">ボタン名</th>
<td> <td>
<input type="text" name="_cnv_protect_options[btn]" <input type="text" name="conv_protection_options[btn]"
value="<?php echo esc_attr( $show_btn ); ?>"> value="<?php echo esc_attr( $show_btn ); ?>">
</td> </td>
</tr> </tr>
+5
View File
@@ -1 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
?>
<div id="settings_updated" class="updated notice is-dismissible"><p><strong>設定を保存しました</strong></p></div> <div id="settings_updated" class="updated notice is-dismissible"><p><strong>設定を保存しました</strong></p></div>
+1 -1
View File
@@ -5,4 +5,4 @@ if (!defined('WP_UNINSTALL_PLUGIN')) {
} }
// オプション設定の削除 // オプション設定の削除
delete_option('_cnv_protect_options'); delete_option('conv_protection_options');