Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter badscooter1980

    (@badscooter1980)

    I have this in my functions.php

    // Network dropdown functions
    add_filter(‘asl_results’, ‘asl_full_content_in_results’, 10, 4);
    function asl_full_content_in_results($results, $id, $is_ajax, $args) {
    foreach ($results as $k=>&$r) {
    $r->flag = apply_filters(‘the_title’, get_post_field(‘network_countries’, $r->id));
    $r->website = apply_filters(‘the_title’, get_post_field(‘network_website’, $r->id));
    }
    return $results;
    }

    Removing it makes it work, but I need this function to add some ACF data to the search results. What, in the above, isn’t working in PHP 7.1+?

    Plugin Author wpdreams

    (@wpdreams)

    Hi,

    This does not seem like a PHP related issue to me. I think the “apply_filters” might be the problem.

    This:

    get_post_field('network_countries', $r->id)

    ..might be returning a non-string value(?), and the “the_title” hook might be . I guess there the execution stops with an 500 error.

    Also, the “the_title” filters requires 2 parameters, whereas you only using one, that might be an issue as well.

    Best,
    Ernest M.

    Thread Starter badscooter1980

    (@badscooter1980)

    Hi,

    Sorry, I’m still unable to make this compatible.

    I followed your instructions layed out in this post https://www.ads-software.com/support/topic/show-entire-content/ which is what my code is based on.

    Thread Starter badscooter1980

    (@badscooter1980)

    To add, the code I am using below works perfectly in PHP 7, so what is stopping it in 7.1?

    // Network dropdown functions
    add_filter('asl_results', 'asl_full_content_in_results', 10, 4);
    function asl_full_content_in_results($results, $id, $is_ajax, $args) {  
      foreach ($results as $k=>&$r) {
        $r->flag = apply_filters('the_title', get_field('network_countries', $r->id));
        $r->website = apply_filters('the_title', get_field('network_website', $r->id));
      }
      return $results;
    }

    And this, inside the result.php template;

    <div class='asl_content'>
    
          <h3><div class="network-meta"><span class="flag-icon flag-icon-<?php echo $r->flag; ?>"></span> <a href="<?php echo $r->content; ?>" target="_blank"><?php echo $r->title; ?> <i class="fas fa-link"></i></a></div> <div class="network-check"><i class="fas fa-check"></i></div></h3>
    
        </div>

    Screenshot of live site here; https://ibb.co/D1T6YXD

    Thread Starter badscooter1980

    (@badscooter1980)

    Update: March 21 2020

    So, it seems the code was incorrect at this part;

    function asl_full_content_in_results($results, $id, $is_ajax, $args) {

    I simply removed several parameters, so it looks like this;

    function asl_full_content_in_results($results) {

    And BINGO! It works on PHP 7.3

    For reference, the entire snippet inside my functions.php file is;

    add_filter('asl_results', 'asl_full_content_in_results', 1, 1);
    function asl_full_content_in_results($results) {  
      foreach ($results as $k=>&$r) {
        $r->flag = apply_filters('the_title', get_field('network_countries', $r->id));
        $r->website = apply_filters('the_title', get_field('network_website', $r->id));
      }
      return $results;
    }

    With my edits to the result.php template remaining unchanged at;

    <div class='asl_content'>
    
          <h3><div class="network-meta"><span class="flag-icon flag-icon-<?php echo $r->flag; ?>"></span> <a href="<?php echo $r->website; ?>" target="_blank"><?php echo $r->title; ?> <i class="fas fa-link"></i></a></div> <div class="network-check"><i class="fas fa-check"></i></div></h3>
    
        </div>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Not Compatible with PHP 7.1+’ is closed to new replies.