: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Instagram Feed block with live preview.
* Indicates if current integration is allowed to load.
public function allow_load() {
return function_exists( 'register_block_type' );
protected function hooks() {
add_action( 'init', array( $this, 'register_block' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
* Register Instagram Feed Gutenberg block on the backend.
public function register_block() {
trailingslashit( CTF_PLUGIN_URL ) . 'css/ctf-blocks.css',
array( 'wp-edit-blocks' ),
'shortcodeSettings' => array(
'attributes' => $attributes,
'render_callback' => array( $this, 'get_feed_html' ),
* Load Instagram Feed Gutenberg block scripts.
public function enqueue_block_editor_assets() {
ctf_scripts_and_styles( true );
wp_enqueue_style( 'ctf-blocks-styles' );
trailingslashit( CTF_PLUGIN_URL ) . 'js/ctf-blocks.js',
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
'addSettings' => esc_html__( 'Add Settings', 'custom-twitter-feeds' ),
'shortcodeSettings' => esc_html__( 'Shortcode Settings', 'custom-twitter-feeds' ),
'example' => esc_html__( 'Example', 'custom-twitter-feeds' ),
'preview' => esc_html__( 'Apply Changes', 'custom-twitter-feeds' ),
'wpnonce' => wp_create_nonce( 'ctf-blocks' ),
'configureLink' => get_admin_url() . '?page=custom-twitter-feeds',
'shortcodeSettings' => $shortcodeSettings,
* Get form HTML to display in a Instagram Feed Gutenberg block.
* @param array $attr Attributes passed by Instagram Feed Gutenberg block.
public function get_feed_html( $attr ) {
$shortcode_settings = isset( $attr['shortcodeSettings'] ) ? $attr['shortcodeSettings'] : '';
$shortcode_settings = str_replace(array( '[custom-twitter-feeds', ']' ), '', $shortcode_settings );
$return .= do_shortcode( '[custom-twitter-feeds '.$shortcode_settings.']' );
* Checking if is Gutenberg REST API call.
* @return bool True if is Gutenberg REST API call.
public static function is_gb_editor() {
// TODO: Find a better way to check if is GB editor API call.
return defined( 'REST_REQUEST' ) && REST_REQUEST && ! empty( $_REQUEST['context'] ) && 'edit' === $_REQUEST['context']; // phpcs:ignore