Responsive Facebook Page Plugin - Version 1.5.0

Version Description

  • Migrated to object oriented
  • Fixed languages XML file being blocked by iThemes Security
  • Added option for switching between HTML5/XHTML
  • Fixed HTML issue with dashboard widget
  • Added script that makes the plugin fully responsive
Download this release

Release Info

Developer cameronjonesweb
Plugin Icon 128x128 Responsive Facebook Page Plugin
Version 1.5.0
Comparing to
See all releases

Code changes from version 1.4.1 to 1.5.0

facebook-page-feed-graph-api.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Facebook Page Plugin
4
  * Plugin URI: https://cameronjones.x10.mx/projects/facebook-page-plugin
5
  * Description: It's time to upgrade from your old like box! Display the Facebook Page Plugin from the Graph API using a shortcode or widget. Now available in 95 different languages
6
- * Version: 1.4.1
7
  * Author: Cameron Jones
8
  * Author URI: http://cameronjones.x10.mx
9
  * License: GPLv2
@@ -22,136 +22,178 @@
22
 
23
  defined( 'ABSPATH' ) or die();
24
 
25
- //Hooks
26
- add_shortcode( 'facebook-page-plugin', 'facebook_page_plugin' );
27
- add_filter( 'widget_text', 'do_shortcode' );
28
- add_action( 'wp_dashboard_setup', 'facebook_page_plugin_dashboard_widget' );
29
- add_action( 'admin_enqueue_scripts', 'facebook_page_plugin_admin_resources' );
30
- add_action( 'widgets_init', 'facebook_page_plugin_load_widget' );
31
- add_action( 'admin_notices', 'facebook_page_plugin_admin_notice' );
32
- add_action( 'admin_init', 'facebook_page_plugin_admin_notice_ignore' );
33
- add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'facebook_page_plugin_action_links' );
34
 
35
- function facebook_page_plugin( $filter ) {
36
- $return = NULL;
37
- $a = shortcode_atts( array(
38
- 'href' => NULL,
39
- 'width' => 340,
40
- 'height' => 130,
41
- 'cover' => NULL,
42
- 'facepile' => NULL,
43
- 'posts' => NULL,
44
- 'tabs' => array(),
45
- 'language' => get_bloginfo('language'),
46
- 'cta' => NULL,
47
- 'small' => NULL,
48
- 'adapt' => NULL,
49
- 'link' => true,
50
- 'linktext' => NULL,
51
- ), $filter );
52
- if(isset($a['href']) && !empty($a['href'])){
53
- $a['language'] = str_replace("-", "_", $a['language']);
54
- $return .= '<div id="fb-root" data-version="1.4.1"></div><script async>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/' . $a['language'] . '/sdk.js#xfbml=1&version=v2.4";fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\'));</script>';
55
- $return .= '<div class="fb-page" data-version="1.4.1" data-href="https://facebook.com/' . $a["href"] . '" ';
56
- if(isset($a['width']) && !empty($a['width'])){
57
- $return .= ' data-width="' . $a['width'] . '"';
58
- }
59
- if(isset($a['height']) && !empty($a['height'])){
60
- $return .= ' data-height="' . $a['height'] . '"';
61
- }
62
- if(isset($a['cover']) && !empty($a['cover'])){
63
- if($a['cover'] == "false"){
64
- $return .= ' data-hide-cover="true"';
65
- } else if($a['cover'] == "true"){
66
- $return .= ' data-hide-cover="false"';
67
- }
68
- }
69
- if(isset($a['facepile']) && !empty($a['facepile'])){
70
- $return .= ' data-show-facepile="' . $a['facepile'] . '"';
71
- }
72
- if(isset($a['tabs']) && !empty($a['tabs'])){
73
- $return .= ' data-tabs="' . $a['tabs'] . '"';
74
- } else if(isset($a['posts']) && !empty($a['posts'])){
75
- if($a['posts'] == 'true'){
76
- $return .= ' data-tabs="timeline"';
77
- } else {
78
- $return .= ' data-tabs="false"';
79
  }
80
  }
81
- if(isset($a['cta']) && !empty($a['cta'])){
82
- $return .= ' data-hide-cta="' . $a['cta'] . '"';
83
- }
84
- if(isset($a['small']) && !empty($a['small'])){
85
- $return .= ' data-small-header="' . $a['small'] . '"';
86
- }
87
- if(isset($a['adapt']) && !empty($a['adapt'])){
88
- $return .= ' data-adapt-container-width="' . $a['adapt'] . '"';
89
- } else {
90
- $return .= ' data-adapt-container-width="false"';
91
- }
92
- $return .= '><div class="fb-xfbml-parse-ignore">';
93
- if( $a['link'] == 'true' ){
94
- $return .= '<blockquote cite="https://www.facebook.com/' . $a['href'] . '">';
95
- $return .= '<a href="https://www.facebook.com/' . $a['href'] . '">';
96
- if( empty( $a['linktext'] ) ) {
97
- $return .= 'https://www.facebook.com/' . $a['href'];
98
- } else {
99
- $return .= $a['linktext'];
100
- }
101
- $return .= '</a>';
102
- $return .= '</blockquote>';
103
  }
104
- $return .= '</div></div>';
105
  }
106
- return $return;
107
- }
108
 
109
- function facebook_page_plugin_dashboard_widget() {
110
- wp_add_dashboard_widget( 'facebook-page-plugin-shortcode-generator', __( 'Facebook Page Plugin Shortcode Generator', 'facebook-page-feed-graph-api' ), 'facebook_page_plugin_dashboard_widget_callback' );
111
- }
 
 
112
 
113
- function facebook_page_plugin_dashboard_widget_callback() {
114
- try {
115
- //$lang_xml = file_get_contents('https://www.facebook.com/translations/FacebookLocales.xml');
116
- $lang_xml = file_get_contents( plugin_dir_url( __FILE__ ) . 'lang.xml');
117
- }catch(Exception $ex){
118
- $lang_xml = NULL;
119
  }
120
- if(isset($lang_xml) && !empty($lang_xml)){
121
- $langs = new SimpleXMLElement($lang_xml);
122
- } else {
123
- $langs = NULL;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
- echo '<form>';
126
- echo '<p><label>' . __( 'Facebook Page URL', 'facebook-page-feed-graph-api' ) . ': <input type="url" id="fbpp-href" /></label></p>';
127
- echo '<p><label>' . __( 'Width (pixels)', 'facebook-page-feed-graph-api' ) . ': <input type="number" max="500" min="180" id="fbpp-width" /></label></p>';
128
- echo '<p><label>' . __( 'Height (pixels)', 'facebook-page-feed-graph-api' ) . ': <input type="number" min="70" id="fbpp-height" /></label></p>';
129
- echo '<p><label>' . __( 'Show Cover Photo', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-cover" /></label></p>';
130
- echo '<p><label>' . __( 'Show Facepile', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-facepile" /></label></p>';
131
- echo '<p><label>' . __( 'Page Tabs (formerly posts)', 'facebook-page-feed-graph-api' ) . ': <select id="fbpp-posts"><option value="">None</option><option value="timeline">Timeline</option><option value="messages">Messages</option><option value="timeline,messages">Timeline, Messages</option><option value="messages,timeline">Messages, Timeline</option></select></label></p>';
132
- echo '<p><label>' . __( 'Hide Call To Action', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-cta" /></label></p>';
133
- echo '<p><label>' . __( 'Small Header', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-small" /></label></p>';
134
- echo '<p><label>' . __( 'Adaptive Width', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-adapt" checked /></label></p>';
135
- echo '<p><label>' . __( 'Display link while loading', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-link" checked /></label></p>';
136
- echo '<p><label>' . __( 'Link text', 'facebook-page-feed-graph-api' ) . ': <input type="text" id="fbpp-linktext" /></label></p>';
137
- echo '<p><label>' . __( 'Language', 'facebook-page-feed-graph-api' ) . ': <select id="fbpp-lang" /><option value="">' . __( 'Site Language', 'facebook-page-feed-graph-api' ) . '</option>';
138
- if(isset($langs) && !empty($langs)){
139
- foreach($langs as $lang){
140
- //echo '<option value="' . $lang->codes->code->standard->representation . '">' . __( $lang->englishName, 'facebook-page-feed-graph-api' ) . '</option>'; // This is for Facebook loaded only
141
- echo '<option value="' . $lang->standard->representation . '">' . __( $lang->englishName, 'facebook-page-feed-graph-api' ) . '</option>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
- echo '</label></p>';
145
- echo '<input type="text" readonly="readonly" id="facebook-page-plugin-shortcode-generator-output" onfocus="this.select()" />';
146
- echo '</form>';
147
- }
148
 
149
- function facebook_page_plugin_admin_resources() {
150
- wp_enqueue_script( 'Facebook Page Plugin Admin Scripts', plugin_dir_url( __FILE__ ) . '/js/facebook-page-plugin-admin.js' );
151
- wp_enqueue_style( 'Facebook Page Plugin Admin Styles', plugin_dir_url( __FILE__ ) . '/css/facebook-page-plugin-admin.css' );
152
  }
153
 
154
- class facebook_page_plugin_widget extends WP_Widget {
155
 
156
  private $facebookURLs = array('https://www.facebook.com/', 'https://facebook.com/', 'www.facebook.com/', 'facebook.com/');
157
 
@@ -337,17 +379,9 @@ class facebook_page_plugin_widget extends WP_Widget {
337
  } else {
338
  $language = '';
339
  }
340
- try {
341
- //$lang_xml = file_get_contents('https://www.facebook.com/translations/FacebookLocales.xml');
342
- $lang_xml = file_get_contents( plugin_dir_url( __FILE__ ) . 'lang.xml');
343
- } catch( Exception $ex ) {
344
- $lang_xml = NULL;
345
- }
346
- if(isset($lang_xml) && !empty($lang_xml)){
347
- $langs = new SimpleXMLElement($lang_xml);
348
- } else {
349
- $langs = NULL;
350
- }
351
  echo '<p>';
352
  echo '<label for="' . $this->get_field_id( 'title' ) . '">';
353
  _e( 'Title:', 'facebook-page-feed-graph-api' );
@@ -456,34 +490,33 @@ class facebook_page_plugin_widget extends WP_Widget {
456
  }
457
  } // Class wpb_widget ends here
458
 
459
- // Register and load the widget
460
  function facebook_page_plugin_load_widget() {
461
- register_widget( 'facebook_page_plugin_widget' );
462
  }
 
463
 
464
- function facebook_page_plugin_admin_notice() {
465
- $screen = get_current_screen();
466
- //Only display on the dashboard, widgets and plugins pages
467
- if( $screen->base === 'widgets' || $screen->base === 'dashboard' || $screen->base === 'plugins' ){
468
- global $current_user ;
469
- $user_id = $current_user->ID;
470
- if ( !get_user_meta( $user_id, 'facebook_page_plugin_admin_notice_ignore' ) || get_user_meta( $user_id, 'facebook_page_plugin_admin_notice_ignore' ) === false ) {
471
- echo '<div class="updated" id="facebook-page-plugin-review"><p>';
472
- echo __( 'Thank you for using the Facebook Page Plugin. If you enjoy using it, please take the time to', 'facebook-page-feed-graph-api' ) . ' <a href="https://wordpress.org/support/view/plugin-reviews/facebook-page-feed-graph-api?rate=5#postform" target="_blank">' . __( 'leave a review', 'facebook-page-feed-graph-api' ) . '</a>. ' . __( 'Thanks', 'facebook-page-feed-graph-api' );
473
- echo '<a href="?facebook_page_plugin_admin_notice_ignore=0" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice', 'facebook-page-feed-graph-api' ) . '.</span></a></p></div>';
474
- }
 
475
  }
476
- }
477
 
478
- function facebook_page_plugin_admin_notice_ignore() {
479
- global $current_user;
480
- $user_id = $current_user->ID;
481
- if ( isset($_GET['facebook_page_plugin_admin_notice_ignore']) && '0' == $_GET['facebook_page_plugin_admin_notice_ignore'] ) {
482
- update_user_meta($user_id, 'facebook_page_plugin_admin_notice_ignore', 'true', true);
483
  }
 
 
484
  }
485
 
486
- function facebook_page_plugin_action_links( $links ) {
487
- $links[] = '<a href="https://profiles.wordpress.org/cameronjonesweb/#content-plugins" target="_blank">More plugins by cameronjonesweb</a>';
488
- return $links;
489
- }
3
  * Plugin Name: Facebook Page Plugin
4
  * Plugin URI: https://cameronjones.x10.mx/projects/facebook-page-plugin
5
  * Description: It's time to upgrade from your old like box! Display the Facebook Page Plugin from the Graph API using a shortcode or widget. Now available in 95 different languages
6
+ * Version: 1.5.0
7
  * Author: Cameron Jones
8
  * Author URI: http://cameronjones.x10.mx
9
  * License: GPLv2
22
 
23
  defined( 'ABSPATH' ) or die();
24
 
25
+ class cameronjonesweb_facebook_page_plugin {
 
 
 
 
 
 
 
 
26
 
27
+ public function __construct() {
28
+
29
+ define( 'CJW_FBPP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
30
+ define( 'CJW_FBPP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
31
+ define( 'CJW_FBPP_PLUGIN_VER', '1.5.0' );
32
+
33
+ //Add all the hooks and actions
34
+ add_shortcode( 'facebook-page-plugin', array( $this, 'facebook_page_plugin' ) );
35
+ add_filter( 'widget_text', 'do_shortcode' );
36
+ add_action( 'wp_dashboard_setup', array( $this, 'facebook_page_plugin_dashboard_widget' ) );
37
+ add_action( 'admin_enqueue_scripts', array( $this, 'facebook_page_plugin_admin_resources' ) );
38
+ add_action( 'admin_notices', array( $this, 'facebook_page_plugin_admin_notice' ) );
39
+ add_action( 'admin_init', array( $this, 'facebook_page_plugin_admin_notice_ignore' ) );
40
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'facebook_page_plugin_action_links' ) );
41
+ }
42
+
43
+
44
+ //Admin functions
45
+ //Display review notice
46
+ public function facebook_page_plugin_admin_notice() {
47
+ $screen = get_current_screen();
48
+ //Only display on the dashboard, widgets and plugins pages
49
+ if( $screen->base === 'widgets' || $screen->base === 'dashboard' || $screen->base === 'plugins' ){
50
+ global $current_user ;
51
+ $user_id = $current_user->ID;
52
+ //Don't show if they have hidden it
53
+ if ( !get_user_meta( $user_id, 'facebook_page_plugin_admin_notice_ignore' ) || get_user_meta( $user_id, 'facebook_page_plugin_admin_notice_ignore' ) === false ) {
54
+ echo '<div class="updated" id="facebook-page-plugin-review"><p>';
55
+ echo __( 'Thank you for using the Facebook Page Plugin. If you enjoy using it, please take the time to', 'facebook-page-feed-graph-api' ) . ' <a href="https://wordpress.org/support/view/plugin-reviews/facebook-page-feed-graph-api?rate=5#postform" target="_blank">' . __( 'leave a review', 'facebook-page-feed-graph-api' ) . '</a>. ' . __( 'Thanks', 'facebook-page-feed-graph-api' );
56
+ echo '<a href="?facebook_page_plugin_admin_notice_ignore=0" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice', 'facebook-page-feed-graph-api' ) . '.</span></a></p></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
  }
59
+ }
60
+
61
+ //Handler function for when review notice is hidden
62
+ public function facebook_page_plugin_admin_notice_ignore() {
63
+ global $current_user;
64
+ $user_id = $current_user->ID;
65
+ if ( isset($_GET['facebook_page_plugin_admin_notice_ignore']) && '0' == $_GET['facebook_page_plugin_admin_notice_ignore'] ) {
66
+ update_user_meta($user_id, 'facebook_page_plugin_admin_notice_ignore', 'true', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
 
68
  }
 
 
69
 
70
+ //Add link on plugins page to my plugins directory
71
+ public function facebook_page_plugin_action_links( $links ) {
72
+ $links[] = '<a href="https://profiles.wordpress.org/cameronjonesweb/#content-plugins" target="_blank">More plugins by cameronjonesweb</a>';
73
+ return $links;
74
+ }
75
 
76
+ //Enqueue CSS and JS for admin
77
+ public function facebook_page_plugin_admin_resources() {
78
+ wp_enqueue_script( 'facebook-page-plugin-admin-scripts', CJW_FBPP_PLUGIN_URL . 'js/facebook-page-plugin-admin.js' );
79
+ wp_enqueue_style( 'facebook-page-plugin-admin-styles', CJW_FBPP_PLUGIN_URL . 'css/facebook-page-plugin-admin.css' );
 
 
80
  }
81
+
82
+ //Register the dashboard widget
83
+ public function facebook_page_plugin_dashboard_widget() {
84
+ wp_add_dashboard_widget( 'facebook-page-plugin-shortcode-generator', __( 'Facebook Page Plugin Shortcode Generator', 'facebook-page-feed-graph-api' ), array( $this, 'facebook_page_plugin_dashboard_widget_callback' ) );
85
+ }
86
+
87
+ //Load the dashboard widget
88
+ function facebook_page_plugin_dashboard_widget_callback() {
89
+
90
+ $langs = get_locale_xml();
91
+
92
+ echo '<form>';
93
+ echo '<p><label>' . __( 'Facebook Page URL', 'facebook-page-feed-graph-api' ) . ': <input type="url" id="fbpp-href" /></label></p>';
94
+ echo '<p><label>' . __( 'Width (pixels)', 'facebook-page-feed-graph-api' ) . ': <input type="number" max="500" min="180" id="fbpp-width" /></label></p>';
95
+ echo '<p><label>' . __( 'Height (pixels)', 'facebook-page-feed-graph-api' ) . ': <input type="number" min="70" id="fbpp-height" /></label></p>';
96
+ echo '<p><label>' . __( 'Show Cover Photo', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-cover" /></label></p>';
97
+ echo '<p><label>' . __( 'Show Facepile', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-facepile" /></label></p>';
98
+ echo '<p><label>' . __( 'Page Tabs (formerly posts)', 'facebook-page-feed-graph-api' ) . ': <select id="fbpp-tabs"><option value="">None</option><option value="timeline">Timeline</option><option value="messages">Messages</option><option value="timeline,messages">Timeline, Messages</option><option value="messages,timeline">Messages, Timeline</option></select></label></p>';
99
+ echo '<p><label>' . __( 'Hide Call To Action', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-cta" /></label></p>';
100
+ echo '<p><label>' . __( 'Small Header', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-small" /></label></p>';
101
+ echo '<p><label>' . __( 'Adaptive Width', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-adapt" checked /></label></p>';
102
+ echo '<p><label>' . __( 'Display link while loading', 'facebook-page-feed-graph-api' ) . ': <input type="checkbox" value="true" id="fbpp-link" checked /></label></p>';
103
+ echo '<p id="linktext-label"><label>' . __( 'Link text', 'facebook-page-feed-graph-api' ) . ': <input type="text" id="fbpp-linktext" /></label></p>';
104
+ echo '<p><label>' . __( 'Language', 'facebook-page-feed-graph-api' ) . ': <select id="fbpp-lang"><option value="">' . __( 'Site Language', 'facebook-page-feed-graph-api' ) . '</option>';
105
+ if(isset($langs) && !empty($langs)){
106
+ foreach($langs as $lang){
107
+ //echo '<option value="' . $lang->codes->code->standard->representation . '">' . __( $lang->englishName, 'facebook-page-feed-graph-api' ) . '</option>'; // This is for Facebook loaded only
108
+ echo '<option value="' . $lang->standard->representation . '">' . __( $lang->englishName, 'facebook-page-feed-graph-api' ) . '</option>';
109
+ }
110
+ }
111
+ echo '</select></label></p>';
112
+ echo '<input type="text" readonly="readonly" id="facebook-page-plugin-shortcode-generator-output" onfocus="this.select()" />';
113
+ echo '</form>';
114
  }
115
+
116
+ //Client side stuff
117
+ //Parse shortcode
118
+ function facebook_page_plugin( $filter ) {
119
+ wp_enqueue_script( 'facebook-page-plugin-responsive-script', CJW_FBPP_PLUGIN_URL . 'js/responsive.js', 'jquery', NULL, true );
120
+ $return = NULL;
121
+ $a = shortcode_atts( array(
122
+ 'href' => NULL,
123
+ 'width' => 340,
124
+ 'height' => 130,
125
+ 'cover' => NULL,
126
+ 'facepile' => NULL,
127
+ 'posts' => NULL,
128
+ 'tabs' => array(),
129
+ 'language' => get_bloginfo('language'),
130
+ 'cta' => NULL,
131
+ 'small' => NULL,
132
+ 'adapt' => NULL,
133
+ 'link' => true,
134
+ 'linktext' => NULL,
135
+ 'standard' => 'html5',
136
+ ), $filter );
137
+ if(isset($a['href']) && !empty($a['href'])){
138
+ $a['language'] = str_replace("-", "_", $a['language']);
139
+ $return .= '<div id="fb-root" data-version="' . CJW_FBPP_PLUGIN_VER . '"></div><script async>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/' . $a['language'] . '/sdk.js#xfbml=1&version=v2.4";fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\'));</script>';
140
+ $return .= '<div id="fb-page" class="fb-page" data-version="' . CJW_FBPP_PLUGIN_VER . '" data-href="https://facebook.com/' . $a["href"] . '" ';
141
+ if(isset($a['width']) && !empty($a['width'])){
142
+ $return .= ' data-width="' . $a['width'] . '"';
143
+ }
144
+ if(isset($a['height']) && !empty($a['height'])){
145
+ $return .= ' data-height="' . $a['height'] . '"';
146
+ }
147
+ if(isset($a['cover']) && !empty($a['cover'])){
148
+ if($a['cover'] == "false"){
149
+ $return .= ' data-hide-cover="true"';
150
+ } else if($a['cover'] == "true"){
151
+ $return .= ' data-hide-cover="false"';
152
+ }
153
+ }
154
+ if(isset($a['facepile']) && !empty($a['facepile'])){
155
+ $return .= ' data-show-facepile="' . $a['facepile'] . '"';
156
+ }
157
+ if(isset($a['tabs']) && !empty($a['tabs'])){
158
+ $return .= ' data-tabs="' . $a['tabs'] . '"';
159
+ } else if(isset($a['posts']) && !empty($a['posts'])){
160
+ if($a['posts'] == 'true'){
161
+ $return .= ' data-tabs="timeline"';
162
+ } else {
163
+ $return .= ' data-tabs="false"';
164
+ }
165
+ }
166
+ if(isset($a['cta']) && !empty($a['cta'])){
167
+ $return .= ' data-hide-cta="' . $a['cta'] . '"';
168
  }
169
+ if(isset($a['small']) && !empty($a['small'])){
170
+ $return .= ' data-small-header="' . $a['small'] . '"';
171
+ }
172
+ if(isset($a['adapt']) && !empty($a['adapt'])){
173
+ $return .= ' data-adapt-container-width="' . $a['adapt'] . '"';
174
+ } else {
175
+ $return .= ' data-adapt-container-width="false"';
176
+ }
177
+ $return .= '><div class="fb-xfbml-parse-ignore">';
178
+ if( $a['link'] == 'true' ){
179
+ $return .= '<blockquote cite="https://www.facebook.com/' . $a['href'] . '">';
180
+ $return .= '<a href="https://www.facebook.com/' . $a['href'] . '">';
181
+ if( empty( $a['linktext'] ) ) {
182
+ $return .= 'https://www.facebook.com/' . $a['href'];
183
+ } else {
184
+ $return .= $a['linktext'];
185
+ }
186
+ $return .= '</a>';
187
+ $return .= '</blockquote>';
188
+ }
189
+ $return .= '</div></div>';
190
  }
191
+ return $return;
192
+ }
 
 
193
 
 
 
 
194
  }
195
 
196
+ class cameronjonesweb_facebook_page_plugin_widget extends WP_Widget {
197
 
198
  private $facebookURLs = array('https://www.facebook.com/', 'https://facebook.com/', 'www.facebook.com/', 'facebook.com/');
199
 
379
  } else {
380
  $language = '';
381
  }
382
+
383
+ $langs = get_locale_xml();
384
+
 
 
 
 
 
 
 
 
385
  echo '<p>';
386
  echo '<label for="' . $this->get_field_id( 'title' ) . '">';
387
  _e( 'Title:', 'facebook-page-feed-graph-api' );
490
  }
491
  } // Class wpb_widget ends here
492
 
493
+ //Register the widget
494
  function facebook_page_plugin_load_widget() {
495
+ register_widget( 'cameronjonesweb_facebook_page_plugin_widget' );
496
  }
497
+ add_action( 'widgets_init', 'facebook_page_plugin_load_widget' );
498
 
499
+ function get_locale_xml() {
500
+
501
+ include_once( ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php' );
502
+ include_once( ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php' );
503
+ $wp_filesystem = new WP_Filesystem_Direct( null );
504
+
505
+ try {
506
+ //$xml = file_get_contents('https://www.facebook.com/translations/FacebookLocales.xml');
507
+ //$xml = file_get_contents( CJW_FBPP_PLUGIN_URL ) . 'lang.xml');
508
+ $lang_xml = $wp_filesystem->get_contents( CJW_FBPP_PLUGIN_DIR . '/lang.xml');
509
+ } catch( Exception $ex ){
510
+ $lang_xml = NULL;
511
  }
 
512
 
513
+ if(isset($lang_xml) && !empty($lang_xml)){
514
+ $langs = new SimpleXMLElement($lang_xml);
515
+ } else {
516
+ $langs = NULL;
 
517
  }
518
+
519
+ return $langs;
520
  }
521
 
522
+ $cameronjonesweb_facebook_page_plugin = new cameronjonesweb_facebook_page_plugin;
 
 
 
js/facebook-page-plugin-admin.js CHANGED
@@ -4,7 +4,12 @@
4
  e.preventDefault();
5
  });
6
  var $facebookURLs = ['https://www.facebook.com/', 'https://facebook.com/', 'www.facebook.com/', 'facebook.com/'];
7
- $('#facebook-page-plugin-shortcode-generator input').change(function(){
 
 
 
 
 
8
  var $shortcode = '';
9
  $shortcode += '[facebook-page-plugin ';
10
  var $href = $('#fbpp-href').val();
@@ -35,8 +40,10 @@
35
  $shortcode += 'adapt="' + $adapt + '" ';
36
  var $link = $('#fbpp-link').prop("checked");
37
  $shortcode += 'link="' + $link + '" ';
38
- var $linktext = $('#fbpp-linktext').val();
39
- $shortcode += 'linktext="' + $linktext + '" ';
 
 
40
  var $lang = $('#fbpp-lang').val();
41
  if($lang.length > 0){
42
  $shortcode += 'lang="' + $lang + '" ';
4
  e.preventDefault();
5
  });
6
  var $facebookURLs = ['https://www.facebook.com/', 'https://facebook.com/', 'www.facebook.com/', 'facebook.com/'];
7
+ $('#facebook-page-plugin-shortcode-generator input, #facebook-page-plugin-shortcode-generator select').change(function(){
8
+ if( $('#fbpp-link').prop("checked") == false ) {
9
+ $('#linktext-label').hide();
10
+ } else {
11
+ $('#linktext-label').show();
12
+ }
13
  var $shortcode = '';
14
  $shortcode += '[facebook-page-plugin ';
15
  var $href = $('#fbpp-href').val();
40
  $shortcode += 'adapt="' + $adapt + '" ';
41
  var $link = $('#fbpp-link').prop("checked");
42
  $shortcode += 'link="' + $link + '" ';
43
+ if( $link == true ) {
44
+ var $linktext = $('#fbpp-linktext').val();
45
+ $shortcode += 'linktext="' + $linktext + '" ';
46
+ }
47
  var $lang = $('#fbpp-lang').val();
48
  if($lang.length > 0){
49
  $shortcode += 'lang="' + $lang + '" ';
js/responsive.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(window).resize(function() {
2
+ if(this.resizeTO) clearTimeout(this.resizeTO);
3
+ this.resizeTO = setTimeout(function() {
4
+ jQuery(this).trigger('resizeEnd');
5
+ }, 500);
6
+ });
7
+ jQuery(window).bind('resizeEnd', function() {
8
+ var container = jQuery('#fb-page');
9
+ var url = container.data('href');
10
+ if( jQuery(container).data('adapt-container-width') == true ) {
11
+ container.fadeOut("slow", function() {
12
+ container.load(url, { width: container.width() },
13
+ function() {
14
+ FB.XFBML.parse(document.getElementById('fb-page'),
15
+ function() {
16
+ container.fadeIn("slow");
17
+ });
18
+ })
19
+ });
20
+ }
21
+ });
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: facebook,social,like,facepile,activity feed,recommendations,shortcode,widg
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=WLV5HPHSPM2BG&lc=AU&item_name=Cameron%20Jones%20Web%20Development�cy_code=AUD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 4.0
6
  Tested up to: 4.3.1
7
- Stable tag: 1.4.1
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
 
@@ -106,8 +106,20 @@ Chances are your plugin isn't tall enough to display the facepile properly. The
106
 
107
  == Changelog ==
108
 
 
 
 
 
 
 
 
 
 
 
 
109
  = 1.4.1 =
110
  * Fixing shortcode generator using posts instead of tabs
 
111
 
112
  = 1.4.0 =
113
  * Options to remove and customise the page link that displays while the plugin loads
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=WLV5HPHSPM2BG&lc=AU&item_name=Cameron%20Jones%20Web%20Development�cy_code=AUD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 4.0
6
  Tested up to: 4.3.1
7
+ Stable tag: 1.5
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
 
106
 
107
  == Changelog ==
108
 
109
+ = 1.5.0 =
110
+ * Migrated to object oriented
111
+ * Fixed languages XML file being blocked by iThemes Security
112
+ * Added option for switching between HTML5/XHTML
113
+ * Fixed HTML issue with dashboard widget
114
+ * Added script that makes the plugin fully responsive
115
+
116
+ = 1.4.2 =
117
+ * Fixing shortcode not being updated when tabs change in the shortcode generator
118
+ * Removing link text parameter and option when `Show Link` is false
119
+
120
  = 1.4.1 =
121
  * Fixing shortcode generator using posts instead of tabs
122
+ * Verifying compatibility with 4.3.1
123
 
124
  = 1.4.0 =
125
  * Options to remove and customise the page link that displays while the plugin loads