Compare commits
7 Commits
VER1.0
...
849d7a89fd
| Author | SHA1 | Date | |
|---|---|---|---|
| 849d7a89fd | |||
| 961a591e61 | |||
| 1390e315a6 | |||
| 6734c41bac | |||
| 3e78366de6 | |||
| 247f3d4d26 | |||
| 622d8dc3c8 |
@@ -0,0 +1 @@
|
|||||||
|
/.idea/
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
} // Exit if accessed directly
|
||||||
|
|
||||||
|
if ( ! class_exists( 'conv_protection_txt' ) ) {
|
||||||
|
|
||||||
|
class conv_protection_txt {
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'admin_menu', array( $this, 'add_pages' ) );
|
||||||
|
add_filter( 'protected_title_format', array( $this, 'edit_protected_word' ) );
|
||||||
|
add_filter( 'the_password_form', array( $this, 'protect_password_form' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add_pages() {
|
||||||
|
add_menu_page(
|
||||||
|
'限定公開ページテキストカスタマイズ',
|
||||||
|
'限定公開ページテキストカスタマイズ',
|
||||||
|
'level_8',
|
||||||
|
__FILE__,
|
||||||
|
array(
|
||||||
|
$this,
|
||||||
|
'show_text_option_page'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show_text_option_page() {
|
||||||
|
$update_option = filter_input( INPUT_POST, 'conv_protection_options', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
|
||||||
|
if ( ! empty( $update_option ) ) {
|
||||||
|
check_admin_referer( 'conv_options' );
|
||||||
|
update_option( 'conv_protection_options', $update_option );
|
||||||
|
include_once conv_protection_txt_settings::TEMPLATE_DIR . 'success.php';
|
||||||
|
}
|
||||||
|
include_once conv_protection_txt_settings::TEMPLATE_DIR . 'conv_protection_txt_form.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit_protected_word( $text ) {
|
||||||
|
$opt = get_option( 'conv_protection_options' );
|
||||||
|
if ( isset( $opt['flag'] ) && $opt['flag'] == 2 ) {
|
||||||
|
return '%s';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
//パスワード保護時のメッセージ
|
||||||
|
public function protect_password_form( $form_text ): string {
|
||||||
|
$opt = get_option( 'conv_protection_options' );
|
||||||
|
if ( isset( $opt['text'] ) && ! empty( $opt['text'] ) ) {
|
||||||
|
$alert_text = $opt['text'];
|
||||||
|
} else {
|
||||||
|
$alert_text = conv_protection_txt_settings::ALERT_TEXT;
|
||||||
|
}
|
||||||
|
if ( isset( $opt['label'] ) && ! empty( $opt['label'] ) ) {
|
||||||
|
$btn_label = $opt['label'] . ' : ';
|
||||||
|
} else {
|
||||||
|
$btn_label = conv_protection_txt_settings::BTN_LABEL . ' : ';
|
||||||
|
}
|
||||||
|
if ( isset( $opt['btn'] ) && ! empty( $opt['btn'] ) ) {
|
||||||
|
$btn_text = $opt['btn'];
|
||||||
|
} else {
|
||||||
|
$btn_text = conv_protection_txt_settings::BTN_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '
|
||||||
|
<form action="' . wp_login_url() . '?action=postpass" class="post-password-form" method="post">
|
||||||
|
<p>' . nl2br( esc_html( $alert_text ) ) . '</p>
|
||||||
|
<p>
|
||||||
|
<label for="pwbox">' . esc_html( $btn_label ) .
|
||||||
|
'<input name="post_password" id="pwbox" type="password" size="20">
|
||||||
|
</label>
|
||||||
|
<input type="submit" name="Submit" value="' . esc_attr( $btn_text ) . '">
|
||||||
|
</p>
|
||||||
|
</form>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
} // Exit if accessed directly
|
||||||
|
|
||||||
|
if ( ! class_exists( 'conv_protection_txt_settings' ) ) {
|
||||||
|
|
||||||
|
class conv_protection_txt_settings{
|
||||||
|
|
||||||
|
const ALERT_TEXT = 'このコンテンツはパスワードで保護されています。閲覧するには以下にパスワードを入力してください。';
|
||||||
|
const BTN_LABEL = 'パスワード';
|
||||||
|
const BTN_TEXT = '確定';
|
||||||
|
const TEMPLATE_DIR = __DIR__ . '/../template/';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+24
-127
@@ -1,135 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Plugin Name: Convert Protection Text
|
Plugin Name: Convert Protection Text
|
||||||
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
|
Plugin URI: https://develop.n-k-y.net/wordpress/convert-protection-text
|
||||||
Description: A brief description of the Plugin.
|
Author: NBK45
|
||||||
Version: 1.0
|
Author URI: https://develop.n-k-y.net
|
||||||
Author: nobu
|
Description: Convert Protection Text はWordPressで記事(ページ)の公開状態を限定公開(「パスワード保護」)にしたときのテキストをカスタマイズするプラグインです。
|
||||||
Author URI: http://URI_Of_The_Plugin_Author
|
Version: 1.0.1
|
||||||
License: A "Slug" license name e.g. GPL2
|
License: GPLv2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CNV_Protection_Text {
|
/* Copyright 2021 NBK45 (email : nbk.develop@gmail.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.
|
||||||
|
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.
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
const ALERT_TEXT = 'このコンテンツはパスワードで保護されています。閲覧するには以下にパスワードを入力してください。';
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
const BTN_LABEL = 'パスワード';
|
exit;
|
||||||
const BTN_TEXT = '確定';
|
} // Exit if accessed directly
|
||||||
|
|
||||||
public function __construct() {
|
include_once __DIR__ . '/class/conv_protection_txt_settings.php';
|
||||||
add_action( 'admin_menu', array( $this, 'add_pages' ) );
|
include_once __DIR__ . '/class/class.conv_protection_txt.php';
|
||||||
add_filter( 'protected_title_format', array( $this, 'edit_protected_word' ) );
|
|
||||||
add_filter( 'the_password_form', array( $this, 'my_password_form' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function add_pages() {
|
new conv_protection_txt;
|
||||||
add_menu_page( 'アクセス権限ページ設定', 'アクセス権限ページ設定', 'level_8', __FILE__, array(
|
|
||||||
$this,
|
|
||||||
'show_text_option_page'
|
|
||||||
), '', 90 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function show_text_option_page() {
|
|
||||||
//$_POST['_cnv_protect_options'])があったら保存
|
|
||||||
if ( isset( $_POST['_cnv_protect_options'] ) ) {
|
|
||||||
check_admin_referer( 'cnv_options' );
|
|
||||||
$opt = $_POST['_cnv_protect_options'];
|
|
||||||
update_option( '_cnv_protect_options', $opt );
|
|
||||||
?>
|
|
||||||
<div class="updated fade"><p><strong>設定を保存しました</strong></p></div><?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="wrap">
|
|
||||||
<div id="icon-options-general" class="icon32"><br/></div>
|
|
||||||
<h2>アクセス権限ページ設定</h2>
|
|
||||||
<form action="" method="post">
|
|
||||||
<?php
|
|
||||||
wp_nonce_field( 'cnv_options' );
|
|
||||||
$opt = get_option( '_cnv_protect_options' );
|
|
||||||
$show_radio = $opt['flag'] ?? 1;
|
|
||||||
$show_text = $opt['text'] ?? self::ALERT_TEXT;
|
|
||||||
$show_label = $opt['label'] ?? self::BTN_LABEL;
|
|
||||||
$show_btn = $opt['btn'] ?? self::BTN_TEXT;
|
|
||||||
?>
|
|
||||||
<table class="form-table">
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row"><label for="inputtext">保護中</label></th>
|
|
||||||
<td>
|
|
||||||
<?php if ( $show_radio == 2 ) : ?>
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="_cnv_protect_options[flag]" value="1">表示
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="_cnv_protect_options[flag]" value="2" checked>非表示
|
|
||||||
</label>
|
|
||||||
<?php elseif ( $show_radio == 1 ): ?>
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="_cnv_protect_options[flag]" value="1" checked>表示
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="_cnv_protect_options[flag]" value="2">非表示
|
|
||||||
</label>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row">メッセージ</th>
|
|
||||||
<td>
|
|
||||||
<textarea name="_cnv_protect_options[text]" rows="4"
|
|
||||||
cols="60"><?php echo $show_text; ?></textarea>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row">ボタンラベル</th>
|
|
||||||
<td>
|
|
||||||
<input type="text" name="_cnv_protect_options[label]" value="<?php echo $show_label; ?>">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr valign="top">
|
|
||||||
<th scope="row">ボタン名</th>
|
|
||||||
<td>
|
|
||||||
<input type="text" name="_cnv_protect_options[btn]" value="<?php echo $show_btn; ?>">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
|
||||||
</form>
|
|
||||||
<!-- /.wrap --></div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
public function edit_protected_word( $text ) {
|
|
||||||
$opt = get_option( '_cnv_protect_options' );
|
|
||||||
if ( isset( $opt['flag'] ) && $opt['flag'] == 2 ) {
|
|
||||||
return '%s';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
//パスワード保護時のメッセージ
|
|
||||||
public function my_password_form( $form_text ): string {
|
|
||||||
$opt = get_option( '_cnv_protect_options' );
|
|
||||||
if ( isset( $opt['text'] ) && ! empty( $opt['text'] ) ) {
|
|
||||||
$alert_text = $opt['text'];
|
|
||||||
} else {
|
|
||||||
$alert_text = self::ALERT_TEXT;
|
|
||||||
}
|
|
||||||
if ( isset( $opt['label'] ) && ! empty( $opt['label'] ) ) {
|
|
||||||
$btn_label = $opt['label'] . ' : ';
|
|
||||||
} else {
|
|
||||||
$btn_label = self::BTN_LABEL . ' : ';
|
|
||||||
}
|
|
||||||
if ( isset( $opt['btn'] ) && ! empty( $opt['btn'] ) ) {
|
|
||||||
$btn_text = $opt['btn'];
|
|
||||||
} else {
|
|
||||||
$btn_text = self::BTN_TEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<form action="' . home_url() . '/wp-login.php?action=postpass" class="post-password-form" method="post">
|
|
||||||
<p>' . nl2br( $alert_text ) . '</p>
|
|
||||||
<p><label for="pwbox">' . $btn_label . '<input name="post_password" id="pwbox" type="password" size="20"></label> <input type="submit" name="Submit" value="' . $btn_text . '"></p></form>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
new CNV_Protection_Text;
|
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
=== Convert Protection Text ===
|
||||||
|
Contributors: NBK45
|
||||||
|
Tags: password protected
|
||||||
|
Requires at least: 4.9
|
||||||
|
Tested up to: 6.6
|
||||||
|
Requires PHP: 7.4
|
||||||
|
Stable tag: 1.0.1
|
||||||
|
License: GPLv2 or later
|
||||||
|
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
||||||
|
Convert Protection Text はWordPressで記事(ページ)の公開状態を限定公開(「パスワード保護」)にしたときのテキストをカスタマイズするプラグインです。
|
||||||
|
|
||||||
|
== Description ==
|
||||||
|
|
||||||
|
WordPressで記事(ページ)の限定公開(「パスワード保護」)時に表示される認証ページをカスタマイズします。
|
||||||
|
・保護中の表示・非表示の切り替え
|
||||||
|
・ページメッセージ
|
||||||
|
・パスワードフォームのラベル
|
||||||
|
・確定ボタンのラベル
|
||||||
|
|
||||||
|
= 仕様 =
|
||||||
|
1)保護中の表示・非表示の切り替え
|
||||||
|
「保護中」の表示と非表示を切り替えます。
|
||||||
|
|
||||||
|
2)ページメッセージ
|
||||||
|
標準のメッセージから任意のメッセージに変更します。
|
||||||
|
テキストエリアの改行は維持されますが、HTMLタグは除去されます。
|
||||||
|
|
||||||
|
3)パスワードフォームのラベル
|
||||||
|
ラベルを「パスワード」から任意のテキストに変更します。
|
||||||
|
|
||||||
|
4)確定ボタンのラベル
|
||||||
|
ボタンラベルの「確定」を任意のテキストに変更します。
|
||||||
|
|
||||||
|
== Installation ==
|
||||||
|
|
||||||
|
= 自動インストール =
|
||||||
|
1. プラグインの検索フィールドより「Convert Protection Text」と入力し、"プラグインの検索"をクリックします。
|
||||||
|
2. 当プラグインを見つけたら、"今すぐインストール"をクリックしてインストールし、プラグインを有効化してください。
|
||||||
|
|
||||||
|
= 手動インストール =
|
||||||
|
1. プラグインをダウンロードします。
|
||||||
|
2. プラグインフォルダ内にアップロードし、管理画面よりプラグインを有効化してください。
|
||||||
|
|
||||||
|
== Frequently Asked Questions ==
|
||||||
|
|
||||||
|
|
||||||
|
== Screenshots ==
|
||||||
|
|
||||||
|
screenshot-1.png
|
||||||
|
|
||||||
|
|
||||||
|
== Changelog ==
|
||||||
|
= 1.0.0 =
|
||||||
|
初回リリース
|
||||||
|
|
||||||
|
== Upgrade Notice ==
|
||||||
|
No information
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
} // Exit if accessed directly
|
||||||
|
?>
|
||||||
|
<div class="wrap">
|
||||||
|
<h2>限定公開ページテキストカスタマイズ</h2>
|
||||||
|
<form action="" method="post">
|
||||||
|
<?php
|
||||||
|
wp_nonce_field( 'conv_options' );
|
||||||
|
$opt = get_option( 'conv_protection_options' );
|
||||||
|
$show_radio = $opt['flag'] ?? 1;
|
||||||
|
$show_text = $opt['text'] ?? conv_protection_txt_settings::ALERT_TEXT;
|
||||||
|
$show_label = $opt['label'] ?? conv_protection_txt_settings::BTN_LABEL;
|
||||||
|
$show_btn = $opt['btn'] ?? conv_protection_txt_settings::BTN_TEXT;
|
||||||
|
?>
|
||||||
|
<table class="form-table">
|
||||||
|
<tr valign="top">
|
||||||
|
<th scope="row"><label for="inputtext">保護中</label></th>
|
||||||
|
<td>
|
||||||
|
<?php if ( $show_radio == 2 ) : ?>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="conv_protection_options[flag]" value="1">表示
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="conv_protection_options[flag]" value="2" checked>非表示
|
||||||
|
</label>
|
||||||
|
<?php elseif ( $show_radio == 1 ): ?>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="conv_protection_options[flag]" value="1" checked>表示
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="conv_protection_options[flag]" value="2">非表示
|
||||||
|
</label>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<th scope="row">メッセージ</th>
|
||||||
|
<td>
|
||||||
|
<textarea name="conv_protection_options[text]" rows="4"
|
||||||
|
cols="60"><?php echo esc_attr( $show_text ); ?></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<th scope="row">ボタンラベル</th>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="conv_protection_options[label]"
|
||||||
|
value="<?php echo esc_attr( $show_label ); ?>">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="top">
|
||||||
|
<th scope="row">ボタン名</th>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="conv_protection_options[btn]"
|
||||||
|
value="<?php echo esc_attr( $show_btn ); ?>">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存"/></p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
@@ -0,0 +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>
|
||||||
+1
-1
@@ -5,4 +5,4 @@ if (!defined('WP_UNINSTALL_PLUGIN')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// オプション設定の削除
|
// オプション設定の削除
|
||||||
delete_option('_cnv_protect_options');
|
delete_option('conv_protection_options');
|
||||||
Reference in New Issue
Block a user