Plugin Directory

Changeset 3487385


Ignore:
Timestamp:
03/20/2026 06:07:56 PM (2 weeks ago)
Author:
ugoltsev
Message:

release 1.1.0 fixes)

Location:
ask-my-content/trunk/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ask-my-content/trunk/includes/indexing.php

    r3486628 r3487385  
    162162
    163163    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    }
    164167    $accepted_embed_requests = 0;
    165168
     169    // Preserve previously indexed counts for buckets not included in this run.
     170    // Included buckets are recalculated from this run's processed/skipped items.
    166171    $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);
    169174
    170175    $args = [
     
    202207            askmyco_bump_and_save_embed_counters($post->post_type, $embedded_pages, $embedded_posts, $embedded_others);
    203208
    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
    205211                . ' < last_indexed_gmt ' . ($compare_dt ? $compare_dt->format('c') : 'n/a') . ')');
    206212            continue;
  • ask-my-content/trunk/includes/sync.php

    r3486628 r3487385  
    1010function askmyco_handle_post_save($post_id, $post, $update)
    1111{
    12     // Ignore autosaves/revisions and only act on published posts/pages
     12    // Ignore autosaves/revisions and only act on published indexable content types
    1313    if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) return;
    1414    if ($post->post_status !== 'publish') return;
     
    1616    $ptype = get_post_type($post_id);
    1717
    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;
    1922
    2023    $option_name = askmyco_get_modified_queue_option_name($ptype);
  • ask-my-content/trunk/includes/utils.php

    r3486628 r3487385  
    125125    $types = get_post_types([
    126126        'public' => true,
     127        'publicly_queryable' => true,
    127128    ], 'names');
    128129
     
    131132        'page',
    132133        'attachment',
     134        'elementor_library',
    133135    ];
    134136
     
    138140
    139141    return $types;
     142}
     143
     144function 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
     154function 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;
    140163}
    141164
     
    207230
    208231    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);
    213233    }
    214234
     
    224244    $total = 0;
    225245    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);
    230247    }
    231248
Note: See TracChangeset for help on using the changeset viewer.