PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.2.2
Defender Security – Malware Scanner, Login Security & Firewall v6.2.2
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / integrations / class-smush.php

class-smush.php in Defender Security – Malware Scanner, Login Security & Firewall 6.2.2, at src/integrations/class-smush.php

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