Changeset 2917867
- Timestamp:
- 05/26/2023 03:14:20 PM (3 years ago)
- Location:
- fazae-wp-booster
- Files:
-
- 2 added
- 8 edited
- 1 copied
-
tags/1.4.4 (copied) (copied from fazae-wp-booster/trunk)
-
tags/1.4.4/Plugin.php (modified) (2 diffs)
-
tags/1.4.4/README.txt (modified) (1 diff)
-
tags/1.4.4/src/Commands.php (modified) (1 diff)
-
tags/1.4.4/src/Commands/WebpGenerateCommand.php (added)
-
tags/1.4.4/src/WebP.php (modified) (3 diffs)
-
trunk/Plugin.php (modified) (2 diffs)
-
trunk/README.txt (modified) (1 diff)
-
trunk/src/Commands.php (modified) (1 diff)
-
trunk/src/Commands/WebpGenerateCommand.php (added)
-
trunk/src/WebP.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fazae-wp-booster/tags/1.4.4/Plugin.php
r2912568 r2917867 3 3 * Plugin Name: Fazaé WP Booster 4 4 * Description: Boost your WordPress and unleash the full potential of your Fazaé hosting ! 5 * Version: 1.4. 35 * Version: 1.4.4 6 6 * Author: Fazaé 7 7 * Author URI: https://www.fazae.com … … 19 19 } 20 20 21 define('fazaeWPBooster_VERSION', '1.4. 3');21 define('fazaeWPBooster_VERSION', '1.4.4'); 22 22 23 23 require_once __DIR__ . "/vendor/autoload.php"; -
fazae-wp-booster/tags/1.4.4/README.txt
r2912568 r2917867 5 5 Requires at least: 4.9.1 6 6 Tested up to: 6.2 7 Stable tag: 1.4. 37 Stable tag: 1.4.4 8 8 Requires PHP: 7.2 9 9 License: GPLv2 or later -
fazae-wp-booster/tags/1.4.4/src/Commands.php
r2717215 r2917867 21 21 public function configure() { 22 22 \WP_CLI::add_command('booster_clear', Commands\CacheClearCommand::class); 23 \WP_CLI::add_command('wepb_generate', Commands\WebpGenerateCommand::class); 23 24 } 24 25 -
fazae-wp-booster/tags/1.4.4/src/WebP.php
r2902352 r2917867 17 17 return self::$instance; 18 18 } 19 19 20 20 static public function isActiveInHtAccess() { 21 21 $content = file_get_contents(ABSPATH . ".htaccess"); … … 56 56 $sizes = $metadata['sizes']; 57 57 if (count($sizes) > 0) { 58 $uri = wp_get_attachment_url($attachment_id); 59 $attachment_base = _wp_get_attachment_relative_path($uri); 60 $directory_uploads = wp_get_upload_dir(); 61 $source_directory = $directory_uploads['basedir'] . "/" . $attachment_base; 58 $sourceDirectory = $this->getSourceDirectoryForAttachment($attachment_id); 59 62 60 // On converti le fichier de base 63 61 $this->generateWebPForMetaDataFileSize( 64 [65 "width" => $metadata['width'],66 "height" => $metadata['height'],67 "file" => basename($metadata['file'])68 ], $source_directory);62 [ 63 "width" => $metadata['width'], 64 "height" => $metadata['height'], 65 "file" => basename($metadata['file']), 66 ], $sourceDirectory); 69 67 foreach ($sizes as $size) { 70 $this->generateWebPForMetaDataFileSize($size, $source _directory);68 $this->generateWebPForMetaDataFileSize($size, $sourceDirectory); 71 69 } 72 70 } … … 97 95 } 98 96 97 public function generateWebPForAllAttachments(): array { 98 99 $result = []; 100 $attachments = get_posts([ 101 'post_type' => 'attachment', 102 'posts_per_page' => -1, 103 ]); 104 foreach ($attachments as $attachment) { 105 106 $metadata = wp_get_attachment_metadata($attachment->ID); 107 if (!$metadata || !isset($metadata['file']) || !isset($metadata['width']) || !isset($metadata['height'])) { 108 continue; 109 } 110 $sourceDirectory = $this->getSourceDirectoryForAttachment($attachment->ID); 111 112 $sourceMetadata = [ 113 "width" => $metadata['width'], 114 "height" => $metadata['height'], 115 "file" => basename($metadata['file']) 116 ]; 117 if ($this->generateWebPForMetaDataFileSize($sourceMetadata, $sourceDirectory)) { 118 $result[] = basename($metadata['file']) . " - " . $metadata['width'] . "x" . $metadata['height']; 119 } 120 121 if (!isset($metadata['sizes']) || !$metadata['sizes']) { 122 continue; 123 } 124 foreach ($metadata['sizes'] as $size) { 125 if ($this->generateWebPForMetaDataFileSize($size, $sourceDirectory)) { 126 $result[] = basename($size['file']) . " - " . $size['width'] . "x" . $size['height']; 127 } 128 129 } 130 131 } 132 133 return $result; 134 } 135 136 private function getSourceDirectoryForAttachment($attachmentId): string { 137 $attachmentBase = _wp_get_attachment_relative_path( 138 wp_get_attachment_url($attachmentId) 139 ); 140 return wp_get_upload_dir()['basedir'] . "/" . $attachmentBase; 141 } 142 99 143 } -
fazae-wp-booster/trunk/Plugin.php
r2912568 r2917867 3 3 * Plugin Name: Fazaé WP Booster 4 4 * Description: Boost your WordPress and unleash the full potential of your Fazaé hosting ! 5 * Version: 1.4. 35 * Version: 1.4.4 6 6 * Author: Fazaé 7 7 * Author URI: https://www.fazae.com … … 19 19 } 20 20 21 define('fazaeWPBooster_VERSION', '1.4. 3');21 define('fazaeWPBooster_VERSION', '1.4.4'); 22 22 23 23 require_once __DIR__ . "/vendor/autoload.php"; -
fazae-wp-booster/trunk/README.txt
r2912568 r2917867 5 5 Requires at least: 4.9.1 6 6 Tested up to: 6.2 7 Stable tag: 1.4. 37 Stable tag: 1.4.4 8 8 Requires PHP: 7.2 9 9 License: GPLv2 or later -
fazae-wp-booster/trunk/src/Commands.php
r2717215 r2917867 21 21 public function configure() { 22 22 \WP_CLI::add_command('booster_clear', Commands\CacheClearCommand::class); 23 \WP_CLI::add_command('wepb_generate', Commands\WebpGenerateCommand::class); 23 24 } 24 25 -
fazae-wp-booster/trunk/src/WebP.php
r2902352 r2917867 17 17 return self::$instance; 18 18 } 19 19 20 20 static public function isActiveInHtAccess() { 21 21 $content = file_get_contents(ABSPATH . ".htaccess"); … … 56 56 $sizes = $metadata['sizes']; 57 57 if (count($sizes) > 0) { 58 $uri = wp_get_attachment_url($attachment_id); 59 $attachment_base = _wp_get_attachment_relative_path($uri); 60 $directory_uploads = wp_get_upload_dir(); 61 $source_directory = $directory_uploads['basedir'] . "/" . $attachment_base; 58 $sourceDirectory = $this->getSourceDirectoryForAttachment($attachment_id); 59 62 60 // On converti le fichier de base 63 61 $this->generateWebPForMetaDataFileSize( 64 [65 "width" => $metadata['width'],66 "height" => $metadata['height'],67 "file" => basename($metadata['file'])68 ], $source_directory);62 [ 63 "width" => $metadata['width'], 64 "height" => $metadata['height'], 65 "file" => basename($metadata['file']), 66 ], $sourceDirectory); 69 67 foreach ($sizes as $size) { 70 $this->generateWebPForMetaDataFileSize($size, $source _directory);68 $this->generateWebPForMetaDataFileSize($size, $sourceDirectory); 71 69 } 72 70 } … … 97 95 } 98 96 97 public function generateWebPForAllAttachments(): array { 98 99 $result = []; 100 $attachments = get_posts([ 101 'post_type' => 'attachment', 102 'posts_per_page' => -1, 103 ]); 104 foreach ($attachments as $attachment) { 105 106 $metadata = wp_get_attachment_metadata($attachment->ID); 107 if (!$metadata || !isset($metadata['file']) || !isset($metadata['width']) || !isset($metadata['height'])) { 108 continue; 109 } 110 $sourceDirectory = $this->getSourceDirectoryForAttachment($attachment->ID); 111 112 $sourceMetadata = [ 113 "width" => $metadata['width'], 114 "height" => $metadata['height'], 115 "file" => basename($metadata['file']) 116 ]; 117 if ($this->generateWebPForMetaDataFileSize($sourceMetadata, $sourceDirectory)) { 118 $result[] = basename($metadata['file']) . " - " . $metadata['width'] . "x" . $metadata['height']; 119 } 120 121 if (!isset($metadata['sizes']) || !$metadata['sizes']) { 122 continue; 123 } 124 foreach ($metadata['sizes'] as $size) { 125 if ($this->generateWebPForMetaDataFileSize($size, $sourceDirectory)) { 126 $result[] = basename($size['file']) . " - " . $size['width'] . "x" . $size['height']; 127 } 128 129 } 130 131 } 132 133 return $result; 134 } 135 136 private function getSourceDirectoryForAttachment($attachmentId): string { 137 $attachmentBase = _wp_get_attachment_relative_path( 138 wp_get_attachment_url($attachmentId) 139 ); 140 return wp_get_upload_dir()['basedir'] . "/" . $attachmentBase; 141 } 142 99 143 }
Note: See TracChangeset
for help on using the changeset viewer.