How to return multiples lines in a shortcode?

I found this example of a shortcode on the Internet:

function project_shortcode( $atts, $content = null ) {
    extract( shortcode_atts( array(
        'class' => '',
        'id' => '',
        ), $atts ) );

        return '<div id="' . $id . '" class="' . $class . '">' . $content . '</div>';

}
add_shortcode('button', 'project_shortcode');

This is the output I want:

Read More
<div class="container item">
    <div class="row">
        <div class="intro twelvecol">
            <div class="top-border"></div>
        </div>
        <div class="screenshot eightcol">
            <img src="<?php bloginfo( 'template_url' ); ?>/images/studyatbest.png">
        </div>
        <div class="screenshot fourcol last">
            <h3>BEST LANGUAGE CENTER</h3>
            <p>BEST Language Center is an educational establishment in Taichung, Taiwan. I was asked to build and design a website they could use to offer classes, programs and display photos online.</p>
            <ul>
                <li>
                    <h4>ROLE</h4>
                    <p>Design, HTML/CSS, JavaScript</p>
                <li>
                    <h4>YEAR</h4>
                    <p>2010</p>
                </li>
                <li>
                    <h4>WEBSITE</h4>
                    <p><a href="http://studyatbest.com/">studyatbest.com</a></p>
                </li>
            </ul>
        </div>
    </div>
</div>

But I’m not sure how to do it so that I can return multiples lines in the shortcode (in order to keep the code clean). Any suggestions?

Related posts

Leave a Reply

2 comments

  1. Got it:

    // Project shortcode
    function project_shortcode( $atts, $content = null ) {
        extract( shortcode_atts( array(
            'client' => '',
            'screenshot' => '',
            'role' => '',
            'year' => '',
            'website' => '',
            ), $atts ) );
    
            ob_start();
        ?>
    
        <div class="container item">
            <div class="row">
                <div class="intro twelvecol">
                    <div class="top-border"></div>
                </div>
                <div class="screenshot eightcol">
                    <img src="<?php bloginfo( 'template_url' ); ?>/images/<?php echo $screenshot ?>">
                </div>
                <div class="screenshot fourcol last">
                    <h3><?php echo $client ?></h3>
                    <p><?php echo $content ?></p>
                    <ul>
                        <li>
                            <h4>ROLE</h4>
                            <p><?php echo $role ?></p>
                        <li>
                            <h4>YEAR</h4>
                            <p><?php echo $year ?></p>
                        </li>
                        <li>
                            <h4>WEBSITE</h4>
                            <p><a href="http://<?php echo $website ?>"><?php echo $website ?></a></p>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    
        <?php
            return ob_get_clean();
    }
    add_shortcode('project', 'project_shortcode');
    

    (Please tell me if there is any bad practice in that code).