: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Enqueue CSS/JS of all the blocks.
// Exit if accessed directly.
use EmbedPress\Includes\Classes\Helper;
if (!defined('ABSPATH')) {
* Enqueue Gutenberg block assets for both frontend + backend.
* @uses {wp-editor} for WP editor styles.
function embedpress_blocks_cgb_block_assets()
'embedpress_blocks-cgb-style-css', // Handle.
EMBEDPRESS_GUTENBERG_DIR_URL . 'dist/blocks.style.build.css', // Block style CSS.
is_admin() ? array('wp-editor') : null, // Dependency to include the CSS after it.
filemtime(EMBEDPRESS_GUTENBERG_DIR_PATH . 'dist/blocks.style.build.css') // Version: File modification time.
// Hook: Frontend assets.
add_action('enqueue_block_assets', 'embedpress_blocks_cgb_block_assets');
if(!function_exists('get_options_value')){
function get_options_value($key){
$g_settings = get_option(EMBEDPRESS_PLG_NAME);
if(isset($g_settings[$key])){
return $g_settings[$key];
* Enqueue Gutenberg block assets for backend editor.
* @uses {wp-blocks} for block type registration & related functions.
* @uses {wp-element} for WP Element abstraction — structure of blocks.
* @uses {wp-i18n} to internationalize the block's text.
* @uses {wp-editor} for WP editor styles.
function embedpress_blocks_cgb_editor_assets()
$elements = (array) get_option(EMBEDPRESS_PLG_NAME . ":elements", []);
$g_blocks = isset($elements['gutenberg']) ? (array) $elements['gutenberg'] : [];
if (!wp_script_is('embedpress-pdfobject')) {
EMBEDPRESS_URL_ASSETS . 'js/pdfobject.min.js',
'embedpress_blocks-cgb-block-js', // Handle.
EMBEDPRESS_GUTENBERG_DIR_URL . 'dist/blocks.build.js', // Block.build.js: We register the block here. Built with Webpack.
array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-api-fetch', 'wp-is-shallow-equal', 'wp-editor', 'wp-components', 'embedpress-pdfobject'), // Dependencies, defined above.
filemtime(EMBEDPRESS_GUTENBERG_DIR_PATH . 'dist/blocks.build.js'), // Version: File modification time.
true // Enqueue the script in the footer.
if (!empty($g_blocks['document'])) {
'embedpress_documents_viewer_script',
EMBEDPRESS_PLUGIN_DIR_URL . 'assets/js/documents-viewer-script.js',
array('wp-blocks', 'wp-dom-ready', 'wp-edit-post'),
EMBEDPRESS_PLUGIN_VERSION,
'watch_from_beginning' => __('Watch from the beginning', 'embedpress'),
'skip_to_where_you_left_off' => __('Skip to where you left off', 'embedpress'),
'you_have_watched_it_before' => __('It looks like you\'ve watched<br />part of this video before!', 'embedpress'),
$elements = (array) get_option(EMBEDPRESS_PLG_NAME . ":elements", []);
$active_blocks = isset($elements['gutenberg']) ? (array) $elements['gutenberg'] : [];
$wistia_labels = json_encode($wistia_labels);
if (function_exists('embedpress_wisita_pro_get_options')) :
$wistia_options = embedpress_wisita_pro_get_options();
$pars_url = wp_parse_url(get_site_url());
$documents_cta_options = (array) get_option(EMBEDPRESS_PLG_NAME . ':document');
wp_localize_script('embedpress_blocks-cgb-block-js', 'embedpressObj', array(
'wistia_labels' => $wistia_labels,
'wisita_options' => $wistia_options,
'embedpress_powered_by' => apply_filters('embedpress_document_block_powered_by', true),
'embedpress_pro' => defined('EMBEDPRESS_PRO_PLUGIN_FILE'),
'twitch_host' => !empty($pars_url['host']) ? $pars_url['host'] : '',
'site_url' => site_url(),
'active_blocks' => $active_blocks,
'document_cta' => $documents_cta_options,
'pdf_renderer' => Helper::get_pdf_renderer(),
'is_pro_plugin_active' => defined('EMBEDPRESS_SL_ITEM_SLUG'),
'ajaxurl' => admin_url('admin-ajax.php'),
'source_nonce' => wp_create_nonce('source_nonce_embedpress'),
'can_upload_media' => current_user_can('upload_files'),
'EMBEDPRESS_URL_ASSETS' => EMBEDPRESS_URL_ASSETS,
'iframe_width' => get_options_value('enableEmbedResizeWidth'),
'iframe_height' => get_options_value('enableEmbedResizeHeight'),
'pdf_custom_color' => get_options_value('custom_color'),
'embedpress_blocks-cgb-block-editor-css', // Handle.
EMBEDPRESS_GUTENBERG_DIR_URL . 'dist/blocks.editor.build.css', // Block editor CSS.
array('wp-edit-blocks'), // Dependency to include the CSS after it.
filemtime(EMBEDPRESS_GUTENBERG_DIR_PATH . 'dist/blocks.editor.build.css') // Version: File modification time.
wp_enqueue_style('embedpress_blocks-cgb-style-css');
add_action('enqueue_block_editor_assets', 'embedpress_blocks_cgb_editor_assets');
function embedpress_block_category($categories, $post)
$wp_version = get_bloginfo('version', 'display');
if (version_compare($wp_version, '5.8', '>=')) {
add_filter('block_categories_all', 'embedpress_block_category', 10, 2);
add_filter('block_categories', 'embedpress_block_category', 10, 2);
foreach (glob(EMBEDPRESS_GUTENBERG_DIR_PATH . 'block-backend/*.php') as $block_logic) {
require_once $block_logic;
* Registers the embedpress gutneberg block on server.
function embedpress_gutenberg_register_all_block()
if (function_exists('register_block_type')) :
$elements = (array) get_option(EMBEDPRESS_PLG_NAME . ":elements", []);
$g_blocks = isset($elements['gutenberg']) ? (array) $elements['gutenberg'] : [];
$blocks_to_registers = ['twitch-block', 'google-slides-block', 'google-sheets-block', 'google-maps-block', 'google-forms-block', 'google-drawings-block', 'google-docs-block', 'embedpress', 'embedpress-pdf', 'embedpress-calendar', 'document'];
foreach ($blocks_to_registers as $blocks_to_register) {
if (!empty($g_blocks[$blocks_to_register])) {
if ('embedpress' === $blocks_to_register) {
register_block_type('embedpress/embedpress', [
'render_callback' => 'embedpress_render_block',
'default' => get_options_value('enableEmbedResizeHeight')
'default' => get_options_value('enableEmbedResizeWidth')
'default' => 'Content Locked'
'default' => 'Content is locked and requires password to access it.'
'default' => 'Oops, that wasn\'t the right password. Try again.'
'passwordPlaceholder' => [
'submitUnlockingText' => [
'enableFooterMessage' => [
'default' => 'In case you don\'t have the password, kindly reach out to content owner or administrator to request access.'
// custom player attributes
'playerHideControls' => [
'default' => 'insta-grid',
'default' => 'user_account_type',
'instafeedAccountType' => [
'instafeedProfileImage' => [
'instafeedProfileImageUrl' => [
'instafeedFollowBtn' => [
'instafeedFollowBtnLabel' => [
'instafeedPostsCount' => [
'instafeedPostsCountText' => [
'default' => '[count] posts',
'instafeedFollowersCount' => [
'instafeedFollowersCountText' => [