From ba1c462079b1900190904a76ab6bf8a69ca0c1d7 Mon Sep 17 00:00:00 2001 From: Cameron Jones Date: Sat, 28 May 2016 16:32:35 +1000 Subject: [PATCH 1/5] Adding new interface for page tabs to the widget form --- facebook-page-feed-graph-api.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/facebook-page-feed-graph-api.php b/facebook-page-feed-graph-api.php index f0ff543..6edb125 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' ) ); @@ -408,12 +409,21 @@ 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. + $oldtabs = esc_attr( $tabs ); + $newtabs = explode( ',', $tabs ); + $tabs = $newtabs; + foreach( CJW_FBPP_TABS as $tab ) { + 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. - $oldtabs = esc_attr( $tabs ); - $newtabs = explode( ',', $tabs ); - $tabs = $newtabs; + if( !is_array( $tabs ) ) { + $oldtabs = esc_attr( $tabs ); + $newtabs = explode( ',', $tabs ); + $tabs = $newtabs; + } foreach( CJW_FBPP_TABS as $tab ) { - 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");