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
foreach($matches[3] as $video){
[9000] Fix | Delete
$video_attr = json_decode($video);
[9001] Fix | Delete
$get_url = $video_attr->youtube_url;
[9002] Fix | Delete
$get_id = get_video_id_from_url($get_url);
[9003] Fix | Delete
if(ampforwp_get_setting('ampforwp-amp-video-lightbox')==true)
[9004] Fix | Delete
{
[9005] Fix | Delete
$content_html=preg_replace('/<div\s+class="(.*?)elementor-widget-video"(.*?)data-settings=\'(.*?)\'\sdata-widget_type="video.default">/','<amp-lightbox id="open-video'.esc_attr($get_id).'" layout="nodisplay">
[9006] Fix | Delete
<div class="amp-lightbox-video" on="tap:open-video'.esc_attr($get_id).'.close,btn-play'.esc_attr($get_id).'.show" role="button" tabindex=0 aria-label="Close Video">
[9007] Fix | Delete
<a title="close" class="lb-x" href="#" on="tap:open-video'.esc_attr($get_id).'.close,btn-play'.esc_attr($get_id).'.show" role="button" tabindex=0></a>
[9008] Fix | Delete
<div class="amp-video-box"><amp-youtube data-videoid="'.esc_attr($get_id).'" layout="responsive" width="480" height="270"></amp-youtube></div></div></amp-lightbox>
[9009] Fix | Delete
<div class="amp-video-img" id="btn-play'.esc_attr($get_id).'" on="tap:video.show, video.play, btn-play'.esc_attr($get_id).'.hide,open-video'.esc_attr($get_id).'" role="button" aria-label="Play Video">
[9010] Fix | Delete
<amp-img alt="Video" src="http://i3.ytimg.com/vi/'.esc_attr($get_id).'/hqdefault.jpg" width="480" height="270" layout="responsive"></amp-img>
[9011] Fix | Delete
<div class="amp-video-play-on-image"></div>
[9012] Fix | Delete
</div>', $content);
[9013] Fix | Delete
[9014] Fix | Delete
}
[9015] Fix | Delete
else
[9016] Fix | Delete
{
[9017] Fix | Delete
$content_html = preg_replace('/<div\s+class="(.*?)elementor-widget-video"(.*?)data-settings=\'(.*?)\'\sdata-widget_type="video.default">/','<amp-youtube
[9018] Fix | Delete
data-videoid="'.esc_attr($get_id).'"
[9019] Fix | Delete
layout="responsive"
[9020] Fix | Delete
width="480" height="270"></amp-youtube>', $content);
[9021] Fix | Delete
}
[9022] Fix | Delete
return $content_html;
[9023] Fix | Delete
}
[9024] Fix | Delete
}
[9025] Fix | Delete
return $content;
[9026] Fix | Delete
}
[9027] Fix | Delete
[9028] Fix | Delete
function get_video_id_from_url( $url ) {
[9029] Fix | Delete
$short_url_host = 'youtu.be';
[9030] Fix | Delete
$video_id = false;
[9031] Fix | Delete
$parsed_url = parse_url( $url );
[9032] Fix | Delete
[9033] Fix | Delete
if(!isset($parsed_url['host'])){
[9034] Fix | Delete
$parsed_url['host'] = '';
[9035] Fix | Delete
}
[9036] Fix | Delete
if ($short_url_host === substr( $parsed_url['host'], -strlen($short_url_host ) ) ) {
[9037] Fix | Delete
// youtu.be/{id}
[9038] Fix | Delete
$parts = explode( '/', $parsed_url['path'] );
[9039] Fix | Delete
if ( ! empty( $parts ) ) {
[9040] Fix | Delete
$video_id = $parts[1];
[9041] Fix | Delete
}
[9042] Fix | Delete
} else {
[9043] Fix | Delete
// ?v={id} or ?list={id}
[9044] Fix | Delete
if(isset($parsed_url['query'])){
[9045] Fix | Delete
parse_str( $parsed_url['query'], $query_args );
[9046] Fix | Delete
}
[9047] Fix | Delete
[9048] Fix | Delete
if ( isset( $query_args['v'] ) ) {
[9049] Fix | Delete
if ( false !== strpos( $query_args['v'], '?' ) ) {
[9050] Fix | Delete
$video_id = strtok( $query_args['v'], '?' );
[9051] Fix | Delete
}
[9052] Fix | Delete
else{
[9053] Fix | Delete
$video_id = $query_args['v'];
[9054] Fix | Delete
}
[9055] Fix | Delete
}
[9056] Fix | Delete
}
[9057] Fix | Delete
[9058] Fix | Delete
if ( empty( $video_id ) ) {
[9059] Fix | Delete
// /(v|e|embed)/{id}
[9060] Fix | Delete
$parts = explode( '/', $parsed_url['path'] );
[9061] Fix | Delete
[9062] Fix | Delete
if ( in_array( $parts[1], array( 'v', 'e', 'embed' ) ) ) {
[9063] Fix | Delete
$video_id = $parts[2];
[9064] Fix | Delete
}
[9065] Fix | Delete
}
[9066] Fix | Delete
[9067] Fix | Delete
return $video_id;
[9068] Fix | Delete
}
[9069] Fix | Delete
[9070] Fix | Delete
if(!function_exists('ampforwp_imagify_webp_compatibility')){
[9071] Fix | Delete
function ampforwp_imagify_webp_compatibility($content){
[9072] Fix | Delete
if(function_exists('_imagify_init')){
[9073] Fix | Delete
preg_match_all('/src="(.*?)"/', $content,$src);
[9074] Fix | Delete
$imageify_opt = get_option( 'imagify_settings' );
[9075] Fix | Delete
$convert_to_webp = false;
[9076] Fix | Delete
if(isset($imageify_opt['convert_to_webp'])){
[9077] Fix | Delete
$convert_to_webp = $imageify_opt['convert_to_webp'];
[9078] Fix | Delete
}
[9079] Fix | Delete
$display_webp = false;
[9080] Fix | Delete
if(isset($imageify_opt['display_webp'])){
[9081] Fix | Delete
$display_webp = $imageify_opt['display_webp'];
[9082] Fix | Delete
}
[9083] Fix | Delete
if($convert_to_webp && $display_webp){
[9084] Fix | Delete
$img_url = esc_url($src[1][0]);
[9085] Fix | Delete
if(!preg_match('/\.webp/', $img_url)){
[9086] Fix | Delete
$rep_url = esc_url($src[1][0]).".webp";
[9087] Fix | Delete
if(preg_match('/http(.*)\/wp-content\/uploads/', $rep_url)){
[9088] Fix | Delete
$upload_dir = wp_upload_dir()['basedir'];
[9089] Fix | Delete
$img_file = preg_replace('/http(.*)\/wp-content\/uploads/', $upload_dir, $rep_url);
[9090] Fix | Delete
if(file_exists($img_file)){
[9091] Fix | Delete
$content = str_replace($img_url, $rep_url, $content);
[9092] Fix | Delete
}
[9093] Fix | Delete
}
[9094] Fix | Delete
}
[9095] Fix | Delete
}
[9096] Fix | Delete
}
[9097] Fix | Delete
$content = str_replace('.webp.webp','.webp',$content);
[9098] Fix | Delete
return $content;
[9099] Fix | Delete
}
[9100] Fix | Delete
}
[9101] Fix | Delete
if(!function_exists('ampforwp_set_default_fallback_image')){
[9102] Fix | Delete
function ampforwp_set_default_fallback_image($content){
[9103] Fix | Delete
if(!function_exists('_imagify_init') && !function_exists('ewww_image_optimizer_webp_initialize') && !has_action('penci_loop_product_image')){
[9104] Fix | Delete
preg_match_all('/src="(.*?)"/', $content,$cc); // need to check extenstion for fallback.
[9105] Fix | Delete
if(isset($cc[1][0])){
[9106] Fix | Delete
$img = $cc[1][0];
[9107] Fix | Delete
$defaul_fallback_img = ampforwp_get_setting('ampforwp_default_fallback_image');
[9108] Fix | Delete
if(isset($defaul_fallback_img['url']) && $defaul_fallback_img['url']!=''){
[9109] Fix | Delete
$defaul_fallback_img = esc_url($defaul_fallback_img['url']);
[9110] Fix | Delete
$content = str_replace($img, $defaul_fallback_img, $content); // need to change fallback extenstion.
[9111] Fix | Delete
}
[9112] Fix | Delete
}
[9113] Fix | Delete
[9114] Fix | Delete
}
[9115] Fix | Delete
return $content;
[9116] Fix | Delete
}
[9117] Fix | Delete
}
[9118] Fix | Delete
if(!function_exists('ampforwp_ewww_webp_compatibility')){
[9119] Fix | Delete
function ampforwp_ewww_webp_compatibility($content){
[9120] Fix | Delete
if(defined( 'EWWW_IO_CLOUD_PLUGIN' )){
[9121] Fix | Delete
preg_match_all('/src="(.*?)"/', $content,$src);
[9122] Fix | Delete
if(isset($src[1][0])){
[9123] Fix | Delete
$img_url = esc_url($src[1][0]);
[9124] Fix | Delete
if(!preg_match('/\.webp/', $img_url)){
[9125] Fix | Delete
$rep_url = esc_url($src[1][0]).".webp";
[9126] Fix | Delete
if(preg_match('/http(.*)\/wp-content\/uploads/', $rep_url)){
[9127] Fix | Delete
$upload_dir = wp_upload_dir()['basedir'];
[9128] Fix | Delete
$img_file = preg_replace('/http(.*)\/wp-content\/uploads/', $upload_dir, $rep_url);
[9129] Fix | Delete
if(file_exists($img_file)){
[9130] Fix | Delete
$content = str_replace($img_url, $rep_url, $content);
[9131] Fix | Delete
}
[9132] Fix | Delete
}
[9133] Fix | Delete
}
[9134] Fix | Delete
}
[9135] Fix | Delete
}
[9136] Fix | Delete
$content = str_replace('.webp.webp','.webp',$content);
[9137] Fix | Delete
return $content;
[9138] Fix | Delete
}
[9139] Fix | Delete
}
[9140] Fix | Delete
[9141] Fix | Delete
if(!function_exists('ampforwp_check_image_existance')){
[9142] Fix | Delete
function ampforwp_check_image_existance($image){
[9143] Fix | Delete
if(preg_match('/wp-content\/uploads/', $image)){
[9144] Fix | Delete
$img_arr = explode('wp-content', $image);
[9145] Fix | Delete
if(!empty($img_arr) && isset($img_arr[1])){
[9146] Fix | Delete
$img = WP_CONTENT_DIR.$img_arr[1];
[9147] Fix | Delete
if(!file_exists($img)){
[9148] Fix | Delete
if(preg_match('/\d+x\d+/', $image,$ma)){
[9149] Fix | Delete
$t_sizes = explode('x', $ma[0]);
[9150] Fix | Delete
$width = $t_sizes[0];
[9151] Fix | Delete
$height = $t_sizes[1];
[9152] Fix | Delete
$image = preg_replace('/-\d+x\d+/','', $image);
[9153] Fix | Delete
$resize = ampforwp_aq_resize( $image, $width , $height , true, false, true );
[9154] Fix | Delete
if(isset($resize[0])){
[9155] Fix | Delete
$image = $resize[0];
[9156] Fix | Delete
}
[9157] Fix | Delete
}
[9158] Fix | Delete
}
[9159] Fix | Delete
}
[9160] Fix | Delete
}
[9161] Fix | Delete
return $image;
[9162] Fix | Delete
}
[9163] Fix | Delete
}
[9164] Fix | Delete
[9165] Fix | Delete
if (function_exists('themify_builder_activate')) {
[9166] Fix | Delete
add_filter('ampforwp_modify_the_content','ampforwp_themify_compatibility');
[9167] Fix | Delete
}
[9168] Fix | Delete
function ampforwp_themify_compatibility($content){
[9169] Fix | Delete
$get_data = get_post_meta(ampforwp_get_the_ID(),'_themify_builder_settings_json',true);
[9170] Fix | Delete
if($get_data){
[9171] Fix | Delete
$decode = json_decode($get_data,true);
[9172] Fix | Delete
$cols = '';
[9173] Fix | Delete
for($i=0;$i<count($decode);$i++){
[9174] Fix | Delete
if(isset($decode[$i]['cols'])){
[9175] Fix | Delete
$cols = $decode[$i]['cols'];
[9176] Fix | Delete
}
[9177] Fix | Delete
for($j=0;$j<count($cols);$j++){
[9178] Fix | Delete
if (isset($cols[$j]['modules'])) {
[9179] Fix | Delete
$modules = $cols[$j]['modules'];
[9180] Fix | Delete
for($k=0;$k<count($modules);$k++){
[9181] Fix | Delete
foreach ($modules as $key => $value) {
[9182] Fix | Delete
foreach ($value['mod_settings'] as $key => $val) {
[9183] Fix | Delete
$content.=$val;
[9184] Fix | Delete
}
[9185] Fix | Delete
}
[9186] Fix | Delete
}
[9187] Fix | Delete
}
[9188] Fix | Delete
}
[9189] Fix | Delete
}
[9190] Fix | Delete
}
[9191] Fix | Delete
return $content;
[9192] Fix | Delete
}
[9193] Fix | Delete
[9194] Fix | Delete
add_action( 'wp_ajax_ampforwp_referesh_related_post', 'ampforwp_referesh_related_post' );
[9195] Fix | Delete
function ampforwp_referesh_related_post(){
[9196] Fix | Delete
if(!wp_verify_nonce($_POST['verify_nonce'],'ampforwp_refresh_related_poost') ){
[9197] Fix | Delete
echo wp_json_encode(array('status'=>403,'message'=>esc_html__('user request is not allowed','accelerated-mobile-pages'))) ;
[9198] Fix | Delete
die;
[9199] Fix | Delete
}
[9200] Fix | Delete
$orderby = 'ID';
[9201] Fix | Delete
[9202] Fix | Delete
$args=array(
[9203] Fix | Delete
'fields' => 'ids',
[9204] Fix | Delete
'post_type' => 'post',
[9205] Fix | Delete
'posts_per_page'=> 30,
[9206] Fix | Delete
'orderby' => $orderby,
[9207] Fix | Delete
'ignore_sticky_posts'=>1,
[9208] Fix | Delete
'has_password' => false ,
[9209] Fix | Delete
'post_status'=> 'publish',
[9210] Fix | Delete
'no_found_rows' => true,
[9211] Fix | Delete
'meta_query' => array(
[9212] Fix | Delete
array(
[9213] Fix | Delete
'key' => 'ampforwp-amp-on-off',
[9214] Fix | Delete
'compare' => 'NOT EXISTS',
[9215] Fix | Delete
)
[9216] Fix | Delete
)
[9217] Fix | Delete
);
[9218] Fix | Delete
$my_query = new wp_query( $args );
[9219] Fix | Delete
while( $my_query->have_posts() ) {
[9220] Fix | Delete
$my_query->the_post();
[9221] Fix | Delete
update_post_meta(get_the_ID(),'ampforwp-amp-on-off','default');
[9222] Fix | Delete
}
[9223] Fix | Delete
/*$args=array(
[9224] Fix | Delete
'fields' => 'ids',
[9225] Fix | Delete
'post_status' => 'publish',
[9226] Fix | Delete
'ignore_sticky_posts' => true,
[9227] Fix | Delete
'posts_per_page' => 50,
[9228] Fix | Delete
'no_found_rows' => true,
[9229] Fix | Delete
'meta_query' => array(
[9230] Fix | Delete
array(
[9231] Fix | Delete
'key' => 'ampforwp-ia-on-off',
[9232] Fix | Delete
'compare' => 'NOT EXISTS',
[9233] Fix | Delete
)
[9234] Fix | Delete
)
[9235] Fix | Delete
);
[9236] Fix | Delete
$my_query = new wp_query( $args );
[9237] Fix | Delete
while( $my_query->have_posts() ) {
[9238] Fix | Delete
$my_query->the_post();
[9239] Fix | Delete
update_post_meta(get_the_ID(),'ampforwp-ia-on-off','default');
[9240] Fix | Delete
}*/
[9241] Fix | Delete
$data['response'] = ampforwp_get_post_percent();
[9242] Fix | Delete
echo wp_json_encode($data);
[9243] Fix | Delete
}
[9244] Fix | Delete
[9245] Fix | Delete
// HIDE/SHOW TAG AND CATEGORY #4326
[9246] Fix | Delete
function ampforwp_save_taxonomy_meta($term_id){
[9247] Fix | Delete
if(isset($_POST['amp_taxonomy'])){
[9248] Fix | Delete
$cat_status = sanitize_text_field($_POST['amp_taxonomy']);
[9249] Fix | Delete
$hide_tax = sanitize_text_field($_POST['hide_tax']);
[9250] Fix | Delete
add_term_meta($term_id, 'amp_taxonomy', $cat_status );
[9251] Fix | Delete
add_term_meta( $term_id,'amp_hide_tax', $hide_tax);
[9252] Fix | Delete
}
[9253] Fix | Delete
}
[9254] Fix | Delete
function ampforwp_update_taxonomy_meta($term_id, $term_id1){
[9255] Fix | Delete
if(isset($_POST['amp_taxonomy'])){
[9256] Fix | Delete
$cat_status = sanitize_text_field($_POST['amp_taxonomy']);
[9257] Fix | Delete
$hide_tax = sanitize_text_field($_POST['hide_tax']);
[9258] Fix | Delete
update_term_meta( $term_id,'amp_taxonomy', $cat_status);
[9259] Fix | Delete
update_term_meta( $term_id,'amp_hide_tax', $hide_tax);
[9260] Fix | Delete
}
[9261] Fix | Delete
}
[9262] Fix | Delete
[9263] Fix | Delete
if ( isset( $_REQUEST['taxonomy'] )) {
[9264] Fix | Delete
$taxonomy = $_REQUEST['taxonomy'];
[9265] Fix | Delete
add_action('edited_'.esc_attr($taxonomy), 'ampforwp_update_taxonomy_meta',10,2);
[9266] Fix | Delete
add_action('create_'.esc_attr($taxonomy), 'ampforwp_save_taxonomy_meta', 10);
[9267] Fix | Delete
add_action('edited_'.esc_attr($taxonomy), 'ampforwp_update_taxonomy_meta',10,2);
[9268] Fix | Delete
add_action('create_'.esc_attr($taxonomy), 'ampforwp_save_taxonomy_meta', 10);
[9269] Fix | Delete
add_action (esc_attr($taxonomy).'_edit_form_fields', 'ampforwp_extra_category_fields');
[9270] Fix | Delete
add_action (esc_attr($taxonomy).'_add_form_fields', 'ampforwp_extra_category_fields');
[9271] Fix | Delete
}
[9272] Fix | Delete
function ampforwp_extra_category_fields( $tag ) {
[9273] Fix | Delete
$label = 'Category';
[9274] Fix | Delete
if(is_object($tag)){
[9275] Fix | Delete
if($tag->taxonomy=="post_tag"){
[9276] Fix | Delete
$label = 'Tag';
[9277] Fix | Delete
}else if($tag->taxonomy!='category'){
[9278] Fix | Delete
$label = $tag->taxonomy;
[9279] Fix | Delete
}
[9280] Fix | Delete
}else{
[9281] Fix | Delete
if($tag=='post_tag'){
[9282] Fix | Delete
$label = 'Tag';
[9283] Fix | Delete
}
[9284] Fix | Delete
}
[9285] Fix | Delete
?>
[9286] Fix | Delete
<tr class="form-field">
[9287] Fix | Delete
<?php if(!isset($tag->term_id)){?>
[9288] Fix | Delete
<th scope="row" valign="top"></th>
[9289] Fix | Delete
<td>
[9290] Fix | Delete
<div class="form-field term-parent-wrap">
[9291] Fix | Delete
<label for="show_amp_taxonomy">AMP</label>
[9292] Fix | Delete
<select name="amp_taxonomy" id="show_amp_taxonomy" class="postform">
[9293] Fix | Delete
<option class="level-0" value="show">Show</option>
[9294] Fix | Delete
<option class="level-0" value="hide">Hide</option>
[9295] Fix | Delete
</select>
[9296] Fix | Delete
<p>You can enable or disable AMP on this category. <a href="https://ampforwp.com/tutorials/article/how-to-show-hide-the-amp-from-the-categories-or-product-pages-or-any-custom-taxonomy-in-amp/" target="_blank">Learn More</a>.</p>
[9297] Fix | Delete
</div>
[9298] Fix | Delete
<div id="amp-show-hide-tax" class="mrtop-10" style="display: none">
[9299] Fix | Delete
<div class="hide-show-amp-tax">
[9300] Fix | Delete
<input type="radio" value="hide-cat" name="hide_tax" checked="">
[9301] Fix | Delete
<strong><?php echo esc_attr($label);?>:</strong>
[9302] Fix | Delete
Hide from <?php echo esc_attr($label);?> Archive Page.
[9303] Fix | Delete
</div>
[9304] Fix | Delete
<div class="mrtop-10 hide-show-amp-tax">
[9305] Fix | Delete
<input type="radio" value="hide-tax-post" name="hide_tax">
[9306] Fix | Delete
<strong><?php echo esc_attr($label);?> & Posts: </strong>
[9307] Fix | Delete
Hide from <?php echo esc_attr($label);?> Archive Page and all it's posts
[9308] Fix | Delete
</div>
[9309] Fix | Delete
</div>
[9310] Fix | Delete
<br>
[9311] Fix | Delete
</td>
[9312] Fix | Delete
<?php }else{
[9313] Fix | Delete
$term_data = ampforwp_get_taxonomy_meta($tag->term_id);
[9314] Fix | Delete
$visible = '';
[9315] Fix | Delete
$visible_status = '';
[9316] Fix | Delete
if(isset($term_data['visible']) && !empty($term_data['visible'])){
[9317] Fix | Delete
$visible = $term_data['visible'][0];
[9318] Fix | Delete
$visible_status = $term_data['visible_status'][0];
[9319] Fix | Delete
}
[9320] Fix | Delete
?>
[9321] Fix | Delete
<th scope="row"><label for="show_amp_taxonomy">AMP</label></th>
[9322] Fix | Delete
<td>
[9323] Fix | Delete
<select name="amp_taxonomy" id="show_amp_taxonomy" class="postform">
[9324] Fix | Delete
<option class="level-0" value="show" <?php if($visible=='show'){ echo "selected"; }?>>Show</option>
[9325] Fix | Delete
<option class="level-0" value="hide" <?php if($visible=='hide'){ echo "selected";} ?>>Hide</option>
[9326] Fix | Delete
</select><br />
[9327] Fix | Delete
<span class="description">You can enable or disable AMP on this category. <a href="https://ampforwp.com/tutorials/article/how-to-show-hide-the-amp-from-the-categories-or-product-pages-or-any-custom-taxonomy-in-amp/" target="_blank">Learn More</a>.</span>
[9328] Fix | Delete
<div id="amp-show-hide-tax" <?php if($visible=='show' || $visible==''){?>style="display: none;"<?php }?> class="edit_hide_tax mrtop-10">
[9329] Fix | Delete
<div class="hide-show-amp-tax">
[9330] Fix | Delete
<input type="radio" value="hide-cat" name="hide_tax" <?php if($visible_status=='hide-cat' || $visible_status==''){?> checked <?php }?>>
[9331] Fix | Delete
<strong><?php echo esc_attr($label);?>:</strong>
[9332] Fix | Delete
Hide from <?php echo esc_attr($label);?> Archive Page.
[9333] Fix | Delete
</div>
[9334] Fix | Delete
<div class="mrtop-10 hide-show-amp-tax">
[9335] Fix | Delete
<input type="radio" value="hide-tax-post" name="hide_tax" <?php if($visible_status=='hide-tax-post'){?> checked <?php }?>>
[9336] Fix | Delete
<strong><?php echo esc_attr($label);?> & Posts: </strong>
[9337] Fix | Delete
Hide from <?php echo esc_attr($label);?> Archive Page and all it's posts
[9338] Fix | Delete
</div>
[9339] Fix | Delete
</div>
[9340] Fix | Delete
</td>
[9341] Fix | Delete
<?php }?>
[9342] Fix | Delete
</tr>
[9343] Fix | Delete
<?php
[9344] Fix | Delete
}
[9345] Fix | Delete
//4710 Added support to load featured image for lazy load option of Dues theme.
[9346] Fix | Delete
if(function_exists('wpg_lazyload_image_attributes')){
[9347] Fix | Delete
add_action('wp','ampforwp_dues_theme_load_featured_image');
[9348] Fix | Delete
}
[9349] Fix | Delete
function ampforwp_dues_theme_load_featured_image(){
[9350] Fix | Delete
if(ampforwp_is_amp_endpoint()){
[9351] Fix | Delete
remove_filter( 'wp_get_attachment_image_attributes', 'wpg_lazyload_image_attributes', 8, 3 );
[9352] Fix | Delete
}
[9353] Fix | Delete
}
[9354] Fix | Delete
if(function_exists('rocket_activation')){
[9355] Fix | Delete
add_filter("ampforwp_the_content_last_filter",'ampforwp_wp_rocket_compatibility',25);
[9356] Fix | Delete
}
[9357] Fix | Delete
function ampforwp_wp_rocket_compatibility($content){
[9358] Fix | Delete
$cdn_url = get_option('wp_rocket_settings');
[9359] Fix | Delete
if($cdn_url['cdn'] == 1){
[9360] Fix | Delete
$img_cdn_url = '';
[9361] Fix | Delete
$cnds_arr = array();
[9362] Fix | Delete
if(!empty($cdn_url['cdn_zone']) && !empty($cdn_url['cdn_cnames'])){
[9363] Fix | Delete
foreach ($cdn_url['cdn_zone'] as $key => $element) {
[9364] Fix | Delete
if(isset($cdn_url['cdn_cnames'][$key]) && $cdn_url['cdn_cnames'][$key]!=''){
[9365] Fix | Delete
$cnds_arr[$element] = $cdn_url['cdn_cnames'][$key];
[9366] Fix | Delete
}
[9367] Fix | Delete
}
[9368] Fix | Delete
}
[9369] Fix | Delete
if(isset($cnds_arr['images'])){
[9370] Fix | Delete
$img_cdn_url = $cnds_arr['images'];
[9371] Fix | Delete
$img_cdn_url = apply_filters( 'ampforwp_modify_wp_rocket_cdn_url', $img_cdn_url );
[9372] Fix | Delete
}else if(isset($cnds_arr['all'])){
[9373] Fix | Delete
$img_cdn_url = $cnds_arr['all'];
[9374] Fix | Delete
}
[9375] Fix | Delete
if($img_cdn_url!=''){
[9376] Fix | Delete
$parse_url = parse_url($img_cdn_url);
[9377] Fix | Delete
if(!isset($parse_url['scheme'])){
[9378] Fix | Delete
if(!preg_match('/\/\//', $img_cdn_url)){
[9379] Fix | Delete
$img_cdn_url = '//'.$img_cdn_url;
[9380] Fix | Delete
}
[9381] Fix | Delete
}
[9382] Fix | Delete
$comp_dom = new DOMDocument();
[9383] Fix | Delete
@$comp_dom->loadHTML($content);
[9384] Fix | Delete
$xpath = new DOMXPath( $comp_dom );
[9385] Fix | Delete
$nodes = $xpath->query('//amp-img[@src]');
[9386] Fix | Delete
$home_url = home_url();
[9387] Fix | Delete
foreach ($nodes as $node) {
[9388] Fix | Delete
$url = $node->getAttribute('src');
[9389] Fix | Delete
$srcset = $node->getAttribute('srcset');
[9390] Fix | Delete
$is_external = ampforwp_isexternal($url);
[9391] Fix | Delete
if(!$is_external && !$node->hasAttribute('fallback')){
[9392] Fix | Delete
$img_src = str_replace($home_url, $img_cdn_url, $url);
[9393] Fix | Delete
$content = str_replace($url, $img_src, $content);
[9394] Fix | Delete
$srcset_arr = explode(",", $srcset);
[9395] Fix | Delete
for($i=0;$i<count($srcset_arr);$i++){
[9396] Fix | Delete
$original = $srcset_arr[$i];
[9397] Fix | Delete
$new = str_replace($home_url, $img_cdn_url, $original);
[9398] Fix | Delete
if(preg_match('/'.preg_quote($original,'/').'/', $content)){
[9399] Fix | Delete
$content = preg_replace('/'.preg_quote($original,'/').'/', $new, $content);
[9400] Fix | Delete
}
[9401] Fix | Delete
}
[9402] Fix | Delete
}
[9403] Fix | Delete
}
[9404] Fix | Delete
}
[9405] Fix | Delete
}
[9406] Fix | Delete
return $content;
[9407] Fix | Delete
}
[9408] Fix | Delete
// Adding Mobile theme color meta data in header
[9409] Fix | Delete
if(true == ampforwp_get_setting('mobile-theme-color')){
[9410] Fix | Delete
add_action( 'amp_post_template_head', 'ampforwp_mobile_theme_color');
[9411] Fix | Delete
}
[9412] Fix | Delete
function ampforwp_mobile_theme_color(){
[9413] Fix | Delete
$content_code = ampforwp_get_setting('mobile-theme-color-picker','color');
[9414] Fix | Delete
if(empty($content_code)){
[9415] Fix | Delete
$content_code = '#ffffff';
[9416] Fix | Delete
}
[9417] Fix | Delete
?>
[9418] Fix | Delete
<meta name="theme-color" content="<?php echo ampforwp_sanitize_color($content_code); ?>"/>
[9419] Fix | Delete
<?php
[9420] Fix | Delete
}
[9421] Fix | Delete
[9422] Fix | Delete
if(function_exists('herald_theme_setup')){
[9423] Fix | Delete
add_filter('the_content', 'ampforwp_herald_popup_media_in_content', 100, 1 );
[9424] Fix | Delete
add_filter('bbp_get_topic_content','herald_popup_media_in_content');
[9425] Fix | Delete
add_filter('bbp_get_reply_content','herald_popup_media_in_content');
[9426] Fix | Delete
}
[9427] Fix | Delete
function ampforwp_herald_popup_media_in_content( $content ) {
[9428] Fix | Delete
if(ampforwp_is_amp_endpoint()){
[9429] Fix | Delete
if (function_exists('herald_get_option') && herald_get_option( 'on_single_img_popup' ) ) {
[9430] Fix | Delete
if(preg_match("/<a class=\"herald-popup-img\" href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")><img(.*?)<\/a>/i", $content,$matches)){
[9431] Fix | Delete
$content = preg_replace( "/<a class=\"herald-popup-img\" href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")><img(.*?)<\/a>/i", '<img on="tap:amp-img-lightbox" role="button" tabindex="0" $5', $content );
[9432] Fix | Delete
}
[9433] Fix | Delete
}
[9434] Fix | Delete
}
[9435] Fix | Delete
return $content;
[9436] Fix | Delete
}
[9437] Fix | Delete
// Added TravelTour theme page builder content support.#4540
[9438] Fix | Delete
function ampforwp_gdlr_core_page_builder_content($content){
[9439] Fix | Delete
ob_start();
[9440] Fix | Delete
do_action('gdlr_core_print_page_builder');
[9441] Fix | Delete
$content_gdlr = ob_get_contents();
[9442] Fix | Delete
ob_end_clean();
[9443] Fix | Delete
if ( $content_gdlr ) {
[9444] Fix | Delete
$content = $content . $content_gdlr ;
[9445] Fix | Delete
}
[9446] Fix | Delete
return $content;
[9447] Fix | Delete
}
[9448] Fix | Delete
add_filter('wpseo_robots', 'ampforwp_yoast_home_robots');
[9449] Fix | Delete
function ampforwp_yoast_home_robots($string) {
[9450] Fix | Delete
if (ampforwp_is_home() || ampforwp_is_front_page() && method_exists('WPSEO_Meta', 'get_value') && '1' == WPSEO_Meta::get_value( 'meta-robots-noindex', get_option( 'page_for_posts' )) && '0' == WPSEO_Meta::get_value( 'meta-robots-noindex', ampforwp_get_the_ID())) {
[9451] Fix | Delete
$string= "index";
[9452] Fix | Delete
}
[9453] Fix | Delete
return $string;
[9454] Fix | Delete
}
[9455] Fix | Delete
//Fallback added
[9456] Fix | Delete
if( function_exists('fifu_activate') && !function_exists( 'fifu_amp_url' ) ) {
[9457] Fix | Delete
function fifu_amp_url($url, $width, $height) {
[9458] Fix | Delete
$size = get_post_meta(ampforwp_get_the_ID(), 'fifu_image_dimension');
[9459] Fix | Delete
if (!empty($size)) {
[9460] Fix | Delete
$size = explode(';', $size[0]);
[9461] Fix | Delete
$width = $size[0];
[9462] Fix | Delete
$height = $size[1];
[9463] Fix | Delete
}
[9464] Fix | Delete
return array(0 => $url, 1 => $width, 2 => $height);
[9465] Fix | Delete
}
[9466] Fix | Delete
}
[9467] Fix | Delete
add_filter('ampforwp_post_template_data','ampforwp_amp_bind_script');
[9468] Fix | Delete
function ampforwp_amp_bind_script($data) {
[9469] Fix | Delete
if ( empty( $data['amp_component_scripts']['amp-bind'] ) ) {
[9470] Fix | Delete
$data['amp_component_scripts']['amp-bind'] = 'https://cdn.ampproject.org/v0/amp-bind-latest.js';
[9471] Fix | Delete
}
[9472] Fix | Delete
return $data;
[9473] Fix | Delete
}
[9474] Fix | Delete
add_filter('ampforwp_post_template_data','ampforwp_amp_story_player_script',12);
[9475] Fix | Delete
function ampforwp_amp_story_player_script($data) {
[9476] Fix | Delete
if ( isset($data['post'])) {
[9477] Fix | Delete
$post_content = $data['post']->post_content;
[9478] Fix | Delete
if ( (preg_match('/<amp-story-player(.*?)<\/amp-story-player>/s', $post_content) || preg_match('/web-stories/', $post_content )) && empty( $data['amp_component_scripts']['amp-story-player'] ) ) {
[9479] Fix | Delete
$data['amp_component_scripts']['amp-story-player'] = 'https://cdn.ampproject.org/v0/amp-story-player-latest.js';
[9480] Fix | Delete
}
[9481] Fix | Delete
}
[9482] Fix | Delete
return $data;
[9483] Fix | Delete
}
[9484] Fix | Delete
[9485] Fix | Delete
if(!function_exists('ampforwp_video_lightbox')){
[9486] Fix | Delete
function ampforwp_video_lightbox($content){
[9487] Fix | Delete
$video_tags_arr = array('amp-youtube');
[9488] Fix | Delete
add_action('amp_post_template_css','ampforwp_video_lightbox_css',30);
[9489] Fix | Delete
for($i=0;$i<count($video_tags_arr);$i++){
[9490] Fix | Delete
$tag = $video_tags_arr[$i];
[9491] Fix | Delete
preg_match_all('/<'.$tag.' (.*?)<\/'.$tag.'>/', $content, $matches);
[9492] Fix | Delete
if(!empty($matches)){
[9493] Fix | Delete
if(isset($matches[0])){
[9494] Fix | Delete
$con = "";
[9495] Fix | Delete
for($i=0;$i<count($matches[0]);$i++){
[9496] Fix | Delete
$match = $matches[0][$i];
[9497] Fix | Delete
$dom = AMP_DOM_Utils::get_dom_from_content($match);
[9498] Fix | Delete
$nodes = $dom->getElementsByTagName( 'amp-youtube' );
[9499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function