52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
/*
|
|
* Plugin Name: Remove decode tags
|
|
* Author: Pierre
|
|
* Text Domain: decode-remove-tags
|
|
*/
|
|
|
|
/**
|
|
* Just before uninstalling the plugin....
|
|
* // REMOVE all metatag used by the plugins.
|
|
*/
|
|
|
|
|
|
add_action('wp_loaded', 'remove_decode_tags');
|
|
|
|
if ( ! function_exists('remove_decode_tags') ) {
|
|
|
|
// Register EVENTS post type
|
|
function remove_decode_tags(){
|
|
if (!isset($_GET['decode-remove'])) {
|
|
return;
|
|
}
|
|
|
|
delete_post_meta_by_key( 'decoded' );
|
|
delete_post_meta_by_key( 'decoded_msg' );
|
|
|
|
|
|
$args = array(
|
|
'post_type' => array("event", "page", "souvenir", "breve", "attachment"), // Specify the post type you want to update, e.g., 'post', 'events', 'books'
|
|
// 'post_type' => 'attachment',
|
|
'numberposts' => -1,
|
|
'post_status' => 'any',
|
|
'meta_query' => array(
|
|
'relation' => 'AND',
|
|
array(
|
|
'key' => 'decoded',
|
|
'value' => '',
|
|
'compare' => '!=',
|
|
),
|
|
array(
|
|
'key' => 'decoded_msg',
|
|
'value' => '',
|
|
'compare' => '!=',
|
|
),
|
|
),
|
|
);
|
|
|
|
$all_posts = get_posts( $args );
|
|
|
|
echo '<div style="width:60%; margin:auto;"><span>Posts with meta fields : ' . print_r(sizeof($all_posts), true) . '</span></div>';
|
|
}
|
|
}
|