PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
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
← All changes | src/model/class-scan-item.php +40 -7 5.6.0 → 6.3.0 View file →
@@ -74,18 +74,23 @@
74 74 *
75 75 * @param int $parent_id The primary key of the scan table.
76 76 * @param string $status Active or ignore status of scan item(s).
77 77 *
78 - * @return array Return array of group and all total.
78 + * @return array Return array of groups and all total.
79 79 */
80 - public function get_types_total( $parent_id, $status ) {
80 + public function get_types_total( $parent_id, $status ): array {
81 81 global $wpdb;
82 82
83 + $types = self::get_all_scan_types();
84 + $placeholders = implode( ', ', array_fill( 0, count( $types ), '%s' ) );
85 +
83 86 $records = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
84 - $wpdb->prepare(
85 - "SELECT IFNULL(`type`, 'all') as `item_type`, count(*) as `type_total` FROM {$wpdb->base_prefix}defender_scan_item WHERE `parent_id` = %d AND `status` = %s Group BY `type` WITH ROLLUP",
86 - $parent_id,
87 - $status
87 + $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
88 + "SELECT IFNULL(`type`, 'all') as `item_type`, count(*) as `type_total`" .
89 + " FROM {$wpdb->base_prefix}defender_scan_item" .
90 + " WHERE `parent_id` = %d AND `status` = %s AND `type` IN ($placeholders)" . // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
91 + ' Group BY `type` WITH ROLLUP',
92 + array_merge( array( $parent_id, $status ), $types )
88 93 )
89 94 );
90 95
91 96 $results = array();
@@ -118,10 +123,10 @@
118 123 * @return void
119 124 */
120 125 public function import( $data ): void {
121 126 parent::import( $data );
127 + // Add behaviors.
122 128 switch ( $this->type ) {
123 - // Add other behaviors here.
124 129 case self::TYPE_SUSPICIOUS:
125 130 $this->attach_behavior( Malware_Result::class, Malware_Result::class );
126 131 break;
127 132 case self::TYPE_VULNERABILITY:
@@ -133,6 +138,34 @@
133 138 break;
134 139 default:
135 140 break;
136 141 }
142 + }
143 +
144 + /**
145 + * Get all Scan types.
146 + *
147 + * @return array
148 + */
149 + public static function get_all_scan_types(): array {
150 + return array(
151 + self::TYPE_VULNERABILITY,
152 + self::TYPE_SUSPICIOUS,
153 + self::TYPE_INTEGRITY,
154 + self::TYPE_PLUGIN_CHECK,
155 + self::TYPE_PLUGIN_CLOSED,
156 + self::TYPE_PLUGIN_OUTDATED,
157 + );
158 + }
159 +
160 + /**
161 + * Get all scan statuses.
162 + *
163 + * @return array
164 + */
165 + public static function get_all_scan_statuses(): array {
166 + return array(
167 + self::STATUS_ACTIVE,
168 + self::STATUS_IGNORE,
169 + );
137 170 }
138 171 }