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.../post-pag...
File: post-pagination.php
<?php
[0] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[1] Fix | Delete
exit;
[2] Fix | Delete
}
[3] Fix | Delete
function ampforwp_framework_get_post_pagination( $args = '' ) {
[4] Fix | Delete
[5] Fix | Delete
wp_reset_postdata();
[6] Fix | Delete
global $page, $numpages, $multipage, $more, $redux_builder_amp;
[7] Fix | Delete
$next_class = $previous_class = '';
[8] Fix | Delete
$defaults = array(
[9] Fix | Delete
'before' => '<p>' . ( '<span>'. ampforwp_translation($redux_builder_amp['amp-translator-page-text'], 'Page') .':</span>' ),
[10] Fix | Delete
'after' => '</p>',
[11] Fix | Delete
'link_before' => '',
[12] Fix | Delete
'link_after' => '',
[13] Fix | Delete
'next_or_number' => 'number',
[14] Fix | Delete
'separator' => ' ',
[15] Fix | Delete
'nextpagelink' => ampforwp_translation($redux_builder_amp['amp-translator-next-text'], 'Next page'),
[16] Fix | Delete
'previouspagelink' => ampforwp_translation($redux_builder_amp['amp-translator-previous-text'], 'Previous page'),
[17] Fix | Delete
'pagelink' => '%',
[18] Fix | Delete
'echo' => 1
[19] Fix | Delete
);
[20] Fix | Delete
[21] Fix | Delete
$params = wp_parse_args( $args, $defaults );
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Filters the arguments used in retrieving page links for paginated posts.
[25] Fix | Delete
* @param array $params An array of arguments for page links for paginated posts.
[26] Fix | Delete
*/
[27] Fix | Delete
$r = apply_filters( 'ampforwp_framework_get_post_pagination_args', $params );
[28] Fix | Delete
if ( isset($params['next_class']) ) {
[29] Fix | Delete
$next_class = $params['next_class'];
[30] Fix | Delete
}
[31] Fix | Delete
if ( isset($params['previous_class']) ) {
[32] Fix | Delete
$previous_class = $params['previous_class'];
[33] Fix | Delete
}
[34] Fix | Delete
$output = '';
[35] Fix | Delete
if ( $multipage ) {
[36] Fix | Delete
if ( 'number' == $r['next_or_number'] ) {
[37] Fix | Delete
$output .= $r['before'];
[38] Fix | Delete
for ( $i = 1; $i <= $numpages; $i++ ) {
[39] Fix | Delete
$link = $r['link_before'] . str_replace( '%', '<span>'.$i.'</span>', $r['pagelink'] ) . $r['link_after'];
[40] Fix | Delete
if ( $i != $page || ! $more && 1 == $page ) {
[41] Fix | Delete
$link = ampforwp_framework_get_post_paginated_link( $i ) . $link . '</a>';
[42] Fix | Delete
}
[43] Fix | Delete
/**
[44] Fix | Delete
* Filters the HTML output of individual page number links.
[45] Fix | Delete
* @param string $link The page number HTML output.
[46] Fix | Delete
* @param int $i Page number for paginated posts' page links.
[47] Fix | Delete
*/
[48] Fix | Delete
$link = apply_filters( 'ampforwp_framework_get_post_pagination_link', $link, $i );
[49] Fix | Delete
[50] Fix | Delete
// Use the custom links separator beginning with the second link.
[51] Fix | Delete
$output .= ( 1 === $i ) ? ' ' : $r['separator'];
[52] Fix | Delete
$output .= $link;
[53] Fix | Delete
}
[54] Fix | Delete
$output .= $r['after'];
[55] Fix | Delete
} elseif ( $more ) {
[56] Fix | Delete
$output .= $r['before'];
[57] Fix | Delete
$prev = $page - 1;
[58] Fix | Delete
if ( $prev > 0 ) {
[59] Fix | Delete
$link = ampforwp_framework_get_post_paginated_link( $prev, $previous_class ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
[60] Fix | Delete
$output .= apply_filters( 'ampforwp_framework_get_post_pagination_link', $link, $prev );
[61] Fix | Delete
}
[62] Fix | Delete
$next = $page + 1;
[63] Fix | Delete
if ( $next <= $numpages ) {
[64] Fix | Delete
if ( $prev ) {
[65] Fix | Delete
$output .= $r['separator'];
[66] Fix | Delete
}
[67] Fix | Delete
$link = ampforwp_framework_get_post_paginated_link( $next, $next_class ) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
[68] Fix | Delete
$output .= apply_filters( 'ampforwp_framework_get_post_pagination_link', $link, $next );
[69] Fix | Delete
}
[70] Fix | Delete
$output .= $r['after'];
[71] Fix | Delete
}
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Filters the HTML output of page links for paginated posts.
[76] Fix | Delete
* @param string $output HTML output of paginated posts' page links.
[77] Fix | Delete
* @param array $args An array of arguments.
[78] Fix | Delete
*/
[79] Fix | Delete
$html = apply_filters( 'ampforwp_framework_get_post_pagination', $output, $args );
[80] Fix | Delete
if ( $r['echo'] ) {
[81] Fix | Delete
echo ($html);
[82] Fix | Delete
}
[83] Fix | Delete
return $html;
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* Helper function for ampforwp_framework_get_post_pagination().
[88] Fix | Delete
* @access private
[89] Fix | Delete
*
[90] Fix | Delete
* @global WP_Rewrite $wp_rewrite
[91] Fix | Delete
*
[92] Fix | Delete
* @param int $i Page number.
[93] Fix | Delete
* @return string Link.
[94] Fix | Delete
*/
[95] Fix | Delete
function ampforwp_framework_get_post_paginated_link( $i, $args = '' ) {
[96] Fix | Delete
global $wp_rewrite;
[97] Fix | Delete
$post = get_post();
[98] Fix | Delete
$query_args = array();
[99] Fix | Delete
if ( isset($args) ) {
[100] Fix | Delete
$class = "class='".esc_attr($args)."'";
[101] Fix | Delete
}
[102] Fix | Delete
if ( 1 == $i ) {
[103] Fix | Delete
$url = get_permalink();
[104] Fix | Delete
} else {
[105] Fix | Delete
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
[106] Fix | Delete
$url = add_query_arg( 'page', $i, get_permalink() );
[107] Fix | Delete
elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
[108] Fix | Delete
$url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
[109] Fix | Delete
else
[110] Fix | Delete
$url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
if ( is_preview() ) {
[114] Fix | Delete
[115] Fix | Delete
if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
[116] Fix | Delete
$query_args['preview_id'] = wp_unslash( $_GET['preview_id'] );
[117] Fix | Delete
$query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
$url = get_preview_post_link( $post, $query_args, $url );
[121] Fix | Delete
}
[122] Fix | Delete
return '<a href="' . esc_url(trailingslashit( $url) ) . '?amp" ' . $class . '>';
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
add_filter('ampforwp_modify_rel_canonical','amp_paginated_post_modify_amphtml');
[126] Fix | Delete
function amp_paginated_post_modify_amphtml($url) {
[127] Fix | Delete
$mob_pres_link = false;
[128] Fix | Delete
if(function_exists('ampforwp_mobile_redirect_preseve_link')){
[129] Fix | Delete
$mob_pres_link = ampforwp_mobile_redirect_preseve_link();
[130] Fix | Delete
}
[131] Fix | Delete
if( is_single() && (false == ampforwp_get_setting('ampforwp-amp-takeover') && $mob_pres_link == false )){
[132] Fix | Delete
$post_paginated_page='';
[133] Fix | Delete
$post_paginated_page = get_query_var('page');
[134] Fix | Delete
if($post_paginated_page){
[135] Fix | Delete
$url = get_permalink();
[136] Fix | Delete
$new_url = $url."$post_paginated_page/?amp";
[137] Fix | Delete
return esc_url($new_url);
[138] Fix | Delete
}
[139] Fix | Delete
}
[140] Fix | Delete
return $url;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
//add_action('amp_post_template_head','amp_paginated_post_modify_canonical',9);
[144] Fix | Delete
function amp_paginated_post_modify_canonical(){
[145] Fix | Delete
if(is_single()){
[146] Fix | Delete
$post_paginated_page='';
[147] Fix | Delete
$post_paginated_page = get_query_var('page');
[148] Fix | Delete
if($post_paginated_page){
[149] Fix | Delete
remove_action( 'amp_post_template_head', 'AMPforWP\\AMPVendor\\amp_post_template_add_canonical' );
[150] Fix | Delete
add_action('amp_post_template_head','amp_paginated_post_rel_canonical');
[151] Fix | Delete
}
[152] Fix | Delete
}
[153] Fix | Delete
}
[154] Fix | Delete
function amp_paginated_post_rel_canonical(){
[155] Fix | Delete
$post_paginated_page='';
[156] Fix | Delete
$new_canonical_url = '';
[157] Fix | Delete
global $post;
[158] Fix | Delete
$current_post_id = $post->ID;
[159] Fix | Delete
$new_canonical_url = get_permalink($current_post_id);
[160] Fix | Delete
$new_canonical_url = trailingslashit($new_canonical_url);
[161] Fix | Delete
$post_paginated_page = get_query_var('page');
[162] Fix | Delete
if($post_paginated_page){?>
[163] Fix | Delete
<link rel="canonical" href="<?php echo esc_url($new_canonical_url.$post_paginated_page) ?>/" /><?php }
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function