: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
'label' => __('Fit View', 'embedpress'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'embedpress'),
'label_off' => __('Hide', 'embedpress'),
'embedpress_pdf_viewer_style' => 'flip-book',
'label' => __('Bookmark', 'embedpress'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'embedpress'),
'label_off' => __('Hide', 'embedpress'),
'embedpress_pdf_viewer_style' => 'flip-book',
'label' => __('PDF Presentation Mode', 'embedpress'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'embedpress'),
'label_off' => __('Hide', 'embedpress'),
'label' => sprintf(__('Copy Text %s', 'embedpress'), $this->pro_text),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'embedpress'),
'label_off' => __('Hide', 'embedpress'),
'classes' => $this->pro_class,
'embedpress_pdf_viewer_style' => 'modern',
'label' => sprintf(__('Add Text', 'embedpress')),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'embedpress'),
'label_off' => __('Hide', 'embedpress'),
'embedpress_pdf_viewer_style' => 'modern',
'label' => sprintf(__('Draw %s', 'embedpress'), $this->pro_text),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'embedpress'),
'label_off' => __('Hide', 'embedpress'),
'classes' => $this->pro_class,
'embedpress_pdf_viewer_style' => 'modern',
'label' => __('Add Image', 'embedpress'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'embedpress'),
'label_off' => __('Hide', 'embedpress'),
'embedpress_pdf_viewer_style' => 'modern',
'label' => __('Rotation', 'embedpress'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'embedpress'),
'label_off' => __('Hide', 'embedpress'),
'embedpress_pdf_viewer_style' => 'modern',
'label' => __('Properties', 'embedpress'),
'type' => Controls_Manager::SWITCHER,
'label_on' => __('Show', 'embedpress'),
'label_off' => __('Hide', 'embedpress'),
'embedpress_pdf_viewer_style' => 'modern',
$this->end_controls_section();
do_action( 'extend_elementor_controls', $this, '_pdf_', $this->pro_text, $this->pro_class);
if (!is_embedpress_pro_active()) {
$this->start_controls_section(
'embedpress_pro_section',
'label' => __('Go Premium for More Features', 'embedpress'),
'label' => __('Unlock more possibilities', 'embedpress'),
'type' => Controls_Manager::CHOOSE,
'description' => '<span class="pro-feature"> Get the <a href="https://wpdeveloper.com/in/upgrade-embedpress" target="_blank">Pro version</a> for more provider support and customization options.</span>',
$this->end_controls_section();
private function is_pdf($url)
$arr = explode('.', $url);
return end($arr) === 'pdf';
$settings = $this->get_settings();
Helper::get_enable_settings_data_for_scripts($settings);
$url = $this->get_file_url();
if($settings['embedpress_pdf_type'] === 'url') {
if(!empty($settings['__dynamic__']) && !empty($settings['__dynamic__']['embedpress_pdf_file_link'])){
$decode_url = urldecode(($settings['__dynamic__']['embedpress_pdf_file_link']));
preg_match('/name="([^"]+)"/', $decode_url, $name_matches);
if (!empty($name_matches[1])) {
$name_key = $name_matches[1];
if ($name_key === 'acf-url' && class_exists('ACF') && function_exists('get_field')) {
$pattern = '/"key":"([^"]+):([^"]+)"/';
preg_match($pattern, $decode_url, $matches);
} elseif ($name_key === 'toolset-url' && class_exists('Types_Helper_Output_Meta_Box')) {
$pattern = '/"key":"[^"]+:(.*?)"/';
preg_match($pattern, $decode_url, $matches);
if (!empty($matches[1])) {
$get_acf_key = $matches[1];
if ($name_key === 'acf-url') {
$url = get_field($get_acf_key);
} elseif ($name_key === 'toolset-url') {
$url = get_post_meta(get_the_ID(), 'wpcf-' . $get_acf_key, true);
preg_match('/"fallback":"([^"]+)"/', $decode_url, $fallback_matches);
if (!empty($fallback_matches[1])) {
$url = $fallback_matches[1];
$client_id = $this->get_id();
$this->_render($url, $settings, $client_id);
Helper::get_source_data(md5($this->get_id()).'_eb_elementor', $url, 'elementor_source_data', 'elementor_temp_source_data');
public function getParamData($settings){
'themeMode' => $settings['embedpress_theme_mode'],
'toolbar' => !empty($settings['pdf_toolbar']) ? 'true' : 'false',
'position' => $settings['pdf_toolbar_position'],
'presentation' => !empty($settings['pdf_presentation_mode']) ? 'true' : 'false',
'download' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_print_download'] : 'true',
'copy_text' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['pdf_text_copy'] : 'true',
'add_text' => !empty($settings['add_text']) ? 'true' : 'false',
'draw' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION')? $settings['draw'] : 'true',
'add_image' => !empty($settings['add_image']) ? 'true' : 'false',
'pdf_rotation' => !empty($settings['pdf_rotate_access']) ? 'true' : 'false',
'pdf_details' => !empty($settings['pdf_details']) ? 'true' : 'false',
'zoom_in' => !empty($settings['pdf_zoom_in']) ? 'true' : 'false',
'zoom_out' => !empty($settings['pdf_zoom_out']) ? 'true' : 'false',
'fit_view' => !empty($settings['pdf_fit_view']) ? 'true' : 'false',
'bookmark' => !empty($settings['pdf_bookmark']) ? 'true' : 'false',
'flipbook_toolbar_position' => !empty($settings['flipbook_toolbar_position']) ? $settings['flipbook_toolbar_position'] : 'bottom',
if($settings['embedpress_theme_mode'] == 'custom') {
$urlParamData['customColor'] = $settings['embedpress_pdf_custom_color'];
if($settings['embedpress_pdf_viewer_style'] == 'flip-book'){
return "&key=" . base64_encode(mb_convert_encoding(http_build_query($urlParamData), "UTF-8"));
return "#key=" . base64_encode(mb_convert_encoding(http_build_query($urlParamData), "UTF-8"));
public function _render($url, $settings, $id)
$unitoption = 'emebedpress-unit-px';
if($settings['embedpress_elementor_document_width']['unit'] === '%'){
$unitoption = 'emebedpress-unit-percent';
$id = 'embedpress-pdf-' . $id;
$hash_pass = hash('sha256', wp_salt(32) . md5($settings['embedpress_pdf_lock_content_password']));
$password_correct = isset($_COOKIE['password_correct_' . $client_id]) ? sanitize_text_field($_COOKIE['password_correct_' . $client_id]) : '';
if(empty($settings['embedpress_pdf_lock_content']) || empty($settings['embedpress_pdf_lock_content_password']) || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct))){
$dimension = "width: {$settings['embedpress_elementor_document_width']['size']}{$settings['embedpress_elementor_document_width']['unit']}!important;height: {$settings['embedpress_elementor_document_height']['size']}px;";
$content_protection_class = 'ep-content-protection-enabled';
$content_locked_class = 'ep-content-locked';
if(empty($settings['embedpress_pdf_lock_content']) || empty($settings['embedpress_pdf_lock_content_password']) || $hash_pass === $password_correct) {
$content_locked_class = '';
$content_protection_class = 'ep-content-protection-disabled';
$pass_hash_key = md5($settings['embedpress_pdf_lock_content_password']);
$this->add_render_attribute('embedpres-pdf-render', [
'class' => ['embedpress-embed-document-pdf', esc_attr($id)],
'data-emid' => esc_attr($id)
$this->add_render_attribute('embedpress-document', [
'class' => ['embedpress-document-embed', 'ep-doc-' . md5($id), 'ose-document', $unitoption, $content_locked_class ],
'data-thememode' => isset($settings['embedpress_theme_mode']) ? esc_attr($settings['embedpress_theme_mode']) : '',
'data-customcolor' => isset($settings['embedpress_pdf_custom_color']) ? esc_attr($settings['embedpress_pdf_custom_color']) : '',
'data-toolbar' => isset($settings['pdf_toolbar']) ? esc_attr($settings['pdf_toolbar']) : '',
'data-toolbar-position' => isset($settings['pdf_toolbar_position']) ? esc_attr($settings['pdf_toolbar_position']) : 'top',
'data-open' => 'no', // Assuming 'no' is a static value, no need to sanitize
'data-presentation-mode' => isset($settings['pdf_presentation_mode']) ? esc_attr($settings['pdf_presentation_mode']) : '',
'data-download' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION') ? esc_attr($settings['pdf_print_download']) : 'yes', // Assuming 'yes' is a safe fallback
'data-copy' => defined('EMBEDPRESS_PRO_PLUGIN_VERSION') ? esc_attr($settings['pdf_text_copy']) : 'yes', // Assuming 'yes' is a safe fallback
'data-add-image' => isset($settings['add_image']) ? esc_attr($settings['add_image']) : '',
'data-rotate' => isset($settings['pdf_rotate_access']) ? esc_attr($settings['pdf_rotate_access']) : '',
'data-details' => isset($settings['pdf_details']) ? esc_attr($settings['pdf_details']) : '',
'data-id' => $id // Assuming $id is safe, no need to sanitize
$embed_settings['customThumbnail'] = !empty($settings['embedpress_pdf_content_share_custom_thumbnail']['url']) ? esc_url($settings['embedpress_pdf_content_share_custom_thumbnail']['url']) : '';
$embed_settings['customTitle'] = !empty($settings['embedpress_pdf_content_title']) ? sanitize_text_field($settings['embedpress_pdf_content_title']) : Helper::get_file_title($url);
$embed_settings['customDescription'] = !empty($settings['embedpress_pdf_content_descripiton']) ? sanitize_text_field($settings['embedpress_pdf_content_descripiton']) : Helper::get_file_title($url);
$embed_settings['sharePosition'] = !empty($settings['embedpress_pdf_content_share_position']) ? sanitize_text_field($settings['embedpress_pdf_content_share_position']) : 'right';
$embed_settings['lockHeading'] = !empty($settings['embedpress_pdf_lock_content_heading']) ? sanitize_text_field($settings['embedpress_pdf_lock_content_heading']) : '';
$embed_settings['lockSubHeading'] = !empty($settings['embedpress_pdf_lock_content_sub_heading']) ? sanitize_text_field($settings['embedpress_pdf_lock_content_sub_heading']) : '';
$embed_settings['lockErrorMessage'] = !empty($settings['embedpress_pdf_lock_content_error_message']) ? sanitize_text_field($settings['embedpress_pdf_lock_content_error_message']) : '';
$embed_settings['passwordPlaceholder'] = !empty($settings['embedpress_pdf_password_placeholder']) ? sanitize_text_field($settings['embedpress_pdf_password_placeholder']) : '';
$embed_settings['submitButtonText'] = !empty($settings['embedpress_pdf_submit_button_text']) ? sanitize_text_field($settings['embedpress_pdf_submit_button_text']) : '';
$embed_settings['submitUnlockingText'] = !empty($settings['embedpress_pdf_submit_Unlocking_text']) ? sanitize_text_field($settings['embedpress_pdf_submit_Unlocking_text']) : '';
$embed_settings['enableFooterMessage'] = !empty($settings['embedpress_pdf_enable_footer_message']) ? sanitize_text_field($settings['embedpress_pdf_enable_footer_message']) : '';
$embed_settings['footerMessage'] = !empty($settings['embedpress_pdf_lock_content_footer_message']) ? sanitize_text_field($settings['embedpress_pdf_lock_content_footer_message']) : '';
if($settings['embedpress_elementor_document_width']['unit'] === '%'){
$width_class = ' ep-percentage-width';
$width_class = 'ep-fixed-width';
$content_share_class = '';
$share_position_class = '';
$share_position = isset($settings['embedpress_pdf_content_share_position']) ? $settings['embedpress_pdf_content_share_position'] : 'right';
if(!empty($settings['embedpress_pdf_content_share'])) {
$content_share_class = 'ep-content-share-enabled';
$share_position_class = 'ep-share-position-'.$share_position;
if (!empty($settings['adManager'])) {
$ad = base64_encode(json_encode($settings)); // Using WordPress JSON encoding function
$adsAtts = 'data-sponsored-id="' . esc_attr($client_id) . '" data-sponsored-attrs="' . esc_attr($ad) . '" class="ad-mask"';
<div <?php echo $this->get_render_attribute_string('embedpress-document'); ?> style=" max-width:100%; display: inline-block">
do_action('embedpress_pdf_after_embed', $settings, $url, $id, $this);
if ($this->is_pdf($url) && !$this->is_external_url($url)) {
$renderer = Helper::get_pdf_renderer();
$src = $renderer . ((strpos($renderer, '?') == false) ? '?' : '&') . 'file=' . urlencode($url).$this->getParamData($settings);
if (!empty($settings['embedpress_pdf_zoom'])) {
$zoom = $settings['embedpress_pdf_zoom'];
if (!empty($settings['embedpress_pdf_zoom_custom'])) {
$zoom = $settings['embedpress_pdf_zoom_custom'];
$src = $src . "&zoom=$zoom";
if(isset($settings['embedpress_pdf_viewer_style']) && $settings['embedpress_pdf_viewer_style'] === 'modern') {
$embed_content = '<iframe title="'.esc_attr(Helper::get_file_title($url)).'" class="embedpress-embed-document-pdf '.esc_attr($id).'" style="'.esc_attr($dimension).'; max-width:100%; display: inline-block" src="'.esc_url($src).'"';
$src = urlencode($url).$this->getParamData($settings);
$embed_content = '<iframe title="'.esc_attr(Helper::get_file_title($url)).'" class="embedpress-embed-document-pdf '.esc_attr($id).'" style="'.esc_attr($dimension).'; max-width:100%; display: inline-block" src="'.esc_url(EMBEDPRESS_URL_ASSETS . 'pdf-flip-book/viewer.html?file='.$src).'"';
$embed_content .= ' '.$this->get_render_attribute_string('embedpres-pdf-render').' frameborder="0"></iframe>';
if ($settings['embedpress_pdf_powered_by'] === 'yes') {
$embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
$embed_content = '<iframe title="'.esc_attr(Helper::get_file_title($url)).'" class="embedpress-embed-document-pdf '.esc_attr($id).'" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true" style="'.esc_attr($dimension).'; max-width:100%;" src="'.esc_url($url).'"';
$embed_content .= ' '.$this->get_render_attribute_string('embedpres-pdf-render').'></iframe>';
if ($settings['embedpress_pdf_powered_by'] === 'yes') {
$embed_content .= sprintf('<p class="embedpress-el-powered">%s</p>', __('Powered By EmbedPress', 'embedpress'));
<div <?php echo $adsAtts; ?>>
<div id="ep-elementor-content-<?php echo esc_attr( $client_id )?>" class="ep-elementor-content <?php if(!empty($settings['embedpress_pdf_content_share'])) : echo esc_attr( 'position-'.$settings['embedpress_pdf_content_share_position'].'-wraper' ); endif; ?> <?php echo esc_attr($width_class.' '.$content_share_class.' '.$share_position_class.' '.$content_protection_class); ?>">
<div id="<?php echo esc_attr( $this->get_id() ); ?>" class="ep-embed-content-wraper">
$embed = '<div>'.$embed_content.'</div>';
$content_id = $client_id;
if((empty($settings['embedpress_pdf_lock_content']) || empty($settings['embedpress_pdf_lock_content_password']) || $settings['embedpress_pdf_lock_content'] == 'no') || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct)) ){
if(!empty($settings['embedpress_pdf_content_share'])){
$embed .= Helper::embed_content_share($content_id, $embed_settings);
if(!empty($settings['embedpress_pdf_content_share'])){
$embed .= Helper::embed_content_share($content_id, $embed_settings);
Helper::display_password_form($client_id, $embed, $pass_hash_key, $embed_settings);
if(!empty($settings['adManager'])) {
$embed_content .= Helper::generateAdTemplate($client_id, $settings, 'elementor');
private function get_file_url()
$settings = $this->get_settings();
return $settings['embedpress_pdf_type'] === 'url' ? $settings['embedpress_pdf_file_link']['url'] : $settings['embedpress_pdf_Uploader']['url'];
protected function is_external_url($url)
return strpos($url, get_site_url()) === false;