diff --git a/facebook-page-feed-graph-api.php b/facebook-page-feed-graph-api.php index f0ff543..811ec15 100644 --- a/facebook-page-feed-graph-api.php +++ b/facebook-page-feed-graph-api.php @@ -29,6 +29,7 @@ public function __construct() { define( 'CJW_FBPP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'CJW_FBPP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'CJW_FBPP_PLUGIN_VER', '1.5.3' ); + define( 'CJW_FBPP_TABS', array( 'timeline', 'events', 'messages' ) ); //Add all the hooks and actions add_shortcode( 'facebook-page-plugin', array( $this, 'facebook_page_plugin' ) ); @@ -278,7 +279,16 @@ public function widget( $args, $instance ) { $shortcode .= ' facepile="' . $facepile . '"'; } if( isset( $tabs ) && !empty( $tabs ) ){ - $shortcode .= ' tabs="' . $tabs . '"'; + if( is_array( $tabs ) ) { + $shortcode .= ' tabs="'; + for( $i = 0; $i < count( $tabs ); $i++ ) { + $shortcode .= $tabs[$i]; + $shortcode .= ( $i != count( $tabs ) - 1 ? ',' : '' ); + } + $shortcode .= '"'; + } else { + $shortcode .= ' tabs="' . $tabs . '"'; + } } if( isset( $language ) && !empty( $language ) ){ $shortcode .= ' language="' . $language . '"'; @@ -408,12 +418,23 @@ public function form( $instance ) { echo ''; echo ' '; echo '

'; - echo '

'; - echo ''; - echo ' '; - echo '

'; + echo '

'; + _e( 'Page Tabs:', 'facebook-page-feed-graph-api' ); + if( !empty( CJW_FBPP_TABS ) ) { + // First we should convert the string to an array as that's how it will be stored moving forward. + if( !is_array( $tabs ) ) { + $oldtabs = esc_attr( $tabs ); + $newtabs = explode( ',', $tabs ); + $tabs = $newtabs; + } + foreach( CJW_FBPP_TABS as $tab ) { + echo '
'; + } + } + echo '

'; echo '

'; echo '

'; $return .= '

'; $return .= '

'; - $return .= '

'; + $return .= '

'; $return .= '

'; $return .= '

'; diff --git a/js/facebook-page-plugin-admin.js b/js/facebook-page-plugin-admin.js index 9560c4b..f666e3f 100644 --- a/js/facebook-page-plugin-admin.js +++ b/js/facebook-page-plugin-admin.js @@ -30,8 +30,22 @@ $shortcode += 'cover="' + $cover + '" '; var $facepile = $('#fbpp-facepile').prop("checked"); $shortcode += 'facepile="' + $facepile + '" '; - var $tabs = $('#fbpp-tabs').val(); - $shortcode += 'tabs="' + $tabs + '" '; + var $tabs = []; + $('.fbpp-tabs').each(function(){ + if( $(this).prop('checked') == true ) { + $tabs.push( $(this).attr('name' ) ); + } + }); + if($tabs.length > 0){ + var $tabstring = ''; + for( $i = 0; $i < $tabs.length; $i++ ) { + $tabstring += $tabs[$i]; + if( $i != $tabs.length - 1 ) { + $tabstring += ',' + } + } + $shortcode += 'tabs="' + $tabstring + '" '; + } var $cta = $('#fbpp-cta').prop("checked"); $shortcode += 'cta="' + $cta + '" '; var $small = $('#fbpp-small').prop("checked");