PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.3.0
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.3.0
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / inc / classes / class-imagify-files-db.php

class-imagify-files-db.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.3.0, at inc/classes/class-imagify-files-db.php

154 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use Imagify\Traits\InstanceGetterTrait;
4
5 /**
6 * DB class that handles files in "custom folders".
7 *
8 * @since 1.7
9 * @author Grégory Viguier
10 */
11 class Imagify_Files_DB extends Imagify_Abstract_DB {
12 use InstanceGetterTrait;
13
14 /**
15 * Class version.
16 *
17 * @var string
18 */
19 const VERSION = '1.1';
20
21 /**
22 * The suffix used in the name of the database table (so, without the wpdb prefix).
23 *
24 * @var string
25 * @since 1.7
26 * @access protected
27 */
28 protected $table = 'imagify_files';
29
30 /**
31 * The version of our database table.
32 *
33 * @var int
34 * @since 1.7
35 * @access protected
36 */
37 protected $table_version = 102;
38
39 /**
40 * Tell if the table is the same for each site of a Multisite.
41 *
42 * @var bool
43 * @since 1.7
44 * @access protected
45 */
46 protected $table_is_global = true;
47
48 /**
49 * The name of the primary column.
50 *
51 * @var string
52 * @since 1.7
53 * @access protected
54 */
55 protected $primary_key = 'file_id';
56
57 /**
58 * Get the column placeholders.
59 *
60 * @since 1.7
61 * @access public
62 * @author Grégory Viguier
63 *
64 * @return array
65 */
66 public function get_columns() {
67 return [
68 'file_id' => '%d',
69 'folder_id' => '%d',
70 'file_date' => '%s',
71 'path' => '%s',
72 'hash' => '%s',
73 'mime_type' => '%s',
74 'modified' => '%d',
75 'width' => '%d',
76 'height' => '%d',
77 'original_size' => '%d',
78 'optimized_size' => '%d',
79 'percent' => '%d',
80 'optimization_level' => '%d',
81 'status' => '%s',
82 'error' => '%s',
83 'data' => '%s',
84 ];
85 }
86
87 /**
88 * Default column values.
89 *
90 * @since 1.7
91 * @access public
92 * @author Grégory Viguier
93 *
94 * @return array
95 */
96 public function get_column_defaults() {
97 return [
98 'file_id' => 0,
99 'folder_id' => 0,
100 'file_date' => '0000-00-00 00:00:00',
101 'path' => '',
102 'hash' => '',
103 'mime_type' => '',
104 'modified' => 0,
105 'width' => 0,
106 'height' => 0,
107 'original_size' => 0,
108 'optimized_size' => null,
109 'percent' => null,
110 'optimization_level' => null,
111 'status' => null,
112 'error' => null,
113 'data' => [],
114 ];
115 }
116
117 /**
118 * Get the query to create the table fields.
119 *
120 * For with and height: `smallint(2) unsigned` means 65,535px max.
121 *
122 * @since 1.7
123 * @access protected
124 * @author Grégory Viguier
125 *
126 * @return string
127 */
128 protected function get_table_schema() {
129 return "
130 file_id bigint(20) unsigned NOT NULL auto_increment,
131 folder_id bigint(20) unsigned NOT NULL default 0,
132 file_date datetime NOT NULL default '0000-00-00 00:00:00',
133 path varchar(191) NOT NULL default '',
134 hash varchar(32) NOT NULL default '',
135 mime_type varchar(100) NOT NULL default '',
136 modified tinyint(1) unsigned NOT NULL default 0,
137 width smallint(2) unsigned NOT NULL default 0,
138 height smallint(2) unsigned NOT NULL default 0,
139 original_size int(4) unsigned NOT NULL default 0,
140 optimized_size int(4) unsigned default NULL,
141 percent smallint(2) unsigned default NULL,
142 optimization_level tinyint(1) unsigned default NULL,
143 status varchar(20) default NULL,
144 error varchar(255) default NULL,
145 data longtext default NULL,
146 PRIMARY KEY (file_id),
147 UNIQUE KEY path (path),
148 KEY folder_id (folder_id),
149 KEY optimization_level (optimization_level),
150 KEY status (status),
151 KEY modified (modified)";
152 }
153 }
154