Changeset 3487385
- Timestamp:
- 03/20/2026 06:07:56 PM (2 weeks ago)
- Location:
- ask-my-content/trunk/includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ask-my-content/trunk/includes/indexing.php
r3486628 r3487385 162 162 163 163 askmyco_debug_log(['index_post_types' => $post_types], 'info'); 164 if ($include_other_post_types) { 165 askmyco_debug_log(['other_post_type_counts' => askmyco_get_other_post_type_counts()], 'info'); 166 } 164 167 $accepted_embed_requests = 0; 165 168 169 // Preserve previously indexed counts for buckets not included in this run. 170 // Included buckets are recalculated from this run's processed/skipped items. 166 171 $embedded_pages = 0; 167 $embedded_posts = 0;168 $embedded_others = 0;172 $embedded_posts = $include_posts ? 0 : (int) get_option('askmyco_embedded_post_count', 0); 173 $embedded_others = $include_other_post_types ? 0 : (int) get_option('askmyco_embedded_other_count', 0); 169 174 170 175 $args = [ … … 202 207 askmyco_bump_and_save_embed_counters($post->post_type, $embedded_pages, $embedded_posts, $embedded_others); 203 208 204 askmyco_debug_log('Skipping post ID ' . $post->ID . ' (modified_gmt ' . $post_modified_iso_gmt 209 askmyco_debug_log('Skipping ' . $post->post_type . ' ID ' . $post->ID 210 . ' [bucket ' . $bucket . '] (modified_gmt ' . $post_modified_iso_gmt 205 211 . ' < last_indexed_gmt ' . ($compare_dt ? $compare_dt->format('c') : 'n/a') . ')'); 206 212 continue; -
ask-my-content/trunk/includes/sync.php
r3486628 r3487385 10 10 function askmyco_handle_post_save($post_id, $post, $update) 11 11 { 12 // Ignore autosaves/revisions and only act on published posts/pages12 // Ignore autosaves/revisions and only act on published indexable content types 13 13 if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) return; 14 14 if ($post->post_status !== 'publish') return; … … 16 16 $ptype = get_post_type($post_id); 17 17 18 if (! is_string($ptype) || ! askmyco_is_post_type_included_for_indexing($ptype)) return; 18 if (! is_string($ptype)) return; 19 20 $safe_types = array_merge(['page', 'post'], askmyco_get_other_post_types()); 21 if (! in_array($ptype, $safe_types, true)) return; 19 22 20 23 $option_name = askmyco_get_modified_queue_option_name($ptype); -
ask-my-content/trunk/includes/utils.php
r3486628 r3487385 125 125 $types = get_post_types([ 126 126 'public' => true, 127 'publicly_queryable' => true, 127 128 ], 'names'); 128 129 … … 131 132 'page', 132 133 'attachment', 134 'elementor_library', 133 135 ]; 134 136 … … 138 140 139 141 return $types; 142 } 143 144 function askmyco_get_post_type_publish_count(string $post_type): int 145 { 146 $counts = wp_count_posts($post_type); 147 if (! is_object($counts) || ! isset($counts->publish)) { 148 return 0; 149 } 150 151 return (int) $counts->publish; 152 } 153 154 function askmyco_get_other_post_type_counts(): array 155 { 156 $counts = []; 157 158 foreach (askmyco_get_other_post_types() as $post_type) { 159 $counts[$post_type] = askmyco_get_post_type_publish_count($post_type); 160 } 161 162 return $counts; 140 163 } 141 164 … … 207 230 208 231 foreach ($post_types as $post_type) { 209 $counts = wp_count_posts($post_type); 210 if (is_object($counts) && isset($counts->publish)) { 211 $total += (int) $counts->publish; 212 } 232 $total += askmyco_get_post_type_publish_count($post_type); 213 233 } 214 234 … … 224 244 $total = 0; 225 245 foreach ($post_types as $post_type) { 226 $counts = wp_count_posts($post_type); 227 if (is_object($counts) && isset($counts->publish)) { 228 $total += (int) $counts->publish; 229 } 246 $total += askmyco_get_post_type_publish_count($post_type); 230 247 } 231 248
Note: See TracChangeset
for help on using the changeset viewer.