最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

functions - Display a text message if the shortcode is found?

matteradmin5PV0评论

For a few hours I try to show a message only if there is a gallery Picu, without success, an idea?

Have try this code, but not work:

    /**
 * 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">
        <section>
        <header class="entry-header">
                    <h1><?php _e( 'Photos gallery.', 'my-theme' ); ?></h1>
                </header>
            <article>

                <div class="entry-content">
                <?php
                $current_user = wp_get_current_user();

                if ( isset( $current_user->user_email ) ) {
                    echo '<p>' . sprintf( __( '%s, here is your client area', 'my-theme' ), $current_user->display_name ) . ':</p>';

                    if($output == '<li class="picu-status-' . get_post_status() . '"><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>') echo '<div class="woocommerce-MyAccount-content">
    <div class="woocommerce-notices-wrapper"></div>
    <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
        Your gallery.   </div>

</div>';
else echo $output;

                    $output = do_shortcode( '[picu_list_collections email="' . $current_user->user_email . '"]' );

// the shortcode returns an empty <ul> tag, if there is no gallery 
// .php#L464

if($output == '<ul class="picu-collection-list"></ul>') echo '<div class="woocommerce-MyAccount-content">
    <div class="woocommerce-notices-wrapper"></div>
    <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
        There is no gallery.    </div>

</div>';
else echo $output;
                }

                ?>
                </div>
            </article>
            </section>
        </main>
    </div>

<?php
}

Thanks in advance Nico

For a few hours I try to show a message only if there is a gallery Picu, without success, an idea?

Have try this code, but not work:

    /**
 * 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">
        <section>
        <header class="entry-header">
                    <h1><?php _e( 'Photos gallery.', 'my-theme' ); ?></h1>
                </header>
            <article>

                <div class="entry-content">
                <?php
                $current_user = wp_get_current_user();

                if ( isset( $current_user->user_email ) ) {
                    echo '<p>' . sprintf( __( '%s, here is your client area', 'my-theme' ), $current_user->display_name ) . ':</p>';

                    if($output == '<li class="picu-status-' . get_post_status() . '"><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>') echo '<div class="woocommerce-MyAccount-content">
    <div class="woocommerce-notices-wrapper"></div>
    <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
        Your gallery.   </div>

</div>';
else echo $output;

                    $output = do_shortcode( '[picu_list_collections email="' . $current_user->user_email . '"]' );

// the shortcode returns an empty <ul> tag, if there is no gallery 
// https://plugins.trac.wordpress/browser/picu/trunk/frontend/includes/picu-template-functions.php#L464

if($output == '<ul class="picu-collection-list"></ul>') echo '<div class="woocommerce-MyAccount-content">
    <div class="woocommerce-notices-wrapper"></div>
    <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
        There is no gallery.    </div>

</div>';
else echo $output;
                }

                ?>
                </div>
            </article>
            </section>
        </main>
    </div>

<?php
}

Thanks in advance Nico

Share Improve this question edited Apr 3, 2019 at 15:53 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Apr 3, 2019 at 13:21 Nicolas LogerotNicolas Logerot 676 bronze badges 3
  • 2 Where is $output first set? It looks like your are checking the value before it's set in your example code. Perhaps you need do_shortcode() at the beginning of your function. – Alexander Holsgrove Commented Apr 3, 2019 at 13:42
  • How is that function being called? What's the problem you're trying to solve with this solution? – Tom J Nowell Commented Apr 3, 2019 at 13:51
  • In fact, gallery user is displaying if user email is find. But if user have no gallery, shortcode is not displaying and I would put a message like: Sorry, you have no gallery for the moment. – Nicolas Logerot Commented Apr 3, 2019 at 13:59
Add a comment  | 

1 Answer 1

Reset to default 2

Try this:

<article>

                <div class="entry-content">
                <?php
                $current_user = wp_get_current_user();

                if ( isset( $current_user->user_email ) ) {
                    echo '<p>' . sprintf( __( '%s, here is your client area', 'my-theme' ), $current_user->display_name ) . ':</p>';


                    $output = do_shortcode( '[picu_list_collections email="' . $current_user->user_email . '"]' );

                    // the shortcode returns an empty <ul> tag, if there is no gallery 
                   // https://plugins.trac.wordpress/browser/picu/trunk/frontend/includes/picu-template-functions.php#L464

                   if($output == '<ul class="picu-collection-list"></ul>') {
                        echo '<div class="woocommerce-MyAccount-content">
                                 <div class="woocommerce-notices-wrapper"></div>
                                 <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
                                   There is no gallery.
                                </div>
                             </div>';
                   }
                   else {
                       echo '<div class="woocommerce-MyAccount-content">
                                <div class="woocommerce-notices-wrapper"></div>
                                <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
                                    Your gallery.
                                </div>
                         </div>';
                       echo $output;
                  }
  }

                ?>
                </div>
            </article>
Post a comment

comment list (0)

  1. No comments so far