PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 4.12.0
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v4.12.0
4.12.0 4.10.0 4.9.0 4.8.1 trunk 1.0 1.1 1.12.1 1.2.3 1.2.4 1.2.5 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5 1.5.1 1.5.2 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.5.1 1.6.6 1.6.6.1 1.6.6.2 1.6.6.3 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.9.0 1.9.1 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.8.1 1.9.9 1.9.9.1 1.9.9.2 1.9.9.3 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.10 2.11 2.11.1 2.12 2.12.1 2.12.2 2.12.3 2.12.4 2.13 2.14 2.14.1 2.15 2.15.1 2.16 2.16.1 2.17 2.17.1 2.18 2.18.1 2.18.2 2.18.3 2.19 2.19.1 2.19.2 2.19.3 2.2 2.2.1 2.3 2.3.1 2.3.10 2.3.2 2.3.3 2.3.4 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.1.1 2.4.1.2 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5 2.5.1 2.5.2 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.7 2.7.1 2.7.2 2.8 2.9 2.9.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.7.5 4.7.6 4.7.7
custom-facebook-feed / inc / Integrations / Divi / CFF_Divi_Handler.php
custom-facebook-feed / inc / Integrations / Divi Last commit date
CFF_Divi_Handler.php 2 weeks ago SBFacebookFeed.php 2 weeks ago index.php 2 weeks ago
CFF_Divi_Handler.php
190 lines
1 <?php
2
3 namespace CustomFacebookFeed\Integrations\Divi;
4
5 use CustomFacebookFeed\CFF_Utils;
6 use CustomFacebookFeed\Integrations\CFF_Integration;
7
8 if (!defined('ABSPATH')) {
9 exit; // Exit if accessed directly
10 }
11
12 /**
13 * Class Divi Handler.
14 *
15 * @since 4.3
16 */
17 class CFF_Divi_Handler
18 {
19 /**
20 * Constructor.
21 *
22 * @since 4.3
23 */
24 public function __construct()
25 {
26 $this->load();
27 }
28
29
30 /**
31 * Indicate if current integration is allowed to load.
32 *
33 * @since 4.3
34 *
35 * @return bool
36 */
37 public function allow_load()
38 {
39 if (function_exists('et_divi_builder_init_plugin')) {
40 return true;
41 }
42
43 $allow_themes = ['Divi'];
44 $theme_name = get_template();
45
46 return in_array($theme_name, $allow_themes, true);
47 }
48
49
50 /**
51 * Load an integration.
52 *
53 * @since 4.3
54 */
55 public function load()
56 {
57 if ($this->allow_load()) {
58 $this->hooks();
59 }
60 }
61
62
63 /**
64 * Hooks.
65 *
66 * @since 4.3
67 */
68 public function hooks()
69 {
70
71 add_action('et_builder_ready', [ $this, 'register_module' ]);
72
73 if (wp_doing_ajax()) {
74 add_action('wp_ajax_sb_facebookfeed_divi_preview', [ $this, 'preview' ]);
75 }
76
77 if ($this->is_divi_builder()) {
78 add_action('wp_enqueue_scripts', [ $this, 'builder_scripts' ]);
79 }
80 }
81
82 /**
83 * Load scripts.
84 *
85 * @since 4.3
86 */
87 public function builder_scripts()
88 {
89
90 wp_enqueue_script(
91 'sbfacebook-divi',
92 // The unminified version is not supported by the browser.
93 CFF_PLUGIN_URL . 'admin/assets/js/divi-handler.min.js',
94 [ 'react', 'react-dom', 'jquery' ],
95 CFFVER,
96 true
97 );
98
99 wp_enqueue_script(
100 'cff-builders-handler',
101 // The unminified version is not supported by the browser.
102 CFF_PLUGIN_URL . 'admin/assets/js/builders-preview-handler.js',
103 ['jquery'],
104 CFFVER,
105 true
106 );
107
108 wp_localize_script(
109 'sbfacebook-divi',
110 'sb_divi_builder',
111 [
112 'ajax_handler' => admin_url('admin-ajax.php'),
113 'nonce' => wp_create_nonce('cff-admin'),
114 'feed_splash' => htmlspecialchars(CFF_Integration::get_widget_cta('button'))
115 ]
116 );
117 wp_register_script(
118 'cffscripts',
119 CFF_PLUGIN_URL . 'assets/js/cff-scripts.min.js',
120 array('jquery'),
121 CFFVER,
122 true
123 );
124 wp_localize_script(
125 'cffscripts',
126 'cffOptions',
127 [
128 'placeholder' => CFF_PLUGIN_URL . 'assets/img/placeholder.png',
129 ]
130 );
131 }
132
133
134 /**
135 * Register module.
136 *
137 * @since 4.3
138 */
139 public function register_module()
140 {
141
142 if (! class_exists('ET_Builder_Module')) {
143 return;
144 }
145
146 new SBFacebookFeed();
147 }
148
149
150 /**
151 * Ajax handler for the Feed preview.
152 *
153 * @since 4.3
154 */
155 public function preview()
156 {
157
158 // check_ajax_referer('cff-admin', 'nonce');
159
160 $cap = current_user_can('manage_custom_facebook_feed_options') ? 'manage_custom_facebook_feed_options' : 'manage_options';
161 $cap = apply_filters('cff_settings_pages_capability', $cap);
162 if (! current_user_can($cap)) {
163 wp_send_json_error(); // This auto-dies.
164 }
165
166 $feed_id = absint(filter_input(INPUT_POST, 'feed_id', FILTER_SANITIZE_NUMBER_INT));
167
168 wp_send_json_success(
169 do_shortcode(
170 sprintf(
171 '[custom-facebook-feed feed="%1$s" disable-js-loading="true"]',
172 absint($feed_id)
173 )
174 )
175 );
176 }
177
178 /**
179 * Determine if a current page is opened in the Divi Builder.
180 *
181 * @since 4.3
182 *
183 * @return bool
184 */
185 private function is_divi_builder()
186 {
187 return ! empty($_GET['et_fb']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
188 }
189 }
190