public function widget($args, $instance)
    {
        extract($instance);
        print $args['before_widget'];
        print $args['before_title'] . $title . $args['after_title'];
        $instagram_api = QodeStockholmInstagramApi::getInstance();
        $images_array = $instagram_api->getImages($number_of_photos, $tag, array('use_transients' => true, 'transient_name' => $args['widget_id'], 'transient_time' => $transient_time));
        $number_of_cols = $number_of_cols == '' ? 3 : $number_of_cols;
        if (is_array($images_array) && count($images_array)) {
            ?>
            <ul class="qode_instagram_feed clearfix col_<?php 
            echo esc_attr($number_of_cols);
            ?>
">
            <?php 
            foreach ($images_array as $image) {
                ?>
                <li>
                    <a href="<?php 
                echo esc_url($instagram_api->getHelper()->getImageLink($image));
                ?>
" target="_blank">
                        <?php 
                print $instagram_api->getHelper()->getImageHTML($image, $image_size);
                ?>
                    </a>
                </li>
            <?php 
            }
            ?>
            </ul>
        <?php 
        }
        print $args['after_widget'];
    }
Beispiel #2
0
    public function render($factory)
    {
        $instagram_api = QodeStockholmInstagramApi::getInstance();
        $message = '';
        //if code wasn't saved to database
        if (!get_option('qode_instagram_code')) {
            //check if code parameter is set in URL. That means that user has connected with Instagram
            if (!empty($_GET['code'])) {
                //update code option so we can use it later
                $instagram_api->storeCode();
                $instagram_api->getAccessToken();
                $message = esc_html__('You have successfully connected with your Instagram account. If you have any issues fetching data from Instagram try reconnecting.', 'qode');
            } else {
                $instagram_api->storeCodeRequestURI();
            }
        }
        $buttonText = $instagram_api->hasUserConnected() ? esc_html__('Re-connect with Instagram', 'qode') : esc_html__('Connect with Instagram', 'qode');
        ?>
		<?php 
        if ($message !== '') {
            ?>
			<div class="alert alert-success" style="margin-top: 20px;">
				<span><?php 
            echo esc_html($message);
            ?>
</span>
			</div>
		<?php 
        }
        ?>
		<div class="qodef-page-form-section" id="qode_enable_social_share">

			<div class="qodef-field-desc">
				<h4><?php 
        esc_html_e('Connect with Instagram', 'qode');
        ?>
</h4>

				<p><?php 
        esc_html_e('Connecting with Instagram will enable you to show your latest photos on your site', 'qode');
        ?>
</p>
			</div>
			<!-- close div.qodef-field-desc -->

			<div class="qodef-section-content">
				<div class="container-fluid">
					<div class="row">
						<div class="col-lg-6">
							<a class="btn btn-primary" href="<?php 
        echo esc_url($instagram_api->getAuthorizeUrl());
        ?>
"><?php 
        echo esc_html($buttonText);
        ?>
</a>
						</div>
						<?php 
        if ($instagram_api->hasUserConnected()) {
            ?>
							<div class="col-lg-6">
								<a id="qodef-instagram-disconnect-button" class="btn btn-primary" href="#"><?php 
            esc_html_e('Disconnect from Instagram', 'qode');
            ?>
</a>
								<input type="hidden" data-name="current-page-url" value="<?php 
            echo esc_url($instagram_api->buildCurrentPageURI());
            ?>
"/>
							</div>
						<?php 
        }
        ?>
					</div>
				</div>
			</div>
			<!-- close div.qodef-section-content -->

		</div>
	<?php 
    }
Beispiel #3
0
 /**
  * Wrapper function for disconnecting from instagram.
  * Hooks to wp_ajax_qode_instagram_disconnect ajax action
  *
  * @see QodeStockholmInstagramApi::obtainRequestToken()
  */
 function qode_hook_instagram_disconnect_ajax()
 {
     QodeStockholmInstagramApi::getInstance()->disconnectUser();
 }