WP PLUGIN プラグイン削除時のパラメータ削除とCSS調整
・投稿のソート用カスタムフィールドのキーについて、他システム等の競合を避け且つアンインストール時に前方一致で削除可能となるよう接頭辞を追加(接頭辞はプログラム側で持つため、管理画面上は表示しない) ・プラグイン削除時、オプションやカスタムフィールドを全削除するよう修正 ・標準+カスタムフィールドソートの横並びを修正
This commit is contained in:
@@ -22,18 +22,9 @@ 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO:
|
|
||||||
1)カテゴリーのソート用カスタムフィールド取得と設定
|
|
||||||
・保存しているタームIDと投稿が属するタームIDが一致する場合、管理画面に表示する
|
|
||||||
class.apop.apop_post.php、setting_post_custom_field.php
|
|
||||||
* 2)uninstall.php
|
|
||||||
* 投稿とタクソノミーのカスタムフィールド削除方法修正
|
|
||||||
* ・delete_post_meta_by_key()を廃止し、WP_QUERYに変更する
|
|
||||||
*/
|
|
||||||
|
|
||||||
define( 'APOP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
define( 'APOP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
define( 'APOP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
define( 'APOP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
|
||||||
|
define( 'APOP_CUSTOM_FIELD_PREFIX', '_apop_postorder_' );
|
||||||
|
|
||||||
//メイン処理のクラスをインスタンス化
|
//メイン処理のクラスをインスタンス化
|
||||||
require_once __DIR__ . '/class/class.apop.order.php';
|
require_once __DIR__ . '/class/class.apop.order.php';
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ if ( ! class_exists( 'APOP_POST' ) ) {
|
|||||||
private function get_custom_field_data( $custom_filed_name ) {
|
private function get_custom_field_data( $custom_filed_name ) {
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
return get_post_meta( $post->ID, $custom_filed_name, true );
|
return get_post_meta( $post->ID, APOP_CUSTOM_FIELD_PREFIX . $custom_filed_name, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
// カスタムフィールドの値を保存
|
// カスタムフィールドの値を保存
|
||||||
@@ -118,8 +118,9 @@ if ( ! class_exists( 'APOP_POST' ) ) {
|
|||||||
$this->get_update_meta_fields();
|
$this->get_update_meta_fields();
|
||||||
if ( count( $this->name_keys ) > 0 ) {
|
if ( count( $this->name_keys ) > 0 ) {
|
||||||
foreach ( $this->name_keys as $name_key ) {
|
foreach ( $this->name_keys as $name_key ) {
|
||||||
update_post_meta( $post_id, $name_key, $_POST[ $name_key ] ?? '' );
|
$save_key = APOP_CUSTOM_FIELD_PREFIX . $name_key;
|
||||||
update_post_meta( $post_id, $name_key, $_POST[ $name_key ] ?? '' );
|
update_post_meta( $post_id, $save_key, $_POST[ $save_key ] ?? '' );
|
||||||
|
update_post_meta( $post_id, $save_key, $_POST[ $save_key ] ?? '' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ value="meta_value_num"' . self::set_search_normal_checked( $value_type, 'meta_va
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function create_none_select_msg( $str ): string {
|
public static function create_none_select_msg( $str ): string {
|
||||||
return '<p>並べ替えをカスタマイズする' . $str . 'は選択されていません。</p>';
|
return '<p class="no_registered_exp">並べ替えをカスタマイズする' . $str . 'は選択されていません。</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function none_registered_alert_msg(): string {
|
public static function none_registered_alert_msg(): string {
|
||||||
|
|||||||
+40
-3
@@ -131,7 +131,11 @@ dl.apop_setting_list_dd dd input {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
cursor: move;
|
cursor: move;
|
||||||
color: #4b4b4b;
|
color: #4b4b4b;
|
||||||
border: 1px solid #ccc;
|
border-bottom: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enable_box .product-list {
|
||||||
|
padding: 1em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search_normal_sort .product-list {
|
.search_normal_sort .product-list {
|
||||||
@@ -140,6 +144,10 @@ dl.apop_setting_list_dd dd input {
|
|||||||
|
|
||||||
.search_normal_sort .product-list-type-label,
|
.search_normal_sort .product-list-type-label,
|
||||||
.disable_box .product-list-type-label {
|
.disable_box .product-list-type-label {
|
||||||
|
width: calc((100%) - 60px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.enable_box .product-list-type-label {
|
||||||
width: calc(100% / 2);
|
width: calc(100% / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +226,7 @@ dl.apop_setting_list_dd dd input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.disable_box .product-list {
|
.disable_box .product-list {
|
||||||
width: calc((100% / 2) - 20px);
|
width: calc((100% / 2) - 15px);
|
||||||
display: flex;
|
display: flex;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
@@ -235,12 +243,41 @@ dl.apop_setting_list_dd dd input {
|
|||||||
padding-left: .5em;
|
padding-left: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.enable_box {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enable_box,
|
||||||
|
.disable_box {
|
||||||
|
padding: .5em;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.enable_box h4 {
|
||||||
|
margin: .5em 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disable_box h4 {
|
||||||
|
margin: .5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 1264px) {
|
@media only screen and (max-width: 1264px) {
|
||||||
|
.enable_box .product-list,
|
||||||
|
.disable_box .product-list {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.search_normal_sort .product-list {
|
.search_normal_sort .product-list {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search_normal_sort .product-list-type-label {
|
.search_normal_sort .product-list-type-label,
|
||||||
|
.disable_box .product-list-type-label {
|
||||||
|
width: 100%;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search_normal_sort .product-list-sort-type {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
display: block;
|
display: block;
|
||||||
|
|||||||
+12
-8
@@ -29,10 +29,12 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
|
|||||||
<div class="sort_box">
|
<div class="sort_box">
|
||||||
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'normal' ); ?>
|
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'normal' ); ?>
|
||||||
<?php echo $alert; ?>
|
<?php echo $alert; ?>
|
||||||
<h4>有効</h4>
|
<div class="enable_box">
|
||||||
<ul class="post-order-list search_normal_sort">
|
<h4>有効</h4>
|
||||||
<?php echo $list; ?>
|
<ul class="post-order-list search_normal_sort">
|
||||||
</ul>
|
<?php echo $list; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div class="disable_box">
|
<div class="disable_box">
|
||||||
<h4>無効</h4>
|
<h4>無効</h4>
|
||||||
<ul class="disable_normal_list"></ul>
|
<ul class="disable_normal_list"></ul>
|
||||||
@@ -60,10 +62,12 @@ $submit_type = APOP_UI::input_post_filter( 'apop_submit_type', 'str' );
|
|||||||
<div class="sort_box">
|
<div class="sort_box">
|
||||||
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'search' ); ?>
|
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'search' ); ?>
|
||||||
<?php echo $alert; ?>
|
<?php echo $alert; ?>
|
||||||
<h4>有効</h4>
|
<div class="enable_box">
|
||||||
<ul class="post-order-list search_normal_sort">
|
<h4>有効</h4>
|
||||||
<?php echo $list; ?>
|
<ul class="post-order-list search_normal_sort">
|
||||||
</ul>
|
<?php echo $list; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div class="disable_box">
|
<div class="disable_box">
|
||||||
<h4>無効</h4>
|
<h4>無効</h4>
|
||||||
<ul class="disable_normal_list"></ul>
|
<ul class="disable_normal_list"></ul>
|
||||||
|
|||||||
@@ -38,10 +38,12 @@
|
|||||||
<div class="sort_box">
|
<div class="sort_box">
|
||||||
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'tax', $tax_data->term_id ); ?>
|
<?php list( $list, $alert ) = APOP_UI::create_search_normal_list( 'tax', $tax_data->term_id ); ?>
|
||||||
<?php echo $alert; ?>
|
<?php echo $alert; ?>
|
||||||
<h4>有効</h4>
|
<div class="enable_box">
|
||||||
<ul class="post-order-list search_normal_sort">
|
<h4>有効</h4>
|
||||||
<?php echo $list; ?>
|
<ul class="post-order-list search_normal_sort">
|
||||||
</ul>
|
<?php echo $list; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div class="disable_box">
|
<div class="disable_box">
|
||||||
<h4>無効</h4>
|
<h4>無効</h4>
|
||||||
<ul class="disable_normal_list"></ul>
|
<ul class="disable_normal_list"></ul>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<?php foreach ( $items as $item ): ?>
|
<?php foreach ( $items as $item ): ?>
|
||||||
<?php if ( ! empty( $item ) ): ?>
|
<?php if ( ! empty( $item ) ): ?>
|
||||||
<li><label><?php echo $item; ?></label>
|
<li><label><?php echo $item; ?></label>
|
||||||
<input type="text" name="<?php echo $item; ?>"
|
<input type="text" name="<?php echo APOP_CUSTOM_FIELD_PREFIX . $item; ?>"
|
||||||
value="<?php echo $this->get_custom_field_data( $item ); ?>"/>
|
value="<?php echo $this->get_custom_field_data( $item ); ?>"/>
|
||||||
</li>
|
</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
+21
-24
@@ -7,42 +7,39 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|||||||
|
|
||||||
//通常と検索の表示件数、ソート対象設定等を削除
|
//通常と検索の表示件数、ソート対象設定等を削除
|
||||||
$param_settings = array(
|
$param_settings = array(
|
||||||
'_apop_per_page',
|
|
||||||
'_apop_normal_order',
|
|
||||||
'_apop_search_order',
|
|
||||||
'_apop_tax_sort_type',
|
|
||||||
'_apop_normal_order_param',
|
'_apop_normal_order_param',
|
||||||
'_apop_search_order_param',
|
'_apop_search_order_param',
|
||||||
'_apop_tax_order_param',
|
'_apop_tax_order_param',
|
||||||
|
'_apop_tax_sort_type',
|
||||||
|
'_apop_normal_order',
|
||||||
|
'_apop_search_order',
|
||||||
|
'_apop_cat_order',
|
||||||
|
'_apop_tag_order',
|
||||||
|
'_apop_tax_order',
|
||||||
|
'_apop_per_page',
|
||||||
);
|
);
|
||||||
foreach ( $param_settings as $param_setting ) {
|
foreach ( $param_settings as $param_setting ) {
|
||||||
delete_option( $param_setting );
|
delete_option( $param_setting );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
//通常と検索用のカスタム表示順を削除
|
//通常と検索用のカスタム表示順を削除
|
||||||
$option_orders = array(
|
$option_orders = array(
|
||||||
'_apop_post_normal',
|
"'" . '_apop_post_normal' . "'",
|
||||||
'_apop_post_search',
|
"'" . '_apop_post_search' . "'",
|
||||||
);
|
);
|
||||||
foreach ( $option_orders as $option_order ) {
|
$stmnt = 'DELETE FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key IN(' . implode( ',', $option_orders ) . ')';
|
||||||
delete_post_meta_by_key( $option_order );
|
$wpdb->query( $stmnt );
|
||||||
}
|
|
||||||
|
|
||||||
//タクソノミー設定を削除
|
//タクソノミー設定を削除(WEHRE LIKE 'XXX%')
|
||||||
$tax_order_settings = array(
|
$tax_order_settings = array(
|
||||||
'_apop_cat_order' => '_apop_post_category_',
|
'_apop_post_category_',
|
||||||
'_apop_tax_order' => '_apop_post_tax_',
|
'_apop_post_post_tag_',
|
||||||
'_apop_tag_order' => '_apop_post_post_tag_',
|
'_apop_post_tax_',
|
||||||
|
'_apop_postorder_'
|
||||||
);
|
);
|
||||||
foreach ( $tax_order_settings as $post_option => $post_meta ) {
|
foreach ( $tax_order_settings as $tax_order_setting ) {
|
||||||
$target_tax = get_option( $post_option );
|
$stmnt = 'DELETE FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key LIKE ' . "'" . $tax_order_setting . "%'";
|
||||||
foreach ( $target_tax['target_cat'] as $tax_id => $status ) {
|
$wpdb->query( $stmnt );
|
||||||
delete_post_meta_by_key( $post_meta . $tax_id );
|
|
||||||
}
|
|
||||||
delete_option( $post_option );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ if ( ! trait_exists( 'APOP_ORDER_SETTING' ) ) {
|
|||||||
|
|
||||||
private static function set_custom_filed_sort( &$orderby, $order_col, $orders, $sort_param ): array {
|
private static function set_custom_filed_sort( &$orderby, $order_col, $orders, $sort_param ): array {
|
||||||
if ( strpos( $order_col, 'custom_field' ) !== false ) {
|
if ( strpos( $order_col, 'custom_field' ) !== false ) {
|
||||||
$meta_key = $orders['field']['meta_key'];
|
$meta_key = APOP_CUSTOM_FIELD_PREFIX . $orders['field']['meta_key'];
|
||||||
$orderby_sort = $orders['sort'];
|
$orderby_sort = $orders['sort'];
|
||||||
$type = 'CHAR';
|
$type = 'CHAR';
|
||||||
if ( $orders['field']['value_type'] == 'meta_value_num' ) {
|
if ( $orders['field']['value_type'] == 'meta_value_num' ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user