File "widgets.php"

Full Path: /home/flipjqml/onlinebetsolution.com/next_old/wp-content/plugins/cyarb-toolkit/inc/widgets.php
File size: 19.38 KB
MIME-type: text/x-php
Charset: utf-8

<?php

class Cyarb_posts_thumbs extends WP_Widget{

    function __construct(){
        $widget_ops = array('description' => esc_html__('Display Random or Recent posts with a small image.', 'cyarb-toolkit'));
        parent::__construct( false, esc_html__('Cyarb Recent Posts With Image', 'cyarb-toolkit'), $widget_ops);
    }

    function widget($args, $instance){
        global $cyarb_theme, $cyarb_opt;
        extract($args); //it receives an associative array

        $title = apply_filters('widget_title', $instance['title']);
        $args = array(
            'posts_per_page' => $instance['number'],
            'post_type' => 'post',
            'order' => 'DESC',
            'orderby' => $instance['orderby']
        );
       
        $query = new WP_Query($args);

        if( !$query->have_posts() ) return;
        echo $before_widget;
        if($title) echo $before_title.$title.$after_title;
        if(!$instance['number']) $instance['number'] = 4;

        if($query->have_posts()):
            $c = 0;
            
            while($query->have_posts()): $query->the_post(); ?>
                <?php
                $class = 'item';
                $post_id = get_the_ID();
                $thumb_size = 'cyarb_widget_thumb';
                ?>
                <?php if( !has_post_thumbnail() ) $class .= ' no-thumb'; ?>
                <article <?php post_class($class); ?>>

                    <?php if( has_post_thumbnail() ): ?>
                        <?php
                        $thumb_id   = get_post_thumbnail_id($post_id);
                        $thumb_type = get_post_mime_type($thumb_id);
                        $image_alt  = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true);
                        if( !$image_alt ){
                            $image_alt = get_the_title($post_id);
                        }
                        if($thumb_type == 'image/gif'){
                            $thumb_size = '';
                        }
                        ?>
                        <a href="<?php the_permalink(); ?>" class="thumb hover-effect" aria-label="<?php the_title(); ?>">
                            <?php if( !empty($cyarb_theme) && $cyarb_theme['enable_lazyload'] == '1' ): ?>
                                <span class="fullimage cover lazy" role="img" aria-label="<?php echo esc_attr($image_alt); ?>" data-src="<?php the_post_thumbnail_url($thumb_size); ?>"></span>
                            <?php else: ?>
                                <span class="fullimage cover" role="img" aria-label="<?php echo esc_attr($image_alt); ?>" style="background: url('<?php the_post_thumbnail_url($thumb_size); ?>');"></span>
                            <?php endif; ?>
                        </a>
                    <?php endif; ?>

                    <div class="info gradient-effect">
                        <h4 class="title usmall"><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></h4>
                        <?php if( isset( $cyarb_opt['is_post_meta'] ) && $cyarb_opt['is_post_meta'] == true ) { ?>
                            <time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time( get_option('date_format') ); ?></time><?php
                        } ?>
                        								
                    </div>

                    <div class="clear"></div>
                </article>
            <?php
            endwhile;
            wp_reset_postdata();
        endif;
        echo $after_widget;
    }

    function update($new_instance, $old_instance){
        $instance = $old_instance;
        $instance['title'] = strip_tags($new_instance['title']);
        $instance['number'] = (int) $new_instance['number'];
        $instance['orderby'] = $new_instance['orderby'];
        return $instance;
    }

    function form($instance){
        $defaults = array(
            'title' => 'Recent posts',
            'number' => 4,
            'orderby' => 'date'
        );
        $instance = wp_parse_args((array)$instance, $defaults);
        $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 4;
        ?>
        <p>
            <label for="<?php echo $this->get_field_id('title'); ?>">
                <?php esc_html_e('Title:', 'cyarb-toolkit'); ?>
                <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo $this->get_field_id('number'); ?>"><?php esc_html_e( 'Number of posts to show:', 'cyarb-toolkit'); ?></label>
            <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" />
        </p>
        <p>
            <label for="<?php echo $this->get_field_id('orderby'); ?>"><?php esc_html_e('Mode:', 'cyarb-toolkit') ?> </label>
            <select id="<?php echo $this->get_field_id('orderby'); ?>" name="<?php echo $this->get_field_name('orderby'); ?>">
                <option <?php if ($instance['orderby'] == 'date') echo 'selected="selected"'; ?> value="date"><?php esc_html_e('Recent Posts', 'cyarb-toolkit'); ?></option>
                <option <?php if ($instance['orderby'] == 'rand') echo 'selected="selected"'; ?> value="rand"><?php esc_html_e('Random Posts', 'cyarb-toolkit'); ?></option>
                <?php if( function_exists('get_field') ): // By views ?>
                    <option <?php if ($instance['orderby'] == 'views') echo 'selected="selected"'; ?> value="views"><?php esc_html_e('Post views', 'cyarb-toolkit'); ?></option>
                <?php endif; ?>
            </select>
        </p>
        <?php
    }

}

function cyarb_register_posts_thumbs() {
    register_widget('Cyarb_posts_thumbs');
}

add_action('widgets_init', 'cyarb_register_posts_thumbs');

 /**
 * Author Widget
 */
class Cyarb_author_info extends WP_Widget{

    function __construct(){
        $widget_ops = array('description' => esc_html__('Display Author Info', 'cyarb-toolkit'));
        parent::__construct( false, esc_html__('Cyarb Author Info', 'cyarb-toolkit'), $widget_ops);
    }

    function widget($args, $instance){
        extract($args);
        global $cyarb_theme;

        echo wp_kses_post($before_widget);
        ?>
            <div class="widget_author">

                <?php if ( $instance['author_image_link'] !='' ) : ?>
                    <img src="<?php echo esc_url($instance['author_image_link'] ); ?> " alt="<?php esc_attr_e( 'Author Image Link', 'cyarb' ); ?>" >
                <?php endif; ?>

                <h3><?php the_author() ?></h3>

                <?php if( $instance['logo_info'] != '' ): ?>
                    <span><?php echo esc_html($instance['logo_info']); ?></span>
                <?php endif; ?>
                
                <?php if( $instance['follow_us'] != '' ): ?>
                    <p><?php echo esc_html($instance['follow_us']); ?></p>
                <?php endif; ?>

                <?php if ( $instance['img-sig'] !='' ) : ?>
                    <img src="<?php echo esc_url($instance['img-sig'] ); ?> " alt="<?php esc_attr_e( 'Signature Image', 'cyarb' ); ?>" >
                <?php endif; ?>
            </div>
        <?php
        echo wp_kses_post($after_widget);
    }

    function update($new_instance, $old_instance){
        $instance                               = $old_instance;
        
        $instance['author_image_link']          = $new_instance['author_image_link'];
        $instance['logo_info']                  = $new_instance['logo_info'];
        $instance['follow_us']                  = $new_instance['follow_us'];
        $instance['img-sig']                    = $new_instance['img-sig'];

        return $instance;
    }

    function form($instance){
        $defaults = array(
            'author_image_link'             => '#',
            'logo_info'                     => esc_html__('Blogger'),
            'follow_us'                     => esc_html__('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.', 'cyarb-toolkit'),
            'img-sig'                       => '#',
        );
        $instance = wp_parse_args((array)$instance, $defaults);
        ?>
        
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('author_image_link')); ?>">
                <?php esc_html_e('Author Image Link:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('author_image_link')); ?>" name="<?php echo esc_attr($this->get_field_name('author_image_link')); ?>" type="text" value="<?php echo wp_kses_post($instance['author_image_link']); ?>" />
            </label>
        </p>

        <p>
            <label for="<?php echo esc_attr($this->get_field_id('logo_info')); ?>">
                <?php esc_html_e('Author Info:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('logo_info')); ?>" name="<?php echo esc_attr($this->get_field_name('logo_info')); ?>" type="text" value="<?php echo wp_kses_post($instance['logo_info']); ?>" />
            </label>
        </p>

        <p>
            <label for="<?php echo esc_attr($this->get_field_id('follow_us')); ?>">
                <?php esc_html_e('Author Content:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('follow_us')); ?>" name="<?php echo esc_attr($this->get_field_name('follow_us')); ?>" type="text" value="<?php echo wp_kses_post($instance['follow_us']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('img-sig')); ?>">
                <?php esc_html_e('Author Signature Image:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('img-sig')); ?>" name="<?php echo esc_attr($this->get_field_name('img-sig')); ?>" type="text" value="<?php echo wp_kses_post($instance['img-sig']); ?>" />
            </label>
        </p>

        <?php
    }

}

function cyarb_register_author_info() {
    register_widget('Cyarb_author_info');
}

add_action('widgets_init', 'cyarb_register_author_info');

/**
 * About Us Widget
 */
class Cyarb_about_info extends WP_Widget{

    function __construct(){
        $widget_ops = array('description' => esc_html__('Display Social Info', 'cyarb-toolkit'));
        parent::__construct( false, esc_html__('Cyarb Social Info', 'cyarb-toolkit'), $widget_ops);
    }

    function widget($args, $instance){
        extract($args);
        global $cyarb_theme;

        echo wp_kses_post($before_widget);
        ?>
            <div class="widget_follow_us">

                <?php if( $instance['follow_us'] != '' ): ?>
                    <h3 class="widget-title"><span><?php echo esc_html($instance['follow_us']); ?></span></h3>
                <?php endif; ?>
                <ul>
                    <?php if( $instance['facebook_link'] != '' ): ?>
                        <li>
                            <a href="<?php echo esc_url( $instance['facebook_link'] ); ?>" target="_blank"><?php echo esc_html($instance['fb_text']); ?></a>
                        </li>
                    <?php endif; ?>
                    <?php if( $instance['twitter_link'] != '' ): ?>
                        <li>
                            <a href="<?php echo esc_url( $instance['twitter_link'] ); ?>" target="_blank"><?php echo esc_html($instance['twit_text']); ?></a>
                        </li>
                    <?php endif; ?>
                    <?php if( $instance['instagram_link'] != '' ): ?>
                        <li>
                            <a href="<?php echo esc_url( $instance['instagram_link'] ); ?>" target="_blank"><?php echo esc_html($instance['insta_text']); ?></a>
                        </li>
                    <?php endif; ?>
                    <?php if( $instance['linkedin_link'] != '' ): ?>
                        <li>
                            <a href="<?php echo esc_url( $instance['pinterest_link'] ); ?>" target="_blank"><?php echo esc_html($instance['pin_text']); ?></a>
                        </li>
                    <?php endif; ?>
                    <?php if( $instance['linkedin_link'] != '' ): ?>
                        <li>
                            <a href="<?php echo esc_url( $instance['linkedin_link'] ); ?>" target="_blank"><?php echo esc_html($instance['link_text']); ?></a>
                        </li>
                    <?php endif; ?>
                </ul>
            </div>
        <?php
        echo wp_kses_post($after_widget);
    }

    function update($new_instance, $old_instance){
        $instance                    = $old_instance;
        $instance['follow_us']       = $new_instance['follow_us'];
        $instance['facebook_link']   = $new_instance['facebook_link'];
        $instance['twitter_link']    = $new_instance['twitter_link'];
        $instance['instagram_link']  = $new_instance['instagram_link'];
        $instance['linkedin_link']   = $new_instance['linkedin_link'];
        $instance['pinterest_link']  = $new_instance['pinterest_link'];
        $instance['fb_text']         = $new_instance['fb_text'];
        $instance['twit_text']       = $new_instance['twit_text'];
        $instance['insta_text']      = $new_instance['insta_text'];
        $instance['link_text']       = $new_instance['link_text'];
        $instance['pin_text']        = $new_instance['pin_text'];

        return $instance;
    }

    function form($instance){
        $defaults = array(
            'follow_us'         => esc_html__('Follow Us:', 'cyarb-toolkit'),
            'facebook_link'     => '#',
            'twitter_link'      => '#',
            'instagram_link'    => '#',
            'linkedin_link'     => '#',
            'pinterest_link'    => '',
            'fb_text'           => '#',
            'twit_text'         => '#',
            'insta_text'        => '#',
            'link_text'         => '#',
            'pin_text'          => '',
        );
        $instance = wp_parse_args((array)$instance, $defaults);
        ?>

        <p>
            <label for="<?php echo esc_attr($this->get_field_id('follow_us')); ?>">
                <?php esc_html_e('Follow Us:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('follow_us')); ?>" name="<?php echo esc_attr($this->get_field_name('follow_us')); ?>" type="text" value="<?php echo wp_kses_post($instance['follow_us']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('facebook_link')); ?>">
                <?php esc_html_e('Facebook Link:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('facebook_link')); ?>" name="<?php echo esc_attr($this->get_field_name('facebook_link')); ?>" type="text" value="<?php echo wp_kses_post($instance['facebook_link']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('fb_text')); ?>">
                <?php esc_html_e('Facebook Text:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('fb_text')); ?>" name="<?php echo esc_attr($this->get_field_name('fb_text')); ?>" type="text" value="<?php echo wp_kses_post($instance['fb_text']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('twitter_link')); ?>">
                <?php esc_html_e('Twitter Link:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('twitter_link')); ?>" name="<?php echo esc_attr($this->get_field_name('twitter_link')); ?>" type="text" value="<?php echo wp_kses_post($instance['twitter_link']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('twit_text')); ?>">
                <?php esc_html_e('Twitter Text:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('twit_text')); ?>" name="<?php echo esc_attr($this->get_field_name('twit_text')); ?>" type="text" value="<?php echo wp_kses_post($instance['twit_text']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('instagram_link')); ?>">
                <?php esc_html_e('Instagram Link:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('instagram_link')); ?>" name="<?php echo esc_attr($this->get_field_name('instagram_link')); ?>" type="text" value="<?php echo wp_kses_post($instance['instagram_link']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('insta_text')); ?>">
                <?php esc_html_e('Instagram Text:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('insta_text')); ?>" name="<?php echo esc_attr($this->get_field_name('insta_text')); ?>" type="text" value="<?php echo wp_kses_post($instance['insta_text']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('pinterest_link')); ?>">
                <?php esc_html_e('Pinterest Link:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('pinterest_link')); ?>" name="<?php echo esc_attr($this->get_field_name('pinterest_link')); ?>" type="text" value="<?php echo wp_kses_post($instance['pinterest_link']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('pin_text')); ?>">
                <?php esc_html_e('Pinterest Text:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('pin_text')); ?>" name="<?php echo esc_attr($this->get_field_name('pin_text')); ?>" type="text" value="<?php echo wp_kses_post($instance['pin_text']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('linkedin_link')); ?>">
                <?php esc_html_e('Linkedin Link:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('linkedin_link')); ?>" name="<?php echo esc_attr($this->get_field_name('linkedin_link')); ?>" type="text" value="<?php echo wp_kses_post($instance['linkedin_link']); ?>" />
            </label>
        </p>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('link_text')); ?>">
                <?php esc_html_e('Linkedin Text:', 'cyarb-toolkit'); ?>
                <input class="widget" id="<?php echo esc_attr($this->get_field_id('link_text')); ?>" name="<?php echo esc_attr($this->get_field_name('link_text')); ?>" type="text" value="<?php echo wp_kses_post($instance['link_text']); ?>" />
            </label>
        </p>

        <?php
    }

}

function cyarb_register_about_info() {
    register_widget('Cyarb_about_info');
}

add_action('widgets_init', 'cyarb_register_about_info');