|
@@ 72-91 (lines=20) @@
|
| 69 |
|
* |
| 70 |
|
* @return string|null The post ID or NULL if there are no posts to synchronize. |
| 71 |
|
*/ |
| 72 |
|
public function next() { |
| 73 |
|
global $wpdb; |
| 74 |
|
|
| 75 |
|
// Limit the query to the allowed post types. |
| 76 |
|
$post_type_in = implode( "','", array_map( 'esc_sql', \Wordlift_Entity_Service::valid_entity_post_types() ) ); |
| 77 |
|
|
| 78 |
|
// Get the next post ID. |
| 79 |
|
return $wpdb->get_var( " |
| 80 |
|
SELECT p.ID |
| 81 |
|
FROM $wpdb->posts p |
| 82 |
|
LEFT JOIN $wpdb->postmeta pm |
| 83 |
|
ON pm.post_id = p.ID |
| 84 |
|
AND pm.meta_key = '_wl_synced_gmt' |
| 85 |
|
WHERE p.post_status = 'publish' |
| 86 |
|
AND p.post_type IN ( '$post_type_in' ) |
| 87 |
|
AND ( pm.meta_value IS NULL OR pm.meta_value < p.post_modified_gmt ) |
| 88 |
|
ORDER BY p.post_modified_gmt DESC |
| 89 |
|
LIMIT 1 |
| 90 |
|
" ); |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
public function count() { |
| 94 |
|
global $wpdb; |
|
@@ 93-107 (lines=15) @@
|
| 90 |
|
" ); |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
public function count() { |
| 94 |
|
global $wpdb; |
| 95 |
|
$post_type_in = implode( "','", array_map( 'esc_sql', \Wordlift_Entity_Service::valid_entity_post_types() ) ); |
| 96 |
|
|
| 97 |
|
return $wpdb->get_var( " |
| 98 |
|
SELECT COUNT( 1 ) |
| 99 |
|
FROM $wpdb->posts p |
| 100 |
|
LEFT JOIN $wpdb->postmeta pm |
| 101 |
|
ON pm.post_id = p.ID |
| 102 |
|
AND pm.meta_key = '_wl_synced_gmt' |
| 103 |
|
WHERE p.post_status = 'publish' |
| 104 |
|
AND p.post_type IN ( '$post_type_in' ) |
| 105 |
|
AND ( pm.meta_value IS NULL OR pm.meta_value < p.post_modified_gmt ) |
| 106 |
|
" ); |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
public function info() { |
| 110 |
|
return Sync_Background_Process::get_state(); |