n Name: Freeze Posts After Date (WP-CLI) * Description: Congela (bozza) i post pubblicati dopo una certa data e permette il ripristino con la data originale. * Author: Marco * Version: 1.0.0 */ if ( ! defined('WP_CLI') || ! WP_CLI ) { return; } class Freeze_Posts_Command { const META_FLAG = '_freeze_flag'; const META_ORIG_DATE = '_freeze_original_post_date'; const META_ORIG_DATE_GMT = '_freeze_original_post_date_gmt'; const META_ORIG_STATUS = '_freeze_original_post_status'; /** * Congela i post pubblicati dopo una data (default: 2024-09-01 00:00:00). * * ## OPTIONS * * [--after=] * : Data (inclusiva) dopo cui congelare i post. Default: 2024-09-01 * * [--post_type=] * : Post type da considerare. Default: post * * [--dry-run] * : Non applica cambiamenti, mostra solo cosa farebbe. * * ## EXAMPLES * wp freeze-posts run --after=2024-09-01 * wp freeze-posts run --post_type=news */ public function run( $args, $assoc_args ) { $after = isset($assoc_args['after']) ? $assoc_args['after'] : '2024-09-01'; $post_type = isset($assoc_args['post_type']) ? $assoc_args['post_type'] : 'post'; $dry_run = isset($assoc_args['dry-run']); $after_dt = date('Y-m-d 00:00:00', strtotime($after)); $q = new WP_Query([ 'post_type' => $post_type, 'post_status' => 'publish', 'date_query' => [ [ 'after' => $after_dt, 'inclusive' => true, 'column' => 'post_date', ], ], 'posts_per_page' => -1, 'fields' => 'ids', 'no_found_rows' => true, ]); $count = 0; if ( $q->have_posts() ) { foreach ( $q->posts as $post_id ) { $already = get_post_meta($post_id, self::META_FLAG, true); if ( $already ) { WP_CLI::log("Skip #$post_id (già congelato)"); continue; } $post = get_post($post_id); $orig_status = $post->post_status; $orig_date = $post->post_date; $orig_date_gmt = $post->post_date_gmt; if ( ! $dry_run ) { // salva meta per ripristino update_post_meta($post_id, self::META_FLAG, 1); update_post_meta($post_id, self::META_ORIG_STATUS, $orig_status); update_post_meta($post_id, self::META_ORIG_DATE, $orig_date); update_post_meta($post_id, self::META_ORIG_DATE_GMT, $orig_date_gmt); // porta offline: draft wp_update_post([ 'ID' => $post_id, 'post_status' => 'draft', ]); } $count++; WP_CLI::log(($dry_run ? '[DRY RUN] ' : '') . "Congelato #$post_id ($post_type) – era publish del $orig_date"); } } WP_CLI::success(($dry_run ? '[DRY RUN] ' : '') . "Totale post congelati: $count"); } /** * Ripristina tutti i post congelati (flag presenti), rimettendo online con la data originale. * * ## OPTIONS * * [--post_type=] * : Post type da considerare. Default: post * * [--dry-run] * : Non applica cambiamenti, mostra solo cosa farebbe. * * ## EXAMPLES * wp freeze-posts restore */ public function restore( $args, $assoc_args ) { $post_type = isset($assoc_args['post_type']) ? $assoc_args['post_type'] : 'post'; $dry_run = isset($assoc_args['dry-run']); $q = new WP_Query([ 'post_type' => $post_type, 'post_status' => ['draft','pending','private','publish','future'], 'meta_query' => [ [ 'key' => self::META_FLAG, 'value' => 1, ], ], 'posts_per_page' => -1, 'fields' => 'ids', 'no_found_rows' => true, ]); $count = 0; if ( $q->have_posts() ) { foreach ( $q->posts as $post_id ) { $orig_status = get_post_meta($post_id, self::META_ORIG_STATUS, true) ?: 'publish'; $orig_date = get_post_meta($post_id, self::META_ORIG_DATE, true); $orig_date_gmt = get_post_meta($post_id, self::META_ORIG_DATE_GMT, true); if ( ! $orig_date || ! $orig_date_gmt ) { WP_CLI::warning("Post #$post_id: mancano date originali, skip."); continue; } if ( ! $dry_run ) { // ripristina status e date wp_update_post([ 'ID' => $post_id, 'post_status' => $orig_status, 'post_date' => $orig_date, 'post_date_gmt' => $orig_date_gmt, ]); // pulizia meta delete_post_meta($post_id, self::META_FLAG); delete_post_meta($post_id, self::META_ORIG_STATUS); delete_post_meta($post_id, self::META_ORIG_DATE); delete_post_meta($post_id, self::META_ORIG_DATE_GMT); } $count++; WP_CLI::log(($dry_run ? '[DRY RUN] ' : '') . "Ripristinato #$post_id → {$orig_status} ({$orig_date})"); } } WP_CLI::success(($dry_run ? '[DRY RUN] ' : '') . "Totale post ripristinati: $count"); } } WP_CLI::add_command('freeze-posts', 'Freeze_Posts_Command'); Informazioni su aeroporti, stazioni e destinazioni: video imperdibili | Viaggiamo.it
Restauro stazione porta garibaldi e negozi il progetto

Negozi alla stazione di Milano Porta Garibaldi

La stazione di Milano Porta Garibaldi non è solo un luogo di transito, ma anche un centro dove trascorrere piacevolmente il proprio tempo nella modernissima galleria commerciale. Qui si possono trovare le catene di tendenza e più famose come Tezenis e Accessorize; oltre a un’ampia gamma di servizi come bar, ristoranti e tabacchi.

drills 506651 1920

Città italiane più economiche

Vi sete sempre chiesti quali siano le città più economiche in Italia? Ecco a voi una lista delle città più accessibili da visitare assolutamente. Nel 2017 il primo posto è occupato dalla bellissima Trapani.

Via del Corso Roma 20160616

Le vie dello shopping low cost a Roma

Roma è una città dalle mille opportunità; perciò è possibile fare shopping low cost. La via dello shopping a prezzi convenienti è Via Tuscolana. A tal proposito si segnalano i diversi mercati rionali come quello di Porta Portese.

plane 170272 1920

Negozi all’aeroporto di Torino

I servizi aeroportuali dell’aeroporto di Torino-Caselle si articolano sui 3 piani della struttura. Quello che ci interessa approfondire di questa vasta gamma di servizi offerti è il servizio shopping.