• Hi guys, so I have two errors that gets repeated plenty of times in my php errorlog.

    First error:

    Array to string conversion in woocommerce/zn-woocommerce-init.php on line 96

    Line 96 in zn-woocommerce-init.php:

    $output .= '<img src="'. woocommerce_placeholder_img_src() .'" alt="Placeholder" width="' . $placeholder_width . '" height="' . $placeholder_height . '" />';

    Second error:

    The called constructor method for WP_Widget is deprecated since version 4.3.0! Use

    __construct()

    instead. in wp-includes/functions.php on line 3619

    Line 3585 to 3630 in functions.php:

    /**
     * Marks a constructor as deprecated and informs when it has been used.
     *
     * Similar to _deprecated_function(), but with different strings. Used to
     * remove PHP4 style constructors.
     *
     * The current behavior is to trigger a user error if <code>WP_DEBUG</code> is true.
     *
     * This function is to be used in every PHP4 style constructor method that is deprecated.
     *
     * @since 4.3.0
     * @access private
     *
     * @param string $class   The class containing the deprecated constructor.
     * @param string $version The version of WordPress that deprecated the function.
     */
    function _deprecated_constructor( $class, $version ) {
    
    	/**
    	 * Fires when a deprecated constructor is called.
    	 *
    	 * @since 4.3.0
    	 *
    	 * @param string $class   The class containing the deprecated constructor.
    	 * @param string $version The version of WordPress that deprecated the function.
    	 */
    	do_action( 'deprecated_constructor_run', $class, $version );
    
    	/**
    	 * Filter whether to trigger an error for deprecated functions.
    	 *
    	 * <code>WP_DEBUG</code> must be true in addition to the filter evaluating to true.
    	 *
    	 * @since 4.3.0
    	 *
    	 * @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
    	 */
    	if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) {
    		if ( function_exists( '__' ) ) {
    			trigger_error( sprintf( __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $class, $version, '<pre>__construct()</pre>' ) );
    		} else {
    			trigger_error( sprintf( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $class, $version, '<pre>__construct()</pre>' ) );
    		}
    	}
    
    }

    Anyone able to spot what I shall edit in these lines?
    I thank you in advance and hopefully these errors will be easy to squash 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • Is WordPress up to date? Your theme? Your plugins?

    Anyone able to spot what I shall edit in these lines?

    You should never edit theme, plugin, or WP core files.

    Thread Starter komani

    (@komani)

    WP & Plugins up to date, theme is not.
    Dont know what is causing it.

    Try updating your theme and seeing if the issue resolves itself.

    Thread Starter komani

    (@komani)

    I updated the theme a long time ago but reverted it because it changed the interface of the website too much.
    So I am looking to fix these issues in some other way, manually.

    Anytime you get a message that something is deprecated, it’s usually because you have a theme or plugin that is out of date. Editing something is WordPress core is not the way to fix it, and is likely to cause even more problems down the road.

    You can always create a child theme to maintain the integrity of your website’s appearance. That way, you can update the theme without losing your appearance and you don’t run into issues like this.

    Thread Starter komani

    (@komani)

    Okay, that a great idea… If I knew how to do it lol.
    So, I have the latest version of the theme downlaoded, I named it themename-child and I shall place it in the same folder as the current theme my site is using; wp-content/themes. So far, so good?

    Next up, I go in Appearance -> Themes -> Activate Child theme -> Done?
    Haven’t done this yet, so would this be a correct way to go about it or am I missing something

    No, not quite.

    The Codex page about child themes is here:

    https://codex.ww.wp.xz.cn/Child_Themes

    But if you have edited theme files already, you should read this tutorial I wrote about wrangling a child theme out of your original theme modifications:

    http://techblog.kjodle.net/2014/04/12/wordpress-child-themes-the-whys-and-hows/

    Even if you didn’t modify theme files, and are just using an older version, you can use the same approach.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Fixing 2 PHP errors’ is closed to new replies.