WP PLUGIN プラグイン削除時のパラメータ削除とCSS調整

・投稿のソート用カスタムフィールドのキーについて、他システム等の競合を避け且つアンインストール時に前方一致で削除可能となるよう接頭辞を追加(接頭辞はプログラム側で持つため、管理画面上は表示しない)
・プラグイン削除時、オプションやカスタムフィールドを全削除するよう修正
・標準+カスタムフィールドソートの横並びを修正
This commit is contained in:
2021-06-15 19:06:08 +09:00
parent e15a46eec4
commit e3c8fc967c
9 changed files with 87 additions and 55 deletions
+21 -24
View File
@@ -7,42 +7,39 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
//通常と検索の表示件数、ソート対象設定等を削除
$param_settings = array(
'_apop_per_page',
'_apop_normal_order',
'_apop_search_order',
'_apop_tax_sort_type',
'_apop_normal_order_param',
'_apop_search_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 ) {
delete_option( $param_setting );
}
global $wpdb;
//通常と検索用のカスタム表示順を削除
$option_orders = array(
'_apop_post_normal',
'_apop_post_search',
"'" . '_apop_post_normal' . "'",
"'" . '_apop_post_search' . "'",
);
foreach ( $option_orders as $option_order ) {
delete_post_meta_by_key( $option_order );
}
$stmnt = 'DELETE FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key IN(' . implode( ',', $option_orders ) . ')';
$wpdb->query( $stmnt );
//タクソノミー設定を削除
//タクソノミー設定を削除(WEHRE LIKE 'XXX%')
$tax_order_settings = array(
'_apop_cat_order' => '_apop_post_category_',
'_apop_tax_order' => '_apop_post_tax_',
'_apop_tag_order' => '_apop_post_post_tag_',
'_apop_post_category_',
'_apop_post_post_tag_',
'_apop_post_tax_',
'_apop_postorder_'
);
foreach ( $tax_order_settings as $post_option => $post_meta ) {
$target_tax = get_option( $post_option );
foreach ( $target_tax['target_cat'] as $tax_id => $status ) {
delete_post_meta_by_key( $post_meta . $tax_id );
}
delete_option( $post_option );
foreach ( $tax_order_settings as $tax_order_setting ) {
$stmnt = 'DELETE FROM ' . $wpdb->prefix . 'postmeta WHERE meta_key LIKE ' . "'" . $tax_order_setting . "%'";
$wpdb->query( $stmnt );
}