protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('element_id' => '', 'source' => '', 'cell_height' => 120, 'space' => 20, 'template' => '', 'class' => ''), $atts);
     /**
      * Enqueue script
      */
     LemonGrid::include_script();
     $templateParams = json_decode($atts['template'], true);
     $atts['class_id'] = 'lemon_grid_id_' . $atts['element_id'];
     $atts['template'] = $templateParams['template'];
     $atts['template_params'] = $templateParams;
     /**
      * wp_query
      */
     list($args, $wp_query) = vc_build_loop_query($atts['source']);
     $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
     if ($paged > 1) {
         $args['paged'] = $paged;
         $wp_query = new WP_Query($args);
     }
     $atts['posts'] = $wp_query;
     wp_enqueue_style('tb-lemongrid-custom-script', TB_CSS . 'lemongrid-custom-script.css');
     wp_add_inline_style('tb-lemongrid-custom-script', renderGridCustomSpaceCss($atts['class_id'], $atts['space']));
     return lgLoadTemplate($atts, $content);
 }
Exemple #2
0
    /**
     * widget
     *
     * @param array $args
     * @param array $instance
     * @return HTML
     */
    public function widget($args, $instance)
    {
        extract($args);
        switch ($instance['type']) {
            case 'social':
                /* Social */
                if ($instance['social'] == 'instagram') {
                    require_once TB_INCLUDES . 'socials/instagram.class.php';
                    $insta = new LG_Instagram();
                    $insta->username = $instance['username'];
                    $insta->client_id = $instance['apikey'];
                    // '2a87113cbe65405aa10b491fc6e39242';
                    $insta->slice = (int) $instance['count'];
                    $media = $insta->getMedia();
                } elseif ($instance['social'] == 'flickr') {
                    require_once TB_INCLUDES . 'socials/flickr.class.php';
                    $flickr = new LG_Flickr();
                    $flickr->username = $instance['username'];
                    $flickr->key = $instance['apikey'];
                    // 'f668d07759169ca3db29e9a60bff128d';
                    $flickr->slice = (int) $instance['count'];
                    $media = $flickr->getMedia();
                }
                $instance['media'] = isset($media) ? $media : array();
                break;
            case 'gallery':
                # code...
                break;
            default:
                /* POST */
                # code...
                break;
        }
        $instance['element_id'] = $instance['wg_id'];
        $instance['class_id'] = 'lemon_grid_id_' . $instance['element_id'];
        /**
         * Enqueue script
         */
        LemonGrid::include_script();
        /**
         * Lib JS Imagelightbox
         */
        wp_enqueue_script('tb-imagelightbox', 'http://osvaldas.info/examples/image-lightbox-responsive-touch-friendly/imagelightbox.js', array('jquery'), '1.0.0', true);
        wp_enqueue_style('tb-lemongrid-custom-script', TB_CSS . 'lemongrid-custom-script.css');
        wp_add_inline_style('tb-lemongrid-custom-script', renderGridCustomSpaceCss($instance['class_id'], $instance['space']));
        $content = lgLoadTemplate($instance);
        echo sprintf('
			%s %s %s', $before_widget, $content, $after_widget);
    }
 protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('element_id' => '', 'images' => '', 'cell_height' => 120, 'space' => 20, 'template' => '', 'class' => ''), $atts);
     /**
      * Enqueue script
      */
     LemonGrid::include_script();
     /**
      * Lib JS Imagelightbox
      */
     wp_enqueue_script('tb-imagelightbox', 'http://osvaldas.info/examples/image-lightbox-responsive-touch-friendly/imagelightbox.js', array('jquery'), '1.0.0', true);
     $atts['class_id'] = 'lemon_grid_id_' . $atts['element_id'];
     wp_enqueue_style('tb-lemongrid-custom-script', TB_CSS . 'lemongrid-custom-script.css');
     wp_add_inline_style('tb-lemongrid-custom-script', renderGridCustomSpaceCss($atts['class_id'], $atts['space']));
     return lgLoadTemplate($atts, $content);
 }
 protected function content($atts, $content = null)
 {
     $atts = shortcode_atts(array('element_id' => '', 'social' => 'instagram', 'username' => '', 'api_key' => '', 'count' => 9, 'cell_height' => 120, 'space' => 20, 'template' => '', 'class' => ''), $atts);
     /**
      * Enqueue script
      */
     LemonGrid::include_script();
     /**
      * Setup social
      */
     switch ($atts['social']) {
         case 'instagram':
             require_once TB_INCLUDES . 'socials/instagram.class.php';
             $insta = new LG_Instagram();
             $insta->username = $atts['username'];
             $insta->client_id = $atts['api_key'];
             // '2a87113cbe65405aa10b491fc6e39242';
             $insta->slice = (int) $atts['count'];
             $media = $insta->getMedia();
             break;
         case 'flickr':
             require_once TB_INCLUDES . 'socials/flickr.class.php';
             $flickr = new LG_Flickr();
             $flickr->username = $atts['username'];
             $flickr->key = $atts['api_key'];
             // 'f668d07759169ca3db29e9a60bff128d';
             $flickr->slice = (int) $atts['count'];
             $media = $flickr->getMedia();
             break;
     }
     $atts['media'] = isset($media) ? $media : array();
     $atts['class_id'] = 'lemon_grid_id_' . $atts['element_id'];
     wp_enqueue_style('tb-lemongrid-custom-script', TB_CSS . 'lemongrid-custom-script.css');
     wp_add_inline_style('tb-lemongrid-custom-script', renderGridCustomSpaceCss($atts['class_id'], $atts['space']));
     return lgLoadTemplate($atts, $content);
 }