| @@ -1,5 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Handles image optimization and compression. | |
| 4 | + * | |
| 5 | + * @package WP_Defender\Integrations | |
| 6 | + */ | |
| 2 | 7 | |
| 3 | 8 | namespace WP_Defender\Integrations; |
| 4 | 9 | |
| 5 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -7,16 +12,26 @@ | ||
| 7 | 12 | } |
| 8 | 13 | |
| 9 | 14 | /** |
| 10 | 15 | * Smush integration module. |
| 11 | - * Class Smush | |
| 12 | 16 | * |
| 13 | 17 | * @since 2.5.1 |
| 14 | - * @package WP_Defender\Integrations | |
| 15 | 18 | */ |
| 16 | 19 | class Smush { |
| 20 | + | |
| 21 | + /** | |
| 22 | + * Table name. | |
| 23 | + * | |
| 24 | + * @var string | |
| 25 | + */ | |
| 17 | 26 | private $table; |
| 18 | 27 | |
| 28 | + /** | |
| 29 | + * Constructor for the class. | |
| 30 | + * Initializes the table name for the Smush directory images. | |
| 31 | + * | |
| 32 | + * @return void | |
| 33 | + */ | |
| 19 | 34 | public function __construct() { |
| 20 | 35 | global $wpdb; |
| 21 | 36 | $this->table = $wpdb->base_prefix . 'smush_dir_images'; |
| 22 | 37 | } |
| @@ -28,26 +43,28 @@ | ||
| 28 | 43 | */ |
| 29 | 44 | public function exist_image_table() { |
| 30 | 45 | global $wpdb; |
| 31 | 46 | |
| 32 | - return (bool) $wpdb->get_var( $wpdb->prepare( | |
| 33 | - 'SHOW TABLES LIKE %s', | |
| 34 | - $wpdb->esc_like( $this->table ) | |
| 35 | - ) ); | |
| 47 | + return (bool) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery | |
| 48 | + $wpdb->prepare( | |
| 49 | + 'SHOW TABLES LIKE %s', | |
| 50 | + $wpdb->esc_like( $this->table ) | |
| 51 | + ) | |
| 52 | + ); | |
| 36 | 53 | } |
| 37 | 54 | |
| 38 | 55 | /** |
| 39 | 56 | * Check optimized image path |
| 40 | - * @param string | |
| 41 | 57 | * |
| 58 | + * @param string $path image path. | |
| 59 | + * | |
| 42 | 60 | * @return bool |
| 43 | 61 | */ |
| 44 | 62 | public function exist_image_path( $path ) { |
| 45 | 63 | global $wpdb; |
| 46 | - | |
| 47 | - return (bool) $wpdb->get_var( | |
| 64 | + return (bool) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery | |
| 48 | 65 | $wpdb->prepare( |
| 49 | - "SELECT id FROM {$this->table} WHERE path = %s", | |
| 66 | + "SELECT id FROM {$this->table} WHERE path = %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared | |
| 50 | 67 | $path |
| 51 | 68 | ) |
| 52 | 69 | ); |
| 53 | 70 | } |