• Fatal error: Can’t use function return value in write context in /home/content/18/10534218/html/wp-content/plugins/top-10/admin/admin.php on line 107

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m getting this error too. In PHP < 5.6 (I think), the empty() function only accepts variables and not returns from another function.

    So what you need to do is change line 107 from:

    $tptn_settings[‘exclude_post_ids’] = empty( sanitize_text_field( $_POST[‘exclude_post_ids’] ) ) ? ” : implode( ‘,’, array_map( ‘absint’, explode( ‘,’, sanitize_text_field( wp_unslash( $_POST[‘exclude_post_ids’] ) ) ) ) );

    … to:

    $exclude_post_ids_value = sanitize_text_field( $_POST[‘exclude_post_ids’] );

    $tptn_settings[‘exclude_post_ids’] = empty( $exclude_post_ids_value ) ? ” : implode( ‘,’, array_map( ‘absint’, explode( ‘,’, sanitize_text_field( wp_unslash( $_POST[‘exclude_post_ids’] ) ) ) ) );

    Basically put the result of sanitize_text_field( $_POST[‘exclude_post_ids’] ) into a variable before you put it through empty().

    This might not be an issue on later versions of PHP, but will likely be required for backwards compatibility.

    Plugin Author Ajay

    (@ajay)

    Thanks for the fix. You could potentially directly use this on line 107.

    $tptn_settings['exclude_post_ids'] = empty( $_POST['exclude_post_ids'] ) ? '' : implode( ',', array_map( 'absint', explode( ',', sanitize_text_field( wp_unslash( $_POST['exclude_post_ids'] ) ) ) ) );
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal error’ is closed to new replies.