• Resolved cantoostinato8989

    (@cantoostinato8989)


    Hello, file PHP_errors.log shows some problems with plugin sp-news-and-widget after we moved to PHP7. There are 3 errors in 3 lines of file widget_function.php:

    Here they are:

    [02-Dec-2020 17:50:16 UTC] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /home/--/--/--/public_html/wp-content/plugins/sp-news-and-widget/widget_function.php on line 213
    [02-Dec-2020 17:50:16 UTC] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /home/--/--/--/public_html/wp-content/plugins/sp-news-and-widget/widget_function.php on line 214
    [02-Dec-2020 17:50:16 UTC] PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /home/--/--/--/public_html/wp-content/plugins/sp-news-and-widget/widget_function.php on line 215

    How to edit these lines 213,214,215 in widget_function.php in order to get well with PHP7?

    if ( isset( $instance['height'] ) && ( 0 < count( $instance['height'] ) ) ) { $args['height'] = intval( $instance['height'] ); }
    		if ( isset( $instance['pause'] ) && ( 0 < count( $instance['pause'] ) ) ) { $args['pause'] = intval( $instance['pause'] ); }
    		if ( isset( $instance['speed'] ) && ( 0 < count( $instance['speed'] ) ) ) { $args['speed'] = intval( $instance['speed'] ); }

    May be to use empty() instead of count(), but how?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    Thanks for reaching here.

    We have check this plugin on our local server and we have not found an error.

    Please send your website URL We will check for and proper solution.

    Thanks,

    Thread Starter cantoostinato8989

    (@cantoostinato8989)

    Hello, actually this is not error, this is warning

    Thread Starter cantoostinato8989

    (@cantoostinato8989)

    Pl, look how it was resolved in file kses.php

    Before:
    if ( ! isset($allowed_html[strtolower($element)]) || count($allowed_html[strtolower($element)]) == 0 )
    After:
    if ( ! isset($allowed_html[strtolower($element)]) || empty($allowed_html[strtolower($element)]))

    But in your case 0 < count I don’t know how to correct…

    Hello,

    Thanks for the quick response.

    Ok, we will check and inform.

    Thanks,

    • This reply was modified 4 years, 6 months ago by Ketan Patel.
    Thread Starter cantoostinato8989

    (@cantoostinato8989)

    Thank you very much

    Thread Starter cantoostinato8989

    (@cantoostinato8989)

    May be like this?

    if ( isset( $instance['height'] ) &&  ! empty( $instance['height'] ) )  { $args['height'] = intval( $instance['height'] ); }
    if ( isset( $instance['pause'] ) &&  ! empty( $instance['pause'] ) ) { $args['pause'] = intval( $instance['pause'] ); }
    if ( isset( $instance['speed'] ) &&  ! empty( $instance['speed'] ) )  { $args['speed'] = intval( $instance['speed'] ); }
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP7 and plugin WP News and Scrolling Widgets’ is closed to new replies.