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/clone/wp-conte.../plugins/accelera.../base_rem...
File: base_remover.php
<?php
[0] Fix | Delete
// Exit if accessed directly
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[2] Fix | Delete
exit;
[3] Fix | Delete
}
[4] Fix | Delete
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
[5] Fix | Delete
[6] Fix | Delete
// check for plugin using plugin name
[7] Fix | Delete
$old_plugin = AMPFORWP_MAIN_PLUGIN_DIR.'amp-category-base-remover/amp-category-base-remover.php';
[8] Fix | Delete
if ( is_plugin_active( $old_plugin ) ) {
[9] Fix | Delete
//plugin is activated
[10] Fix | Delete
deactivate_plugins($old_plugin);
[11] Fix | Delete
add_action( 'admin_notices', 'ampforwp_catagory_base_removal_admin_notice' );
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
function ampforwp_catagory_base_removal_admin_notice(){
[15] Fix | Delete
?>
[16] Fix | Delete
<div class="notice notice-success is-dismissible">
[17] Fix | Delete
<p><?php sprintf( __( 'AMP Category Base URL Remover plugin has De-activated, <br> Category removal option is added in our core plugin <a href=%s>Click here to view details</a>', 'accelerated-mobile-pages' ), "#" ); ?></p>
[18] Fix | Delete
</div>
[19] Fix | Delete
<?php
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
add_filter( 'init', 'ampforwp_url_base_rewrite_rules', 100 );
[23] Fix | Delete
function ampforwp_url_base_rewrite_rules(){
[24] Fix | Delete
global $redux_builder_amp;
[25] Fix | Delete
global $wp_rewrite;
[26] Fix | Delete
$categoryBaseRewrite = 0;
[27] Fix | Delete
$tagBaseRewrite = 0;
[28] Fix | Delete
[29] Fix | Delete
if( isset($redux_builder_amp['ampforwp-category-base-removel-link']) ) {
[30] Fix | Delete
$categoryBaseRewrite = $redux_builder_amp['ampforwp-category-base-removel-link'];
[31] Fix | Delete
}
[32] Fix | Delete
if( isset($redux_builder_amp['ampforwp-tag-base-removal-link']) ) {
[33] Fix | Delete
$tagBaseRewrite = $redux_builder_amp['ampforwp-tag-base-removal-link'];
[34] Fix | Delete
}
[35] Fix | Delete
if($categoryBaseRewrite === '1'){
[36] Fix | Delete
add_action( 'created_category', 'amp_flush_rewrite_rules', 999 );
[37] Fix | Delete
add_action( 'edited_category', 'amp_flush_rewrite_rules', 999 );
[38] Fix | Delete
add_action( 'delete_category', 'amp_flush_rewrite_rules', 999 );
[39] Fix | Delete
add_filter( 'category_rewrite_rules', 'ampforwp_category_url_rewrite_rules');
[40] Fix | Delete
}elseif($categoryBaseRewrite === '0'){
[41] Fix | Delete
remove_action( 'created_category', 'amp_flush_rewrite_rules' , 999 );
[42] Fix | Delete
remove_action( 'edited_category', 'amp_flush_rewrite_rules' , 999 );
[43] Fix | Delete
remove_action( 'delete_category', 'amp_flush_rewrite_rules' , 999 );
[44] Fix | Delete
remove_filter( 'category_rewrite_rules', 'ampforwp_category_url_rewrite_rules');
[45] Fix | Delete
[46] Fix | Delete
}
[47] Fix | Delete
if( $tagBaseRewrite === '1'){
[48] Fix | Delete
add_action( 'created_post_tag', 'amp_flush_rewrite_rules' , 999 );
[49] Fix | Delete
add_action( 'edited_post_tag', 'amp_flush_rewrite_rules', 999 );
[50] Fix | Delete
add_action( 'delete_post_tag', 'amp_flush_rewrite_rules', 999 );
[51] Fix | Delete
add_filter( 'post_tag_rewrite_rules', 'ampforwp_tag_url_rewrite_rules' );
[52] Fix | Delete
if(class_exists('kallookoo\wp_no_base_permalink\Plugin')){
[53] Fix | Delete
$options = get_option( 'wp_no_base_permalink' );
[54] Fix | Delete
if(isset($options['disabled-tag-base']) && $options['disabled-tag-base'] == 1){
[55] Fix | Delete
add_filter( 'tag_rewrite_rules', 'ampforwp_tag_url_rewrite_rules' );
[56] Fix | Delete
}
[57] Fix | Delete
}
[58] Fix | Delete
}elseif( $tagBaseRewrite === '0' ) {
[59] Fix | Delete
remove_action( 'created_post_tag', 'amp_flush_rewrite_rules' , 999 );
[60] Fix | Delete
remove_action( 'edited_post_tag', 'amp_flush_rewrite_rules', 999 );
[61] Fix | Delete
remove_action( 'delete_post_tag', 'amp_flush_rewrite_rules', 999 );
[62] Fix | Delete
remove_filter( 'post_tag_rewrite_rules', 'ampforwp_tag_url_rewrite_rules' );
[63] Fix | Delete
remove_filter( 'tag_rewrite_rules', 'ampforwp_tag_url_rewrite_rules' );
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
[68] Fix | Delete
[69] Fix | Delete
[70] Fix | Delete
function amp_flush_rewrite_rules( $hard=true ) {
[71] Fix | Delete
global $wp_rewrite;
[72] Fix | Delete
$wp_rewrite->flush_rules( $hard );
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
function ampforwp_category_url_rewrite_rules( $rewrite ) {
[76] Fix | Delete
global $redux_builder_amp, $wp_rewrite;
[77] Fix | Delete
$categoryBaseRewrite = $redux_builder_amp['ampforwp-category-base-removel-link'];
[78] Fix | Delete
$categories = get_categories( array( 'hide_empty' => false ) );
[79] Fix | Delete
if(is_array( $categories ) && ! empty( $categories ) ) {
[80] Fix | Delete
[81] Fix | Delete
[82] Fix | Delete
foreach ( $categories as $category ) {
[83] Fix | Delete
$category_nicename = $category->slug;
[84] Fix | Delete
if ( $category->parent === $category->cat_ID ) {
[85] Fix | Delete
$category->parent = 0;
[86] Fix | Delete
} elseif ( 0 !== $category->parent ) {
[87] Fix | Delete
$category_nicename = get_category_parents( $category->parent, false, '/', true ) . $category_nicename;
[88] Fix | Delete
}
[89] Fix | Delete
$category_nicename = trim($category_nicename);
[90] Fix | Delete
[91] Fix | Delete
$rewrite[ '('.$category_nicename.')'.'/amp/?$' ] = 'index.php?amp&category_name=$matches[1]';
[92] Fix | Delete
$rewrite[ '('.$category_nicename.')'.'/amp/' . $wp_rewrite->pagination_base . '/?([0-9]{1,})/?$' ] = 'index.php?amp&category_name=$matches[1]&paged=$matches[2]';
[93] Fix | Delete
[94] Fix | Delete
// Redirect support from Old Category Base
[95] Fix | Delete
$old_category_base = get_option( 'category_base' ) ? get_option( 'category_base' ) : 'category';
[96] Fix | Delete
$old_category_base = trim( $old_category_base, '/' );
[97] Fix | Delete
$rewrite[ $old_category_base . '/(.*)$' ] = 'index.php?category_redirect=$matches[1]';
[98] Fix | Delete
[99] Fix | Delete
}
[100] Fix | Delete
}
[101] Fix | Delete
return $rewrite;
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
[105] Fix | Delete
function ampforwp_tag_url_rewrite_rules( $rewrite ) {
[106] Fix | Delete
$tags = get_terms('post_tag', array('hide_empty' => false));
[107] Fix | Delete
if(is_array( $tags ) && ! empty( $tags ) ) {
[108] Fix | Delete
foreach ( $tags as $tag ) {
[109] Fix | Delete
$tag_nicename = trim($tag->slug);
[110] Fix | Delete
$rewrite[ '('.$tag_nicename.')'.'/amp/?$' ] = 'index.php?amp&tag=$matches[1]';
[111] Fix | Delete
$rewrite[ '('.$tag_nicename.')'.'/amp/page/?([0-9]{1,})/?$' ] = 'index.php?amp&tag=$matches[1]&paged=$matches[2]';
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
return $rewrite;
[116] Fix | Delete
}
[117] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function