I’m probably doing something wrong, I’m getting the following error:
Your PHP code changes were rolled back due to an error on line 35 of file wp-content/themes/maxstore-child/functions.php. Please fix and try saving again.
syntax error, unexpected ‘function’ (T_FUNCTION)
Have I added it in the right place? The file is :
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
function chld_thm_cfg_locale_css( $uri ){
if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
$uri = get_template_directory_uri() . '/rtl.css';
return $uri;
}
endif;
add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
function chld_thm_cfg_parent_css() {
wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array( 'bootstrap' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 );
if ( !function_exists( 'child_theme_configurator_css' ) ):
function child_theme_configurator_css() {
wp_enqueue_style( 'chld_thm_cfg_separate', trailingslashit( get_stylesheet_directory_uri() ) . 'ctc-style.css', array( 'chld_thm_cfg_parent','maxstore-stylesheet','font-awesome' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'child_theme_configurator_css', 20 );
// END ENQUEUE PARENT ACTION
add_shortcode( 'yikes_display_product_categories', 'yikes_display_product_categories' );
function yikes_display_product_categories() {
global $product;
if ( ! is_object( $product ) || empty( $product ) ) {
return;
}
$product_id = $product->get_id();
$product_terms = get_the_terms( $product_id, 'product_cat' );
if ( empty( $product_terms ) ) {
return;
}
$shortcode_html = '';
$shortcode_html .= '<ul class="yikes-product-cats-shortcode">';
foreach ( $product_terms as $term ) {
// Filter out Toshiba and child cats.
if ( ! empty( $term->parent ) || $term->name === 'Toshiba' ) {
continue;
}
$shortcode_html .= "<li>{$term->name}</li>";
}
$shortcode_html .= '</ul>';
return $shortcode_html;
}