| @@ -265,8 +265,38 @@ | ||
| 265 | 265 | return $last_send_time; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
| 269 | + * Get non elementor post usages. | |
| 270 | + * | |
| 271 | + * Retrieve the number of posts that not using elementor. | |
| 272 | + | |
| 273 | + * @return array The number of posts using not used by Elementor grouped by post types | |
| 274 | + * and post status. | |
| 275 | + */ | |
| 276 | + public static function get_non_elementor_posts_usage() { | |
| 277 | + global $wpdb; | |
| 278 | + | |
| 279 | + $usage = []; | |
| 280 | + | |
| 281 | + $results = $wpdb->get_results( | |
| 282 | + "SELECT `post_type`, `post_status`, COUNT(`ID`) `hits` | |
| 283 | + FROM {$wpdb->posts} `p` | |
| 284 | + LEFT JOIN {$wpdb->postmeta} `pm` ON(`p`.`ID` = `pm`.`post_id` AND `meta_key` = '_elementor_edit_mode' ) | |
| 285 | + WHERE `post_type` != 'elementor_library' AND `meta_value` IS NULL | |
| 286 | + GROUP BY `post_type`, `post_status`;" | |
| 287 | + ); | |
| 288 | + | |
| 289 | + if ( $results ) { | |
| 290 | + foreach ( $results as $result ) { | |
| 291 | + $usage[ $result->post_type ][ $result->post_status ] = $result->hits; | |
| 292 | + } | |
| 293 | + } | |
| 294 | + | |
| 295 | + return $usage; | |
| 296 | + } | |
| 297 | + | |
| 298 | + /** | |
| 269 | 299 | * Get posts usage. |
| 270 | 300 | * |
| 271 | 301 | * Retrieve the number of posts using Elementor. |
| 272 | 302 | * |
| @@ -297,9 +327,8 @@ | ||
| 297 | 327 | } |
| 298 | 328 | } |
| 299 | 329 | |
| 300 | 330 | return $usage; |
| 301 | - | |
| 302 | 331 | } |
| 303 | 332 | |
| 304 | 333 | /** |
| 305 | 334 | * Get library usage. |
| @@ -355,8 +384,9 @@ | ||
| 355 | 384 | 'site_lang' => get_bloginfo( 'language' ), |
| 356 | 385 | 'email' => get_option( 'admin_email' ), |
| 357 | 386 | 'usages' => [ |
| 358 | 387 | 'posts' => self::get_posts_usage(), |
| 388 | + 'non-elementor-posts' => self::get_non_elementor_posts_usage(), | |
| 359 | 389 | 'library' => self::get_library_usage(), |
| 360 | 390 | ], |
| 361 | 391 | 'is_first_time' => $is_first_time, |
| 362 | 392 | ]; |