get_the_author_meta is not working in wordpress - php

here is the code
<?php
/**
* Display detail author of current post
* Use in single post
*
* #since 1.0
*/
?>
<div class="post-author">
<div class="author-img">
<?php if( function_exists('get_simple_local_avatar') ){
if( get_simple_local_avatar( get_the_author_meta( 'ID' ) ) ){
echo get_simple_local_avatar( get_the_author_meta( 'ID' ), '100' );
} else {
echo get_avatar( get_the_author_meta( 'email' ), '100' );
}
} else {
echo get_avatar( get_the_author_meta( 'email' ), '100' );
}
?>
</div>
<div class="author-content">
<h5><?php the_author_posts_link(); ?></h5>
<p><?php the_author_meta( 'description' ); ?></p
<br>
<?php
$bool=0;
if ( get_the_author_meta( 'user_url' ) )
{
$bool = 1;
}
if ( get_the_author_meta( 'facebook' ) )
{
$bool = 1;
}
if ( get_the_author_meta( 'twitter' ) )
{
$bool = 1;
}
if ( get_the_author_meta( 'instagram' ) )
{
$bool = 1;
}
if ( get_the_author_meta( 'pinterest' ) )
{
$bool = 1;
}
if ( get_the_author_meta( 'tumblr' ) )
{
$bool = 1;
}
if ( get_the_author_meta( 'email' ) && get_theme_mod( 'penci_post_author_email' ) )
{
$bool = 1;
}
if($bool==1){
if (get_locale()=='ar') { ?>
<h5 class="connect_with_ar">تواصل مع <?php the_author_posts_link(); ?></h5>
<br>
<?php } else {?>
<h5 class="connect_with">Connect With <?php the_author_posts_link(); ?></h5>
<br>
<?php } } ?>
<?php if ( get_the_author_meta( 'user_url' ) ) : ?>
<a target="_blank" class="author-social" href="<?php the_author_meta( 'user_url'); ?>"><?php penci_fawesome_icon('fas fa-globe'); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta( 'facebook' ) ) : ?>
<a target="_blank" class="author-social" href="http://facebook.com/<?php echo esc_attr( the_author_meta( 'facebook' ) ); ?>"><?php penci_fawesome_icon('fab fa-facebook-f'); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta( 'twitter' ) ) : ?>
<a target="_blank" class="author-social" href="http://twitter.com/<?php echo esc_attr( the_author_meta( 'twitter' ) ); ?>"><?php penci_fawesome_icon('fab fa-twitter'); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta( 'instagram' ) ) : ?>
<a target="_blank" class="author-social" href="http://instagram.com/<?php echo esc_attr( the_author_meta( 'instagram' ) ); ?>"><?php penci_fawesome_icon('fab fa-instagram'); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta( 'pinterest' ) ) : ?>
<a target="_blank" class="author-social" href="http://pinterest.com/<?php echo esc_attr( the_author_meta( 'pinterest' ) ); ?>"><?php penci_fawesome_icon('fab fa-pinterest'); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta( 'tumblr' ) ) : ?>
<a target="_blank" class="author-social" href="http://<?php echo esc_attr( the_author_meta( 'tumblr' ) ); ?>.tumblr.com/"><?php penci_fawesome_icon('fab fa-tumblr'); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta( 'email' ) && get_theme_mod( 'penci_post_author_email' ) ) : ?>
<a class="author-social" href="mailto:<?php echo esc_attr( the_author_meta( 'email' ) ); ?>"><?php penci_fawesome_icon('fas fa-envelope'); ?></a>
<?php endif; ?>
</div>
</div>
this code working for old users
but it does not work with new users
EDIT
all the plugins that I am using in the website are
EDIT 2

if(isset($_GET['author_name'])){
$curauth = get_user_by('slug', $author_name);
}
else{
$curauth = get_userdata(intval($author));
}
Put this code in author.php. Then change the relevant places.
For example.
printf( wp_kses ( __( '<h1 class="page-title">%s</h1>', 'soledad' ), penci_allow_html() ), get_the_author() );
This line 61. Soledad theme -> author.php
You can put
$ curauth-> first_name instead of "get_the_author ()"
$curauth->user_email;
$curauth->first_name;
$curauth->last_name;
This way you can get all the user's variables.

Related

change the category from article when the date is expire with wordpress

i have a problem the category does not change
I want to change the category from open to interviewing of an article when the date is expired.
I have added a custom field on my posts called closing_date, when the current date passes the closing date the category changes
this is my code
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
global $post;
$args = array(
'post_type' => 'openings',
'posts_per_page' => 40,
'meta_key' => 'closing_date',
'orderby' => 'closing_date',
'order' => "DESC",
'tax_query' => array(
'taxonomy' => 'openings_status',
'field' => 'slug',
'terms' => array('open, interviewing, filled'),
),
);
$groupedPosts = get_posts( $args );
foreach($groupedPosts as $post) : setup_postdata($post);
$closing_date = get_field('closing_date');
$Status = get_the_terms($post->ID, 'openings_status' );
//get current date
//convert expire into a date obj
$closing_date = new DateTime($closing_date);
//get current date
$today = new DateTime();
//convert dates to seconds for easier comparison
$closing_date_secs = $closing_date->format('U');
$today_secs = $today->format('U');
if ($closing_date_secs < $today_secs ) :
$Status = 'Interviewing';
//featured set to false
//update_post_meta($post->ID, 'Interviewing', $Status );
// set back to empty
update_post_meta($post->ID, 'closing_date', '' );
?>
<li data-filter="<?php $term = get_the_terms( $post->ID, 'openings_status' ); if ( !empty( $term ) ) { foreach ($term as $t) { echo $t->slug; } } ?>" class="grid-item">
<figure>
<?php if ( has_post_thumbnail() ) : ?><a class="img" href="<?php the_permalink(); ?>"><?php the_post_thumbnail('cp_thumb', array()); ?></a><?php endif; ?>
<figcaption>
<h5 title="<?php the_title(); ?>"><?php the_title(); ?></h5>
<?php if( get_post_meta($post->ID, 'company_name', true) ) { ?><h6><?php if( get_post_meta($post->ID, 'openings_url', true) ) { ?><a target="_blank" href="<?php the_field('openings_url'); ?>"><?php } ?><?php the_field('company_name'); ?><?php if( get_post_meta($post->ID, 'openings_url', true) ) { ?></a><?php } ?></h6><?php } ?>
<?php the_excerpt(); ?>
<p class="more">Learn More</p>
</figcaption>
<ul>
<?php $term = get_the_terms( $post->ID, 'openings_status' );
if ( !empty( $term ) ) { ?>
<li class="status">
<?php foreach ($term as $t) { ?>
<span class="<?php echo $t->slug; ?>"><?php echo $t->name; ?></span>
<?php } ?>
</li>
<?php } ?>
<?php if( get_post_meta($post->ID, 'location', true) ) { ?><li class="location"><?php the_field('location'); ?></li><?php } ?>
<li class="share pdf">
<?php echo do_shortcode('[addtoany]') ?>
</li>
<!-- <?php // if( get_post_meta($post->ID, 'openings_pdf', true) ) { ?> -->
<li class="download-2">
<?php echo do_shortcode('[WORDPRESS_PDF]'); ?>
<p>Download as a PDF
<?php if( function_exists( 'mpdf_pdfbutton' ) ) {
mpdf_pdfbutton( false, 'my link', 'my login text' );
} ?>
</p>
</li>
</ul>
</figure>
</li>
<?php endif;
endforeach;?>

Display latest orders on WooCommerce "My account" Dashboard

I'm trying to show customer last 3 orders on WooCommerce dashboard. But get_template() does not work at all and shows nothing.
I also tried to put orders.php form table in to the dashboard.php template file but It displays no orders here, while already I have some active orders. I'm so confused and have no idea about this problem.
This is my dashboard code:
<?php get_header();?>
<?php
* #see https://docs.woocommerce.com/document/template-structure/
* #package WooCommerce\Templates
* #version 4.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
$allowed_html = array(
'a' => array(
'href' => array(),
),
);
?>
<p>
<!-- <?php
printf(
/* translators: 1: user display name 2: logout url */
wp_kses( __( 'Hello %1$s (not %1$s? Log out)', 'woocommerce' ), $allowed_html ),
'<strong>' . esc_html( $current_user->display_name ) . '</strong>',
esc_url( wc_logout_url() )
);
?> -->
</p>
<p>
<?php
/* translators: 1: Orders URL 2: Address URL 3: Account URL. */
// $dashboard_desc = __( 'From your account dashboard you can view your recent orders, manage your billing address, and edit your password and account details.', 'woocommerce' );
// if ( wc_shipping_enabled() ) {
// /* translators: 1: Orders URL 2: Addresses URL 3: Account URL. */
// $dashboard_desc = __( 'From your account dashboard you can view your recent orders, manage your shipping and billing addresses, and edit your password and account details.', 'woocommerce' );
// }
// printf(
// wp_kses( $dashboard_desc, $allowed_html ),
// esc_url( wc_get_endpoint_url( 'orders' ) ),
// esc_url( wc_get_endpoint_url( 'edit-address' ) ),
// esc_url( wc_get_endpoint_url( 'edit-account' ) )
// );
?>
</p>
<?php
/**
* My Account dashboard.
*
* #since 2.6.0
*/?>
<?php do_action( 'woocommerce_account_dashboard' );?>
<div class="row">
<div class="col-10 d-flex dashboard-custom">
<h4>Addresses</h4>
<div class="questionMark">
?
</div>
</div>
<div class="col-2 text-center pt-5 mt-2">
<a href="#" class="viwAdress">
See
</a>
</div>
</div>
<div class="row pt-5">
<div class="adress-dashboard">
<div class="col-12 pt-4 d-flex">
<?php
$fname = get_user_meta( $current_user->ID, 'first_name', true );
$lname = get_user_meta( $current_user->ID, 'last_name', true );
$address_1 = get_user_meta( $current_user->ID, 'billing_address_1', true );
$address_2 = get_user_meta( $current_user->ID, 'billing_address_2', true );
$phonenumber = get_user_meta( $current_user->ID, 'billing_mobile_phone', true );
$city = get_user_meta( $current_user->ID, 'billing_city', true );
$postcode = get_user_meta( $current_user->ID, 'billing_postcode', true );
// echo $fname . "<BR>";
// echo $lname . "<BR>";
// echo $address_1 . "<BR>";
// echo $address_2 . "<BR>";
// echo $city . "<BR>";
// echo $postcode . "<BR>";
?>
<svg id="a47b7a8a-e7bb-4135-b65b-2487268cdcff" width="14" height="17" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 17"><defs><style>.b21eb9b6-977e-44fb-a0e8-fad7fb47a827{fill:#909298;fill-rule:evenodd;}</style></defs><path class="b21eb9b6-977e-44fb-a0e8-fad7fb47a827" d="M10.32,7.26A3.11,3.11,0,1,1,7.21,4.13,3.12,3.12,0,0,1,10.32,7.26Zm-1.55,0A1.56,1.56,0,1,1,7.21,5.7,1.56,1.56,0,0,1,8.77,7.26Z" transform="translate(0 -0.01)"/><path class="b21eb9b6-977e-44fb-a0e8-fad7fb47a827" d="M2.17,12.15a7.07,7.07,0,0,1-.24-10A7,7,0,0,1,11.83,2a7.07,7.07,0,0,1,.24,10L7.24,17Zm8.77-1.32-3.75,4L3.25,11a5.5,5.5,0,0,1-.19-7.75,5.42,5.42,0,0,1,7.69-.19A5.5,5.5,0,0,1,10.94,10.83Z" transform="translate(0 -0.01)"/>
</svg>
<h5><?php echo $address_1; ?></h5>
</div>
<div class="col-12 d-flex pt-4">
<svg id="bd6f5e62-b10a-4e71-b77c-d5f9368c28e6" width="14" height="17" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11 18"><defs><style>.a30aed3e-ff50-49ef-a803-e1cfe573925c,.fa1d0d58-d038-41f3-bd11-17bb673b76c2{fill:#909298;}.a30aed3e-ff50-49ef-a803-e1cfe573925c{fill-rule:evenodd;}</style></defs><path class="a30aed3e-ff50-49ef-a803-e1cfe573925c" d="M9.17,4A3.84,3.84,0,0,1,5.5,8,3.84,3.84,0,0,1,1.83,4,3.84,3.84,0,0,1,5.5,0,3.84,3.84,0,0,1,9.17,4ZM7.33,4A1.92,1.92,0,0,1,5.5,6,1.92,1.92,0,0,1,3.67,4,1.92,1.92,0,0,1,5.5,2,1.92,1.92,0,0,1,7.33,4Z"/><path class="fa1d0d58-d038-41f3-bd11-17bb673b76c2" d="M9.17,12a1,1,0,0,0-.92-1H2.75a1,1,0,0,0-.92,1v6H0V12A2.88,2.88,0,0,1,2.75,9h5.5A2.88,2.88,0,0,1,11,12v6H9.17Z"/>
</svg>
<h5>Customer :<?php echo $fname ; ?> </h5>
</div>
<div class="col-12 d-flex pt-4">
<h5>Phone :<?php echo $phonenumber; ?> </h5>
</div>
<div class="col-12 d-flex pt-4">
<h5>ZipCode:<?php echo $postcode ; ?> </h5>
</div>
</div>
<!-- adres box -->
</div>
<?php
/**
* Deprecated woocommerce_before_my_account action.
*
* #deprecated 2.6.0
*/
do_action( 'woocommerce_before_my_account' );
/**
* Deprecated woocommerce_after_my_account action.
*
* #deprecated 2.6.0
*/
do_action( 'woocommerce_after_my_account' );
/* Omit closing PHP tag at the end of PHP files to avoid "headers already sent" issues. */?>
</section>
And this is my Order template code that work on Orders Tab but don't work on dashboard Tab:
<?php
/**
* My Orders - Deprecated
*
* #deprecated 2.6.0 this template file is no longer used. My Account shortcode uses orders.php.
* #package WooCommerce\Templates
*/
defined('ABSPATH') || exit;
$my_orders_columns = apply_filters(
'woocommerce_my_account_my_orders_columns',
array(
'order-number' => esc_html__('Order', 'woocommerce'),
'order-date' => esc_html__('Date', 'woocommerce'),
'order-status' => esc_html__('Status', 'woocommerce'),
'order-total' => esc_html__('Total', 'woocommerce'),
'order-actions' => ' ',
)
);
$customer_orders = get_posts(
apply_filters(
'woocommerce_my_account_my_orders_query',
array(
'numberposts' => $order_count,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types('view-orders'),
'post_status' => array_keys(wc_get_order_statuses()),
)
)
); ?>
<?php if ($customer_orders) : ?>
<h2><?php echo apply_filters('woocommerce_my_account_my_orders_title', esc_html__('Recent orders', 'woocommerce')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></h2>
<table class="shop_table shop_table_responsive my_account_orders">
<thead>
<tr>
<?php foreach ($my_orders_columns as $column_id => $column_name) : ?>
<th class="<?php echo esc_attr($column_id); ?>"><span
class="nobr"><?php echo esc_html($column_name); ?></span></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php
foreach ($customer_orders as $customer_order) :
$order = wc_get_order($customer_order); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$item_count = $order->get_item_count();
?>
<tr class="order">
<?php foreach ($my_orders_columns as $column_id => $column_name) : ?>
<td class="<?php echo esc_attr($column_id); ?>" data-title="<?php echo esc_attr($column_name); ?>">
<?php if (has_action('woocommerce_my_account_my_orders_column_' . $column_id)) : ?>
<?php do_action('woocommerce_my_account_my_orders_column_' . $column_id, $order); ?>
<?php elseif ('order-number' === $column_id) : ?>
<a href="<?php echo esc_url($order->get_view_order_url()); ?>">
<?php echo _x('#', 'hash before order number', 'woocommerce') . $order->get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</a>
<?php elseif ('order-date' === $column_id) : ?>
<time datetime="<?php echo esc_attr($order->get_date_created()->date('c')); ?>"><?php echo esc_html(wc_format_datetime($order->get_date_created())); ?></time>
<?php elseif ('order-status' === $column_id) : ?>
<?php echo esc_html(wc_get_order_status_name($order->get_status())); ?>
<?php elseif ('order-total' === $column_id) : ?>
<?php
/* translators: 1: formatted order total 2: total order items */
printf(_n('%1$s for %2$s item', '%1$s for %2$s items', $item_count, 'woocommerce'), $order->get_formatted_order_total(), $item_count); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
<?php elseif ('order-actions' === $column_id) : ?>
<?php
$actions = wc_get_account_orders_actions($order);
if (!empty($actions)) {
foreach ($actions as $key => $action) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
echo '' . esc_html($action['name']) . '';
}
}
?>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php
wc_get_template( 'myaccount/orders.php' );
?>
No need to overwrite template files, you can use the woocommerce_account_dashboard hook
Most of the code was copied from myaccount/orders.php template file,
here and there, however, there is an adjustment so that directly copying the template file is not a (complete) solution.
So you get:
function action_woocommerce_account_dashboard() {
// Set limit
$limit = 3;
// Get customer $limit last orders
$customer_orders = wc_get_orders( array(
'customer' => get_current_user_id(),
'limit' => $limit
) );
// Count customers orders
$count = count( $customer_orders );
// Greater than or equal to
if ( $count >= 1 ) {
// Message
echo '<p>' . sprintf( _n( 'Your last order', 'Your last %s orders', $count, 'woocommerce' ), $count ) . '</p>';
?>
<table class="woocommerce-orders-table woocommerce-MyAccount-orders shop_table shop_table_responsive my_account_orders account-orders-table">
<thead>
<tr>
<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>
<th class="woocommerce-orders-table__header woocommerce-orders-table__header-<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php
foreach ( $customer_orders as $customer_order ) {
$order = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$item_count = $order->get_item_count() - $order->get_item_count_refunded();
?>
<tr class="woocommerce-orders-table__row woocommerce-orders-table__row--status-<?php echo esc_attr( $order->get_status() ); ?> order">
<?php foreach ( wc_get_account_orders_columns() as $column_id => $column_name ) : ?>
<td class="woocommerce-orders-table__cell woocommerce-orders-table__cell-<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>">
<?php if ( has_action( 'woocommerce_my_account_my_orders_column_' . $column_id ) ) : ?>
<?php do_action( 'woocommerce_my_account_my_orders_column_' . $column_id, $order ); ?>
<?php elseif ( 'order-number' === $column_id ) : ?>
<a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
<?php echo esc_html( _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number() ); ?>
</a>
<?php elseif ( 'order-date' === $column_id ) : ?>
<time datetime="<?php echo esc_attr( $order->get_date_created()->date( 'c' ) ); ?>"><?php echo esc_html( wc_format_datetime( $order->get_date_created() ) ); ?></time>
<?php elseif ( 'order-status' === $column_id ) : ?>
<?php echo esc_html( wc_get_order_status_name( $order->get_status() ) ); ?>
<?php elseif ( 'order-total' === $column_id ) : ?>
<?php
/* translators: 1: formatted order total 2: total order items */
echo wp_kses_post( sprintf( _n( '%1$s for %2$s item', '%1$s for %2$s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ) );
?>
<?php elseif ( 'order-actions' === $column_id ) : ?>
<?php
$actions = wc_get_account_orders_actions( $order );
if ( ! empty( $actions ) ) {
foreach ( $actions as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
echo '' . esc_html( $action['name'] ) . '';
}
}
?>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
} else {
?>
<div class="woocommerce-message woocommerce-message--info woocommerce-Message woocommerce-Message--info woocommerce-info">
<a class="woocommerce-Button button" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"><?php esc_html_e( 'Browse products', 'woocommerce' ); ?></a>
<?php esc_html_e( 'No order has been made yet.', 'woocommerce' ); ?>
</div>
<?php
}
}
add_action( 'woocommerce_account_dashboard', 'action_woocommerce_account_dashboard' );
Code goes in functions.php file of the active child theme (or active theme).

YITH WooCommerce Wishlist: Help me show the first item / product thumbnail within the sidebar widget and wishlist manage areas?

I am using YITH Wishlist within WooCommerce, WordPress.
Within an individual wishlist - it displays the image, with 'remove from list', the product title and a link through to the individual product all working.
So going one step higher up the 'folders' when I display the individual wishlists within the Manage Wishlists page, I am only able to show the name of the list and the link through to that individual list where you can see all the products grouped. This is where I wish to be able to display the 'first product within that individual wishlist' 's first image or thumbnail.
I have tried and broken the script numerous times. How can I write a script that will grab that image and let me display it within the Manage Wishlist's page? Better yet, is there a shortcode that does this for me (if there is such a thing)?
Here is the pretty much stock relevant template files...
This is the manage page template (if you Ctrl+F for 'I WANT TO SHOW IMAGE HERE' to see where I want to pull image through) - where I want to display image:
<?php
/**
* Wishlist manage template
*
* #author Your Inspiration Themes
* #package YITH WooCommerce Wishlist
* #version 2.0.5
*/
if ( ! defined( 'YITH_WCWL' ) ) {
exit;
} // Exit if accessed directly
?>
<form id="yith-wcwl-form" action="<?php echo esc_url( YITH_WCWL()->get_wishlist_url( 'manage' ) ) ?>" method="post">
<!-- TITLE -->
<?php
do_action( 'yith_wcwl_before_wishlist_title' );
if( ! empty( $page_title ) ) {
echo apply_filters( 'yith_wcwl_wishlist_title', '<h2 class="h1 blue lh2 mt2 mb0 p0">Manage My Boards</h2>' );
}
do_action( 'yith_wcwl_before_wishlist_manage' );
?>
<table class="shop_table cart wishlist_table wishlist_manage_table" cellspacing="0" >
<thead>
<tr>
<th class="wishlist-name">
<span class="nobr">
Boards
<?php // echo apply_filters( 'yith_wcwl_wishlist_manage_name_heading', __( 'Wishlists', 'yith-woocommerce-wishlist' ) ) ?>
</span>
</th>
<?php /* ?>
<th class="wishlist-privacy">
<span class="nobr">
<?php echo apply_filters( 'yith_wcwl_wishlist_manage_privacy_heading', __( 'Privacy', 'yith-woocommerce-wishlist' ) ) ?>
</span>
</th>
<?php */ ?>
<th class="wishlist-delete">
<span class="nobr">
<?php echo apply_filters( 'yith_wcwl_wishlist_manage_delete_heading', __( 'Delete', 'yith-woocommerce-wishlist' ) ) ?>
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="wishlist-name">
<a title="<?php echo $default_wishlist_title ?>" class="wishlist-anchor" href="<?php echo YITH_WCWL()->get_wishlist_url( 'user' . '/' . $current_user_id ) ?>">
<?php echo $default_wishlist_title ?>
</a>
</td>
<?php /* ?>
<td class="wishlist-privacy">
<?php echo apply_filters( 'yith_wcwl_wishlist_manage_default_privacy', __( 'Public', 'yith-woocommerce-wishlist' ) )?>
</td>
<?php */ ?>
<td class="wishlist-delete"></td>
</tr>
<?php
$wishlist_count = 0;
if( ! empty( $user_wishlists ) ):
?>
<?php foreach( $user_wishlists as $wishlist ): ?>
<?php if( ! $wishlist['is_default'] ): ?>
<tr>
<td class="wishlist-name">
<a title="<?php echo $wishlist['wishlist_name'] ?>" class="wishlist-anchor" href="<?php echo YITH_WCWL()->get_wishlist_url( 'view' . '/' . $wishlist['wishlist_token'] ) ?>">
<!-- I WANT TO SHOW IMAGE HERE (OF THE FIRST PRODUCT IN THE WISHLIST CURRENTLY BEING LOOPED THROUGH) -->
<?php echo $wishlist['wishlist_name'] ?>
</a>
</td>
<?php /* ?>
<td class="wishlist-privacy">
<select name="wishlist_options[<?php echo $wishlist['ID'] ?>][wishlist_privacy]" class="wishlist-visibility selectBox">
<option value="0" class="public-visibility" <?php selected( $wishlist['wishlist_privacy'], 0 ) ?> ><?php echo apply_filters( 'yith_wcwl_public_wishlist_visibility', __( 'Public', 'yith-woocommerce-wishlist' ) )?></option>
<option value="1" class="shared-visibility" <?php selected( $wishlist['wishlist_privacy'], 1 ) ?> ><?php echo apply_filters( 'yith_wcwl_shared_wishlist_visibility', __( 'Shared', 'yith-woocommerce-wishlist' ) )?></option>
<option value="2" class="private-visibility" <?php selected( $wishlist['wishlist_privacy'], 2 ) ?> ><?php echo apply_filters( 'yith_wcwl_private_wishlist_visibility', __( 'Private', 'yith-woocommerce-wishlist' ) )?></option>
</select>
</td>
<?php */ ?>
<td class="wishlist-delete">
<!-- <input type="checkbox" value="yes" name="wishlist_options[<?php echo $wishlist['ID'] ?>][delete]"/> -->
<a class="button" href="<?php echo esc_url( add_query_arg( 'wishlist_id', $wishlist['ID'], wp_nonce_url( YITH_WCWL()->get_wishlist_url( 'manage' ), 'yith_wcwl_delete_action', 'yith_wcwl_delete' ) ) ) ?>"><?php _e( 'Delete', 'yith-woocommerce-wishlist' ) ?></a>
</td>
</tr>
<?php
$wishlist_count ++;
endif;
?>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
<tfoot>
<tr>
<td colspan="3">
<a class="btn button create-new-wishlist" href="<?php echo YITH_WCWL()->get_wishlist_url( 'create' ) ?>">
<?php echo apply_filters( 'yith_wcwl_create_new_wishlist_icon', '<i class="icon-plus"></i>' )?>
<?php echo apply_filters( 'yith_wcwl_create_new_wishlist_title', __( 'Create a new board', 'yith-woocommerce-wishlist' ) )?>
</a>
<?php if( ! empty( $user_wishlists ) && $wishlist_count ): ?>
<button class="submit-wishlist-changes">
<?php echo apply_filters( 'yith_wcwl_mange_wishlist_icon', '<i class="icon-ok"></i>' )?>
<?php _e( 'Save Settings', 'yith-woocommerce-wishlist' ) ?>
</button>
<?php endif; ?>
</td>
</tr>
</tfoot>
</table>
<?php wp_nonce_field( 'yith_wcwl_manage_action', 'yith_wcwl_manage' )?>
<?php do_action( 'yith_wcwl_after_wishlist_manage' ); ?>
</form>
This is the individual wishlist page, with the working Show Product Image script (Ctrl+F 'GRABBING THE IMAGE SUCCESSFULLY' to get to relevant code) - where I can see a working example of pulling the image from a product through:
<?php
/**
* Wishlist page template
*
* #author Your Inspiration Themes
* #package YITH WooCommerce Wishlist
* #version 2.0.12
*/
if ( ! defined( 'YITH_WCWL' ) ) {
exit;
} // Exit if accessed directly
?>
<script type="text/javascript">
var root = document.documentElement;
root.className += ' wishlist-view';
</script>
<?php do_action( 'yith_wcwl_before_wishlist_form', $wishlist_meta ); ?>
<?php
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
uasort($users_wishlists, 'cmp');
?>
<?php /* ?>
<pre><code>
<?php
print_r($wishlist_items);
// print_r($users_wishlists);
?>
</code></pre>
<?php */ ?>
<!--
<div class="my-materials-sidebar bg-dark-blue white lg:absolute top-0 left-0 bottom-0">
<div class="bg-darken-3 p2 lg:p3 height-100 overflow-auto">
<h3 class="h1 mt0">My Materials</h3>
<h3 class="h2 lg:h1 mb1">My Boards</h3>
<ul class="list-reset my3 p0 uppercase lg:h3">
<li>Add new board</li>
<li>Manage boards</li>
</ul>
<ul class="list-reset m0 p0 uppercase lg:h3 boards">
<?php foreach ($users_wishlists as $users_wishlist) : ?>
<?php
$token = $users_wishlist['wishlist_token'];
$name = $users_wishlist['wishlist_name'];
?>
<?php /* <pre><code><?php print_r($users_wishlist); ?></code></pre> */ ?>
<li>
<?php if( $name ) : ?>
<a href="/my-materials/view/<?php echo $token; ?>">
<?php echo $name; ?>
</a>
<?php else : ?>
<a href="/my-materials">
Main board
</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<ul class="list-reset m0 p0 uppercase lg:h3">
<li>
My account
</li>
<li>
Log out
</li>
</ul>
</div>
</div>
-->
<form id="yith-wcwl-form" action="<?php echo $form_action ?>" method="post" class="woocommerce">
<?php wp_nonce_field( 'yith-wcwl-form', 'yith_wcwl_form_nonce' ) ?>
<!-- TITLE -->
<?php
do_action( 'yith_wcwl_before_wishlist_title', $wishlist_meta );
if( ! empty( $page_title ) ) :
?>
All Boards
<?php if( count( $wishlist_items ) > 0 ) : ?>
<a href="#" class="btn dark-grey hover:black right" data-edit-board>Edit Board</a>
<?php else : ?>
<?php endif; ?>
<div class="wishlist-title <?php echo ( $is_custom_list ) ? 'wishlist-title-with-form' : ''?>">
<?php echo apply_filters( 'yith_wcwl_wishlist_title', '<h2 class="h1 blue lh2 mt2 mb0 p0">' . $page_title . '</h2>' ); ?>
<?php /* if( $is_custom_list ): ?>
<a class="btn button show-title-form">
<?php echo apply_filters( 'yith_wcwl_edit_title_icon', '<i class="fa fa-pencil"></i>' )?>
<?php _e( 'Edit title', 'yith-woocommerce-wishlist' ) ?>
</a>
<?php endif; */ ?>
</div>
<?php if( $is_custom_list ): ?>
<div class="hidden-title-form">
<input type="text" value="<?php echo $page_title ?>" name="wishlist_name"/>
<button class="button">
<?php echo apply_filters( 'yith_wcwl_save_wishlist_title_icon', '<i class="fa fa-check fa-fw"></i>' )?>
<span>
<?php _e( 'Save', 'yith-woocommerce-wishlist' )?>
</span>
</button>
<a class="hide-title-form btn button">
<?php echo apply_filters( 'yith_wcwl_cancel_wishlist_title_icon', '<i class="fa fa-remove fa-fw"></i>' )?>
<span>
<?php _e( 'Cancel', 'yith-woocommerce-wishlist' )?>
</span>
</a>
</div>
<?php endif; ?>
<?php
endif;
do_action( 'yith_wcwl_before_wishlist', $wishlist_meta ); ?>
<?php /* ?>
<ul class="products columns-4">
<?php if( count( $wishlist_items ) > 0 ) :
$added_items = array();
foreach( $wishlist_items as $item ) :
global $product;
$item['prod_id'] = yit_wpml_object_id ( $item['prod_id'], 'product', true );
if( in_array( $item['prod_id'], $added_items ) ){
continue;
}
$added_items[] = $item['prod_id'];
$product = wc_get_product( $item['prod_id'] );
$availability = $product->get_availability();
$stock_status = $availability['class'];
if( $product && $product->exists() ) :
?>
<li class="product">
<a href="<?php echo esc_url( get_permalink( apply_filters( 'woocommerce_in_cart_product', $item['prod_id'] ) ) ) ?>">
<?php echo $product->get_image() ?>
<h2 class="woocommerce-loop-product__title"><?php echo apply_filters( 'woocommerce_in_cartproduct_obj_title', $product->get_title(), $product ) ?></h2>
<?php do_action( 'yith_wcwl_table_after_product_name', $item ); ?>
</a>
<?php if( $is_user_owner ): ?>
<div class="product-remove">
×
</div>
<?php endif; ?>
<?php if( $available_multi_wishlist && is_user_logged_in() && count( $users_wishlists ) > 1 && $move_to_another_wishlist && $is_user_owner ): ?>
<select class="change-wishlist selectBox-">
<option value=""><?php _e( 'Move', 'yith-woocommerce-wishlist' ) ?></option>
<?php
foreach( $users_wishlists as $wl ):
if( $wl['wishlist_token'] == $wishlist_meta['wishlist_token'] ){
continue;
}
?>
<option value="<?php echo esc_attr( $wl['wishlist_token'] ) ?>">
<?php
$wl_title = ! empty( $wl['wishlist_name'] ) ? esc_html( $wl['wishlist_name'] ) : esc_html( $default_wishlsit_title );
if( $wl['wishlist_privacy'] == 1 ){
$wl_privacy = __( 'Shared', 'yith-woocommerce-wishlist' );
}
elseif( $wl['wishlist_privacy'] == 2 ){
$wl_privacy = __( 'Private', 'yith-woocommerce-wishlist' );
}
else{
$wl_privacy = __( 'Public', 'yith-woocommerce-wishlist' );
}
// echo sprintf( '%s - %s', $wl_title, $wl_privacy );
echo sprintf( '%s', $wl_title );
?>
</option>
<?php
endforeach;
?>
</select>
<?php endif; ?>
</li>
<?php
endif;
endforeach;
else: ?>
<?php endif; ?>
</ul>
<?php */ ?>
<?php ?>
<!-- WISHLIST TABLE -->
<table class="shop_table cart wishlist_table" data-pagination="<?php echo esc_attr( $pagination )?>" data-per-page="<?php echo esc_attr( $per_page )?>" data-page="<?php echo esc_attr( $current_page )?>" data-id="<?php echo $wishlist_id ?>" data-token="<?php echo $wishlist_token ?>">
<?php $column_count = 2; ?>
<thead>
<tr>
<?php if( $show_cb ) : ?>
<th class="product-checkbox">
<input type="checkbox" value="" name="" id="bulk_add_to_cart"/>
</th>
<?php
$column_count ++;
endif;
?>
<?php if( $is_user_owner ): ?>
<th class="product-remove"></th>
<?php
$column_count ++;
endif;
?>
<th class="product-thumbnail"></th>
<th class="product-name">
<span class="nobr"><?php echo apply_filters( 'yith_wcwl_wishlist_view_name_heading', __( 'Product Name', 'yith-woocommerce-wishlist' ) ) ?></span>
</th>
<?php if( $show_price ) : ?>
<th class="product-price">
<span class="nobr">
<?php echo apply_filters( 'yith_wcwl_wishlist_view_price_heading', __( 'Unit Price', 'yith-woocommerce-wishlist' ) ) ?>
</span>
</th>
<?php
$column_count ++;
endif;
?>
<?php if( $show_stock_status ) : ?>
<th class="product-stock-status">
<span class="nobr">
<?php echo apply_filters( 'yith_wcwl_wishlist_view_stock_heading', __( 'Stock Status', 'yith-woocommerce-wishlist' ) ) ?>
</span>
</th>
<?php
$column_count ++;
endif;
?>
<?php if( $show_last_column ) : ?>
<th class="product-move"></th>
<?php
$column_count ++;
endif;
?>
</tr>
</thead>
<tbody>
<?php
if( count( $wishlist_items ) > 0 ) :
$added_items = array();
foreach( $wishlist_items as $item ) :
global $product;
$item['prod_id'] = yit_wpml_object_id ( $item['prod_id'], 'product', true );
if( in_array( $item['prod_id'], $added_items ) ){
continue;
}
$added_items[] = $item['prod_id'];
$product = wc_get_product( $item['prod_id'] );
$availability = $product->get_availability();
$stock_status = $availability['class'];
if( $product && $product->exists() ) :
?>
<tr id="yith-wcwl-row-<?php echo $item['prod_id'] ?>" data-row-id="<?php echo $item['prod_id'] ?>">
<?php if( $show_cb ) : ?>
<td class="product-checkbox">
<input type="checkbox" value="<?php echo esc_attr( $item['prod_id'] ) ?>" name="add_to_cart[]" <?php echo ( ! $product->is_type( 'simple' ) ) ? 'disabled="disabled"' : '' ?>/>
</td>
<?php endif ?>
<?php if( $is_user_owner ): ?>
<td class="product-remove">
<div>
×
</div>
</td>
<?php endif; ?>
<td class="product-thumbnail">
<a href="<?php echo esc_url( get_permalink( apply_filters( 'woocommerce_in_cart_product', $item['prod_id'] ) ) ) ?>">
<!-- THIS IS GRABBING THE IMAGE SUCCESSFULLY -->
<?php echo $product->get_image() ?>
<h2 class="product-name"><?php echo apply_filters( 'woocommerce_in_cartproduct_obj_title', $product->get_title(), $product ) ?></h2>
<?php do_action( 'yith_wcwl_table_after_product_name', $item ); ?>
</a>
</td>
<?php /* ?>
<td class="product-name">
<?php echo apply_filters( 'woocommerce_in_cartproduct_obj_title', $product->get_title(), $product ) ?>
<?php do_action( 'yith_wcwl_table_after_product_name', $item ); ?>
</td>
<?php */ ?>
<?php if( $show_price ) : ?>
<td class="product-price">
<?php
$base_product = $product->is_type( 'variable' ) ? $product->get_variation_regular_price( 'max' ) : $product->get_price();
echo $base_product ? $product->get_price_html() : apply_filters( 'yith_free_text', __( 'Free!', 'yith-woocommerce-wishlist' ) );
?>
</td>
<?php endif ?>
<?php if( $show_stock_status ) : ?>
<td class="product-stock-status">
<?php echo $stock_status == 'out-of-stock' ? '<span class="wishlist-out-of-stock">' . __( 'Out of Stock', 'yith-woocommerce-wishlist' ) . '</span>' : '<span class="wishlist-in-stock">' . __( 'In Stock', 'yith-woocommerce-wishlist' ) . '</span>'; ?>
</td>
<?php endif ?>
<?php if( $show_last_column ): ?>
<td class="product-move">
<!-- Date added -->
<?php
if( $show_dateadded && isset( $item['dateadded'] ) ):
echo '<span class="dateadded">' . sprintf( __( 'Added on : %s', 'yith-woocommerce-wishlist' ), date_i18n( get_option( 'date_format' ), strtotime( $item['dateadded'] ) ) ) . '</span>';
endif;
?>
<!-- Add to cart button -->
<?php if( $show_add_to_cart && isset( $stock_status ) && $stock_status != 'out-of-stock' ): ?>
<?php woocommerce_template_loop_add_to_cart(); ?>
<?php endif ?>
<!-- Change wishlist -->
<?php if( $available_multi_wishlist && is_user_logged_in() && count( $users_wishlists ) > 1 && $move_to_another_wishlist && $is_user_owner ): ?>
<div class="product-move-trigger">
<!-- <img src="<?php echo get_template_directory_uri(); ?>/assets/img/plus-white.svg" alt="" class=""> -->
</div>
<div class="product-move-dropdown">
<h3>Move to Board</h3>
<select class="change-wishlist selectBox- select">
<option value=""><?php _e( 'Choose...', 'yith-woocommerce-wishlist' ) ?></option>
<?php
foreach( $users_wishlists as $wl ):
if( $wl['wishlist_token'] == $wishlist_meta['wishlist_token'] ){
continue;
}
?>
<option value="<?php echo esc_attr( $wl['wishlist_token'] ) ?>">
<?php
$wl_title = ! empty( $wl['wishlist_name'] ) ? esc_html( $wl['wishlist_name'] ) : esc_html( $default_wishlsit_title );
if( $wl['wishlist_privacy'] == 1 ){
$wl_privacy = __( 'Shared', 'yith-woocommerce-wishlist' );
}
elseif( $wl['wishlist_privacy'] == 2 ){
$wl_privacy = __( 'Private', 'yith-woocommerce-wishlist' );
}
else{
$wl_privacy = __( 'Public', 'yith-woocommerce-wishlist' );
}
if ( $wl_title == 'My Materials' ) {
$wl_title = 'Main board';
}
// echo sprintf( '%s - %s', $wl_title, $wl_privacy );
echo sprintf( '%s', $wl_title );
?>
</option>
<?php
endforeach;
?>
</select>
</div>
<?php endif; ?>
<!-- Remove from wishlist -->
<?php if( $is_user_owner && $repeat_remove_button ): ?>
<?php _e( 'Remove', 'yith-woocommerce-wishlist' ) ?>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php
endif;
endforeach;
else: ?>
<tr class="empty">
<td colspan="<?php echo esc_attr( $column_count ) ?>" class="wishlist-empty"><?php echo apply_filters( 'yith_wcwl_no_product_to_remove_message', __( 'No items have been added to this board yet', 'yith-woocommerce-wishlist' ) ) ?></td>
</tr>
<?php
endif;
if( ! empty( $page_links ) ) : ?>
<tr class="pagination-row">
<td colspan="<?php echo esc_attr( $column_count ) ?>"><?php echo $page_links ?></td>
</tr>
<?php endif ?>
</tbody>
<tfoot>
<tr>
<td colspan="<?php echo esc_attr( $column_count ) ?>">
<?php if( $show_cb ) : ?>
<div class="custom-add-to-cart-button-cotaniner">
<?php echo apply_filters( 'yith_wcwl_custom_add_to_cart_text', __( 'Add the selected products to the cart', 'yith-woocommerce-wishlist' ) ) ?>
</div>
<?php endif; ?>
<?php if ( $is_user_owner && $show_ask_estimate_button && $count > 0 ): ?>
<div class="ask-an-estimate-button-container">
<a href="<?php echo ( $additional_info || ! is_user_logged_in() ) ? '#ask_an_estimate_popup' : $ask_estimate_url ?>" class="btn button ask-an-estimate-button" <?php echo ( $additional_info ) ? 'data-rel="prettyPhoto[ask_an_estimate]"' : '' ?> >
<?php echo apply_filters( 'yith_wcwl_ask_an_estimate_icon', '<i class="fa fa-shopping-cart"></i>' )?>
<?php echo apply_filters( 'yith_wcwl_ask_an_estimate_text', __( 'Ask for an estimate', 'yith-woocommerce-wishlist' ) ) ?>
</a>
</div>
<?php endif; ?>
<?php
do_action( 'yith_wcwl_before_wishlist_share', $wishlist_meta );
if ( is_user_logged_in() && $is_user_owner && ! $is_private && $share_enabled ){
yith_wcwl_get_template( 'share.php', $share_atts );
}
do_action( 'yith_wcwl_after_wishlist_share', $wishlist_meta );
?>
</td>
</tr>
</tfoot>
</table>
<?php ?>
<?php wp_nonce_field( 'yith_wcwl_edit_wishlist_action', 'yith_wcwl_edit_wishlist' ); ?>
<?php if( ! $is_default ): ?>
<input type="hidden" value="<?php echo $wishlist_token ?>" name="wishlist_id" id="wishlist_id">
<?php endif; ?>
<?php do_action( 'yith_wcwl_after_wishlist', $wishlist_meta ); ?>
</form>
<?php do_action( 'yith_wcwl_after_wishlist_form', $wishlist_meta ); ?>
<?php if( $show_ask_estimate_button && ( ! is_user_logged_in() || $additional_info ) ): ?>
<div id="ask_an_estimate_popup">
<form action="<?php echo $ask_estimate_url ?>" method="post" class="wishlist-ask-an-estimate-popup">
<?php if( ! is_user_logged_in() ): ?>
<label for="reply_email"><?php echo apply_filters( 'yith_wcwl_ask_estimate_reply_mail_label', __( 'Your email', 'yith-woocommerce-wishlist' ) ) ?></label>
<input type="email" value="" name="reply_email" id="reply_email">
<?php endif; ?>
<?php if( ! empty( $additional_info_label ) ):?>
<label for="additional_notes"><?php echo esc_html( $additional_info_label ) ?></label>
<?php endif; ?>
<textarea id="additional_notes" name="additional_notes"></textarea>
<button class="btn button ask-an-estimate-button ask-an-estimate-button-popup" >
<?php echo apply_filters( 'yith_wcwl_ask_an_estimate_icon', '<i class="fa fa-shopping-cart"></i>' )?>
<?php echo apply_filters( 'yith_wcwl_ask_an_estimate_text', __( 'Ask for an estimate', 'yith-woocommerce-wishlist' ) ) ?>
</button>
</form>
</div>
<?php endif; ?>
I know this script cannot be directly copied as it is looking through product variables knowing which product it is looking through, I need to write something similar that will look inside the wishlist instead of inside the product.
I think I know what I need to do, I just have no idea how to do it.
I have tried simple stuff I predicted wouldn't work before even implementing it. Trying to guess shortcodes / scouring the web for a list of shortcodes.
Edit
Attempting to achieve this using 'simplehtmldom'...
I have downloaded and installed simplehtmldom then called it into the file:
<?php
$simplehtmldom = get_template_directory() . "/simplehtmldom/simple_html_dom.php";
include_once($simplehtmldom);
?>
Then gone on to try find the image within the wishlist by gathering the src of the first product in that wishlist:
<?php
$boardlink = YITH_WCWL()->get_wishlist_url( 'view' . '/' . $wishlist['wishlist_token'] );
$html = file_get_html($boardlink);
$wishlistimage = $html->find('.attachment-woocommerce_thumbnail', 0)->src;
?>
The variable $boardlink value has been taken from the href within the section:
<a title="<?php echo $wishlist['wishlist_name'] ?>" class="wishlist-anchor" href="<?php echo YITH_WCWL()->get_wishlist_url( 'view' . '/' . $wishlist['wishlist_token'] ) ?>">
So technically should / could work...
However, I get a range of errors:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /home/example/public_html/development/wp-content/themes/bolt/simplehtmldom/simple_html_dom.php on line 136
Warning: file_get_contents(): Failed to enable crypto in /home/example/public_html/development/wp-content/themes/bolt/simplehtmldom/simple_html_dom.php on line 136
Warning: file_get_contents(https://development.example.com/my-materials/view/9OW01M6785H9/): failed to open stream: operation failed in /home/example/public_html/development/wp-content/themes/bolt/simplehtmldom/simple_html_dom.php on line 136
This site doesn't have a valid SSL as it is just a staging dev site. The live site does have an SSL.
I think the main issue is with the wishlists being private to the user, I don't think we are able to scrape from these pages.

Display Product Addons in Columns (Woocommerce)

I am using product addons in Woocommerce. Unfortunately, with the current functionality, each new addon goes after the other. Just like this:
Addon 1
Addon 2
and so on..
You can visit the link here enter link description here
Now, what I was trying to do is:
Whenever there's more than one add on then it should follow the following layout:
Addon 1 | Addon 2
Addon 3 | Addon 4
Addon 5
and so on..
Below is the existing code for the addons
<div class="<?php if ( 1 == $required ) echo 'required-product-addon'; ?> product-addon product-addon-<?php echo sanitize_title( $name ); ?>">
<?php do_action( 'wc_product_addon_start', $addon ); ?>
<?php if ( $name ) : ?>
<h3 class="addon-name"><?php echo wptexturize( $name ); ?> <?php if ( 1 == $required ) echo '<abbr class="required" title="' . __( 'Required field', 'woocommerce-product-addons' ) . '">*</abbr>'; ?></h3>
<?php endif; ?>
<?php if ( $description ) : ?>
<?php echo '<div class="addon-description">' . wpautop( wptexturize( $description ) ) . '</div>'; ?>
<?php endif; ?>
<?php do_action( 'wc_product_addon_options', $addon ); ?>
Please help!
Here's what I tried with my little knowledge of PHP:
<div class="su-row">
<div class="su-column su-column-size-1-2"><div class="su-column-inner su-clearfix">
<div class="<?php if ( 1 == $required ) echo 'required-product-addon'; ?> product-addon product-addon-<?php echo sanitize_title( $name ); ?>">
<?php do_action( 'wc_product_addon_start', $addon ); ?>
<?php if ( $name ) : ?>
<h3 class="addon-name"><?php echo wptexturize( $name ); ?> <?php if ( 1 == $required ) echo '<abbr class="required" title="' . __( 'Required field', 'woocommerce-product-addons' ) . '">*</abbr>'; ?></h3>
<?php endif; ?>
<?php if ( $description ) : ?>
<?php echo '<div class="addon-description">' . wpautop( wptexturize( $description ) ) . '</div>'; ?>
<?php endif; ?>
<?php do_action( 'wc_product_addon_options', $addon ); ?>
</div></div>
<div class="su-column su-column-size-1-2"><div class="su-column-inner su-clearfix">
<? php if (i+1 == $addon) ?>
<div class="<?php if ( 1 == $required ) echo 'required-product-addon'; ?> product-addon product-addon-<?php echo sanitize_title( $name ); ?>">
<?php do_action( 'wc_product_addon_start', $addon ); ?>
<?php if ( $name ) : ?>
<h3 class="addon-name"><?php echo wptexturize( $name ); ?> <?php if ( 1 == $required ) echo '<abbr class="required" title="' . __( 'Required field', 'woocommerce-product-addons' ) . '">*</abbr>'; ?></h3>
<?php endif; ?>
<?php if ( $description ) : ?>
<?php echo '<div class="addon-description">' . wpautop( wptexturize( $description ) ) . '</div>'; ?>
<?php endif; ?>
<?php do_action( 'wc_product_addon_options', $addon ); ?>
</div></div>
</div>

Wordpress - Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING)

I have the following error with Wordpress using Woo-Commerce and Storefront theme.
Error is - Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING)
Can anyone help?
This is the standard code from the theme. No edits. It just started to not work.
Here is the function from line 31:
<?php
if ( ! function_exists( 'storefront_display_comments' ) ) {
function storefront_display_comments() {
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
}
}
if ( ! function_exists( 'storefront_comment' ) ) {
function storefront_comment( $comment, $args, $depth ) {
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo esc_attr( $tag ); ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<div class="comment-body">
<div class="comment-meta commentmetadata">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 128 ); ?>
<?php printf( wp_kses_post( '<cite class="fn">%s</cite>', 'storefront' ), get_comment_author_link() ); ?>
</div>
<?php if ( '0' == $comment->comment_approved ) : ?>
<em class="comment-awaiting-moderation"><?php esc_attr_e( 'Your comment is awaiting moderation.', 'storefront' ); ?></em>
<br />
<?php endif; ?>
<a href="<?php echo esc_url( htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ); ?>" class="comment-date">
<?php echo '<time datetime="' . get_comment_date( 'c' ) . '">' . get_comment_date() . '</time>'; ?>
</a>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-content">
<?php endif; ?>
<div class="comment-text">
<?php comment_text(); ?>
</div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
<?php edit_comment_link( __( 'Edit', 'storefront' ), ' ', '' ); ?>
</div>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
}
Found out the answer myself.
Went into the file and removed a hr tag which was out of place and it fixed the issue.

Categories