PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 4.1.5
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v4.1.5
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 / CFF_Blocks.php
custom-facebook-feed / inc Last commit date
Admin 3 years ago Builder 3 years ago Helpers 3 years ago CFF_Autolink.php 3 years ago CFF_Blocks.php 3 years ago CFF_Cache.php 3 years ago CFF_Education.php 3 years ago CFF_Elementor_Base.php 3 years ago CFF_Elementor_Widget.php 3 years ago CFF_Error_Reporter.php 3 years ago CFF_FB_Settings.php 3 years ago CFF_Feed_Elementor_Control.php 3 years ago CFF_Feed_Locator.php 3 years ago CFF_Feed_Pro.php 3 years ago CFF_GDPR_Integrations.php 3 years ago CFF_Group_Posts.php 3 years ago CFF_HTTP_Request.php 3 years ago CFF_Oembed.php 3 years ago CFF_Parse.php 3 years ago CFF_Resizer.php 3 years ago CFF_Response.php 3 years ago CFF_Shortcode.php 3 years ago CFF_Shortcode_Display.php 3 years ago CFF_SiteHealth.php 3 years ago CFF_Utils.php 3 years ago CFF_View.php 3 years ago Custom_Facebook_Feed.php 3 years ago SB_Facebook_Data_Encryption.php 3 years ago SB_Facebook_Data_Manager.php 3 years ago
CFF_Blocks.php
169 lines
1 <?php
2 /**
3 * Custom Facebook Feed block with live preview.
4 *
5 * @since 2.3
6 */
7 namespace CustomFacebookFeed;
8
9 class CFF_Blocks {
10
11 /**
12 * Indicates if current integration is allowed to load.
13 *
14 * @since 1.8
15 *
16 * @return bool
17 */
18 public function allow_load() {
19 return function_exists( 'register_block_type' );
20 }
21
22 /**
23 * Loads an integration.
24 *
25 * @since 2.3
26 */
27 public function load() {
28 $this->hooks();
29 }
30
31 /**
32 * Integration hooks.
33 *
34 * @since 2.3
35 */
36 protected function hooks() {
37 add_action( 'init', array( $this, 'register_block' ) );
38 add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
39 }
40
41 /**
42 * Register Custom Facebook Feed Gutenberg block on the backend.
43 *
44 * @since 2.3
45 */
46 public function register_block() {
47
48 wp_register_style(
49 'cff-blocks-styles',
50 trailingslashit( CFF_PLUGIN_URL ) . 'assets/css/cff-blocks.css',
51 array( 'wp-edit-blocks' ),
52 CFFVER
53 );
54
55 $attributes = array(
56 'shortcodeSettings' => array(
57 'type' => 'string',
58 ),
59 'noNewChanges' => array(
60 'type' => 'boolean',
61 ),
62 'executed' => array(
63 'type' => 'boolean',
64 )
65 );
66
67 register_block_type(
68 'cff/cff-feed-block',
69 array(
70 'attributes' => $attributes,
71 'render_callback' => array( $this, 'get_feed_html' ),
72 )
73 );
74 }
75
76 /**
77 * Load Custom Facebook Feed Gutenberg block scripts.
78 *
79 * @since 2.3
80 */
81 public function enqueue_block_editor_assets() {
82 $access_token = get_option('cff_access_token');
83
84 \cff_main()->enqueue_styles_assets();
85 \cff_main()->enqueue_scripts_assets();
86
87 #cff_add_my_stylesheet();
88 #cff_scripts_method();
89
90 wp_enqueue_style( 'cff-blocks-styles' );
91 wp_enqueue_script(
92 'cff-feed-block',
93 trailingslashit( CFF_PLUGIN_URL ) . 'assets/js/cff-blocks.js',
94 array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
95 CFFVER,
96 true
97 );
98
99 $shortcodeSettings = '';
100
101 $i18n = array(
102 'addSettings' => esc_html__( 'Add Settings', 'custom-facebook-feed' ),
103 'shortcodeSettings' => esc_html__( 'Shortcode Settings', 'custom-facebook-feed' ),
104 'example' => esc_html__( 'Example', 'custom-facebook-feed' ),
105 'preview' => esc_html__( 'Apply Changes', 'custom-facebook-feed' ),
106
107 );
108
109 if ( ! empty( $_GET['cff_wizard'] ) ) {
110 $shortcodeSettings = 'feed="' . (int)$_GET['cff_wizard'] . '"';
111 }
112
113 wp_localize_script(
114 'cff-feed-block',
115 'cff_block_editor',
116 array(
117 'wpnonce' => wp_create_nonce( 'facebook-blocks' ),
118 'canShowFeed' => ! empty( $access_token ),
119 'configureLink' => get_admin_url() . '?page=cff-settings',
120 'shortcodeSettings' => $shortcodeSettings,
121 'i18n' => $i18n,
122 )
123 );
124 }
125
126 /**
127 * Get form HTML to display in a Custom Facebook Feed Gutenberg block.
128 *
129 * @param array $attr Attributes passed by Custom Facebook Feed Gutenberg block.
130 *
131 * @since 2.3
132 *
133 * @return string
134 */
135 public function get_feed_html( $attr ) {
136
137 $return = '';
138
139 $shortcode_settings = isset( $attr['shortcodeSettings'] ) ? $attr['shortcodeSettings'] : '';
140
141 if ( empty( $cff_statuses['support_legacy_shortcode'] ) ) {
142 if ( empty( $shortcode_settings ) || strpos( $shortcode_settings, 'feed=' ) === false ){
143 $feeds = \CustomFacebookFeed\Builder\CFF_Feed_Builder::get_feed_list();
144 $feed_id = $feeds[0]['id'];
145 $shortcode_settings .= ' feed="' . (int)$feed_id . '"';
146 }
147 }
148
149 $shortcode_settings = str_replace(array( '[custom-facebook-feed', ']' ), '', $shortcode_settings);
150
151 $return .= do_shortcode( '[custom-facebook-feed '.$shortcode_settings.']' );
152
153 return $return;
154
155 }
156
157 /**
158 * Checking if is Gutenberg REST API call.
159 *
160 * @since 2.3
161 *
162 * @return bool True if is Gutenberg REST API call.
163 */
164 public static function is_gb_editor() {
165 return defined( 'REST_REQUEST' ) && REST_REQUEST && ! empty( $_REQUEST['context'] ) && 'edit' === $_REQUEST['context']; // phpcs:ignore
166 }
167
168 }
169