MOON
Server: Apache
System: Linux server.netcommlabs.in 3.10.0-1160.83.1.el7.x86_64 #1 SMP Wed Jan 25 16:41:43 UTC 2023 x86_64
User: dermova (1051)
PHP: 5.4.45
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/dermova/www/india/wp-content/plugins/rit-core/inc/shortcode/rit_recent_post.php
<?php
/**
 * RIT Core Plugin
 * @package     RIT Core
 * @version     0.1
 * @author      CleverSoft
 * @link        http://cleversoft.co
 * @copyright   Copyright (c) 2015 CleverSoft
 * @license     GPL v2
 */

if (!function_exists('rit_shortcode_recent_post')) {
    function rit_shortcode_recent_post($atts)
    {
        $atts = shortcode_atts(array(
            'title' => '',
            'column' => 'col-md-6 col-sm-6',
            'cat' => '',
            'post_in' => '',
            'posts_per_page' => 3,
            'view_more' => false,
            'el_class' => '',
            'title_align'=>'',
            'pagination' => 0
        ), $atts);

        if ($atts['cat'] != ''){
             $args['category__in'] = explode(',', $atts['cat']);
        }

        $class_col ='col-md-6 col-sm-6';
        $number=2;
        $class = '';
        $class_col = str_replace('column', 'products-',$atts['column']);

        if($class_col       == "col-md-12 col-sm-12"){
            $number=1;
        }
        elseif($class_col   == 'col-md-6 col-sm-6'){
            $number=2;
        }
        elseif($class_col   == 'col-md-4 col-sm-4'){
            $number=3;
        }
        elseif($class_col   == 'col-md-3 col-sm-6'){
            $number=4;
        }
        elseif($class_col   == 'col-md-2 col-sm-4'){
            $number=6;
        }else{
            $number=4;
        }

        ob_start();
        $the_query=new WP_Query($atts);
        ?>

        <div class="widget blog-recent-post">
            <?php if ( $atts['title'] ) {?>
                <h3 class="widget-title">
                    <span class="<?php echo $atts['title_align']; ?>"><?php echo htmlspecialchars_decode( $atts['title'] ); ?></span>
                </h3>
            <?php }?>
            <div class="widget-content row">
                    <?php
                    if ($the_query->have_posts()):

                        while ($the_query->have_posts()):
                            $the_query->the_post();
                            ?>
                                <article class="rit-recent-post <?php echo esc_attr($class_col);?> ">

                                    <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) : ?>
                                        <div class="post-image">
                                            <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_post_thumbnail('recent-image', array('class' => 'thumb-image')); ?></a>
                                        </div>
                                    <?php endif; ?>
                                    <div class="entry-header">
                                        <h4 class="entry-title"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h4>
                                    </div>
                                    <div class="article-meta">
                                        <span class="post-date"><i class="fa fa-clock-o"></i><?php echo get_the_date('F jS, Y'); ?></span>
                                        <span class="post-cat"><i class="fa fa-eye"></i><?php echo sp_category(', '); ?></span>
                                    </div>
                                    <div class="entry-content">
                                        <?php
                                            echo rit_content(20);
                                        ?>
                                    </div><!-- .entry-content -->

                                </article>
                        <?php
                        endwhile;
                        if (function_exists("posts_nav")&& $atts['pagination']==1) :
                            posts_nav($the_query->max_num_pages);
                        endif;
                    endif;?>

            </div>
        </div>
        <?php
        $output = ob_get_contents();
        ob_end_clean();
        return $output;
    }
}
add_shortcode('rit_recent_post', 'rit_shortcode_recent_post');

add_action('vc_before_init', 'rit_recent_post_integrate_vc');

if (!function_exists('rit_recent_post_integrate_vc')) {
    function rit_recent_post_integrate_vc()
    {
        vc_map(array(
            'name' => esc_html__('RIT Recent Post', RIT_TEXT_DOMAIN),
            'base' => 'rit_recent_post',
            'category' => esc_html__('RIT', RIT_TEXT_DOMAIN),
            'description' => esc_html__('Show recent post.', RIT_TEXT_DOMAIN),
            'icon' => 'rit-blog',
            "params" => array(
                array(
                    "type" => "textfield",
                    "heading" => esc_html__("Title", RIT_TEXT_DOMAIN),
                    "param_name" => "title",
                    "admin_label" => true,
                    'description' => esc_html__('Enter text used as shortcode title (Note: located above content element)', RIT_TEXT_DOMAIN),
                ),
                array(
                    'type' => 'dropdown',
                    'heading' => __('Title align', RIT_TEXT_DOMAIN),
                    'value' => array(
                        __('Center', RIT_TEXT_DOMAIN) => 'center',
                        __('Left', RIT_TEXT_DOMAIN) => 'left',
                        __('Right', RIT_TEXT_DOMAIN) => 'right',
                        __('Hidden', RIT_TEXT_DOMAIN) => 'hidden'
                    ),
                    'param_name' => 'title_align',
                ),
                array(
                    "type" => "rit_post_categories",
                    "heading" => esc_html__("Category IDs", RIT_TEXT_DOMAIN),
                    "description" => esc_html__("Select category", RIT_TEXT_DOMAIN),
                    "param_name" => "cat",
                    "admin_label" => true,
                    'description' => esc_html__('Select category which you want to get post in', RIT_TEXT_DOMAIN),
                ),
                array(
                    'type' => 'dropdown',
                    'heading' => __('Column count', RIT_TEXT_DOMAIN),
                    'value' => array(
                        __('1 Columns', RIT_TEXT_DOMAIN) => 'col-md-12 col-sm-12',
                        __('2 Columns', RIT_TEXT_DOMAIN) => 'col-md-6 col-sm-6',
                        __('3 Columns', RIT_TEXT_DOMAIN) => 'col-md-4 col-sm-6',
                        __('4 Columns', RIT_TEXT_DOMAIN) => 'col-md-3 col-sm-6',
                        __('6 Columns', RIT_TEXT_DOMAIN) => 'col-md-2 col-sm-4'
                    ),
                    'std' => 'col-md-6 col-sm-6',
                    'param_name' => 'column',
                ),
                array(
                    "type" => "textfield",
                    "heading" => esc_html__("Posts number", RIT_TEXT_DOMAIN),
                    "param_name" => "posts_per_page",
                    "value" => '4',
                    'description' => esc_html__('Number of post showing', RIT_TEXT_DOMAIN),
                ),
                array(
                    'type' => 'textfield',
                    'heading' => esc_html__( 'Extra class name', RIT_TEXT_DOMAIN ),
                    'param_name' => 'el_class',
                    'description' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS.', RIT_TEXT_DOMAIN )
                ),
            )
        ));
    }
}