shprics.php 3.82 KB
<?php 
function fenix_shprics ($atts, $content)
    {
        $atts = shortcode_atts(
            array(
                'post'  => '',
                'id'    => ''
            ),
            $atts,
            'fenix_shprics'
        );

        $out = '';
        if ($atts['post']!=='')
            {
                $args = array(
                    'numberposts'   => 1,
                    'post__in'      => array($atts['post']),
                    'order'         => 'ASC',
                    'limit'         => 1
                );
                $posts = get_posts($args);
                foreach($posts as $key=>$post)
                    {   
                        $out = ''.
                            '<!--Шприцы-->'.
                            '<div id="'.$atts['id'].'" class="fenix-shprics"'.(has_post_thumbnail($post->ID)?' style="background-image: url('.get_the_post_thumbnail_url($post->ID, 'full').');"':'').'>'.
                                '<div class="container text-color-1">'.
                                    '<div class="row">'.
                                        '<div class="col-12 col-md-6 text-md-start">'.
                                            '<div class="info">'.
                                                '<div class="caption mb-md-4">'.($post->post_excerpt===''?$post->post_title:$post->post_excerpt).'</div>'.
                                                '<div class="description">'.$post->post_content.'</div>'.
                                            '</div>'.
                                        '</div>'.
                                        '<div class="col-12 col-md-6 text-md-end">'.
                                            '<form class="needs-validation text-start mx-auto me-md-0 rounded-4 text-color-1 bg-custom-9 shadow-2">'.
                                                '<div class="text-center mb-5 caption">Lorem Ipsum</div>'.
                                                '<div class="mb-3">'.
                                                    '<label for="zayvkaName" class="form-label">Ваше имя</label>'.
                                                    '<input type="text" class="form-control form-control-lg rounded-4 border-0" id="zayvkaName" required="required" />'.
                                                '</div>'.
                                                '<div class="mb-5">'.
                                                    '<label for="zayvkaPhone" class="form-label">Телефон</label>'.
                                                    '<input type="text" class="form-control form-control-lg rounded-4 border-0" id="zayvkaPhone" name="phone" required="required" />'.
                                                '</div>'.
                                                '<div class="mb-5 form-check ps-0">'.
                                                    '<input class="form-check-input d-none" type="checkbox" value="" id="fenix-accept-opr" checked="checked" />'.
                                                    '<label class="form-check-label text-color-10" for="fenix-accept-opr">Согласен на обработку<br/> персональных данных </label>'.
                                                '</div>'.
                                                '<button class="btn btn-lg btn-style-1 rounded-pill mx-auto w-100" type="submit" role="submit">Lorem Ipsum</button>'.
                                            '</form>'.
                                        '</div>'.
                                    '</div>'.
                                '</div>'.
                            '</div>';
                    }
                wp_reset_postdata();

                unset($key, $post, $posts, $args);
            }
        return $out;
    }
add_shortcode('fenix_shprics', 'fenix_shprics');