<?php
/**
 *
 * RS Space
 * @since 1.0.0
 * @version 1.0.0
 *
 */
function rs_instagram( $atts, $content = '', $id = '' ) {
  extract( shortcode_atts( array(
    'username'     => '',
    'limit'        => '',
    'link'         => '',
    'size'         => ''
  ), $atts ) );

  global $wp_widget_factory;

  $output = '';
  if( is_object( $wp_widget_factory ) && isset( $wp_widget_factory->widgets, $wp_widget_factory->widgets['null_instagram_widget'] ) ):
    ob_start();
    the_widget('null_instagram_widget', array('username' => $username, 'number' => $limit, 'size' => $size)); 
    $output .= ob_get_clean();
  endif;

  return $output;
}

add_shortcode('rs_instagram', 'rs_instagram');
