PluginProbe
Plus WebP or AVIF / 4.07
Plus WebP or AVIF v4.07
5.21 5.20 5.12 5.11 trunk 1.00 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 1.12 1.13 2.00 2.01 2.02 2.03 2.04 2.05 All 47 releases
plus-webp / lib / pluswebp-cli.php

pluswebp-cli.php in Plus WebP or AVIF 4.07, at lib/pluswebp-cli.php

55 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Cli Name: Plus WebP CLI
4 * Description: Generate WebP by WP-CLI.
5 * Version: 1.00
6 * Author: Katsushi Kawamori
7 * Author URI: https://riverforest-wp.info/
8 * License: GPLv2 or later
9 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
10 *
11 * @package pluswebp_cli
12 */
13
14 /*
15 Copyright (c) 2024- Katsushi Kawamori (email : dodesyoswift312@gmail.com)
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; version 2 of the License.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */
29
30 /** ==================================================
31 * Plus WebP command
32 *
33 * @since 1.00
34 */
35 function pluswebp_cli_command() {
36
37 $pluswebpadmin = new PlusWebpAdmin();
38
39 $post_ids = $pluswebpadmin->get_allimages();
40 if ( ! empty( $post_ids ) ) {
41 foreach ( $post_ids as $post_id ) {
42 $messages = get_option( 'pluswebp_messages', array() );
43 $metadata_org = wp_get_attachment_metadata( $post_id );
44 do_action( 'wp_generate_attachment_metadata', $metadata_org, $post_id );
45 $webp_id = get_option( 'pluswebp_generate' );
46 delete_option( 'pluswebp_generate' );
47 list( $message, $messages ) = apply_filters( 'pluswebp_mail_messages', $messages, $webp_id );
48 WP_CLI::success( $message );
49 update_option( 'pluswebp_messages', $messages );
50 }
51 $pluswebpadmin->mail_generate_message( $messages, true );
52 }
53 }
54 WP_CLI::add_command( 'pluswebp_cli', 'pluswebp_cli_command' );
55