I'm using the do_shortcode
function to add a shortcode in a page. But I would like to check if that shortcode exists before displaying it. If the user has no gallery, I would like to display a message like this: "Sorry no gallery here".
This is my PHP:
<?php
/**
* galeries content
*/
function iconic_galeries_endpoint_content() {
echo /* Template Name: Client Area */
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<article>
<header class="entry-header">
<h1><?php _e( 'Vos galeries photos.', 'my-theme' ); ?></h1>
</header>
<div class="entry-content">
<?php
$current_user = wp_get_current_user();
if ( isset( $current_user->user_email ) ) {
echo '<p>' . sprintf( __( '%s, this is your galleries', 'my-theme' ), $current_user->display_name ) . ':</p>';
echo do_shortcode( '[picu_list_collections email="' . $current_user->user_email . '"]' );
}
else {
echo '<p>' . sprintf( __( 'Please <a href="%s">log in</a> to see this page', 'my-theme' ), wp_login_url( get_permalink() ) ) . '.</p>';
}
?>
</div>
</article>
</main>
</div>
<?php
}
I haven't found a way to return a message like: "Sorry no gallery here".
Does anyone have a solution?
When client has a gallery to approve
And when client has no gallery to approve or he has already approve his photos
shortcode_exists( 'picu_list_collections' )
?