/* Plugin Name: Instagram Feed Plugin URI: https://smashballoon.com/instagram-feed Description: Display beautifully clean, customizable, and responsive Instagram feeds Version: 1.6.2 Author: Smash Balloon Author URI: https://smashballoon.com/ License: GPLv2 or later Text Domain: instagram-feed Copyright 2018 Smash Balloon LLC (email : hey@smashballoon.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ define( 'SBIVER', '1.6.2' ); if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly //Include admin if ( is_admin() ) include dirname( __FILE__ ) .'/instagram-feed-admin.php'; // Add shortcodes add_shortcode('instagram-feed', 'display_instagram'); function display_instagram($atts, $content = null) { /******************* SHORTCODE OPTIONS ********************/ $options = get_option('sb_instagram_settings'); //Pass in shortcode attrbutes $atts = shortcode_atts( array( 'id' => isset($options[ 'sb_instagram_user_id' ]) ? $options[ 'sb_instagram_user_id' ] : '', 'width' => isset($options[ 'sb_instagram_width' ]) ? $options[ 'sb_instagram_width' ] : '', 'widthunit' => isset($options[ 'sb_instagram_width_unit' ]) ? $options[ 'sb_instagram_width_unit' ] : '', 'widthresp' => isset($options[ 'sb_instagram_feed_width_resp' ]) ? $options[ 'sb_instagram_feed_width_resp' ] : '', 'height' => isset($options[ 'sb_instagram_height' ]) ? $options[ 'sb_instagram_height' ] : '', 'heightunit' => isset($options[ 'sb_instagram_height_unit' ]) ? $options[ 'sb_instagram_height_unit' ] : '', 'sortby' => isset($options[ 'sb_instagram_sort' ]) ? $options[ 'sb_instagram_sort' ] : '', 'num' => isset($options[ 'sb_instagram_num' ]) ? $options[ 'sb_instagram_num' ] : '', 'cols' => isset($options[ 'sb_instagram_cols' ]) ? $options[ 'sb_instagram_cols' ] : '', 'disablemobile' => isset($options[ 'sb_instagram_disable_mobile' ]) ? $options[ 'sb_instagram_disable_mobile' ] : '', 'imagepadding' => isset($options[ 'sb_instagram_image_padding' ]) ? $options[ 'sb_instagram_image_padding' ] : '', 'imagepaddingunit' => isset($options[ 'sb_instagram_image_padding_unit' ]) ? $options[ 'sb_instagram_image_padding_unit' ] : '', 'background' => isset($options[ 'sb_instagram_background' ]) ? $options[ 'sb_instagram_background' ] : '', 'showbutton' => isset($options[ 'sb_instagram_show_btn' ]) ? $options[ 'sb_instagram_show_btn' ] : '', 'buttoncolor' => isset($options[ 'sb_instagram_btn_background' ]) ? $options[ 'sb_instagram_btn_background' ] : '', 'buttontextcolor' => isset($options[ 'sb_instagram_btn_text_color' ]) ? $options[ 'sb_instagram_btn_text_color' ] : '', 'buttontext' => isset($options[ 'sb_instagram_btn_text' ]) ? $options[ 'sb_instagram_btn_text' ] : '', 'imageres' => isset($options[ 'sb_instagram_image_res' ]) ? $options[ 'sb_instagram_image_res' ] : '', 'showfollow' => isset($options[ 'sb_instagram_show_follow_btn' ]) ? $options[ 'sb_instagram_show_follow_btn' ] : '', 'followcolor' => isset($options[ 'sb_instagram_folow_btn_background' ]) ? $options[ 'sb_instagram_folow_btn_background' ] : '', 'followtextcolor' => isset($options[ 'sb_instagram_follow_btn_text_color' ]) ? $options[ 'sb_instagram_follow_btn_text_color' ] : '', 'followtext' => isset($options[ 'sb_instagram_follow_btn_text' ]) ? $options[ 'sb_instagram_follow_btn_text' ] : '', 'showheader' => isset($options[ 'sb_instagram_show_header' ]) ? $options[ 'sb_instagram_show_header' ] : '', 'showbio' => isset($options[ 'sb_instagram_show_bio' ]) ? $options[ 'sb_instagram_show_bio' ] : '', 'headercolor' => isset($options[ 'sb_instagram_header_color' ]) ? $options[ 'sb_instagram_header_color' ] : '', 'class' => '', 'ajaxtheme' => isset($options[ 'sb_instagram_ajax_theme' ]) ? $options[ 'sb_instagram_ajax_theme' ] : '' ), $atts); /******************* VARS ********************/ //User ID $sb_instagram_user_id = trim($atts['id']); if ( empty( $sb_instagram_user_id ) ) { $sb_instagram_settings = get_option( 'sb_instagram_settings' ); $at_arr = isset( $sb_instagram_settings[ 'sb_instagram_at' ] ) ? explode( '.', trim( $sb_instagram_settings[ 'sb_instagram_at' ] ), 2) : array(); $sb_instagram_user_id = $at_arr[0]; } //Container styles $sb_instagram_width = $atts['width']; $sb_instagram_width_unit = $atts['widthunit']; $sb_instagram_height = $atts['height']; $sb_instagram_height_unit = $atts['heightunit']; $sb_instagram_image_padding = $atts['imagepadding']; $sb_instagram_image_padding_unit = $atts['imagepaddingunit']; $sb_instagram_background = $atts['background']; //Set to be 100% width on mobile? $sb_instagram_width_resp = $atts[ 'widthresp' ]; ( $sb_instagram_width_resp == 'on' || $sb_instagram_width_resp == 'true' || $sb_instagram_width_resp == true ) ? $sb_instagram_width_resp = true : $sb_instagram_width_resp = false; if( $atts[ 'widthresp' ] == 'false' ) $sb_instagram_width_resp = false; //Layout options $sb_instagram_cols = $atts['cols']; $sb_instagram_styles = 'style="'; if($sb_instagram_cols == 1) $sb_instagram_styles .= 'max-width: 640px; '; if ( !empty($sb_instagram_width) ) $sb_instagram_styles .= 'width:' . $sb_instagram_width . $sb_instagram_width_unit .'; '; if ( !empty($sb_instagram_height) && $sb_instagram_height != '0' ) $sb_instagram_styles .= 'height:' . $sb_instagram_height . $sb_instagram_height_unit .'; '; if ( !empty($sb_instagram_background) ) $sb_instagram_styles .= 'background-color: ' . $sb_instagram_background . '; '; if ( !empty($sb_instagram_image_padding) ) $sb_instagram_styles .= 'padding-bottom: ' . (2*intval($sb_instagram_image_padding)).$sb_instagram_image_padding_unit . '; '; $sb_instagram_styles .= '"'; //Header $sb_instagram_show_header = $atts['showheader']; ( $sb_instagram_show_header == 'on' || $sb_instagram_show_header == 'true' || $sb_instagram_show_header == true ) ? $sb_instagram_show_header = true : $sb_instagram_show_header = false; if( $atts[ 'showheader' ] === 'false' ) $sb_instagram_show_header = false; $sb_instagram_header_color = str_replace('#', '', $atts['headercolor']); $sb_instagram_show_bio = $atts['showbio']; ( $sb_instagram_show_bio == 'on' || $sb_instagram_show_bio == 'true' || $sb_instagram_show_bio ) ? $sb_instagram_show_bio = 'true' : $sb_instagram_show_bio = 'false'; if( $atts[ 'showbio' ] === 'false' ) $sb_instagram_show_bio = false; // button text $sb_instagram_follow_btn_text = __( $atts['followtext'], 'instagram-feed' ); $sb_instagram_load_btn_text = __( $atts['buttontext'], 'instagram-feed' ); //As this is a new option in the update then set it to be true if it doesn't exist yet if ( !array_key_exists( 'sb_instagram_show_bio', $options ) ) $sb_instagram_show_bio = 'true'; //Load more button $sb_instagram_show_btn = $atts['showbutton']; ( $sb_instagram_show_btn == 'on' || $sb_instagram_show_btn == 'true' || $sb_instagram_show_btn == true ) ? $sb_instagram_show_btn = true : $sb_instagram_show_btn = false; if( $atts[ 'showbutton' ] === 'false' ) $sb_instagram_show_btn = false; $sb_instagram_btn_background = str_replace('#', '', $atts['buttoncolor']); $sb_instagram_btn_text_color = str_replace('#', '', $atts['buttontextcolor']); //Load more button styles $sb_instagram_button_styles = 'style="'; if ( !empty($sb_instagram_btn_background) ) $sb_instagram_button_styles .= 'background: #'.$sb_instagram_btn_background.'; '; if ( !empty($sb_instagram_btn_text_color) ) $sb_instagram_button_styles .= 'color: #'.$sb_instagram_btn_text_color.';'; $sb_instagram_button_styles .= '"'; //Follow button vars $sb_instagram_show_follow_btn = $atts['showfollow']; ( $sb_instagram_show_follow_btn == 'on' || $sb_instagram_show_follow_btn == 'true' || $sb_instagram_show_follow_btn == true ) ? $sb_instagram_show_follow_btn = true : $sb_instagram_show_follow_btn = false; if( $atts[ 'showfollow' ] === 'false' ) $sb_instagram_show_follow_btn = false; $sb_instagram_follow_btn_background = str_replace('#', '', $atts['followcolor']); $sb_instagram_follow_btn_text_color = str_replace('#', '', $atts['followtextcolor']); //Follow button styles $sb_instagram_follow_btn_styles = 'style="'; if ( !empty($sb_instagram_follow_btn_background) ) $sb_instagram_follow_btn_styles .= 'background: #'.$sb_instagram_follow_btn_background.'; '; if ( !empty($sb_instagram_follow_btn_text_color) ) $sb_instagram_follow_btn_styles .= 'color: #'.$sb_instagram_follow_btn_text_color.';'; $sb_instagram_follow_btn_styles .= '"'; //Follow button HTML $sb_instagram_follow_btn_html = '
'; //Mobile $sb_instagram_disable_mobile = $atts['disablemobile']; ( $sb_instagram_disable_mobile == 'on' || $sb_instagram_disable_mobile == 'true' || $sb_instagram_disable_mobile == true ) ? $sb_instagram_disable_mobile = ' sbi_disable_mobile' : $sb_instagram_disable_mobile = ''; if( $atts[ 'disablemobile' ] === 'false' ) $sb_instagram_disable_mobile = ''; //Class !empty( $atts['class'] ) ? $sbi_class = ' ' . trim($atts['class']) : $sbi_class = ''; //Ajax theme $sb_instagram_ajax_theme = $atts['ajaxtheme']; ( $sb_instagram_ajax_theme == 'on' || $sb_instagram_ajax_theme == 'true' || $sb_instagram_ajax_theme == true ) ? $sb_instagram_ajax_theme = true : $sb_instagram_ajax_theme = false; if( $atts[ 'disablemobile' ] === 'false' ) $sb_instagram_ajax_theme = false; /******************* CONTENT ********************/ $sb_instagram_content = '' . __( 'Please enter a User ID on the Instagram Feed plugin Settings page.', 'instagram-feed' ) . '
' . __( 'Please enter an Access Token on the Instagram Feed plugin Settings page.', 'instagram-feed' ) . '