Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/778 avif bulk generate #784

Merged
merged 7 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions classes/Bulk/Bulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function init() {
add_action( 'imagify_convert_next_gen', [ $this, 'generate_next_gen_versions' ], 10, 2 );
add_action( 'imagify_convert_webp_finished', [ $this, 'clear_webp_transients' ], 10, 2 );
add_action( 'wp_ajax_imagify_bulk_optimize', [ $this, 'bulk_optimize_callback' ] );
add_action( 'wp_ajax_imagify_missing_nextgen_generation', [ $this, 'missing_nextgen_callback' ] );
add_action( 'imagify_bulk_optimize', [ $this, 'bulk_optimize' ], 10, 2 );
add_action( 'wp_ajax_imagify_missing_webp_generation', [ $this, 'missing_webp_callback' ] );
add_action( 'wp_ajax_imagify_get_folder_type_data', [ $this, 'get_folder_type_data_callback' ] );
add_action( 'wp_ajax_imagify_bulk_info_seen', [ $this, 'bulk_info_seen_callback' ] );
add_action( 'wp_ajax_imagify_bulk_get_stats', [ $this, 'bulk_get_stats_callback' ] );
Expand Down Expand Up @@ -218,10 +218,11 @@ public function run_optimize( string $context, int $optimization_level ) {
* Runs the WebP generation
*
* @param array $contexts An array of contexts (WP/Custom folders).
* @param array $formats An array of format to generate.
*
* @return array
*/
public function run_generate_webp( array $contexts ) {
public function run_generate_nextgen( array $contexts, array $formats ) {
if ( ! $this->can_optimize() ) {
return [
'success' => false,
Expand Down Expand Up @@ -514,7 +515,7 @@ public function bulk_optimize_callback() {
*
* @return void
*/
public function missing_webp_callback() {
public function missing_nextgen_callback() {
imagify_check_nonce( 'imagify-bulk-optimize' );

$contexts = explode( '_', sanitize_key( wp_unslash( $_GET['context'] ) ) );
Expand All @@ -525,7 +526,9 @@ public function missing_webp_callback() {
}
}

$data = $this->run_generate_webp( $contexts );
$formats = imagify_nextgen_images_formats();

$data = $this->run_generate_nextgen( $contexts, $formats );

if ( false === $data['success'] ) {
wp_send_json_error( [ 'message' => $data['message'] ] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Imagify\Bulk\Bulk;

/**
* Command class for the missing WebP generation
* Command class for the missing Nextgen generation
*/
class GenerateMissingWebpCommand extends AbstractCommand {
class GenerateMissingNextgenCommand extends AbstractCommand {
/**
* Executes the command.
*
Expand Down
4 changes: 2 additions & 2 deletions classes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Imagify\Bulk\Bulk;
use Imagify\CLI\BulkOptimizeCommand;
use Imagify\CLI\GenerateMissingWebpCommand;
use Imagify\CLI\GenerateMissingNextgenCommand;
use Imagify\Notices\Notices;
use Imagify\Admin\AdminBar;

Expand Down Expand Up @@ -80,7 +80,7 @@ class_alias( '\\Imagify\\Traits\\InstanceGetterTrait', '\\Imagify\\Traits\\FakeS
imagify_load_translations();

imagify_add_command( new BulkOptimizeCommand() );
imagify_add_command( new GenerateMissingWebpCommand() );
imagify_add_command( new GenerateMissingNextgenCommand() );

/**
* Fires when Imagify is fully loaded.
Expand Down
2 changes: 1 addition & 1 deletion inc/functions/i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function get_imagify_localize_script_translations( $context ) {
'requirements' => $imagifybeat_actions->get_imagifybeat_id( 'requirements' ),
],
'ajaxActions' => [
'MissingWebp' => 'imagify_missing_webp_generation',
'MissingNextGen' => 'imagify_missing_nextgen_generation',
],
'ajaxNonce' => wp_create_nonce( 'imagify-bulk-optimize' ),
'contexts' => $contexts,
Expand Down