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
/home/sportsfe.../httpdocs/wp-conte.../plugins/accelera.../componen.../related-...
File: related-posts.php
<?php
[0] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[1] Fix | Delete
exit;
[2] Fix | Delete
}
[3] Fix | Delete
/*
[4] Fix | Delete
@data parameter have options for
[5] Fix | Delete
show_excerpt
[6] Fix | Delete
*/
[7] Fix | Delete
function ampforwp_framework_get_related_posts($argsdata=array()){
[8] Fix | Delete
global $post, $redux_builder_amp;
[9] Fix | Delete
$show_image = (isset($argsdata['show_image']) ? $argsdata['show_image'] : true);
[10] Fix | Delete
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts'];
[11] Fix | Delete
$int_number_of_related_posts = (int)$string_number_of_related_posts;
[12] Fix | Delete
$my_query = ampforwp_related_post_loop_query();
[13] Fix | Delete
if ( isset($redux_builder_amp['ampforwp-single-related-posts-switch']) && $redux_builder_amp['ampforwp-single-related-posts-switch'] ) {
[14] Fix | Delete
if( $my_query->have_posts() ) { ?>
[15] Fix | Delete
<div class="amp-related-posts">
[16] Fix | Delete
<ul class="clearfix">
[17] Fix | Delete
<?php ampforwp_related_post(); ?>
[18] Fix | Delete
<?php
[19] Fix | Delete
while( $my_query->have_posts() ) {
[20] Fix | Delete
$my_query->the_post();
[21] Fix | Delete
?>
[22] Fix | Delete
<li class="<?php if ( has_post_thumbnail() ) { echo'has_thumbnail'; } else { echo 'no_thumbnail'; } ?>">
[23] Fix | Delete
<?php
[24] Fix | Delete
$related_post_permalink = ampforwp_url_controller( get_permalink() );
[25] Fix | Delete
if ( $show_image ) {
[26] Fix | Delete
if ( isset($argsdata['image_size']) && '' != $argsdata['image_size'] ) {
[27] Fix | Delete
ampforwp_get_relatedpost_image($argsdata['image_size']);
[28] Fix | Delete
}
[29] Fix | Delete
else {
[30] Fix | Delete
ampforwp_get_relatedpost_image('thumbnail');
[31] Fix | Delete
}
[32] Fix | Delete
}
[33] Fix | Delete
ampforwp_get_relatedpost_content($argsdata);
[34] Fix | Delete
?>
[35] Fix | Delete
</li><?php
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
} ?>
[39] Fix | Delete
</ul>
[40] Fix | Delete
</div>
[41] Fix | Delete
<?php wp_reset_postdata(); ?>
[42] Fix | Delete
<?php do_action('ampforwp_below_related_post_hook');
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
function ampforwp_related_post_loop_query(){
[47] Fix | Delete
global $post, $redux_builder_amp;
[48] Fix | Delete
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts'];
[49] Fix | Delete
$int_number_of_related_posts = (int)$string_number_of_related_posts;
[50] Fix | Delete
$args = null;
[51] Fix | Delete
$orderby = 'ID';
[52] Fix | Delete
if( true == ampforwp_get_setting('ampforwp-single-order-of-related-posts')){
[53] Fix | Delete
$orderby = 'rand';
[54] Fix | Delete
}
[55] Fix | Delete
$args=array(
[56] Fix | Delete
'fields' => 'ids',
[57] Fix | Delete
'post_type' => get_post_type($post),
[58] Fix | Delete
'posts_per_page'=> $int_number_of_related_posts,
[59] Fix | Delete
'orderby' => $orderby,
[60] Fix | Delete
'ignore_sticky_posts'=>1,
[61] Fix | Delete
'has_password' => false ,
[62] Fix | Delete
'post_status'=> 'publish',
[63] Fix | Delete
'no_found_rows' => true,
[64] Fix | Delete
'meta_query' => array(
[65] Fix | Delete
array(
[66] Fix | Delete
'key' => 'ampforwp-amp-on-off',
[67] Fix | Delete
'value' => 'default',
[68] Fix | Delete
)
[69] Fix | Delete
)
[70] Fix | Delete
);
[71] Fix | Delete
if($redux_builder_amp['ampforwp-single-select-type-of-related']==2 && 'post' == $post->post_type ){
[72] Fix | Delete
$categories = get_the_category($post->ID);
[73] Fix | Delete
if ($categories) {
[74] Fix | Delete
$category_ids = array();
[75] Fix | Delete
foreach($categories as $individual_category){ $category_ids[] = $individual_category->term_id;
[76] Fix | Delete
}
[77] Fix | Delete
$args['category__in'] = $category_ids;
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
// tags
[81] Fix | Delete
if($redux_builder_amp['ampforwp-single-select-type-of-related']==1 && 'post' == $post->post_type ) {
[82] Fix | Delete
$ampforwp_tags = get_the_tags($post->ID);
[83] Fix | Delete
if ($ampforwp_tags) {
[84] Fix | Delete
$tag_ids = array();
[85] Fix | Delete
foreach($ampforwp_tags as $individual_tag) {
[86] Fix | Delete
$tag_ids[] = $individual_tag->term_id;
[87] Fix | Delete
}
[88] Fix | Delete
$args['tag__in'] = $tag_ids;
[89] Fix | Delete
[90] Fix | Delete
}
[91] Fix | Delete
}
[92] Fix | Delete
// Related Posts Based on Past few Days #2132
[93] Fix | Delete
if ( isset($redux_builder_amp['ampforwp-related-posts-days-switch']) && true == $redux_builder_amp['ampforwp-related-posts-days-switch'] ) {
[94] Fix | Delete
$date_range = strtotime ( '-' . $redux_builder_amp['ampforwp-related-posts-days-text'] .' day' );
[95] Fix | Delete
$args['date_query'] = array(
[96] Fix | Delete
array(
[97] Fix | Delete
'after' => array(
[98] Fix | Delete
'year' => date('Y', $date_range ),
[99] Fix | Delete
'month' => date('m', $date_range ),
[100] Fix | Delete
'day' => date('d', $date_range ),
[101] Fix | Delete
),
[102] Fix | Delete
)
[103] Fix | Delete
);
[104] Fix | Delete
}
[105] Fix | Delete
$args = apply_filters('ampforwp_component_related_post_args' , $args );
[106] Fix | Delete
$my_query = new wp_query( $args );
[107] Fix | Delete
[108] Fix | Delete
return $my_query;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
function ampforwp_related_post(){
[112] Fix | Delete
global $redux_builder_amp;
[113] Fix | Delete
do_action('ampforwp_above_related_post'); //Above Related Posts
[114] Fix | Delete
?>
[115] Fix | Delete
<h3 class="amp-related-posts-title"><?php
[116] Fix | Delete
if (function_exists('pll__')) {
[117] Fix | Delete
echo pll__(esc_html__( ampforwp_get_setting('amp-translator-related-text'), 'accelerated-mobile-pages'));
[118] Fix | Delete
}else {
[119] Fix | Delete
echo esc_html(ampforwp_translation(ampforwp_get_setting('amp-translator-related-text'), 'Related Post' ));
[120] Fix | Delete
}?></h3>
[121] Fix | Delete
<?php }
[122] Fix | Delete
[123] Fix | Delete
function ampforwp_get_relatedpost_image( $imagetype ='thumbnail', $data=array() ){
[124] Fix | Delete
global $redux_builder_amp;
[125] Fix | Delete
$related_post_permalink = ampforwp_url_controller( get_permalink() );
[126] Fix | Delete
if ( ampforwp_get_setting('ampforwp-single-related-posts-link') ) {
[127] Fix | Delete
$related_post_permalink = get_permalink();
[128] Fix | Delete
}
[129] Fix | Delete
$show_image = (isset($data['show_image']) ? $data['show_image'] : true);
[130] Fix | Delete
$related_post_permalink = ampforwp_modify_url_utm_params($related_post_permalink);
[131] Fix | Delete
?>
[132] Fix | Delete
<a href="<?php echo esc_url( $related_post_permalink ); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
[133] Fix | Delete
<?php
[134] Fix | Delete
if (ampforwp_has_post_thumbnail() ) {
[135] Fix | Delete
$thumb_url = ampforwp_get_post_thumbnail('url', $imagetype);
[136] Fix | Delete
$thumb_width = ampforwp_get_post_thumbnail('width', $imagetype);
[137] Fix | Delete
$thumb_height = ampforwp_get_post_thumbnail('height', $imagetype);
[138] Fix | Delete
$thumb_alt = '';
[139] Fix | Delete
if(isset($data['image_crop']) && $data['image_crop'] != ""){
[140] Fix | Delete
$width = $data['image_crop_width'];
[141] Fix | Delete
if(empty($width)){
[142] Fix | Delete
$width = $thumb_width;
[143] Fix | Delete
}
[144] Fix | Delete
$height = $data['image_crop_height'];
[145] Fix | Delete
if(empty($height)){
[146] Fix | Delete
$height = $thumb_height;
[147] Fix | Delete
}
[148] Fix | Delete
if ( isset($redux_builder_amp['ampforwp-retina-images']) && true == $redux_builder_amp['ampforwp-retina-images'] ) {
[149] Fix | Delete
$resolution = 2;
[150] Fix | Delete
if ( isset($redux_builder_amp['ampforwp-retina-images-res']) && $redux_builder_amp['ampforwp-retina-images-res'] ) {
[151] Fix | Delete
$resolution = $redux_builder_amp['ampforwp-retina-images-res'];
[152] Fix | Delete
}
[153] Fix | Delete
$width = $width * $resolution;
[154] Fix | Delete
$height = $height * $resolution;
[155] Fix | Delete
}
[156] Fix | Delete
$image_dimensions = array();
[157] Fix | Delete
$image_dimensions['width'] = $width;
[158] Fix | Delete
$image_dimensions['height'] = $height;
[159] Fix | Delete
$image_dimensions = apply_filters('ampforwp_related_post_image_size', $image_dimensions);
[160] Fix | Delete
$width = $image_dimensions['width'];
[161] Fix | Delete
$height = $image_dimensions['height'];
[162] Fix | Delete
$thumb_url_array = ampforwp_aq_resize( $thumb_url, $width, $height, true, false, true ); //resize & crop the image
[163] Fix | Delete
$thumb_url = $thumb_url_array[0];
[164] Fix | Delete
$thumb_width = $thumb_url_array[1];
[165] Fix | Delete
$thumb_height = $thumb_url_array[2];
[166] Fix | Delete
$thumb_alt = get_post_meta ( get_post_thumbnail_id(), '_wp_attachment_image_alt', true );
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
if ( $thumb_url && $show_image ) {
[170] Fix | Delete
$img_content = '<amp-img src="'.esc_url( $thumb_url ).'" alt="'.esc_attr($thumb_alt).'" width="'.esc_attr($thumb_width).'" height="'.esc_attr($thumb_height).'" layout="responsive"></amp-img>';
[171] Fix | Delete
if(function_exists('ampforwp_add_fallback_element')){
[172] Fix | Delete
$img_content = ampforwp_add_fallback_element($img_content,'amp-img');
[173] Fix | Delete
}
[174] Fix | Delete
echo $img_content;
[175] Fix | Delete
}
[176] Fix | Delete
} ?>
[177] Fix | Delete
</a>
[178] Fix | Delete
<?php
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
function ampforwp_get_relatedpost_content($argsdata=array()){
[182] Fix | Delete
global $redux_builder_amp;
[183] Fix | Delete
$title = get_the_title();
[184] Fix | Delete
$related_post_permalink = ampforwp_url_controller( get_permalink() );
[185] Fix | Delete
$related_post_permalink = ampforwp_modify_url_utm_params($related_post_permalink);
[186] Fix | Delete
if ( ampforwp_get_setting('ampforwp-single-related-posts-link') ) {
[187] Fix | Delete
$related_post_permalink = get_permalink();
[188] Fix | Delete
if ( ampforwp_get_setting('amp-mobile-redirection') ) {
[189] Fix | Delete
$related_post_permalink = add_query_arg('nonamp','1',$related_post_permalink);
[190] Fix | Delete
}
[191] Fix | Delete
}
[192] Fix | Delete
?>
[193] Fix | Delete
<div class="related_link">
[194] Fix | Delete
<a href="<?php echo esc_url( $related_post_permalink ); ?>" title="<?php echo esc_html( $title ); ?>"><?php the_title(); ?></a>
[195] Fix | Delete
<?php
[196] Fix | Delete
$show_excerpt = (isset($argsdata['show_excerpt'])? $argsdata['show_excerpt'] : true);
[197] Fix | Delete
if($show_excerpt){
[198] Fix | Delete
if(has_excerpt()){
[199] Fix | Delete
$content = get_the_excerpt();
[200] Fix | Delete
}else{
[201] Fix | Delete
$content = get_the_content();
[202] Fix | Delete
}
[203] Fix | Delete
?><p><?php $excerpt_length = ampforwp_get_setting('enable-excerpt-single-related-posts');
[204] Fix | Delete
if(empty($excerpt_length)){
[205] Fix | Delete
$excerpt_length = 15;
[206] Fix | Delete
}
[207] Fix | Delete
if (true == ampforwp_get_setting('excerpt-option-rp-read-more')){
[208] Fix | Delete
$content .= '...';
[209] Fix | Delete
}
[210] Fix | Delete
echo wp_trim_words( strip_shortcodes( $content ) , $excerpt_length );
[211] Fix | Delete
?>
[212] Fix | Delete
<?php if (true == ampforwp_get_setting('excerpt-option-rp-read-more')){?>
[213] Fix | Delete
<a class="readmore-rp" href="<?php echo esc_url( $related_post_permalink ); ?>"><?php echo ampforwp_translation(ampforwp_get_setting('amp-translator-read-more'),'Read More') ?></a></p>
[214] Fix | Delete
<?php
[215] Fix | Delete
} }
[216] Fix | Delete
$show_author = (isset($argsdata['show_author'])? $argsdata['show_author'] : true);
[217] Fix | Delete
if($show_author){
[218] Fix | Delete
$author_args = isset($argsdata['author_args'])? $argsdata['author_args'] : array();
[219] Fix | Delete
ampforwp_framework_get_author_box($author_args);
[220] Fix | Delete
} ?>
[221] Fix | Delete
</div>
[222] Fix | Delete
<?php }
[223] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function