WordPress Page Builder – Beaver Builder - Version 1.5.5

Version Description

Download this release

Release Info

Developer justinbusa
Plugin Icon 128x128 WordPress Page Builder – Beaver Builder
Version 1.5.5
Comparing to
See all releases

Code changes from version 1.5.3 to 1.5.5

Files changed (85) hide show
  1. changelog.txt +23 -0
  2. classes/class-fl-builder-admin-posts.php +51 -29
  3. classes/class-fl-builder-admin-settings.php +203 -123
  4. classes/class-fl-builder-loop.php +40 -7
  5. classes/class-fl-builder-model.php +47 -21
  6. classes/class-fl-builder-photo.php +26 -17
  7. classes/class-fl-builder-service-aweber.php +255 -0
  8. classes/class-fl-builder-service-campaign-monitor.php +259 -0
  9. classes/class-fl-builder-service-constant-contact.php +286 -0
  10. classes/class-fl-builder-service-getresponse.php +210 -0
  11. classes/class-fl-builder-service-icontact.php +286 -0
  12. classes/class-fl-builder-service-madmimi.php +248 -0
  13. classes/class-fl-builder-service-mailchimp.php +227 -0
  14. classes/class-fl-builder-service-mailpoet.php +155 -0
  15. classes/class-fl-builder-service.php +68 -0
  16. classes/class-fl-builder-services.php +338 -0
  17. classes/class-fl-builder.php +27 -11
  18. css/fl-builder-layout-auto-spacing.css +26 -0
  19. css/fl-builder-layout-responsive.css +0 -17
  20. css/fl-builder-layout.css +21 -0
  21. css/fl-builder.css +35 -1
  22. fl-builder.php +10 -6
  23. img/templates/coming-soon.jpg +0 -0
  24. img/templates/pricing.jpg +0 -0
  25. img/templates/signup.jpg +0 -0
  26. img/templates/subscribe.jpg +0 -0
  27. includes/column-css.php +7 -1
  28. includes/field-button.php +1 -0
  29. includes/field.php +12 -6
  30. includes/global-settings.php +11 -1
  31. includes/js-config.php +6 -0
  32. includes/loop-settings.php +10 -0
  33. includes/row-css.php +8 -4
  34. includes/service-settings.php +41 -0
  35. includes/updater-config.php +1 -1
  36. includes/vendor/aweber/aweber.php +292 -0
  37. includes/vendor/aweber/aweber_api.php +8 -0
  38. includes/vendor/aweber/aweber_collection.php +268 -0
  39. includes/vendor/aweber/aweber_entry.php +343 -0
  40. includes/vendor/aweber/aweber_entry_data_array.php +68 -0
  41. includes/vendor/aweber/aweber_response.php +73 -0
  42. includes/vendor/aweber/curl_object.php +103 -0
  43. includes/vendor/aweber/curl_response.php +51 -0
  44. includes/vendor/aweber/exceptions.php +130 -0
  45. includes/vendor/aweber/oauth_adapter.php +11 -0
  46. includes/vendor/aweber/oauth_application.php +682 -0
  47. includes/vendor/campaign-monitor/class/base_classes.php +287 -0
  48. includes/vendor/campaign-monitor/class/cacert.pem +3849 -0
  49. includes/vendor/campaign-monitor/class/log.php +19 -0
  50. includes/vendor/campaign-monitor/class/serialisation.php +129 -0
  51. includes/vendor/campaign-monitor/class/services_json.php +782 -0
  52. includes/vendor/campaign-monitor/class/transport.php +335 -0
  53. includes/vendor/campaign-monitor/csrest_administrators.php +108 -0
  54. includes/vendor/campaign-monitor/csrest_campaigns.php +439 -0
  55. includes/vendor/campaign-monitor/csrest_clients.php +450 -0
  56. includes/vendor/campaign-monitor/csrest_general.php +212 -0
  57. includes/vendor/campaign-monitor/csrest_lists.php +587 -0
  58. includes/vendor/campaign-monitor/csrest_people.php +125 -0
  59. includes/vendor/campaign-monitor/csrest_segments.php +206 -0
  60. includes/vendor/campaign-monitor/csrest_subscribers.php +231 -0
  61. includes/vendor/campaign-monitor/csrest_templates.php +118 -0
  62. includes/vendor/getresponse/getresponse.php +576 -0
  63. includes/vendor/icontact/iContactApi.php +1109 -0
  64. includes/vendor/madmimi/MadMimi.class.php +246 -0
  65. includes/vendor/madmimi/Spyc.class.php +1024 -0
  66. includes/vendor/mailchimp/Mailchimp/Campaigns.php +378 -0
  67. includes/vendor/mailchimp/Mailchimp/Conversations.php +80 -0
  68. includes/vendor/mailchimp/Mailchimp/Ecomm.php +86 -0
  69. includes/vendor/mailchimp/Mailchimp/Exceptions.php +471 -0
  70. includes/vendor/mailchimp/Mailchimp/Folders.php +62 -0
  71. includes/vendor/mailchimp/Mailchimp/Gallery.php +106 -0
  72. includes/vendor/mailchimp/Mailchimp/Goal.php +49 -0
  73. includes/vendor/mailchimp/Mailchimp/Helper.php +237 -0
  74. includes/vendor/mailchimp/Mailchimp/Lists.php +904 -0
  75. includes/vendor/mailchimp/Mailchimp/Mobile.php +10 -0
  76. includes/vendor/mailchimp/Mailchimp/Neapolitan.php +10 -0
  77. includes/vendor/mailchimp/Mailchimp/Reports.php +459 -0
  78. includes/vendor/mailchimp/Mailchimp/Templates.php +114 -0
  79. includes/vendor/mailchimp/Mailchimp/Users.php +105 -0
  80. includes/vendor/mailchimp/Mailchimp/Vip.php +111 -0
  81. includes/vendor/mailchimp/mailchimp.php +261 -0
  82. js/fl-builder-layout.js +103 -29
  83. js/fl-builder-preview.js +18 -4
  84. js/fl-builder-services.js +368 -0
  85. js/fl-builder.js +70 -40
changelog.txt CHANGED
@@ -1,3 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <h4>1.5.3 - 03/31/2015</h4>
2
  <p><strong>Enhancements</strong></p>
3
  <ul>
1
+ <h4>1.5.5 - 04/12/2015</h4>
2
+ <p><strong>Enhancements</strong></p>
3
+ <ul>
4
+ <li>The Subscribe Form module is here! Please see <a href="https://www.wpbeaverbuilder.com/build-your-email-lists-with-beaver-builders-new-subscribe-form-module/">the blog post</a> for complete details.</li>
5
+ <li>Added four new templates.</li>
6
+ </ul>
7
+
8
+ <h4>1.5.4 - 04/08/2015</h4>
9
+ <p><strong>Enhancements</strong></p>
10
+ <ul>
11
+ <li>Added offset setting to the Posts module.</li>
12
+ <li>Added getting started video to the help button.</li>
13
+ <li>Added auto spacing setting to the global settings for turning off auto spacing on responsive layouts.</li>
14
+ <li>Added SVG support to the photo field for sites that have SVG enabled as an mime type.</li>
15
+ </ul>
16
+ <p><strong>Bug Fixes</strong></p>
17
+ <ul>
18
+ <li>Fixed a bug with switching back to the WordPress editor.</li>
19
+ <li>Fixed a bug with textarea text color being overridden by row text color.</li>
20
+ <li>Fixed an issue with varnish by removing the question mark from the URL when publishing.</li>
21
+ <li>Removed FLBuilderModel::delete_asset_cache_domain_change as it's causing issues and we now have the clear cache button.</li>
22
+ </ul>
23
+
24
  <h4>1.5.3 - 03/31/2015</h4>
25
  <p><strong>Enhancements</strong></p>
26
  <ul>
classes/class-fl-builder-admin-posts.php CHANGED
@@ -1,66 +1,77 @@
1
  <?php
2
 
3
  /**
4
- * Post admin class.
5
  *
6
- * @class FLBuilderAdminPosts
7
  */
8
  final class FLBuilderAdminPosts {
9
 
10
  /**
11
- * @method init
 
 
 
 
12
  */
13
  static public function init()
14
  {
15
  global $pagenow;
16
 
17
- if(in_array($pagenow, array('post.php', 'post-new.php'))) {
18
 
19
  $post_types = FLBuilderModel::get_post_types();
20
  $screen = get_current_screen();
21
 
22
- if(in_array($screen->post_type, $post_types)) {
23
- add_filter('admin_body_class', 'FLBuilderAdminPosts::body_class');
24
- add_action('admin_enqueue_scripts', 'FLBuilderAdminPosts::styles_scripts');
25
- add_action('edit_form_after_title', 'FLBuilderAdminPosts::render');
26
  }
27
  }
28
  }
29
 
30
  /**
31
- * @method styles_scripts
 
 
 
32
  */
33
  static public function styles_scripts()
34
  {
35
  global $wp_version;
36
 
37
  // Styles
38
- wp_enqueue_style('fl-builder-admin-posts', FL_BUILDER_URL . 'css/fl-builder-admin-posts.css', array(), FL_BUILDER_VERSION);
39
 
40
  // Legacy WP Styles (3.7 and below)
41
- if(version_compare($wp_version, '3.7', '<=')) {
42
- wp_enqueue_style('fl-builder-admin-posts-legacy', FL_BUILDER_URL . 'css/fl-builder-admin-posts-legacy.css', array(), FL_BUILDER_VERSION);
43
  }
44
 
45
  // Scripts
46
- wp_enqueue_script('json2');
47
- wp_enqueue_script('fl-builder-admin-posts', FL_BUILDER_URL . 'js/fl-builder-admin-posts.js', array(), FL_BUILDER_VERSION);
48
  }
49
-
50
  /**
51
- * @method body_class
 
 
 
 
52
  */
53
- static public function body_class($classes)
54
  {
55
  global $wp_version;
56
 
57
  // Builder body class
58
- if(FLBuilderModel::is_builder_enabled()) {
59
  $classes .= ' fl-builder-enabled';
60
  }
61
 
62
  // Pre WP 3.8 body class
63
- if(version_compare($wp_version, '3.8', '<')) {
64
  $classes .= ' fl-pre-wp-3-8';
65
  }
66
 
@@ -68,7 +79,10 @@ final class FLBuilderAdminPosts {
68
  }
69
 
70
  /**
71
- * @method render
 
 
 
72
  */
73
  static public function render()
74
  {
@@ -78,32 +92,40 @@ final class FLBuilderAdminPosts {
78
 
79
  include FL_BUILDER_DIR . 'includes/admin-posts.php';
80
  }
81
-
82
  /**
83
- * @method render_row_actions_link
 
 
 
 
84
  */
85
- static public function render_row_actions_link($actions)
86
  {
87
  global $post;
88
 
89
- if(current_user_can('edit_post', $post->ID) && wp_check_post_lock($post->ID) === false) {
90
 
91
  $post_types = FLBuilderModel::get_post_types();
92
 
93
- if(in_array($post->post_type, $post_types)) {
94
  $actions['fl-builder'] = '<a href="' . FLBuilderModel::get_edit_url() . '">' . FLBuilderModel::get_branding() . '</a>';
95
  }
96
  }
97
 
98
  return $actions;
99
  }
100
-
101
  /**
102
- * @method redirect_post_location
 
 
 
 
103
  */
104
- static public function redirect_post_location($location)
105
  {
106
- if(isset($_POST['fl-builder-redirect'])) {
107
  $location = $_POST['fl-builder-redirect'];
108
  }
109
 
1
  <?php
2
 
3
  /**
4
+ * Handles logic for the post edit screen.
5
  *
6
+ * @since 1.5.0
7
  */
8
  final class FLBuilderAdminPosts {
9
 
10
  /**
11
+ * Sets the body class, loads assets and renders the UI
12
+ * if we are on a post type that supports the builder.
13
+ *
14
+ * @since 1.5.0
15
+ * @return void
16
  */
17
  static public function init()
18
  {
19
  global $pagenow;
20
 
21
+ if ( in_array( $pagenow, array( 'post.php', 'post-new.php') ) ) {
22
 
23
  $post_types = FLBuilderModel::get_post_types();
24
  $screen = get_current_screen();
25
 
26
+ if ( in_array( $screen->post_type, $post_types ) ) {
27
+ add_filter( 'admin_body_class', 'FLBuilderAdminPosts::body_class' );
28
+ add_action( 'admin_enqueue_scripts', 'FLBuilderAdminPosts::styles_scripts' );
29
+ add_action( 'edit_form_after_title', 'FLBuilderAdminPosts::render' );
30
  }
31
  }
32
  }
33
 
34
  /**
35
+ * Enqueues the CSS/JS for the post edit screen.
36
+ *
37
+ * @since 1.5.0
38
+ * @return void
39
  */
40
  static public function styles_scripts()
41
  {
42
  global $wp_version;
43
 
44
  // Styles
45
+ wp_enqueue_style( 'fl-builder-admin-posts', FL_BUILDER_URL . 'css/fl-builder-admin-posts.css', array(), FL_BUILDER_VERSION );
46
 
47
  // Legacy WP Styles (3.7 and below)
48
+ if ( version_compare( $wp_version, '3.7', '<=' ) ) {
49
+ wp_enqueue_style( 'fl-builder-admin-posts-legacy', FL_BUILDER_URL . 'css/fl-builder-admin-posts-legacy.css', array(), FL_BUILDER_VERSION );
50
  }
51
 
52
  // Scripts
53
+ wp_enqueue_script( 'json2' );
54
+ wp_enqueue_script( 'fl-builder-admin-posts', FL_BUILDER_URL . 'js/fl-builder-admin-posts.js', array(), FL_BUILDER_VERSION );
55
  }
56
+
57
  /**
58
+ * Adds classes to the post edit screen body class.
59
+ *
60
+ * @since 1.5.0
61
+ * @param string $classes The existing body classes.
62
+ * @return string The body classes.
63
  */
64
+ static public function body_class( $classes = '' )
65
  {
66
  global $wp_version;
67
 
68
  // Builder body class
69
+ if ( FLBuilderModel::is_builder_enabled() ) {
70
  $classes .= ' fl-builder-enabled';
71
  }
72
 
73
  // Pre WP 3.8 body class
74
+ if ( version_compare( $wp_version, '3.8', '<' ) ) {
75
  $classes .= ' fl-pre-wp-3-8';
76
  }
77
 
79
  }
80
 
81
  /**
82
+ * Renders the HTML for the post edit screen.
83
+ *
84
+ * @since 1.5.0
85
+ * @return void
86
  */
87
  static public function render()
88
  {
92
 
93
  include FL_BUILDER_DIR . 'includes/admin-posts.php';
94
  }
95
+
96
  /**
97
+ * Renders the action link for post listing pages.
98
+ *
99
+ * @since 1.5.0
100
+ * @param array $actions
101
+ * @return array The array of action data.
102
  */
103
+ static public function render_row_actions_link( $actions = array() )
104
  {
105
  global $post;
106
 
107
+ if ( current_user_can( 'edit_post', $post->ID ) && wp_check_post_lock( $post->ID ) === false ) {
108
 
109
  $post_types = FLBuilderModel::get_post_types();
110
 
111
+ if ( in_array( $post->post_type, $post_types ) ) {
112
  $actions['fl-builder'] = '<a href="' . FLBuilderModel::get_edit_url() . '">' . FLBuilderModel::get_branding() . '</a>';
113
  }
114
  }
115
 
116
  return $actions;
117
  }
118
+
119
  /**
120
+ * Where to redirect this post on save.
121
+ *
122
+ * @since 1.5.0
123
+ * @param string $location
124
+ * @return string The location to redirect this post on save.
125
  */
126
+ static public function redirect_post_location( $location )
127
  {
128
+ if ( isset( $_POST['fl-builder-redirect'] ) ) {
129
  $location = $_POST['fl-builder-redirect'];
130
  }
131
 
classes/class-fl-builder-admin-settings.php CHANGED
@@ -1,73 +1,93 @@
1
  <?php
2
 
3
  /**
4
- * Settings admin class.
5
  *
6
- * @class FLBuilderAdminSettings
7
  */
8
  final class FLBuilderAdminSettings {
9
 
10
  /**
11
- * @property $errors
 
 
 
 
12
  */
13
  static public $errors = array();
14
 
15
  /**
16
- * @method init
 
 
 
 
17
  */
18
  static public function init()
19
  {
20
- add_action('admin_menu', 'FLBuilderAdminSettings::menu');
21
 
22
- if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'fl-builder-settings') {
23
- add_action('admin_enqueue_scripts', 'FLBuilderAdminSettings::styles_scripts');
24
  self::save();
25
  }
26
  }
27
-
28
- /**
29
- * @method styles_scripts
30
- */
 
 
 
31
  static public function styles_scripts()
32
  {
33
  // Styles
34
- wp_enqueue_style('fl-builder-admin-settings', FL_BUILDER_URL . 'css/fl-builder-admin-settings.css', array(), FL_BUILDER_VERSION);
35
 
36
  // Scripts
37
- wp_enqueue_script('fl-builder-admin-settings', FL_BUILDER_URL . 'js/fl-builder-admin-settings.js', array(), FL_BUILDER_VERSION);
38
 
39
  // Media Uploader
40
  wp_enqueue_media();
41
  }
42
-
43
- /**
44
- * @method menu
 
 
 
45
  */
46
  static public function menu()
47
  {
48
- if(current_user_can('delete_plugins')) {
49
 
50
  $title = FLBuilderModel::get_branding();
51
  $cap = 'delete_plugins';
52
  $slug = 'fl-builder-settings';
53
  $func = 'FLBuilderAdminSettings::render';
54
 
55
- add_submenu_page('options-general.php', $title, $title, $cap, $slug, $func);
56
  }
57
  }
58
-
59
- /**
60
- * @method render
61
- */
 
 
 
62
  static public function render()
63
  {
64
  include FL_BUILDER_DIR . 'includes/admin-settings-js-config.php';
65
  include FL_BUILDER_DIR . 'includes/admin-settings.php';
66
  }
67
-
68
- /**
69
- * @method render_page_class
70
- */
 
 
 
71
  static public function render_page_class()
72
  {
73
  if ( self::multisite_support() ) {
@@ -77,10 +97,13 @@ final class FLBuilderAdminSettings {
77
  echo 'fl-settings-single-install';
78
  }
79
  }
80
-
81
- /**
82
- * @method render_page_heading
83
- */
 
 
 
84
  static public function render_page_heading()
85
  {
86
  $icon = FLBuilderModel::get_branding_icon();
@@ -92,9 +115,12 @@ final class FLBuilderAdminSettings {
92
 
93
  echo '<span>' . sprintf( _x( '%s Settings', '%s stands for custom branded "Page Builder" name.', 'fl-builder' ), FLBuilderModel::get_branding() ) . '</span>';
94
  }
95
-
96
- /**
97
- * @method render_update_message
 
 
 
98
  */
99
  static public function render_update_message()
100
  {
@@ -107,10 +133,13 @@ final class FLBuilderAdminSettings {
107
  echo '<div class="updated"><p>' . __( 'Settings updated!', 'fl-builder' ) . '</p></div>';
108
  }
109
  }
110
-
111
- /**
112
- * @method render_nav_items
113
- */
 
 
 
114
  static public function render_nav_items()
115
  {
116
  $item_data = array(
@@ -166,10 +195,13 @@ final class FLBuilderAdminSettings {
166
  }
167
  }
168
  }
169
-
170
- /**
171
- * @method render_forms
172
- */
 
 
 
173
  static public function render_forms()
174
  {
175
  // License
@@ -209,20 +241,28 @@ final class FLBuilderAdminSettings {
209
  // Uninstall
210
  self::render_form( 'uninstall' );
211
  }
212
-
213
- /**
214
- * @method render_form
215
- */
 
 
 
 
216
  static public function render_form( $type )
217
  {
218
  if ( self::has_support( $type ) ) {
219
  include FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php';
220
  }
221
  }
222
-
223
- /**
224
- * @method render_form_action
225
- */
 
 
 
 
226
  static public function render_form_action( $type = '' )
227
  {
228
  if ( is_network_admin() ) {
@@ -232,9 +272,13 @@ final class FLBuilderAdminSettings {
232
  echo admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
233
  }
234
  }
235
-
236
- /**
237
- * @method get_form_action
 
 
 
 
238
  */
239
  static public function get_form_action( $type = '' )
240
  {
@@ -245,34 +289,48 @@ final class FLBuilderAdminSettings {
245
  return admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
246
  }
247
  }
248
-
249
- /**
250
- * @method supports
251
- */
 
 
 
 
252
  static public function has_support( $type )
253
  {
254
  return file_exists( FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php' );
255
  }
256
-
257
- /**
258
- * @method multisite_support
259
- */
 
 
 
260
  static public function multisite_support()
261
  {
262
  return is_multisite() && class_exists( 'FLBuilderMultisiteSettings' );
263
  }
264
-
265
- /**
266
- * @method add_error
267
- */
 
 
 
 
268
  static public function add_error( $message )
269
  {
270
  self::$errors[] = $message;
271
  }
272
-
273
- /**
274
- * @method save
275
- */
 
 
 
276
  static public function save()
277
  {
278
  // Only admins can save settings.
@@ -290,11 +348,13 @@ final class FLBuilderAdminSettings {
290
  self::clear_cache();
291
  self::uninstall();
292
  }
293
-
294
- /**
295
- * @method save_enabled_modules
296
- * @private
297
- */
 
 
298
  static private function save_enabled_modules()
299
  {
300
  if ( isset( $_POST['fl-modules-nonce'] ) && wp_verify_nonce( $_POST['fl-modules-nonce'], 'modules' ) ) {
@@ -316,11 +376,13 @@ final class FLBuilderAdminSettings {
316
  }
317
  }
318
  }
319
-
320
- /**
321
- * @method save_enabled_templates
322
- * @private
323
- */
 
 
324
  static private function save_enabled_templates()
325
  {
326
  if ( isset( $_POST['fl-templates-nonce'] ) && wp_verify_nonce( $_POST['fl-templates-nonce'], 'templates' ) ) {
@@ -338,11 +400,13 @@ final class FLBuilderAdminSettings {
338
  }
339
  }
340
  }
341
-
342
- /**
343
- * @method save_enabled_post_types
344
- * @private
345
- */
 
 
346
  static private function save_enabled_post_types()
347
  {
348
  if ( isset( $_POST['fl-post-types-nonce'] ) && wp_verify_nonce( $_POST['fl-post-types-nonce'], 'post-types' ) ) {
@@ -370,11 +434,13 @@ final class FLBuilderAdminSettings {
370
  }
371
  }
372
  }
373
-
374
- /**
375
- * @method save_enabled_icons
376
- * @private
377
- */
 
 
378
  static private function save_enabled_icons()
379
  {
380
  if ( isset( $_POST['fl-icons-nonce'] ) && wp_verify_nonce( $_POST['fl-icons-nonce'], 'icons' ) ) {
@@ -472,11 +538,13 @@ final class FLBuilderAdminSettings {
472
  self::update_enabled_icons( $enabled_icons );
473
  }
474
  }
475
-
476
- /**
477
- * @method update_enabled_icons
478
- * @private
479
- */
 
 
480
  static private function update_enabled_icons( $enabled_icons = array() )
481
  {
482
  if ( is_network_admin() ) {
@@ -490,11 +558,13 @@ final class FLBuilderAdminSettings {
490
  update_option( '_fl_builder_enabled_icons', $enabled_icons );
491
  }
492
  }
493
-
494
- /**
495
- * @method save_editing_capability
496
- * @private
497
- */
 
 
498
  static private function save_editing_capability()
499
  {
500
  if ( isset( $_POST['fl-editing-nonce'] ) && wp_verify_nonce( $_POST['fl-editing-nonce'], 'editing' ) ) {
@@ -512,11 +582,13 @@ final class FLBuilderAdminSettings {
512
  }
513
  }
514
  }
515
-
516
- /**
517
- * @method save_branding
518
- * @private
519
- */
 
 
520
  static private function save_branding()
521
  {
522
  if ( isset( $_POST['fl-branding-nonce'] ) && wp_verify_nonce( $_POST['fl-branding-nonce'], 'branding' ) ) {
@@ -534,11 +606,13 @@ final class FLBuilderAdminSettings {
534
  }
535
  }
536
  }
537
-
538
- /**
539
- * @method save_help_button
540
- * @private
541
- */
 
 
542
  static private function save_help_button()
543
  {
544
  if ( isset( $_POST['fl-help-button-nonce'] ) && wp_verify_nonce( $_POST['fl-help-button-nonce'], 'help-button' ) ) {
@@ -602,11 +676,13 @@ final class FLBuilderAdminSettings {
602
  }
603
  }
604
  }
605
-
606
- /**
607
- * @method clear_cache
608
- * @private
609
- */
 
 
610
  static private function clear_cache()
611
  {
612
  if ( ! current_user_can( 'delete_plugins' ) ) {
@@ -621,11 +697,13 @@ final class FLBuilderAdminSettings {
621
  }
622
  }
623
  }
624
-
625
- /**
626
- * @method clear_cache_for_all_sites
627
- * @private
628
- */
 
 
629
  static private function clear_cache_for_all_sites()
630
  {
631
  global $blog_id;
@@ -646,11 +724,13 @@ final class FLBuilderAdminSettings {
646
  // Revert to the original blog.
647
  switch_to_blog( $original_blog_id );
648
  }
649
-
650
- /**
651
- * @method uninstall
652
- * @private
653
- */
 
 
654
  static private function uninstall()
655
  {
656
  if ( ! current_user_can( 'delete_plugins' ) ) {
1
  <?php
2
 
3
  /**
4
+ * Handles logic for the admin settings page.
5
  *
6
+ * @since 1.5.0
7
  */
8
  final class FLBuilderAdminSettings {
9
 
10
  /**
11
+ * Holds any errors that may arise from
12
+ * saving admin settings.
13
+ *
14
+ * @since 1.5.0
15
+ * @var array $errors
16
  */
17
  static public $errors = array();
18
 
19
  /**
20
+ * Adds the admin menu and enqueues CSS/JS if we are on
21
+ * the builder admin settings page.
22
+ *
23
+ * @since 1.5.0
24
+ * @return void
25
  */
26
  static public function init()
27
  {
28
+ add_action( 'admin_menu', 'FLBuilderAdminSettings::menu' );
29
 
30
+ if ( isset( $_REQUEST['page'] ) && 'fl-builder-settings' == $_REQUEST['page'] ) {
31
+ add_action( 'admin_enqueue_scripts', 'FLBuilderAdminSettings::styles_scripts' );
32
  self::save();
33
  }
34
  }
35
+
36
+ /**
37
+ * Enqueues the needed CSS/JS for the builder's admin settings page.
38
+ *
39
+ * @since 1.5.0
40
+ * @return void
41
+ */
42
  static public function styles_scripts()
43
  {
44
  // Styles
45
+ wp_enqueue_style( 'fl-builder-admin-settings', FL_BUILDER_URL . 'css/fl-builder-admin-settings.css', array(), FL_BUILDER_VERSION );
46
 
47
  // Scripts
48
+ wp_enqueue_script( 'fl-builder-admin-settings', FL_BUILDER_URL . 'js/fl-builder-admin-settings.js', array(), FL_BUILDER_VERSION );
49
 
50
  // Media Uploader
51
  wp_enqueue_media();
52
  }
53
+
54
+ /**
55
+ * Renders the admin settings menu.
56
+ *
57
+ * @since 1.5.0
58
+ * @return void
59
  */
60
  static public function menu()
61
  {
62
+ if ( current_user_can( 'delete_plugins' ) ) {
63
 
64
  $title = FLBuilderModel::get_branding();
65
  $cap = 'delete_plugins';
66
  $slug = 'fl-builder-settings';
67
  $func = 'FLBuilderAdminSettings::render';
68
 
69
+ add_submenu_page( 'options-general.php', $title, $title, $cap, $slug, $func );
70
  }
71
  }
72
+
73
+ /**
74
+ * Renders the admin settings.
75
+ *
76
+ * @since 1.5.0
77
+ * @return void
78
+ */
79
  static public function render()
80
  {
81
  include FL_BUILDER_DIR . 'includes/admin-settings-js-config.php';
82
  include FL_BUILDER_DIR . 'includes/admin-settings.php';
83
  }
84
+
85
+ /**
86
+ * Renders the page class for network installs and single site installs.
87
+ *
88
+ * @since 1.5.0
89
+ * @return void
90
+ */
91
  static public function render_page_class()
92
  {
93
  if ( self::multisite_support() ) {
97
  echo 'fl-settings-single-install';
98
  }
99
  }
100
+
101
+ /**
102
+ * Renders the admin settings page heading.
103
+ *
104
+ * @since 1.5.0
105
+ * @return void
106
+ */
107
  static public function render_page_heading()
108
  {
109
  $icon = FLBuilderModel::get_branding_icon();
115
 
116
  echo '<span>' . sprintf( _x( '%s Settings', '%s stands for custom branded "Page Builder" name.', 'fl-builder' ), FLBuilderModel::get_branding() ) . '</span>';
117
  }
118
+
119
+ /**
120
+ * Renders the update message.
121
+ *
122
+ * @since 1.5.0
123
+ * @return void
124
  */
125
  static public function render_update_message()
126
  {
133
  echo '<div class="updated"><p>' . __( 'Settings updated!', 'fl-builder' ) . '</p></div>';
134
  }
135
  }
136
+
137
+ /**
138
+ * Renders the nav items for the admin settings menu.
139
+ *
140
+ * @since 1.5.0
141
+ * @return void
142
+ */
143
  static public function render_nav_items()
144
  {
145
  $item_data = array(
195
  }
196
  }
197
  }
198
+
199
+ /**
200
+ * Renders the admin settings forms.
201
+ *
202
+ * @since 1.5.0
203
+ * @return void
204
+ */
205
  static public function render_forms()
206
  {
207
  // License
241
  // Uninstall
242
  self::render_form( 'uninstall' );
243
  }
244
+
245
+ /**
246
+ * Renders an admin settings form based on the type specified.
247
+ *
248
+ * @since 1.5.0
249
+ * @param string $type The type of form to render.
250
+ * @return void
251
+ */
252
  static public function render_form( $type )
253
  {
254
  if ( self::has_support( $type ) ) {
255
  include FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php';
256
  }
257
  }
258
+
259
+ /**
260
+ * Renders the action for a form.
261
+ *
262
+ * @since 1.5.0
263
+ * @param string $type The type of form being rendered.
264
+ * @return void
265
+ */
266
  static public function render_form_action( $type = '' )
267
  {
268
  if ( is_network_admin() ) {
272
  echo admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
273
  }
274
  }
275
+
276
+ /**
277
+ * Returns the action for a form.
278
+ *
279
+ * @since 1.5.0
280
+ * @param string $type The type of form being rendered.
281
+ * @return string The URL for the form action.
282
  */
283
  static public function get_form_action( $type = '' )
284
  {
289
  return admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
290
  }
291
  }
292
+
293
+ /**
294
+ * Checks to see if a settings form is supported.
295
+ *
296
+ * @since 1.5.0
297
+ * @param string $type The type of form to check.
298
+ * @return bool
299
+ */
300
  static public function has_support( $type )
301
  {
302
  return file_exists( FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php' );
303
  }
304
+
305
+ /**
306
+ * Checks to see if multisite is supported.
307
+ *
308
+ * @since 1.5.0
309
+ * @return bool
310
+ */
311
  static public function multisite_support()
312
  {
313
  return is_multisite() && class_exists( 'FLBuilderMultisiteSettings' );
314
  }
315
+
316
+ /**
317
+ * Adds an error message to be rendered.
318
+ *
319
+ * @since 1.5.0
320
+ * @param string $message The error message to add.
321
+ * @return void
322
+ */
323
  static public function add_error( $message )
324
  {
325
  self::$errors[] = $message;
326
  }
327
+
328
+ /**
329
+ * Saves the admin settings.
330
+ *
331
+ * @since 1.5.0
332
+ * @return void
333
+ */
334
  static public function save()
335
  {
336
  // Only admins can save settings.
348
  self::clear_cache();
349
  self::uninstall();
350
  }
351
+
352
+ /**
353
+ * Saves the enabled modules.
354
+ *
355
+ * @since 1.5.0
356
+ * @return void
357
+ */
358
  static private function save_enabled_modules()
359
  {
360
  if ( isset( $_POST['fl-modules-nonce'] ) && wp_verify_nonce( $_POST['fl-modules-nonce'], 'modules' ) ) {
376
  }
377
  }
378
  }
379
+
380
+ /**
381
+ * Saves the enabled templates.
382
+ *
383
+ * @since 1.5.0
384
+ * @return void
385
+ */
386
  static private function save_enabled_templates()
387
  {
388
  if ( isset( $_POST['fl-templates-nonce'] ) && wp_verify_nonce( $_POST['fl-templates-nonce'], 'templates' ) ) {
400
  }
401
  }
402
  }
403
+
404
+ /**
405
+ * Saves the enabled post types.
406
+ *
407
+ * @since 1.5.0
408
+ * @return void
409
+ */
410
  static private function save_enabled_post_types()
411
  {
412
  if ( isset( $_POST['fl-post-types-nonce'] ) && wp_verify_nonce( $_POST['fl-post-types-nonce'], 'post-types' ) ) {
434
  }
435
  }
436
  }
437
+
438
+ /**
439
+ * Saves the enabled icons.
440
+ *
441
+ * @since 1.5.0
442
+ * @return void
443
+ */
444
  static private function save_enabled_icons()
445
  {
446
  if ( isset( $_POST['fl-icons-nonce'] ) && wp_verify_nonce( $_POST['fl-icons-nonce'], 'icons' ) ) {
538
  self::update_enabled_icons( $enabled_icons );
539
  }
540
  }
541
+
542
+ /**
543
+ * Updates the enabled icons in the database.
544
+ *
545
+ * @since 1.5.0
546
+ * @return void
547
+ */
548
  static private function update_enabled_icons( $enabled_icons = array() )
549
  {
550
  if ( is_network_admin() ) {
558
  update_option( '_fl_builder_enabled_icons', $enabled_icons );
559
  }
560
  }
561
+
562
+ /**
563
+ * Saves the editing capability.
564
+ *
565
+ * @since 1.5.0
566
+ * @return void
567
+ */
568
  static private function save_editing_capability()
569
  {
570
  if ( isset( $_POST['fl-editing-nonce'] ) && wp_verify_nonce( $_POST['fl-editing-nonce'], 'editing' ) ) {
582
  }
583
  }
584
  }
585
+
586
+ /**
587
+ * Saves the branding settings.
588
+ *
589
+ * @since 1.5.0
590
+ * @return void
591
+ */
592
  static private function save_branding()
593
  {
594
  if ( isset( $_POST['fl-branding-nonce'] ) && wp_verify_nonce( $_POST['fl-branding-nonce'], 'branding' ) ) {
606
  }
607
  }
608
  }
609
+
610
+ /**
611
+ * Saves the help button settings.
612
+ *
613
+ * @since 1.5.0
614
+ * @return void
615
+ */
616
  static private function save_help_button()
617
  {
618
  if ( isset( $_POST['fl-help-button-nonce'] ) && wp_verify_nonce( $_POST['fl-help-button-nonce'], 'help-button' ) ) {
676
  }
677
  }
678
  }
679
+
680
+ /**
681
+ * Clears the builder cache.
682
+ *
683
+ * @since 1.5.3
684
+ * @return void
685
+ */
686
  static private function clear_cache()
687
  {
688
  if ( ! current_user_can( 'delete_plugins' ) ) {
697
  }
698
  }
699
  }
700
+
701
+ /**
702
+ * Clears the builder cache for all sites on a network.
703
+ *
704
+ * @since 1.5.3
705
+ * @return void
706
+ */
707
  static private function clear_cache_for_all_sites()
708
  {
709
  global $blog_id;
724
  // Revert to the original blog.
725
  switch_to_blog( $original_blog_id );
726
  }
727
+
728
+ /**
729
+ * Uninstalls the builder and all of its data.
730
+ *
731
+ * @since 1.5.0
732
+ * @return void
733
+ */
734
  static private function uninstall()
735
  {
736
  if ( ! current_user_can( 'delete_plugins' ) ) {
classes/class-fl-builder-loop.php CHANGED
@@ -13,21 +13,42 @@ final class FLBuilderLoop {
13
  */
14
  static public function query($settings)
15
  {
16
- $posts_per_page = empty($settings->posts_per_page) ? 10 : $settings->posts_per_page;
17
- $post_type = empty($settings->post_type) ? 'post' : $settings->post_type;
18
- $order_by = empty($settings->order_by) ? 'date' : $settings->order_by;
19
- $order = empty($settings->order) ? 'DESC' : $settings->order;
20
- $users = empty($settings->users) ? '' : $settings->users;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
 
22
  $args = array(
23
- 'paged' => is_front_page() ? get_query_var('page') : get_query_var('paged'),
24
  'posts_per_page' => $posts_per_page,
25
  'post_type' => $post_type,
26
  'orderby' => $order_by,
27
  'order' => $order,
28
  'author' => $users,
29
  'tax_query' => array('relation' => 'AND'),
30
- 'ignore_sticky_posts' => true
 
 
 
31
  );
32
 
33
  // Build the taxonomy query.
@@ -72,6 +93,18 @@ final class FLBuilderLoop {
72
  // Return the query.
73
  return $query;
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  /**
77
  * @method pagination
13
  */
14
  static public function query($settings)
15
  {
16
+ $posts_per_page = empty($settings->posts_per_page) ? 10 : $settings->posts_per_page;
17
+ $post_type = empty($settings->post_type) ? 'post' : $settings->post_type;
18
+ $order_by = empty($settings->order_by) ? 'date' : $settings->order_by;
19
+ $order = empty($settings->order) ? 'DESC' : $settings->order;
20
+ $users = empty($settings->users) ? '' : $settings->users;
21
+ $paged = is_front_page() ? get_query_var('page') : get_query_var('paged');
22
+
23
+ // Get the offset.
24
+ if ( ! isset( $settings->offset ) || ! is_int( ( int )$settings->offset ) ) {
25
+ $offset = 0;
26
+ }
27
+ else {
28
+ $offset = $settings->offset;
29
+ }
30
+
31
+ // Get the paged offset.
32
+ if ( $paged < 2 ) {
33
+ $paged_offset = $offset;
34
+ }
35
+ else {
36
+ $paged_offset = $offset + ( ( $paged - 1 ) * $posts_per_page );
37
+ }
38
 
39
+ // Build the query args.
40
  $args = array(
41
+ 'paged' => $paged,
42
  'posts_per_page' => $posts_per_page,
43
  'post_type' => $post_type,
44
  'orderby' => $order_by,
45
  'order' => $order,
46
  'author' => $users,
47
  'tax_query' => array('relation' => 'AND'),
48
+ 'ignore_sticky_posts' => true,
49
+ 'offset' => $paged_offset,
50
+ 'fl_original_offset' => $offset,
51
+ 'fl_builder_loop' => true
52
  );
53
 
54
  // Build the taxonomy query.
93
  // Return the query.
94
  return $query;
95
  }
96
+
97
+ /**
98
+ * @method found_posts
99
+ */
100
+ static public function found_posts( $found_posts, $query )
101
+ {
102
+ if ( isset( $query->query ) && isset( $query->query['fl_builder_loop'] ) ) {
103
+ return $found_posts - $query->query['fl_original_offset'];
104
+ }
105
+
106
+ return $found_posts;
107
+ }
108
 
109
  /**
110
  * @method pagination
classes/class-fl-builder-model.php CHANGED
@@ -624,25 +624,6 @@ final class FLBuilderModel {
624
  }
625
  }
626
 
627
- /**
628
- * Delete the asset cache if the domain has changed.
629
- *
630
- * @method delete_asset_cache_domain_change
631
- */
632
- static public function delete_asset_cache_domain_change()
633
- {
634
- $home_url = home_url();
635
- $saved_url = get_option( '_fl_builder_home_url' );
636
-
637
- if ( ! $saved_url ) {
638
- update_option( '_fl_builder_home_url', $home_url );
639
- }
640
- else if ( $home_url != $saved_url ) {
641
- self::delete_all_asset_cache();
642
- update_option( '_fl_builder_home_url', $home_url );
643
- }
644
- }
645
-
646
  /**
647
  * @method generate_node_id
648
  */
@@ -2478,6 +2459,9 @@ final class FLBuilderModel {
2478
 
2479
  // Get the templates array.
2480
  $templates = self::get_templates();
 
 
 
2481
 
2482
  // Get new ids for the nodes.
2483
  $settings->nodes = self::generate_new_node_ids($data);
@@ -2729,8 +2713,8 @@ final class FLBuilderModel {
2729
  $defaults = array(
2730
  'enabled' => true,
2731
  'tour' => true,
2732
- 'video' => false,
2733
- 'video_embed' => '<iframe width="420" height="315" src="https://www.youtube.com/embed/CNJbH2gaACo" frameborder="0" allowfullscreen></iframe>',
2734
  'knowledge_base' => true,
2735
  'knowledge_base_url' => 'https://www.wpbeaverbuilder.com/knowledge-base/?utm_source=external&utm_medium=builder&utm_campaign=docs-button',
2736
  'forums' => true,
@@ -2765,6 +2749,48 @@ final class FLBuilderModel {
2765
  }
2766
  }
2767
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2768
  /**
2769
  * @method plugin_basename
2770
  */
624
  }
625
  }
626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
627
  /**
628
  * @method generate_node_id
629
  */
2459
 
2460
  // Get the templates array.
2461
  $templates = self::get_templates();
2462
+
2463
+ // Make sure we have an object.
2464
+ $settings = ( object )$settings;
2465
 
2466
  // Get new ids for the nodes.
2467
  $settings->nodes = self::generate_new_node_ids($data);
2713
  $defaults = array(
2714
  'enabled' => true,
2715
  'tour' => true,
2716
+ 'video' => true,
2717
+ 'video_embed' => '<iframe src="https://player.vimeo.com/video/124230072?autoplay=1" width="420" height="315" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>',
2718
  'knowledge_base' => true,
2719
  'knowledge_base_url' => 'https://www.wpbeaverbuilder.com/knowledge-base/?utm_source=external&utm_medium=builder&utm_campaign=docs-button',
2720
  'forums' => true,
2749
  }
2750
  }
2751
 
2752
+ /**
2753
+ * @method get_services
2754
+ */
2755
+ static public function get_services()
2756
+ {
2757
+ return get_option( '_fl_builder_services', array() );
2758
+ }
2759
+
2760
+ /**
2761
+ * @method update_services
2762
+ */
2763
+ static public function update_services( $service, $account, $data )
2764
+ {
2765
+ $services = self::get_services();
2766
+ $account = sanitize_text_field( $account );
2767
+
2768
+ if ( ! isset( $services[ $service ] ) ) {
2769
+ $services[ $service ] = array();
2770
+ }
2771
+
2772
+ $services[ $service ][ $account ] = $data;
2773
+
2774
+ update_option( '_fl_builder_services', $services );
2775
+ }
2776
+
2777
+ /**
2778
+ * @method delete_service_account
2779
+ */
2780
+ static public function delete_service_account( $service, $account )
2781
+ {
2782
+ $services = self::get_services();
2783
+
2784
+ if ( isset( $services[ $service ][ $account ] ) ) {
2785
+ unset( $services[ $service ][ $account ] );
2786
+ }
2787
+ if ( 0 === count( $services[ $service ] ) ) {
2788
+ unset( $services[ $service ] );
2789
+ }
2790
+
2791
+ update_option( '_fl_builder_services', $services );
2792
+ }
2793
+
2794
  /**
2795
  * @method plugin_basename
2796
  */
classes/class-fl-builder-photo.php CHANGED
@@ -55,10 +55,13 @@ final class FLBuilderPhoto {
55
  */
56
  static public function get_thumb($photo)
57
  {
58
- if(empty($photo)) {
59
  echo FL_BUILDER_URL . 'img/spacer.png';
60
  }
61
- else if(!empty($photo->sizes->thumbnail)) {
 
 
 
62
  echo $photo->sizes->thumbnail->url;
63
  }
64
  else {
@@ -71,20 +74,26 @@ final class FLBuilderPhoto {
71
  */
72
  static public function get_src_options($selected, $photo)
73
  {
74
- $titles = array(
75
- 'full' => _x( 'Full Size', 'Image size.', 'fl-builder' ),
76
- 'large' => _x( 'Large', 'Image size.', 'fl-builder' ),
77
- 'medium' => _x( 'Medium', 'Image size.', 'fl-builder' ),
78
- 'thumbnail' => _x( 'Thumbnail', 'Image size.', 'fl-builder' )
79
- );
80
-
81
- foreach($photo->sizes as $key => $val) {
82
-
83
- if(!isset($titles[$key])) {
84
- $titles[$key] = ucwords(str_replace(array('_', '-'), ' ', $key));
85
- }
86
-
87
- echo '<option value="' . $val->url . '" ' . selected($selected, $val->url) . '>' . $titles[$key] . ' - ' . $val->width . ' x ' . $val->height . '</option>';
88
- }
 
 
 
 
 
 
89
  }
90
  }
55
  */
56
  static public function get_thumb($photo)
57
  {
58
+ if ( empty( $photo ) ) {
59
  echo FL_BUILDER_URL . 'img/spacer.png';
60
  }
61
+ else if ( ! isset( $photo->sizes ) ) {
62
+ echo $photo->url;
63
+ }
64
+ else if ( ! empty( $photo->sizes->thumbnail ) ) {
65
  echo $photo->sizes->thumbnail->url;
66
  }
67
  else {
74
  */
75
  static public function get_src_options($selected, $photo)
76
  {
77
+ if ( ! isset( $photo->sizes ) ) {
78
+ echo '<option value="' . $photo->url . '" selected="selected">' . _x( 'Full Size', 'Image size.', 'fl-builder' ) . '</option>';
79
+ }
80
+ else {
81
+
82
+ $titles = array(
83
+ 'full' => _x( 'Full Size', 'Image size.', 'fl-builder' ),
84
+ 'large' => _x( 'Large', 'Image size.', 'fl-builder' ),
85
+ 'medium' => _x( 'Medium', 'Image size.', 'fl-builder' ),
86
+ 'thumbnail' => _x( 'Thumbnail', 'Image size.', 'fl-builder' )
87
+ );
88
+
89
+ foreach($photo->sizes as $key => $val) {
90
+
91
+ if(!isset($titles[$key])) {
92
+ $titles[$key] = ucwords(str_replace(array('_', '-'), ' ', $key));
93
+ }
94
+
95
+ echo '<option value="' . $val->url . '" ' . selected($selected, $val->url) . '>' . $titles[$key] . ' - ' . $val->width . ' x ' . $val->height . '</option>';
96
+ }
97
+ }
98
  }
99
  }
classes/class-fl-builder-service-aweber.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Helper class for the AWeber API.
5
+ *
6
+ * @since 1.5.4
7
+ */
8
+ final class FLBuilderServiceAWeber extends FLBuilderService {
9
+
10
+ /**
11
+ * The ID for this service.
12
+ *
13
+ * @since 1.5.4
14
+ * @var string $id
15
+ */
16
+ public $id = 'aweber';
17
+
18
+ /**
19
+ * @since 1.5.4
20
+ * @var object $api_instance
21
+ * @access private
22
+ */
23
+ private $api_instance = null;
24
+
25
+ /**
26
+ * Get an instance of the API.
27
+ *
28
+ * @since 1.5.4
29
+ * @param string $auth_code A valid authorization code.
30
+ * @return object The API instance.
31
+ */
32
+ public function get_api( $auth_code )
33
+ {
34
+ if ( $this->api_instance ) {
35
+ return $this->api_instance;
36
+ }
37
+ if ( ! class_exists( 'AWeberAPI' ) ) {
38
+ require_once FL_BUILDER_DIR . 'includes/vendor/aweber/aweber_api.php';
39
+ }
40
+
41
+ list( $auth_key, $auth_token, $req_key, $req_token, $oauth ) = explode( '|', $auth_code );
42
+
43
+ $this->api_instance = new AWeberAPI( $auth_key, $auth_token );
44
+ $this->api_instance->user->requestToken = $req_key;
45
+ $this->api_instance->user->tokenSecret = $req_token;
46
+ $this->api_instance->user->verifier = $oauth;
47
+
48
+ return $this->api_instance;
49
+ }
50
+
51
+ /**
52
+ * Test the API connection.
53
+ *
54
+ * @since 1.5.4
55
+ * @param array $fields {
56
+ * @type string $auth_code A valid authorization code.
57
+ * }
58
+ * @return array{
59
+ * @type bool|string $error The error message or false if no error.
60
+ * @type array $data An array of data used to make the connection.
61
+ * }
62
+ */
63
+ public function connect( $fields = array() )
64
+ {
65
+ $response = array(
66
+ 'error' => false,
67
+ 'data' => array()
68
+ );
69
+
70
+ // Make sure we have an authorization code.
71
+ if ( ! isset( $fields['auth_code'] ) || empty( $fields['auth_code'] ) ) {
72
+ $response['error'] = __( 'Error: You must provide an Authorization Code.', 'fl-builder' );
73
+ }
74
+ // Make sure we have a valid authorization code.
75
+ else if ( 6 != count( explode( '|', $fields['auth_code'] ) ) ) {
76
+ $response['error'] = __( 'Error: Please enter a valid Authorization Code.', 'fl-builder' );
77
+ }
78
+ // Try to connect and store the connection data.
79
+ else {
80
+
81
+ $api = $this->get_api( $fields['auth_code'] );
82
+
83
+ // Get an access token from the API.
84
+ try {
85
+ list( $access_token, $access_token_secret ) = $api->getAccessToken();
86
+ }
87
+ catch ( AWeberException $e ) {
88
+ $response['error'] = $e->getMessage();
89
+ }
90
+
91
+ // Make sure we can get the account.
92
+ try {
93
+ $account = $api->getAccount();
94
+ }
95
+ catch ( AWeberException $e ) {
96
+ $response['error'] = $e->getMessage();
97
+ }
98
+
99
+ // Build the response data.
100
+ if ( ! $response['error'] ) {
101
+
102
+ $response['data'] = array(
103
+ 'auth_code' => $fields['auth_code'],
104
+ 'access_token' => $access_token,
105
+ 'access_secret' => $access_token_secret
106
+ );
107
+ }
108
+ }
109
+
110
+ return $response;
111
+ }
112
+
113
+ /**
114
+ * Renders the markup for the connection settings.
115
+ *
116
+ * @since 1.5.4
117
+ * @return string The connection settings markup.
118
+ */
119
+ public function render_connect_settings()
120
+ {
121
+ ob_start();
122
+
123
+ FLBuilder::render_settings_field( 'auth_code', array(
124
+ 'row_class' => 'fl-builder-service-connect-row',
125
+ 'class' => 'fl-builder-service-connect-input',
126
+ 'type' => 'text',
127
+ 'label' => __( 'Authorization Code', 'fl-builder' ),
128
+ 'description' => sprintf( __( 'Please register this website with AWeber to get your Authorization Code. <a%s>Register Now</a>', 'fl-builder' ), ' href="https://auth.aweber.com/1.0/oauth/authorize_app/baa1f131" target="_blank"' ),
129
+ 'preview' => array(
130
+ 'type' => 'none'
131
+ )
132
+ ));
133
+
134
+ return ob_get_clean();
135
+ }
136
+
137
+ /**
138
+ * Render the markup for service specific fields.
139
+ *
140
+ * @since 1.5.4
141
+ * @param string $account The name of the saved account.
142
+ * @param object $settings Saved module settings.
143
+ * @return array {
144
+ * @type bool|string $error The error message or false if no error.
145
+ * @type string $html The field markup.
146
+ * }
147
+ */
148
+ public function render_fields( $account, $settings )
149
+ {
150
+ $account_data = $this->get_account_data( $account );
151
+ $api = $this->get_api( $account_data['auth_code'] );
152
+ $response = array(
153
+ 'error' => false,
154
+ 'html' => ''
155
+ );
156
+
157
+ try {
158
+ $account = $api->getAccount( $account_data['access_token'], $account_data['access_secret'] );
159
+ $lists = $account->loadFromUrl( '/accounts/' . $account->id . '/lists' );
160
+ $response['html'] = $this->render_list_field( $lists, $settings );
161
+ }
162
+ catch ( AWeberException $e ) {
163
+ $response['error'] = $e->getMessage();
164
+ }
165
+
166
+ return $response;
167
+ }
168
+
169
+ /**
170
+ * Render markup for the list field.
171
+ *
172
+ * @since 1.5.4
173
+ * @param array $lists List data from the API.
174
+ * @param object $settings Saved module settings.
175
+ * @return string The markup for the list field.
176
+ * @access private
177
+ */
178
+ private function render_list_field( $lists, $settings )
179
+ {
180
+ ob_start();
181
+
182
+ $options = array( '' => __( 'Choose...', 'fl-builder' ) );
183
+
184
+ foreach ( $lists->data['entries'] as $list ) {
185
+ $options[ $list['id'] ] = $list['name'];
186
+ }
187
+
188
+ FLBuilder::render_settings_field( 'list_id', array(
189
+ 'row_class' => 'fl-builder-service-field-row',
190
+ 'class' => 'fl-builder-service-list-select',
191
+ 'type' => 'select',
192
+ 'label' => __( 'List', 'fl-builder' ),
193
+ 'options' => $options,
194
+ 'preview' => array(
195
+ 'type' => 'none'
196
+ )
197
+ ), $settings);
198
+
199
+ return ob_get_clean();
200
+ }
201
+
202
+ /**
203
+ * Subscribe an email address to AWeber.
204
+ *
205
+ * @since 1.5.4
206
+ * @param object $settings A module settings object.
207
+ * @param string $email The email to subscribe.
208
+ * @param string $name Optional. The full name of the person subscribing.
209
+ * @return array {
210
+ * @type bool|string $error The error message or false if no error.
211
+ * }
212
+ */
213
+ public function subscribe( $settings, $email, $name = false )
214
+ {
215
+ $account_data = $this->get_account_data( $settings->service_account );
216
+ $response = array( 'error' => false );
217
+
218
+ if ( ! $account_data ) {
219
+ $response['error'] = __( 'There was an error subscribing to AWeber. The account is no longer connected.', 'fl-builder' );
220
+ }
221
+ else {
222
+
223
+ $api = $this->get_api( $account_data['auth_code'] );
224
+ $data = array(
225
+ 'ws.op' => 'create',
226
+ 'email' => $email
227
+ );
228
+
229
+ if ( $name ) {
230
+ $data['name'] = $name;
231
+ }
232
+
233
+ try {
234
+ $account = $api->getAccount( $account_data['access_token'], $account_data['access_secret'] );
235
+ $url = '/accounts/' . $account->id . '/lists/' . $settings->list_id . '/subscribers';
236
+ $result = $api->adapter->request( 'POST', $url, $data, array( 'return' => 'headers' ) );
237
+
238
+ if ( is_array( $result ) && isset( $result['Status-Code'] ) && 201 == $result['Status-Code'] ) {
239
+ return $response;
240
+ }
241
+ else {
242
+ $response['error'] = __( 'There was an error connecting to AWeber. Please try again.', 'fl-builder' );
243
+ }
244
+ }
245
+ catch ( AWeberAPIException $e ) {
246
+ $response['error'] = sprintf(
247
+ __( 'There was an error subscribing to AWeber. %s', 'fl-builder' ),
248
+ $e->getMessage()
249
+ );
250
+ }
251
+ }
252
+
253
+ return $response;
254
+ }
255
+ }
classes/class-fl-builder-service-campaign-monitor.php ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Helper class for the Campaign Monitor API.
5
+ *
6
+ * @since 1.5.4
7
+ */
8
+ final class FLBuilderServiceCampaignMonitor extends FLBuilderService {
9
+
10
+ /**
11
+ * The ID for this service.
12
+ *
13
+ * @since 1.5.4
14
+ * @var string $id
15
+ */
16
+ public $id = 'campaign-monitor';
17
+
18
+ /**
19
+ * Constructor function.
20
+ *
21
+ * @since 1.5.4
22
+ * @return void
23
+ */
24
+ public function __construct()
25
+ {
26
+ if ( ! class_exists( 'CS_REST_General' ) ) {
27
+ require_once FL_BUILDER_DIR . 'includes/vendor/campaign-monitor/csrest_general.php';
28
+ require_once FL_BUILDER_DIR . 'includes/vendor/campaign-monitor/csrest_clients.php';
29
+ require_once FL_BUILDER_DIR . 'includes/vendor/campaign-monitor/csrest_lists.php';
30
+ require_once FL_BUILDER_DIR . 'includes/vendor/campaign-monitor/csrest_subscribers.php';
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Test the API connection.
36
+ *
37
+ * @since 1.5.4
38
+ * @param array $fields {
39
+ * @type string $api_key A valid API key.
40
+ * }
41
+ * @return array{
42
+ * @type bool|string $error The error message or false if no error.
43
+ * @type array $data An array of data used to make the connection.
44
+ * }
45
+ */
46
+ public function connect( $fields = array() )
47
+ {
48
+ $response = array(
49
+ 'error' => false,
50
+ 'data' => array()
51
+ );
52
+
53
+ // Make sure we have an API key.
54
+ if ( ! isset( $fields['api_key'] ) || empty( $fields['api_key'] ) ) {
55
+ $response['error'] = __( 'Error: You must provide an API key.', 'fl-builder' );
56
+ }
57
+ // Try to connect and store the connection data.
58
+ else {
59
+
60
+ $api = new CS_REST_General( array( 'api_key' => $fields['api_key'] ) );
61
+ $result = $api->get_clients();
62
+
63
+ if ( $result->was_successful() ) {
64
+ $response['data'] = array( 'api_key' => $fields['api_key'] );
65
+ }
66
+ else {
67
+ $response['error'] = __( 'Error: Please check your API key.', 'fl-builder' );
68
+ }
69
+ }
70
+
71
+ return $response;
72
+ }
73
+
74
+ /**
75
+ * Renders the markup for the connection settings.
76
+ *
77
+ * @since 1.5.4
78
+ * @return string The connection settings markup.
79
+ */
80
+ public function render_connect_settings()
81
+ {
82
+ ob_start();
83
+
84
+ FLBuilder::render_settings_field( 'api_key', array(
85
+ 'row_class' => 'fl-builder-service-connect-row',
86
+ 'class' => 'fl-builder-service-connect-input',
87
+ 'type' => 'text',
88
+ 'label' => __( 'API Key', 'fl-builder' ),
89
+ 'help' => __( 'Your API key can be found in your Campaign Monitor account under Account Settings > API Key.', 'fl-builder' ),
90
+ 'preview' => array(
91
+ 'type' => 'none'
92
+ )
93
+ ));
94
+
95
+ return ob_get_clean();
96
+ }
97
+
98
+ /**
99
+ * Render the markup for service specific fields.
100
+ *
101
+ * @since 1.5.4
102
+ * @param string $account The name of the saved account.
103
+ * @param object $settings Saved module settings.
104
+ * @return array {
105
+ * @type bool|string $error The error message or false if no error.
106
+ * @type string $html The field markup.
107
+ * }
108
+ */
109
+ public function render_fields( $account, $settings )
110
+ {
111
+ $post_data = FLBuilderModel::get_post_data();
112
+ $account_data = $this->get_account_data( $account );
113
+ $api = new CS_REST_General( $account_data );
114
+ $result = $api->get_clients();
115
+ $response = array(
116
+ 'error' => false,
117
+ 'html' => ''
118
+ );
119
+
120
+ if ( $result->was_successful() ) {
121
+
122
+ if ( ! isset( $post_data['client'] ) ) {
123
+ $response['html'] .= $this->render_client_field( $result, $settings );
124
+ }
125
+
126
+ $response['html'] .= $this->render_list_field( $account_data, $settings );
127
+ }
128
+ else {
129
+ $response['error'] = __( 'Error: Please check your API key.', 'fl-builder' );
130
+ }
131
+
132
+ return $response;
133
+ }
134
+
135
+ /**
136
+ * Render markup for the client field.
137
+ *
138
+ * @since 1.5.4
139
+ * @param array $clients Client data from the API.
140
+ * @param object $settings Saved module settings.
141
+ * @return string The markup for the list field.
142
+ * @access private
143
+ */
144
+ private function render_client_field( $clients, $settings )
145
+ {
146
+ ob_start();
147
+
148
+ $options = array( '' => __( 'Choose...', 'fl-builder' ) );
149
+
150
+ foreach ( $clients->response as $client ) {
151
+ $options[ $client->ClientID ] = $client->Name;
152
+ }
153
+
154
+ FLBuilder::render_settings_field( 'client_id', array(
155
+ 'row_class' => 'fl-builder-service-field-row',
156
+ 'class' => 'fl-builder-campaign-monitor-client-select',
157
+ 'type' => 'select',
158
+ 'label' => __( 'Client', 'fl-builder' ),
159
+ 'options' => $options,
160
+ 'preview' => array(
161
+ 'type' => 'none'
162
+ )
163
+ ), $settings);
164
+
165
+ return ob_get_clean();
166
+ }
167
+
168
+ /**
169
+ * Render markup for the list field.
170
+ *
171
+ * @since 1.5.4
172
+ * @param array $account_data Saved account data.
173
+ * @param object $settings Saved module settings.
174
+ * @return string The markup for the list field.
175
+ * @access private
176
+ */
177
+ private function render_list_field( $account_data, $settings )
178
+ {
179
+ $post_data = FLBuilderModel::get_post_data();
180
+
181
+ // Get the client ID. Return an empty string if we don't have one yet.
182
+ if ( isset( $post_data['client'] ) ) {
183
+ $client_id = $post_data['client'];
184
+ }
185
+ else if ( isset( $settings->client_id ) ) {
186
+ $client_id = $settings->client_id;
187
+ }
188
+ else {
189
+ return '';
190
+ }
191
+
192
+ // Get the list data.
193
+ $api = new CS_REST_Clients( $client_id, $account_data );
194
+ $lists = $api->get_lists();
195
+
196
+ // Render the list field.
197
+ ob_start();
198
+
199
+ $options = array( '' => __( 'Choose...', 'fl-builder' ) );
200
+
201
+ foreach ( $lists->response as $list ) {
202
+ $options[ $list->ListID ] = $list->Name;
203
+ }
204
+
205
+ FLBuilder::render_settings_field( 'list_id', array(
206
+ 'row_class' => 'fl-builder-service-field-row',
207
+ 'class' => 'fl-builder-service-list-select',
208
+ 'type' => 'select',
209
+ 'label' => __( 'List', 'fl-builder' ),
210
+ 'options' => $options,
211
+ 'preview' => array(
212
+ 'type' => 'none'
213
+ )
214
+ ), $settings);
215
+
216
+ return ob_get_clean();
217
+ }
218
+
219
+ /**
220
+ * Subscribe an email address to Campaign Monitor.
221
+ *
222
+ * @since 1.5.4
223
+ * @param object $settings A module settings object.
224
+ * @param string $email The email to subscribe.
225
+ * @param string $name Optional. The full name of the person subscribing.
226
+ * @return array {
227
+ * @type bool|string $error The error message or false if no error.
228
+ * }
229
+ */
230
+ public function subscribe( $settings, $email, $name = false )
231
+ {
232
+ $account_data = $this->get_account_data( $settings->service_account );
233
+ $response = array( 'error' => false );
234
+
235
+ if ( ! $account_data ) {
236
+ $response['error'] = __( 'There was an error subscribing to Campaign Monitor. The account is no longer connected.', 'fl-builder' );
237
+ }
238
+ else {
239
+
240
+ $api = new CS_Rest_Subscribers( $settings->list_id, $account_data );
241
+ $data = array(
242
+ 'EmailAddress' => $email,
243
+ 'Resubscribe' => true
244
+ );
245
+
246
+ if ( $name ) {
247
+ $data['Name'] = $name;
248
+ }
249
+
250
+ $result = $api->add( $data );
251
+
252
+ if ( ! $result->was_successful() ) {
253
+ $response['error'] = __( 'There was an error subscribing to Campaign Monitor.', 'fl-builder' );
254
+ }
255
+ }
256
+
257
+ return $response;
258
+ }
259
+ }
classes/class-fl-builder-service-constant-contact.php ADDED
@@ -0,0 +1,286 @@