Skip to content

Commit

Permalink
Merge pull request #31 from devuri/2.5.0
Browse files Browse the repository at this point in the history
2.5.0
  • Loading branch information
devuri authored Nov 30, 2020
2 parents 423ca69 + 12c1a53 commit d838772
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 20 deletions.
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://switchwebdev.com/wordpress-plugins/
Tags: Instagram, Instagram photos, Instagram feed, Instagram widget, Instagram gallery
Requires at least: 3.4
Tested up to: 5.5
Stable tag: 2.4.5
Stable tag: 2.5.0
Requires PHP: 5.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
2 changes: 1 addition & 1 deletion sim-social.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Sim Social Feed
* Plugin URI: https://switchwebdev.com/wordpress-plugins/
* Description: Easily Display Social Media Photo Feed for Instagram. The feed will schedule twicedaily updates, you can also update manually with a single click.
* Version: 2.4.5
* Version: 2.5.0
* Requires at least: 3.4
* Requires PHP: 5.6
* Author: SwitchWebdev.com
Expand Down
50 changes: 48 additions & 2 deletions src/InstagramSocialFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,27 @@ public static function token_expire_date() {
/**
* List images
*
* @param string $limit .
* @param string $w .
* @param string $css .
*/
public static function images( $w = '250', $css = '' ) {
public static function images( $limit = 6, $w = '250', $css = '' ) {
echo '<div class="row" style="display: inline-flex; flex-wrap: wrap; ' . $css . '">'; // @codingStandardsIgnoreLine
if ( is_array( get_option( 'simsf_user_media' ) ) ) {
/**
* Get IG list
* limit the return values
*/
$i = 0;
foreach ( get_option( 'simsf_user_media' ) as $mkey => $media ) {
if ( isset( $media->caption ) ) {
$caption = $media->caption;
} else {
$caption = '';
}
if ( 'VIDEO' === $media->media_type ) continue;
echo '<div class="ig-image" style="margin:2px;"><a href="' . esc_url( $media->permalink ) . '" target="_blank"><img class="img-responsive" width="' . esc_attr( $w ) . '" src="' . esc_url( $media->media_url ) . '" alt="' . esc_attr( $caption ) . '"></a></div>';
echo '<div class="ig-image" style="margin:2px;"><a href="' . esc_url( $media->permalink ) . '" target="_blank"><img class="img-responsive" height="230" width="' . esc_attr( $w ) . '" src="' . esc_url( $media->media_url ) . '" alt="' . esc_attr( $caption ) . '"></a></div>';
if ( ++$i === $limit ) break;
}
}
echo '</div>';
Expand Down Expand Up @@ -192,4 +199,43 @@ public static function igfeed( $limit = 6 ) {
</div>
<?php
}

/**
* List images
*
* @param integer $limit .
* @param string $w .
* @param string $h .
* @param string $css .
*
* @return void
*/
public static function igfeedlinked( $limit = 6, $w = '250', $h = '240', $css = '' ) {
echo '<div class="row" style="display: inline-flex; flex-wrap: wrap; ' . $css . '">'; // @codingStandardsIgnoreLine
if ( is_array( get_option( 'simsf_user_media' ) ) ) {
/**
* Get IG list
* limit the return values
*/
$i = 0;
foreach ( get_option( 'simsf_user_media' ) as $mkey => $media ) {
if ( isset( $media->caption ) ) {
$caption = $media->caption;
} else {
$caption = '';
}
if ( 'VIDEO' === $media->media_type ) continue;
$output = '<div class="ig-image" style="margin:2px;"><a href="';
$output .= esc_url( $media->permalink );
$output .= '" target="_blank"><img style="';
$output .= 'width:' . esc_attr( $w ) . 'px; height:';
$output .= esc_attr( $h ) . 'px;" class="img-responsive" width="';
$output .= esc_attr( $w ) . '" src="' . esc_url( $media->media_url );
$output .= '" alt="' . esc_attr( $caption ) . '"></a></div>';
echo $output; // @codingStandardsIgnoreLine
if ( ++$i === $limit ) break;
}
}
echo '</div>';
}
}
10 changes: 5 additions & 5 deletions src/schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
use SimSocialFeed\InstagramSocialFeed;

/**
* run the sim social feed update
* Run the sim social feed update
*/
add_action( 'sim_social_feed_cron', 'sim_social_igfeed_update' );
function sim_social_igfeed_update(){
function sim_social_igfeed_update() {
/**
* update user media
* Update user media
*/
if ( InstagramSocialFeed::is_request_ok() ) :
$ig_user_media = InstagramSocialFeed::user_media();
update_option('simsf_user_media', $ig_user_media->data );
update_option( 'simsf_user_media', $ig_user_media->data );
endif;
}
add_action( 'sim_social_feed_cron', 'sim_social_igfeed_update' );
39 changes: 28 additions & 11 deletions src/shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,43 @@
use SimSocialFeed\InstagramSocialFeed;

/**
* shortcode to use [ig_socialfeed limit="6"]
* Shortcode to use [ig_socialfeed limit="6" linked="yes"]
*
* @param array $atts .
*
* @return string $output_sfd
*/
add_shortcode('ig_socialfeed', 'simsf_igmedia_feed');
function simsf_igmedia_feed($atts) {
function simsf_igmedia_feed( $atts ) {

$a = shortcode_atts(array(
'limit' => 6,
), $atts);
$a = shortcode_atts(
array(
'limit' => 6,
'linked' => 'no',
),
$atts
);

// params
$limit = $a['limit'];
// params .
$limit = absint( $a['limit'] );
$linked = strtolower( $a['linked'] );

/**
* load the grid styles
* Load the grid styles
*/
wp_enqueue_style('sim-social-feed-grid');
wp_enqueue_style( 'sim-social-feed-grid' );

ob_start();
InstagramSocialFeed::igfeed($limit);

if ( 'yes' === $linked ) {
InstagramSocialFeed::igfeedlinked( $limit );
} else {
InstagramSocialFeed::igfeed( $limit );
}

$output_sfd = ob_get_contents();

ob_end_clean();

return $output_sfd;
}
add_shortcode( 'ig_socialfeed', 'simsf_igmedia_feed' );

0 comments on commit d838772

Please sign in to comment.