Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/accelera.../template...
File: features.php
}
[8500] Fix | Delete
$jarr = json_decode($previousData);
[8501] Fix | Delete
if(isset($jarr->settingdata->scripts_data)){
[8502] Fix | Delete
$script_data = $jarr->settingdata->scripts_data;
[8503] Fix | Delete
$content = $data['post_amp_content'];
[8504] Fix | Delete
$script_slug = '';
[8505] Fix | Delete
$allscripts = $script_data;
[8506] Fix | Delete
preg_match_all('/<script(.*?)custom-element=\"(.*?)\"(.*?)src=\"(.*?)\"(.*?)><\/script>/', $allscripts, $matches);
[8507] Fix | Delete
if($matches){
[8508] Fix | Delete
if(isset($matches[2])){
[8509] Fix | Delete
$script_slug = $matches[2];
[8510] Fix | Delete
foreach ($script_slug as $key => $slug) {
[8511] Fix | Delete
if(!preg_match('/'.$slug.'/', $content)){
[8512] Fix | Delete
global $pb_remove_script;
[8513] Fix | Delete
$pb_remove_script[]= esc_attr($slug);
[8514] Fix | Delete
}
[8515] Fix | Delete
}
[8516] Fix | Delete
}
[8517] Fix | Delete
add_filter( 'ampforwp_the_content_last_filter','ampforwp_remove_unused_pb_amp_script',12);
[8518] Fix | Delete
}
[8519] Fix | Delete
}
[8520] Fix | Delete
}
[8521] Fix | Delete
return $data;
[8522] Fix | Delete
}
[8523] Fix | Delete
function ampforwp_remove_unused_pb_amp_script($data){
[8524] Fix | Delete
global $pb_remove_script;
[8525] Fix | Delete
for($i=0;$i<count($pb_remove_script);$i++){
[8526] Fix | Delete
$data = preg_replace('/<script(.*?)custom-element=\"'.esc_attr($pb_remove_script[$i]).'\"(.*?)src=\"(.*?)\"(.*?)><\/script>/', '', $data);
[8527] Fix | Delete
}
[8528] Fix | Delete
return $data;
[8529] Fix | Delete
}
[8530] Fix | Delete
[8531] Fix | Delete
if(class_exists('RankMath')){
[8532] Fix | Delete
add_filter('ampforwp_modify_the_content','ampforwp_rank_math_nofollow_to_external_link');
[8533] Fix | Delete
}
[8534] Fix | Delete
function ampforwp_rank_math_nofollow_to_external_link($content){
[8535] Fix | Delete
$rank_math_external_link = RankMath\Helper::get_settings( 'general.nofollow_external_links' );
[8536] Fix | Delete
if($rank_math_external_link){
[8537] Fix | Delete
preg_match_all('/<a href="(.*?)">(.*?)<\/a>/', $content, $matches);
[8538] Fix | Delete
for($i=0;$i<count($matches[1]);$i++){
[8539] Fix | Delete
$url = $matches[1][$i];
[8540] Fix | Delete
$is_external = ampforwp_isexternal($url);
[8541] Fix | Delete
if($is_external){
[8542] Fix | Delete
$url = esc_url($url);
[8543] Fix | Delete
$url = str_replace("/", "\/", $url);
[8544] Fix | Delete
$content = preg_replace('/(<a href="'.$url.'.*")/', '$1 rel="nofollow"', $content);
[8545] Fix | Delete
}
[8546] Fix | Delete
}
[8547] Fix | Delete
}
[8548] Fix | Delete
return $content;
[8549] Fix | Delete
}
[8550] Fix | Delete
[8551] Fix | Delete
if(class_exists('transposh_plugin')){
[8552] Fix | Delete
add_action('amp_post_template_css','ampforwp_transposh_plugin_rtl_css');
[8553] Fix | Delete
}
[8554] Fix | Delete
if(!function_exists('ampforwp_transposh_plugin_rtl_css')){
[8555] Fix | Delete
function ampforwp_transposh_plugin_rtl_css() {
[8556] Fix | Delete
$rtl_lang_arr = array('ar', 'he', 'fa', 'ur', 'yi');
[8557] Fix | Delete
if(isset($_GET['lang'])){
[8558] Fix | Delete
if(in_array(esc_attr($_GET['lang']), $rtl_lang_arr)){
[8559] Fix | Delete
if(ampforwp_get_setting('header-position-type') == '1'){?>
[8560] Fix | Delete
.tg:checked + .hamb-mnu > .m-ctr {
[8561] Fix | Delete
margin-right: 0%;
[8562] Fix | Delete
}
[8563] Fix | Delete
.m-ctr{
[8564] Fix | Delete
margin-right: -100%;
[8565] Fix | Delete
float: left;
[8566] Fix | Delete
}
[8567] Fix | Delete
<?php } if(ampforwp_get_setting('header-position-type') == '2'){?>
[8568] Fix | Delete
.tg:checked + .hamb-mnu > .m-ctr {
[8569] Fix | Delete
margin-right: calc(100% - <?php echo esc_html(ampforwp_get_setting('header-overlay-width'))?>);
[8570] Fix | Delete
}
[8571] Fix | Delete
.m-ctr{
[8572] Fix | Delete
margin-right: 100%;
[8573] Fix | Delete
float: right;
[8574] Fix | Delete
}
[8575] Fix | Delete
<?php }
[8576] Fix | Delete
}
[8577] Fix | Delete
}
[8578] Fix | Delete
}
[8579] Fix | Delete
}
[8580] Fix | Delete
[8581] Fix | Delete
[8582] Fix | Delete
add_filter('ampforwp_the_content_last_filter','ampforwp_remove_unwanted_code',10);
[8583] Fix | Delete
function ampforwp_remove_unwanted_code($content){
[8584] Fix | Delete
// Mediavine validation issue with form and amp-consent #4206
[8585] Fix | Delete
if(preg_match('/<amp-consent id="mv-consent" layout="nodisplay">(.*?)<\/amp-consent>/s', $content)){
[8586] Fix | Delete
$content = preg_replace('/<amp-consent id="mv-consent" layout="nodisplay">(.*?)<\/amp-consent>/s', '', $content);
[8587] Fix | Delete
}
[8588] Fix | Delete
if(preg_match('/<form class="mv-create-print-form">(.*?)<\/form>/s', $content)){
[8589] Fix | Delete
$content = preg_replace('/<form class="mv-create-print-form">(.*?)<\/form>/s', '', $content);
[8590] Fix | Delete
}
[8591] Fix | Delete
// close #4206
[8592] Fix | Delete
// Ticket #4539
[8593] Fix | Delete
if(function_exists('orbital_setup')){
[8594] Fix | Delete
if(preg_match('/<script>function orbital_expand_navbar(.*?)<\/script>/', $content)){
[8595] Fix | Delete
$content = preg_replace('/<script>function orbital_expand_navbar(.*?)<\/script>/', '', $content);
[8596] Fix | Delete
}
[8597] Fix | Delete
}
[8598] Fix | Delete
if(empty($content)){
[8599] Fix | Delete
return $content;
[8600] Fix | Delete
}
[8601] Fix | Delete
//Remove label from anchor
[8602] Fix | Delete
if(preg_match('/<a(.*?)\slabel\s(.*?)>/', $content)){
[8603] Fix | Delete
$content = preg_replace('/<a(.*?)\slabel\s(.*?)>/', '<a $1$2>', $content);
[8604] Fix | Delete
}
[8605] Fix | Delete
return $content;
[8606] Fix | Delete
}
[8607] Fix | Delete
add_filter('ampforwp_the_content_last_filter','ampforwp_include_required_scripts',12);
[8608] Fix | Delete
function ampforwp_include_required_scripts($content){
[8609] Fix | Delete
$allscripts = $is_script = '';
[8610] Fix | Delete
$comp_to_remove_arr = array();
[8611] Fix | Delete
preg_match_all('/<\/amp-(.*?)>/', $content, $matches);
[8612] Fix | Delete
if(isset($matches[1][0])){
[8613] Fix | Delete
$amp_comp = $matches[1];
[8614] Fix | Delete
$comp_to_remove_json = get_transient('ampforwp_amp_exclude_custom_element');
[8615] Fix | Delete
$comp_to_include_json = get_transient('ampforwp_amp_included_custom_element');
[8616] Fix | Delete
if($comp_to_remove_json){
[8617] Fix | Delete
$comp_to_remove_arr = json_decode($comp_to_remove_json, true);
[8618] Fix | Delete
}
[8619] Fix | Delete
$comp_to_include_arr = array();
[8620] Fix | Delete
if($comp_to_include_json){
[8621] Fix | Delete
$comp_to_include_arr = json_decode($comp_to_include_json, true);
[8622] Fix | Delete
}
[8623] Fix | Delete
$comp = '';
[8624] Fix | Delete
for($i=0;$i<count($amp_comp);$i++){
[8625] Fix | Delete
$comp = $amp_comp[$i];
[8626] Fix | Delete
if(!preg_match('/story/', $comp)){
[8627] Fix | Delete
$script_ver = 'latest';
[8628] Fix | Delete
if($comp == 'auto-ads' || $comp == 'ad'){
[8629] Fix | Delete
$script_ver = '0.1';
[8630] Fix | Delete
}
[8631] Fix | Delete
if($comp=='state' || $comp=='img'){
[8632] Fix | Delete
$comp = 'bind';
[8633] Fix | Delete
}
[8634] Fix | Delete
if($comp == 'img'){
[8635] Fix | Delete
$comp_url = "https://cdn.ampproject.org/v0/amp-bind-latest.js";
[8636] Fix | Delete
}else{
[8637] Fix | Delete
$comp_url = 'https://cdn.ampproject.org/v0/amp-'.esc_attr($comp).'-'.esc_attr($script_ver).'.js';
[8638] Fix | Delete
}
[8639] Fix | Delete
$is_script = false;
[8640] Fix | Delete
$check_comp = 'amp-'.esc_attr($comp);
[8641] Fix | Delete
if(!in_array($comp, $comp_to_remove_arr) && !in_array($comp, $comp_to_include_arr) ){
[8642] Fix | Delete
$ce_valid_scripts = ampforwp_valid_amp_componet_script();
[8643] Fix | Delete
$is_script = in_array($check_comp, $ce_valid_scripts);
[8644] Fix | Delete
if($comp=='state'){
[8645] Fix | Delete
$is_script = true;
[8646] Fix | Delete
}
[8647] Fix | Delete
if($comp=='embed'){
[8648] Fix | Delete
$is_script = false;
[8649] Fix | Delete
}
[8650] Fix | Delete
if($is_script==false){
[8651] Fix | Delete
if ( ini_get( 'allow_url_fopen' ) ) {
[8652] Fix | Delete
$headers = get_headers($comp_url);
[8653] Fix | Delete
if(isset($headers[0])){
[8654] Fix | Delete
$is_script = stripos($headers[0], "200 OK") ? TRUE : FALSE;
[8655] Fix | Delete
}
[8656] Fix | Delete
}
[8657] Fix | Delete
}
[8658] Fix | Delete
if($is_script){
[8659] Fix | Delete
$comp_to_include_arr[] = $comp;
[8660] Fix | Delete
$inc_json = wp_json_encode($comp_to_include_arr);
[8661] Fix | Delete
set_transient('ampforwp_amp_included_custom_element',$inc_json, 30 * DAY_IN_SECONDS);
[8662] Fix | Delete
}else{
[8663] Fix | Delete
$comp_to_remove_arr[] = $comp;
[8664] Fix | Delete
$ex_json = wp_json_encode($comp_to_remove_arr);
[8665] Fix | Delete
set_transient('ampforwp_amp_exclude_custom_element',$ex_json, 30 * DAY_IN_SECONDS);
[8666] Fix | Delete
}
[8667] Fix | Delete
}
[8668] Fix | Delete
$comp_to_include_arr = apply_filters('ampforwp_amp_custom_element_to_include',$comp_to_include_arr);
[8669] Fix | Delete
if(in_array($comp, $comp_to_include_arr) && $comp_url != ''){
[8670] Fix | Delete
if(!preg_match('/<script(\s|\sasync\s)custom-element="amp-'.esc_attr($comp).'"(.*?)>(.*?)<\/script>/s', $content, $matches)){
[8671] Fix | Delete
$script_tag = '<head><script custom-element="amp-'.esc_attr($comp).'" src="'.esc_url($comp_url).'" async></script>';
[8672] Fix | Delete
$content = str_replace('<head>', $script_tag, $content);
[8673] Fix | Delete
}
[8674] Fix | Delete
}
[8675] Fix | Delete
}
[8676] Fix | Delete
}
[8677] Fix | Delete
}
[8678] Fix | Delete
if (empty($content)) {
[8679] Fix | Delete
return '';
[8680] Fix | Delete
}
[8681] Fix | Delete
$comp_dom = new DOMDocument();
[8682] Fix | Delete
@$comp_dom->loadHTML($content);
[8683] Fix | Delete
$xpath = new DOMXPath( $comp_dom );
[8684] Fix | Delete
$elements = $xpath->query("*/script[@custom-element]");
[8685] Fix | Delete
$component_arr = array();
[8686] Fix | Delete
$elements_arr = array();
[8687] Fix | Delete
if (!is_null($elements)) {
[8688] Fix | Delete
foreach ($elements as $element) {
[8689] Fix | Delete
$component_arr[]= $element->getAttribute('custom-element');
[8690] Fix | Delete
$elements_arr[] = $comp_dom->saveHTML($element);
[8691] Fix | Delete
}
[8692] Fix | Delete
}
[8693] Fix | Delete
if (!is_null($elements)) {
[8694] Fix | Delete
if(!empty($component_arr)){
[8695] Fix | Delete
$excl_arr = array('amp-bind','amp-access','amp-analytics','amp-access-laterpay','amp-access-poool','amp-dynamic-css-classes','amp-fx-collection','amp-inputmask','amp-lightbox-gallery','amp-inputmask','amp-mustache','amp-subscriptions-google','amp-subscriptions','amp-video-docking','amp-story');
[8696] Fix | Delete
$inc_elem_arr = array();
[8697] Fix | Delete
for($r=0;$r<count($comp_to_remove_arr);$r++){
[8698] Fix | Delete
$inc_elem_arr[] = 'amp-'.$comp_to_remove_arr[$r];
[8699] Fix | Delete
}
[8700] Fix | Delete
for($i=0;$i<count($component_arr);$i++){
[8701] Fix | Delete
if(isset($component_arr[$i])){
[8702] Fix | Delete
$component = $component_arr[$i];
[8703] Fix | Delete
if(!in_array($component,$excl_arr)){
[8704] Fix | Delete
if(!preg_match("/<\/$component>/", $content) && !$is_script){
[8705] Fix | Delete
$remove_comp = $elements_arr[$i];
[8706] Fix | Delete
$content = str_replace($remove_comp, '', $content);
[8707] Fix | Delete
}else if(in_array($component, $inc_elem_arr )){
[8708] Fix | Delete
for($rc=0;$rc<count($inc_elem_arr);$rc++){
[8709] Fix | Delete
$rcomp = $inc_elem_arr[$rc];
[8710] Fix | Delete
if(preg_match('/<script(\s|\sasync\s)custom-element="'.esc_attr($rcomp).'"(.*?)>(.*?)<\/script>/s', $content,$rmc)){
[8711] Fix | Delete
if(isset($rmc[0])){
[8712] Fix | Delete
$remove_comp = $rmc[0];
[8713] Fix | Delete
$content = str_replace($remove_comp, '', $content);
[8714] Fix | Delete
}
[8715] Fix | Delete
}
[8716] Fix | Delete
}
[8717] Fix | Delete
}
[8718] Fix | Delete
}
[8719] Fix | Delete
// REMOVING DUPLICATE SCRIPT.
[8720] Fix | Delete
$count_elem = array_count_values($component_arr)[$component];
[8721] Fix | Delete
if($count_elem>1){
[8722] Fix | Delete
$content = preg_replace('/<script(\s|\sasync\s)custom-element="'.esc_attr($component).'"(.*?)>(.*?)<\/script>/s','',$content,1,$component_arr[$i]);
[8723] Fix | Delete
}
[8724] Fix | Delete
}
[8725] Fix | Delete
}
[8726] Fix | Delete
}
[8727] Fix | Delete
}
[8728] Fix | Delete
//OTHER COMPONENT CHECK
[8729] Fix | Delete
$other_comp_arr = array('amp-mustache'=>'amp-mustache','amp-embed'=>'amp-ad','form'=>'amp-form','amp-access'=>'amp-access','amp-fx'=>'amp-fx-collection');
[8730] Fix | Delete
if (preg_match('/<amp-carousel(.*?)lightbox(.*?)>/', $content)) {
[8731] Fix | Delete
$other_comp_arr['amp-carousel'] = 'amp-lightbox-gallery';
[8732] Fix | Delete
}
[8733] Fix | Delete
foreach ($other_comp_arr as $key => $value) {
[8734] Fix | Delete
$ocomp = $value;
[8735] Fix | Delete
$celem = 'element';
[8736] Fix | Delete
if($ocomp=='amp-mustache'){
[8737] Fix | Delete
$celem = 'template';
[8738] Fix | Delete
}
[8739] Fix | Delete
if(preg_match('/(type|template|id)="('.$ocomp.')"/', $content) || preg_match("/<\/$key>/", $content) || preg_match("/amp-fx/", $content)){
[8740] Fix | Delete
if(!preg_match('/<script(\s|\sasync\s)custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'"(.*?)>(.*?)<\/script>/s', $content)){
[8741] Fix | Delete
$o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js';
[8742] Fix | Delete
$script_tag = '<head><script custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'" src="'.esc_url($o_comp_url).'" async></script>';
[8743] Fix | Delete
$content = str_replace('<head>', $script_tag, $content);
[8744] Fix | Delete
}
[8745] Fix | Delete
}
[8746] Fix | Delete
}
[8747] Fix | Delete
[8748] Fix | Delete
$amp_video = $xpath->query("//amp-video");
[8749] Fix | Delete
foreach($amp_video as $node) {
[8750] Fix | Delete
if($node->hasAttribute('dock')){
[8751] Fix | Delete
if(ampforwp_get_setting('ampforwp-amp-video-docking') || ampforwp_get_setting('amp-theme-video-docking')){
[8752] Fix | Delete
$celem = 'element';
[8753] Fix | Delete
$ocomp = 'amp-video-docking';
[8754] Fix | Delete
if(!preg_match('/<script(\s|\sasync\s)custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'"(.*?)>(.*?)<\/script>/s', $content)){
[8755] Fix | Delete
$o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js';
[8756] Fix | Delete
$script_tag = '<head><script custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'" src="'.esc_url($o_comp_url).'" async></script>';
[8757] Fix | Delete
$content = str_replace('<head>', $script_tag, $content);
[8758] Fix | Delete
}
[8759] Fix | Delete
}else{
[8760] Fix | Delete
if(preg_match('/<amp-video(.*?) dock|dock=">/', $content)){
[8761] Fix | Delete
$content = preg_replace('/<amp-video(.*?) dock|dock=">/','<amp-video $1>', $content);
[8762] Fix | Delete
}
[8763] Fix | Delete
}
[8764] Fix | Delete
}
[8765] Fix | Delete
}
[8766] Fix | Delete
[8767] Fix | Delete
$amp_video_iframe = $xpath->query("//amp-video-iframe");
[8768] Fix | Delete
foreach($amp_video_iframe as $node) {
[8769] Fix | Delete
if($node->hasAttribute('dock')){
[8770] Fix | Delete
if(ampforwp_get_setting('ampforwp-amp-video-docking') || ampforwp_get_setting('amp-theme-video-docking')){
[8771] Fix | Delete
$celem = 'element';
[8772] Fix | Delete
$ocomp = 'amp-video-docking';
[8773] Fix | Delete
if(!preg_match('/<script(\s|\sasync\s)custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'"(.*?)>(.*?)<\/script>/s', $content)){
[8774] Fix | Delete
$o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js';
[8775] Fix | Delete
$script_tag = '<head><script custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'" src="'.esc_url($o_comp_url).'" async></script>';
[8776] Fix | Delete
$content = str_replace('<head>', $script_tag, $content);
[8777] Fix | Delete
}
[8778] Fix | Delete
}else{
[8779] Fix | Delete
if(preg_match('/<amp-video-iframe(.*?) (dock|dock=")>/', $content)){
[8780] Fix | Delete
$content = preg_replace('/<amp-video-iframe(.*?) (dock|dock=")>/','<amp-video-iframe $1>', $content);
[8781] Fix | Delete
}
[8782] Fix | Delete
}
[8783] Fix | Delete
}
[8784] Fix | Delete
}
[8785] Fix | Delete
[8786] Fix | Delete
$amp_youtube = $xpath->query("//amp-youtube");
[8787] Fix | Delete
foreach($amp_youtube as $node) {
[8788] Fix | Delete
if($node->hasAttribute('dock')){
[8789] Fix | Delete
if(ampforwp_get_setting('ampforwp-amp-video-docking') || ampforwp_get_setting('amp-theme-video-docking')){
[8790] Fix | Delete
$celem = 'element';
[8791] Fix | Delete
$ocomp = 'amp-video-docking';
[8792] Fix | Delete
if(!preg_match('/<script(\s|\sasync\s)custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'"(.*?)>(.*?)<\/script>/s', $content)){
[8793] Fix | Delete
$o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js';
[8794] Fix | Delete
$script_tag = '<head><script custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'" src="'.esc_url($o_comp_url).'" async></script>';
[8795] Fix | Delete
$content = str_replace('<head>', $script_tag, $content);
[8796] Fix | Delete
}
[8797] Fix | Delete
}else{
[8798] Fix | Delete
if(preg_match('/<amp-youtube(.*?) dock|dock=">/', $content)){
[8799] Fix | Delete
$content = preg_replace('/<amp-youtube(.*?) dock|dock=">/','<amp-youtube $1>', $content);
[8800] Fix | Delete
}
[8801] Fix | Delete
}
[8802] Fix | Delete
}
[8803] Fix | Delete
}
[8804] Fix | Delete
[8805] Fix | Delete
$amp_brid_player = $xpath->query("//amp-brid-player");
[8806] Fix | Delete
foreach($amp_brid_player as $node) {
[8807] Fix | Delete
if($node->hasAttribute('dock')){
[8808] Fix | Delete
if(ampforwp_get_setting('ampforwp-amp-video-docking') || ampforwp_get_setting('amp-theme-video-docking')){
[8809] Fix | Delete
$celem = 'element';
[8810] Fix | Delete
$ocomp = 'amp-video-docking';
[8811] Fix | Delete
if(!preg_match('/<script(\s|\sasync\s)custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'"(.*?)>(.*?)<\/script>/s', $content)){
[8812] Fix | Delete
$o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js';
[8813] Fix | Delete
$script_tag = '<head><script custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'" src="'.esc_url($o_comp_url).'" async></script>';
[8814] Fix | Delete
$content = str_replace('<head>', $script_tag, $content);
[8815] Fix | Delete
}
[8816] Fix | Delete
}else{
[8817] Fix | Delete
if(preg_match('/<amp-brid-player(.*?) dock|dock=">/', $content)){
[8818] Fix | Delete
$content = preg_replace('/<amp-brid-player(.*?) dock|dock=">/','<amp-brid-player $1>', $content);
[8819] Fix | Delete
}
[8820] Fix | Delete
}
[8821] Fix | Delete
}
[8822] Fix | Delete
}
[8823] Fix | Delete
$amp_brightcove = $xpath->query("//amp-brightcove");
[8824] Fix | Delete
foreach($amp_brightcove as $node) {
[8825] Fix | Delete
if($node->hasAttribute('dock')){
[8826] Fix | Delete
if(ampforwp_get_setting('ampforwp-amp-video-docking') || ampforwp_get_setting('amp-theme-video-docking')){
[8827] Fix | Delete
$celem = 'element';
[8828] Fix | Delete
$ocomp = 'amp-video-docking';
[8829] Fix | Delete
if(!preg_match('/<script(\s|\sasync\s)custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'"(.*?)>(.*?)<\/script>/s', $content)){
[8830] Fix | Delete
$o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js';
[8831] Fix | Delete
$script_tag = '<head><script custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'" src="'.esc_url($o_comp_url).'" async></script>';
[8832] Fix | Delete
$content = str_replace('<head>', $script_tag, $content);
[8833] Fix | Delete
}
[8834] Fix | Delete
}else{
[8835] Fix | Delete
if(preg_match('/<amp-brightcove(.*?) dock|dock=">/', $content)){
[8836] Fix | Delete
$content = preg_replace('/<amp-brightcove(.*?) dock|dock=">/','<amp-brightcove $1>', $content);
[8837] Fix | Delete
}
[8838] Fix | Delete
}
[8839] Fix | Delete
}
[8840] Fix | Delete
}
[8841] Fix | Delete
$allscripts = apply_filters( 'ampforwp_modify_scripts', $allscripts);
[8842] Fix | Delete
// Scripts added from Options panel should have higher priority #4064
[8843] Fix | Delete
if( $allscripts || (ampforwp_get_setting('amp-header-text-area-for-html') && ampforwp_get_setting('amp-header-text-area-for-html')!="")) {
[8844] Fix | Delete
$allscripts .= ampforwp_get_setting('amp-header-text-area-for-html');
[8845] Fix | Delete
preg_match_all('/<script(.*?)custom-element=\"(.*?)\"(.*?)src=\"(.*?)\"(.*?)>(.*?)<\/script>/s', $allscripts, $rep);
[8846] Fix | Delete
if($rep){
[8847] Fix | Delete
if(isset($rep[2]) && isset($rep[4])){
[8848] Fix | Delete
$script_slug = $rep[2];
[8849] Fix | Delete
$script_url = $rep[4];
[8850] Fix | Delete
for($s=0;$s<count($script_slug);$s++){
[8851] Fix | Delete
$slug = $script_slug[$s];
[8852] Fix | Delete
$surl = $script_url[$s];
[8853] Fix | Delete
if(preg_match('/amp/', $slug) && preg_match('/https/', $surl)){
[8854] Fix | Delete
if(preg_match('/<script(.*?)custom-element=\"'.esc_attr($slug).'\"(.*?)src=\"(.*?)\"(.*?)>(.*?)<\/script>/', $content, $conmatch)){
[8855] Fix | Delete
if(isset($conmatch[3]) && $conmatch[3]!=""){
[8856] Fix | Delete
$rep_url = $conmatch[3];
[8857] Fix | Delete
if(preg_match('/https/', $rep_url)){
[8858] Fix | Delete
$content = str_replace($rep_url, $surl, $content);
[8859] Fix | Delete
}
[8860] Fix | Delete
}
[8861] Fix | Delete
}
[8862] Fix | Delete
}
[8863] Fix | Delete
}
[8864] Fix | Delete
}
[8865] Fix | Delete
}
[8866] Fix | Delete
}
[8867] Fix | Delete
return $content;
[8868] Fix | Delete
}
[8869] Fix | Delete
if(!function_exists('ampforwp_get_retina_image_settings')){
[8870] Fix | Delete
function ampforwp_get_retina_image_settings($width,$height){
[8871] Fix | Delete
$data['width'] = intval($width);
[8872] Fix | Delete
$data['height'] = intval($height);
[8873] Fix | Delete
if ( 1 == ampforwp_get_setting('ampforwp-retina-images') ) {
[8874] Fix | Delete
$resolution = 2;
[8875] Fix | Delete
if (ampforwp_get_setting('ampforwp-retina-images-res')) {
[8876] Fix | Delete
$resolution = ampforwp_get_setting('ampforwp-retina-images-res');
[8877] Fix | Delete
}
[8878] Fix | Delete
$width = $width * $resolution;
[8879] Fix | Delete
$height = $height * $resolution;
[8880] Fix | Delete
$data['width'] = intval($width);
[8881] Fix | Delete
$data['height'] = intval($height);
[8882] Fix | Delete
}
[8883] Fix | Delete
return $data;
[8884] Fix | Delete
}
[8885] Fix | Delete
}
[8886] Fix | Delete
[8887] Fix | Delete
if(!function_exists('ampforwp_add_fallback_element')){
[8888] Fix | Delete
function ampforwp_add_fallback_element($content='',$tag=''){
[8889] Fix | Delete
preg_match_all('/<'.$tag.' (.*?)<\/'.$tag.'>/', $content, $matches);
[8890] Fix | Delete
if(!empty($matches) && false == ampforwp_get_setting('ampforwp-amp-convert-to-wp')){
[8891] Fix | Delete
if(isset($matches[0])){
[8892] Fix | Delete
$con = "";
[8893] Fix | Delete
for($i=0;$i<count($matches[0]);$i++){
[8894] Fix | Delete
$match = $matches[0][$i];
[8895] Fix | Delete
$m_content = $matches[1][$i];
[8896] Fix | Delete
$m_content = ampforwp_imagify_webp_compatibility($m_content);
[8897] Fix | Delete
$m_content = ampforwp_ewww_webp_compatibility($m_content);
[8898] Fix | Delete
$m_content = ampforwp_webp_express_compatibility($m_content);
[8899] Fix | Delete
$m_content = ampforwp_litespeed_webp_compatibility($m_content);
[8900] Fix | Delete
$m1_content = ampforwp_set_default_fallback_image($matches[1][$i]);
[8901] Fix | Delete
preg_match_all('/src="(.*?)"/', $m1_content,$fimgsrc);
[8902] Fix | Delete
preg_match_all('/width="(.*?)"/', $m1_content,$fimgwidth);
[8903] Fix | Delete
preg_match_all('/height="(.*?)"/', $m1_content,$fimgheight);
[8904] Fix | Delete
preg_match_all('/alt="(.*?)"/', $m1_content,$fimgalt);
[8905] Fix | Delete
if((isset($fimgsrc[1][0]) && preg_match_all('/http/', $fimgsrc[1][0],$fbi)) && isset($fimgwidth[1][0]) && isset($fimgheight[1][0])){
[8906] Fix | Delete
$data['src'] = $fimgsrc[1][0];
[8907] Fix | Delete
$data['width'] = $fimgwidth[1][0];
[8908] Fix | Delete
$data['height'] = $fimgheight[1][0];
[8909] Fix | Delete
if(isset($fimgalt[1][0])){
[8910] Fix | Delete
$data['alt'] = $fimgalt[1][0];
[8911] Fix | Delete
}else{
[8912] Fix | Delete
$data['alt'] = '';
[8913] Fix | Delete
}
[8914] Fix | Delete
$fallback_data = apply_filters('ampforwp_fallback_image_params',$data);
[8915] Fix | Delete
$fsrc = $fallback_data['src'];
[8916] Fix | Delete
$fwidth = $fallback_data['width'];
[8917] Fix | Delete
$fheight= $fallback_data['height'];
[8918] Fix | Delete
$falt = $fallback_data['alt'];
[8919] Fix | Delete
$ssrc = $fimgsrc[0][0];
[8920] Fix | Delete
$swidth = $fimgwidth[0][0];
[8921] Fix | Delete
$sheight = $fimgheight[0][0];
[8922] Fix | Delete
$salt = '';
[8923] Fix | Delete
if(isset($fimgalt[0][0])){
[8924] Fix | Delete
$salt = $fimgalt[0][0];
[8925] Fix | Delete
}
[8926] Fix | Delete
$src_rep = 'src="'.esc_url($fsrc).'"';
[8927] Fix | Delete
$width_rep = 'width="'.intval($fwidth).'"';
[8928] Fix | Delete
$height_rep = 'height="'.intval($fheight).'"';
[8929] Fix | Delete
$alt_rep = 'alt="'.esc_attr($falt).'"';
[8930] Fix | Delete
$m1_content = str_replace($ssrc, $src_rep, $m1_content);
[8931] Fix | Delete
$m1_content = str_replace($swidth, $width_rep, $m1_content);
[8932] Fix | Delete
$m1_content = str_replace($sheight, $height_rep, $m1_content);
[8933] Fix | Delete
$m1_content = str_replace($salt, $alt_rep, $m1_content);
[8934] Fix | Delete
if(function_exists('rocket_activation')){
[8935] Fix | Delete
$m1_content = preg_replace('/srcset="(.*?)"/', '', $m1_content);
[8936] Fix | Delete
}
[8937] Fix | Delete
if(has_action('penci_loop_product_image')){
[8938] Fix | Delete
$fallback_img = "<amp-img data-hero ".$m_content."</amp-img>";
[8939] Fix | Delete
}else{
[8940] Fix | Delete
$fallback_img = "<amp-img data-hero ".$m_content."<amp-img fallback data-hero ".$m1_content."</amp-img></amp-img>";//$m_content, $m1_content escaped above.
[8941] Fix | Delete
}
[8942] Fix | Delete
$content = str_replace("$match", $fallback_img, $content);
[8943] Fix | Delete
}
[8944] Fix | Delete
}
[8945] Fix | Delete
}
[8946] Fix | Delete
}
[8947] Fix | Delete
return $content;
[8948] Fix | Delete
}
[8949] Fix | Delete
}
[8950] Fix | Delete
[8951] Fix | Delete
[8952] Fix | Delete
// added fix for youtube video not displaying on AMP using Elementor #5322
[8953] Fix | Delete
add_filter('ampforwp_modify_the_content','amp_youtube_the_content');
[8954] Fix | Delete
[8955] Fix | Delete
function amp_youtube_the_content($content){
[8956] Fix | Delete
/* Check if youtube embed plugin is active
[8957] Fix | Delete
This is the solution for facade mode issue
[8958] Fix | Delete
if facade mode is enabled in embed youtube plugin then video was not working so this is the
[8959] Fix | Delete
solution for that issue
[8960] Fix | Delete
*/
[8961] Fix | Delete
if(is_plugin_active('youtube-embed-plus/youtube.php')){
[8962] Fix | Delete
$youtube_all_opts = get_option('youtubeprefs_alloptions');
[8963] Fix | Delete
if(!empty($youtube_all_opts) && isset($youtube_all_opts['facade_mode'])){
[8964] Fix | Delete
if($youtube_all_opts['facade_mode'] == 1){
[8965] Fix | Delete
preg_match_all('#<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">(.*?)<\/figure>#is', $content, $video_matches);
[8966] Fix | Delete
if(!empty($video_matches) && is_array($video_matches)){
[8967] Fix | Delete
foreach ($video_matches as $vmkey => $vmvalue) {
[8968] Fix | Delete
if(is_array($vmvalue)){
[8969] Fix | Delete
foreach ($vmvalue as $vmkey1 => $vmvalue1) {
[8970] Fix | Delete
if(!empty($vmvalue1)){
[8971] Fix | Delete
$dochtml = new DOMDocument();
[8972] Fix | Delete
$dochtml->loadHTML($vmvalue1);
[8973] Fix | Delete
$div_tags = $dochtml->getElementsByTagName('div');
[8974] Fix | Delete
if(!empty($div_tags)){
[8975] Fix | Delete
foreach($div_tags as $div_tag) {
[8976] Fix | Delete
$facade_src = $div_tag->getAttribute('data-facadesrc');
[8977] Fix | Delete
if(!empty($facade_src)){
[8978] Fix | Delete
$get_id = get_video_id_from_url($facade_src);
[8979] Fix | Delete
$content_html = '<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
[8980] Fix | Delete
<amp-iframe width="800" height="450" src="'.$facade_src.'" class="__youtube_prefs__ epyt-is-override no-lazyload amp-wp-enforced-sizes" sandbox="allow-scripts allow-same-origin allow-popups allow-forms allow-top-navigation" sizes="(min-width: 800px) 800px, 100vw"><div placeholder="" class="amp-wp-iframe-placeholder"></div></amp-iframe>
[8981] Fix | Delete
</div></figure>';
[8982] Fix | Delete
$content = str_replace($vmvalue1, $content_html, $content);
[8983] Fix | Delete
} // facade_src if end
[8984] Fix | Delete
} // div_tags foreach end
[8985] Fix | Delete
} // div_tags if end
[8986] Fix | Delete
} // vmvalue1 if end
[8987] Fix | Delete
} // vmvalue foreach end
[8988] Fix | Delete
} // vmvalue if end
[8989] Fix | Delete
} // video_matches foreach end
[8990] Fix | Delete
} // video_matches if end
[8991] Fix | Delete
} // facade_mode if end
[8992] Fix | Delete
} // youtube_all_opts if end
[8993] Fix | Delete
} // is_plugin_active if end
[8994] Fix | Delete
[8995] Fix | Delete
[8996] Fix | Delete
// checking is Elementor is installed and activated
[8997] Fix | Delete
if ( did_action( 'elementor/loaded' ) ) {
[8998] Fix | Delete
preg_match_all('/<div\s+class="(.*?)elementor-widget-video"(.*?)data-settings=\'(.*?)\'\sdata-widget_type="video.default">/', $content, $matches);
[8999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function