• Resolved juanshaf

    (@juanshaf)


    Hi again,

    I’m receiving another error in the current release.

    Notice: Undefined variable: new_content in public_html/wp-content/plugins/apply-online/public/class-applyonline-public.php on line 287

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Farhan Noor

    (@farhannoor)

    Hi,
    It seems that some modification were made to this plugin. Remove & reinstall this plugin to get it back to original state.

    Regards

    Thread Starter juanshaf

    (@juanshaf)

    I tried your suggestion and deactivated and deleted the plugin. I reinstalled the plugin via the Plugins->Add New, and the problem continues to exist.

    I should point out that I’m using custom single-aol_ad.php and archive-aol_ad.php templates.

    Changing this:

    
    //Show this content if you are viewing aol_ad post type using single.php (not with single-aold_ad.php)
                if(is_singular() and 'single-aol_ad.php' != wp_basename($template)):
                    $new_content = '<div class="aol-single-ad">'.$content.$title_features.$features.$title_form.$form.'</div>';
                endif;
                return apply_filters( 'aol_content', $content, $features, $form );
    

    To This:

    
    //Show this content if you are viewing aol_ad post type using single.php (not with single-aold_ad.php)
                if(is_singular() and 'single-aol_ad.php' != wp_basename($template)):
                    $new_content = '<div class="aol-single-ad">'.$content.$title_features.$features.$title_form.$form.'</div>';
    				return apply_filters( 'aol_content', $new_content, $content, $features, $form );
                endif;
                return apply_filters( 'aol_content', $content, $features, $form );
    

    At the bottom of class-applyonline-public.php fixed my issue as $new_content is undefined for me due to the wp_basename($template) condition.

    Plugin Author Farhan Noor

    (@farhannoor)

    instead of all this, you should use function echo aol_form(); within wordpress loop on your sing-aol_ad.php. Also look at documenation here https://wpreloaded.com/plugins/apply-online/reference/

    • This reply was modified 7 years, 1 month ago by Farhan Noor.
    Thread Starter juanshaf

    (@juanshaf)

    I am already using echo aol_features() and echo aol_form() in my single-aol_ad.php, that’s not the problem. I already read the documentation ??

    The code I posted previously is an issue with the if statement in your plugin code, not my single-aol_ad.php.

    If you inspect the code at line 287 in apply-online/public/class-applyonline-public.php you’ll see the if statement above this line is where $new_content is defined, only if the template is not single-aol_ad.php.

    Then the apply_filter call outside the if enclosure is attempting to use the variable while the conditions were not met, therefore it is undefined when a single-aol_ad.php template is used.

    All you need to do is replace the code at the bottom of apply-online/public/class-applyonline-public.php with the fix I provided above. If you look at line 287 and the if statement above the line, you’ll see what I mean.

    Thanks.

    Plugin Author Farhan Noor

    (@farhannoor)

    Ok, I got it. The best solution is to initiate $new_content before the if condition i.e. $new_content = NULL;

    Thank you for reporting this bug. I appreciate your effort to reach the solution. It will be fixed in next plugin update.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Undefined variable: new_content’ is closed to new replies.