/** * WEBTV - Relancer la génération des sprites par lots de 50 articles * Utilise le hook save_post_post du plugin WebTV Sprite. */ add_action('admin_init', function () { if (!isset($_GET['webtv_sprite_batch'])) { return; } if (!current_user_can('manage_options')) { wp_die('Accès non autorisé.'); } check_admin_referer('webtv_sprite_batch'); $offset = isset($_GET['offset']) ? max(0, intval($_GET['offset'])) : 0; $limit = 50; $articles = get_posts(array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $limit, 'offset' => $offset, 'orderby' => 'date', 'order' => 'DESC', )); if (empty($articles)) { wp_die('Aucun article à traiter pour ce lot.'); } echo '

WebTV : traitement des articles

'; $total = count($articles); foreach ($articles as $index => $article) { echo '

Article ' . ($offset + $index + 1) . ' : ' . esc_html($article->post_title) . '

'; do_action( 'save_post_post', $article->ID, $article, true ); if (function_exists('webtv_sprite_log')) { webtv_sprite_log( 'Relance manuelle : article ' . $article->ID ); } if (function_exists('flush')) { flush(); } } $next_offset = $offset + $total; echo '
'; echo '

Lot terminé : ' . $total . ' articles déclenchés.

'; if ($total === $limit) { $next_url = wp_nonce_url( admin_url( 'index.php?webtv_sprite_batch=1&offset=' . $next_offset ), 'webtv_sprite_batch' ); echo '

Lancer les 50 articles suivants

'; } else { echo '

Tous les articles de cette série ont été parcourus.

'; } exit; }); Communication du Dr Z.ABDELLI - WebTV Université A-MIRA Bejaia

Pin It on Pinterest

Share This