Plugin Directory

Changeset 3754883


Ignore:
Timestamp:
10/19/2026 01:54:27 PM (5 weeks ago)
Author:
8ight
Message:

1.10.1: with the optional blog layout on, unfilled later blog pages redirect to the first page and AIOSEO prints no next link; no change when off

Location:
seo-content-publisher-for-8ight-ai
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • seo-content-publisher-for-8ight-ai/tags/1.10.1/8ight-ai.php

    r3753409 r3754883  
    44 * Plugin URI: https://8ight.ai/wordpress-plugin/
    55 * Description: Connects your WordPress site to the 8ight.ai platform. Automatically publishes SEO-optimized content directly to your site.
    6  * Version: 1.10.0
     6 * Version: 1.10.1
    77 * Author: 8ight.ai
    88 * Author URI: https://8ight.ai
    … …  
    1313if (!defined('ABSPATH')) exit;
    1414
    15 define('EIGHTAI_VERSION', '1.10.0');
     15define('EIGHTAI_VERSION', '1.10.1');
    1616define('EIGHTAI_PLUGIN_DIR', plugin_dir_path(__FILE__));
    1717define('EIGHTAI_PLUGIN_URL', plugin_dir_url(__FILE__));
  • seo-content-publisher-for-8ight-ai/tags/1.10.1/includes/blog-index.php

    r3753409 r3754883  
    414414
    415415    // The front page of the blog: lead, latest, the press, the archive.
     416    list($lead, $latest, $news, $rest) = eightai_bi_front_split($all, $c);
     417
     418    if ($paged > 1) {
     419        $per = max(1, (int) $c['list']);
     420        $from = $c['archive'] + ($paged - 2) * $per;
     421        $page = array_slice($rest, $from, $per);
     422        if (!$page) return '';   // nothing for this page: the theme's own page stays
     423        $more = count($rest) > $from + $per ? '<p class="mg-more"><a href="' . esc_url(get_pagenum_link($paged + 1)) . '">' . esc_html($L['more']) . '</a></p>' : '';
     424        return $h . eightai_bi_list($page, $L['archive'], $more) . '</div>';
     425    }
     426    if ($lead) $h .= eightai_bi_lead($lead, $s);
     427    $h .= eightai_bi_cards($latest, $L['latest']);
     428    $h .= eightai_bi_news($news, $L['news']);
     429    $arch = array_slice($rest, 0, $c['archive']);
     430    $more = count($rest) > count($arch) ? '<p class="mg-more"><a href="' . esc_url(get_pagenum_link(2)) . '">' . esc_html($L['more']) . '</a></p>' : '';
     431    $h .= eightai_bi_list($arch, $L['archive'], $more);
     432    return $h . '</div>';
     433}
     434
     435/** The front page's parts, in one place so the render, the redirect and the next link agree. */
     436function eightai_bi_front_split($all, $c) {
    416437    $pics = array_values(array_filter($all, function ($it) { return !empty($it['img']) && !$it['news']; }));
    417438    $lead = null;
    … …  
    424445    foreach ($all as $it) { if (count($news) >= $c['news']) break; if ($it['news'] && empty($used[$it['id']])) { $news[] = $it; $used[$it['id']] = true; } }
    425446    $rest = array_values(array_filter($all, function ($it) use ($used) { return empty($used[$it['id']]); }));
    426 
    427     if ($paged > 1) {
    428         $per = max(1, (int) $c['list']);
    429         $from = $c['archive'] + ($paged - 2) * $per;
    430         $page = array_slice($rest, $from, $per);
    431         if (!$page) return '';   // nothing for this page: the theme's own page stays
    432         $more = count($rest) > $from + $per ? '<p class="mg-more"><a href="' . esc_url(get_pagenum_link($paged + 1)) . '">' . esc_html($L['more']) . '</a></p>' : '';
    433         return $h . eightai_bi_list($page, $L['archive'], $more) . '</div>';
    434     }
    435     if ($lead) $h .= eightai_bi_lead($lead, $s);
    436     $h .= eightai_bi_cards($latest, $L['latest']);
    437     $h .= eightai_bi_news($news, $L['news']);
    438     $arch = array_slice($rest, 0, $c['archive']);
    439     $more = count($rest) > count($arch) ? '<p class="mg-more"><a href="' . esc_url(get_pagenum_link(2)) . '">' . esc_html($L['more']) . '</a></p>' : '';
    440     $h .= eightai_bi_list($arch, $L['archive'], $more);
    441     return $h . '</div>';
    442 }
     447    return [$lead, $latest, $news, $rest];
     448}
     449
     450/** How many pages the layout fills for this request: a section or a search is one page. */
     451function eightai_bi_page_count($s) {
     452    static $memo = null;
     453    if ($memo !== null) return $memo;
     454    $c = $s['config'];
     455    if (!empty($_GET['category_name']) || (isset($_GET['s']) && $_GET['s'] !== '')) return $memo = 1;   // phpcs:ignore WordPress.Security.NonceVerification
     456    list(, , , $rest) = eightai_bi_front_split(eightai_bi_posts($s), $c);
     457    $extra = max(0, count($rest) - (int) $c['archive']);
     458    return $memo = 1 + (int) ceil($extra / max(1, (int) $c['list']));
     459}
     460
     461// 1.10.1 (2026-10-19, Nadav; Maya found /blog/page/2/ on nationalhomes.com showing the theme's old
     462// listing, because the layout had nothing for page 2): a page of the posts page that the layout does
     463// not fill is sent to the first page for good (301), with the section or search kept, and the SEO
     464// plugin is told there is no next page. Only while the layout is active for everyone (mode on);
     465// preview never redirects a visitor.
     466add_action('template_redirect', function () {
     467    $s = eightai_bi_for_request();
     468    if (!$s || $s['mode'] !== 'on') return;
     469    $paged = max(1, (int) get_query_var('paged'));
     470    if ($paged < 2 || $paged <= eightai_bi_page_count($s)) return;
     471    $args = [];
     472    if (!empty($_GET['category_name'])) $args['category_name'] = sanitize_title(wp_unslash((string) $_GET['category_name']));   // phpcs:ignore WordPress.Security.NonceVerification
     473    if (isset($_GET['s']) && $_GET['s'] !== '') $args['s'] = sanitize_text_field(wp_unslash((string) $_GET['s']));            // phpcs:ignore WordPress.Security.NonceVerification
     474    wp_safe_redirect(eightai_bi_blog_url($args), 301);
     475    exit;
     476}, 2);
     477
     478function eightai_bi_no_next($link) {
     479    $s = eightai_bi_for_request();
     480    if (!$s || $s['mode'] !== 'on') return $link;
     481    $paged = max(1, (int) get_query_var('paged'));
     482    return $paged >= eightai_bi_page_count($s) ? '' : $link;
     483}
     484add_filter('aioseo_next_link', 'eightai_bi_no_next', 99);
  • seo-content-publisher-for-8ight-ai/tags/1.10.1/readme.txt

    r3753409 r3754883  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.10.0
     7Stable tag: 1.10.1
    88License: GPLv2 or later
    99
    … …  
    2424
    2525== Changelog ==
     26
     27= 1.10.1 =
     28* Fix: with the optional blog layout on, a later page of the blog that the layout does not fill now redirects to the blog's first page (keeping a chosen section or search), and All in One SEO no longer points to a next page that does not exist. Nothing changes on sites where the layout is off.
    2629
    2730= 1.10.0 =
  • seo-content-publisher-for-8ight-ai/trunk/8ight-ai.php

    r3753409 r3754883  
    44 * Plugin URI: https://8ight.ai/wordpress-plugin/
    55 * Description: Connects your WordPress site to the 8ight.ai platform. Automatically publishes SEO-optimized content directly to your site.
    6  * Version: 1.10.0
     6 * Version: 1.10.1
    77 * Author: 8ight.ai
    88 * Author URI: https://8ight.ai
    … …  
    1313if (!defined('ABSPATH')) exit;
    1414
    15 define('EIGHTAI_VERSION', '1.10.0');
     15define('EIGHTAI_VERSION', '1.10.1');
    1616define('EIGHTAI_PLUGIN_DIR', plugin_dir_path(__FILE__));
    1717define('EIGHTAI_PLUGIN_URL', plugin_dir_url(__FILE__));
  • seo-content-publisher-for-8ight-ai/trunk/includes/blog-index.php

    r3753409 r3754883  
    414414
    415415    // The front page of the blog: lead, latest, the press, the archive.
     416    list($lead, $latest, $news, $rest) = eightai_bi_front_split($all, $c);
     417
     418    if ($paged > 1) {
     419        $per = max(1, (int) $c['list']);
     420        $from = $c['archive'] + ($paged - 2) * $per;
     421        $page = array_slice($rest, $from, $per);
     422        if (!$page) return '';   // nothing for this page: the theme's own page stays
     423        $more = count($rest) > $from + $per ? '<p class="mg-more"><a href="' . esc_url(get_pagenum_link($paged + 1)) . '">' . esc_html($L['more']) . '</a></p>' : '';
     424        return $h . eightai_bi_list($page, $L['archive'], $more) . '</div>';
     425    }
     426    if ($lead) $h .= eightai_bi_lead($lead, $s);
     427    $h .= eightai_bi_cards($latest, $L['latest']);
     428    $h .= eightai_bi_news($news, $L['news']);
     429    $arch = array_slice($rest, 0, $c['archive']);
     430    $more = count($rest) > count($arch) ? '<p class="mg-more"><a href="' . esc_url(get_pagenum_link(2)) . '">' . esc_html($L['more']) . '</a></p>' : '';
     431    $h .= eightai_bi_list($arch, $L['archive'], $more);
     432    return $h . '</div>';
     433}
     434
     435/** The front page's parts, in one place so the render, the redirect and the next link agree. */
     436function eightai_bi_front_split($all, $c) {
    416437    $pics = array_values(array_filter($all, function ($it) { return !empty($it['img']) && !$it['news']; }));
    417438    $lead = null;
    … …  
    424445    foreach ($all as $it) { if (count($news) >= $c['news']) break; if ($it['news'] && empty($used[$it['id']])) { $news[] = $it; $used[$it['id']] = true; } }
    425446    $rest = array_values(array_filter($all, function ($it) use ($used) { return empty($used[$it['id']]); }));
    426 
    427     if ($paged > 1) {
    428         $per = max(1, (int) $c['list']);
    429         $from = $c['archive'] + ($paged - 2) * $per;
    430         $page = array_slice($rest, $from, $per);
    431         if (!$page) return '';   // nothing for this page: the theme's own page stays
    432         $more = count($rest) > $from + $per ? '<p class="mg-more"><a href="' . esc_url(get_pagenum_link($paged + 1)) . '">' . esc_html($L['more']) . '</a></p>' : '';
    433         return $h . eightai_bi_list($page, $L['archive'], $more) . '</div>';
    434     }
    435     if ($lead) $h .= eightai_bi_lead($lead, $s);
    436     $h .= eightai_bi_cards($latest, $L['latest']);
    437     $h .= eightai_bi_news($news, $L['news']);
    438     $arch = array_slice($rest, 0, $c['archive']);
    439     $more = count($rest) > count($arch) ? '<p class="mg-more"><a href="' . esc_url(get_pagenum_link(2)) . '">' . esc_html($L['more']) . '</a></p>' : '';
    440     $h .= eightai_bi_list($arch, $L['archive'], $more);
    441     return $h . '</div>';
    442 }
     447    return [$lead, $latest, $news, $rest];
     448}
     449
     450/** How many pages the layout fills for this request: a section or a search is one page. */
     451function eightai_bi_page_count($s) {
     452    static $memo = null;
     453    if ($memo !== null) return $memo;
     454    $c = $s['config'];
     455    if (!empty($_GET['category_name']) || (isset($_GET['s']) && $_GET['s'] !== '')) return $memo = 1;   // phpcs:ignore WordPress.Security.NonceVerification
     456    list(, , , $rest) = eightai_bi_front_split(eightai_bi_posts($s), $c);
     457    $extra = max(0, count($rest) - (int) $c['archive']);
     458    return $memo = 1 + (int) ceil($extra / max(1, (int) $c['list']));
     459}
     460
     461// 1.10.1 (2026-10-19, Nadav; Maya found /blog/page/2/ on nationalhomes.com showing the theme's old
     462// listing, because the layout had nothing for page 2): a page of the posts page that the layout does
     463// not fill is sent to the first page for good (301), with the section or search kept, and the SEO
     464// plugin is told there is no next page. Only while the layout is active for everyone (mode on);
     465// preview never redirects a visitor.
     466add_action('template_redirect', function () {
     467    $s = eightai_bi_for_request();
     468    if (!$s || $s['mode'] !== 'on') return;
     469    $paged = max(1, (int) get_query_var('paged'));
     470    if ($paged < 2 || $paged <= eightai_bi_page_count($s)) return;
     471    $args = [];
     472    if (!empty($_GET['category_name'])) $args['category_name'] = sanitize_title(wp_unslash((string) $_GET['category_name']));   // phpcs:ignore WordPress.Security.NonceVerification
     473    if (isset($_GET['s']) && $_GET['s'] !== '') $args['s'] = sanitize_text_field(wp_unslash((string) $_GET['s']));            // phpcs:ignore WordPress.Security.NonceVerification
     474    wp_safe_redirect(eightai_bi_blog_url($args), 301);
     475    exit;
     476}, 2);
     477
     478function eightai_bi_no_next($link) {
     479    $s = eightai_bi_for_request();
     480    if (!$s || $s['mode'] !== 'on') return $link;
     481    $paged = max(1, (int) get_query_var('paged'));
     482    return $paged >= eightai_bi_page_count($s) ? '' : $link;
     483}
     484add_filter('aioseo_next_link', 'eightai_bi_no_next', 99);
  • seo-content-publisher-for-8ight-ai/trunk/readme.txt

    r3753409 r3754883  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.10.0
     7Stable tag: 1.10.1
    88License: GPLv2 or later
    99
    … …  
    2424
    2525== Changelog ==
     26
     27= 1.10.1 =
     28* Fix: with the optional blog layout on, a later page of the blog that the layout does not fill now redirects to the blog's first page (keeping a chosen section or search), and All in One SEO no longer points to a next page that does not exist. Nothing changes on sites where the layout is off.
    2629
    2730= 1.10.0 =
Note: See TracChangeset for help on using the changeset viewer.