• In shopping-feed/src/Product there is a mistake in the code which makes the editing of products impossible when Yoast SEO is enabled

    
    	private function set_category() {
    
    		$return = '';
    		$term   = ShoppingFeedHelper::wc_category_taxonomy();
    
    		if ( class_exists( 'WPSEO_Primary_Term' ) ) {
    			// Show Primary category by Yoast if it is enabled & set
    			$wpseo_primary_term = new WPSEO_Primary_Term( $term, $this->id );
    

    The problem is that this file is namespaced and the WPSEO_Primary_Term is not thus it’s looking for it in the local namespace (and not the global one) and obviously it doesn’t find it

    PHP Fatal error: Uncaught Error: Class 'ShoppingFeed\\ShoppingFeedWC\\Products\\WPSEO_Primary_Term' not found in ...

    It needs a slash in front:

    
    	private function set_category() {
    
    		$return = '';
    		$term   = ShoppingFeedHelper::wc_category_taxonomy();
    
    		if ( class_exists( '\WPSEO_Primary_Term' ) ) {
    			// Show Primary category by Yoast if it is enabled & set
    			$wpseo_primary_term = new \WPSEO_Primary_Term( $term, $this->id );
    

    Or a use \WPSEO_Primary_Term; at the top of the file

  • The topic ‘PHP Error’ is closed to new replies.