Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter asherchayyim

    (@asherchayyim)

    in the newest version of the plugin, 1.6.4, the same issue persists, and the same solution can be applied, only that now, the starting line where you replace code is approx 357, and the ending line is approx 377.

    More exactly, starting from this lines, inclusive:

    $s=0;
    while ($news_mod_map[$s]==0 && $s < count($news_mod_map)) { $s++; }

    and until this lines, inclusive:

    $news_mod2[$s] = str_replace('%the_content_' . $n . '%', $content, $news_mod2[$s]);
    $subject = str_replace('%the_title_1%', $title, $subject);

    you need to delete all that and replace it with the code I’ve provided in the previous post above.

    Good luck, write me in case you need any assistance with this bug, as I’ve managed to solve it.

    Thread Starter asherchayyim

    (@asherchayyim)

    It turns out the plugin was using only the first keyword found on the page, so if I had “the_title_1” first on the page, the plugin would ignore any following keywords, for example “the_content_1” or any other.

    But if, instead, the “content” keyword was first on the page, and let’s say, for example’s sake, the “title” keyword – after, it would ignore replacing the title keyword.

    Because the author of the plugin didn’t show any interest in solving this bug, I had to debug the PHP code and solve it myself.

    What I’ve changed was that while the old code was replacing only the first keyword on the page, the new code I’ve wrote is a “for” loop cycle that searches for every keyword on the page.

    If anybody else has the same issue, you need to edit the following file:

    /public_html/wp-content/plugins/knews/includes/automated_jobs.php

    and approx from line 385 – until you reach a line like this

    knews_debug(‘- included: ‘ . $pp->post_title . “\r\n”)

    you need to replace all that existing code with this below:

    $anyfound = false;
    
    for ($s=0; $s < count($news_mod_map); $s++) {
        if ($news_mod_map[$s]==0) { continue; }
    
        $n=1;
        $found=false;
        while (!$found && $n<10) {
            if (strpos($news_mod2[$s], '%the_title_' . $n . '%') !== false || strpos($news_mod2[$s], '%the_excerpt_' . $n . '%') !== false || strpos($news_mod2[$s], '%the_permalink_' . $n . '%') !== false || strpos($news_mod2[$s], '%the_content_' . $n . '%') !== false) {
                $found=true;
                $anyfound = true;
            } else {
                $n++;
            }
        }
    
        if ($found) {
            $news_mod_map[$s]--;
            $news_mod2[$s] = str_replace('%the_permalink_' . $n . '%', $permalink, $news_mod2[$s]);
            $news_mod2[$s] = str_replace('%the_title_' . $n . '%', $title, $news_mod2[$s]);
            $news_mod2[$s] = str_replace('%the_excerpt_' . $n . '%', $excerpt, $news_mod2[$s]);
            $news_mod2[$s] = str_replace('%the_content_' . $n . '%', $content, $news_mod2[$s]);
        }
    }
    
    if ($anyfound) {
        $subject = str_replace('%the_title_1%', $title, $subject);
    
        // replace until here, below is existing code whch you should leave as is
    
        knews_debug('- included: ' . $pp->post_title . "\r\n");
Viewing 2 replies - 1 through 2 (of 2 total)