• Resolved lgokul

    (@lgokul)


    Hello dear Jose.
    Since the last updates I have noticed that the plugin does not work on woocomerce product variations.

    I went back to previous versions after updating but the plugin still doesn’t work. It just isn’t working on products that have variations.

    In the rest of singular pages if it works like wordpress pages.

    I appreciate your help. Any update on the subject or discovery I will put it here.
    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Jose

    (@giuse)

    Hi dear @lgokul

    I’ve right now tested it with products with variations and it works without problems on my installation, both using the Singles settings and the Post Types settings.

    So, let’s understand what’s the difference with your site.

    Do you have any other plugins that do something on that kind of product? Especially if they change the URL rewrite rules.

    Are you sure you have no problems with the cache?

    If you go to Freesoul Deactivate Plugins => Singles => Products and click on the question mark icon (the third icon, that one next to the eye when you go over with your mouse on the row of a product), what does the popup say?

    Is it possible to share the URL of a product with variations where you should have some plugins disabled?

    Thread Starter lgokul

    (@lgokul)

    Hello dear Jose.

    I found the problem estimated Jose apparently is a problem of permalinks

    Change the eos-deactivate-plugins.php file to version 1.8.0 and it works.

    Upgrade to version 1.8.2 and the problem happened again.

    Compare both files and from a deep analysis I found the error in these lines.

    lines with error:

    $permalink_structure = eos_dp_get_option( 'permalink_structure' );
    		$permalink_structure_base = basename( $permalink_structure );
    		if( !$from_url && false !== strpos( $permalink_structure_base,'%postname%' ) ){
    			$uriArr = explode( '?',$uri );
    			$uri = $clean_uri = $uriArr[0];
    			if( !isset( $_GET['page_id'] ) && !isset( $_GET['p'] ) ){
    				$home_uri = str_replace( 'https://','',str_replace( 'http://','',home_url( '/' ) ) );		
    				if( $uri !== $home_uri ){
    					$arr = array_filter( explode( '/',$uri ) );
    					$after_home_uri = str_replace( $home_uri,'',implode( '/',$arr ) );
    					$after_home_uriArr = explode( '?',$after_home_uri );
    					$after_home_uri = $after_home_uriArr[0];
    					$after_home_uriArr = explode( '#',$after_home_uri );
    					$after_home_uri = untrailingslashit( $after_home_uriArr[0] );
    					$after_postnameArr = explode( '%',$permalink_structure_base );
    					$last_index = count( $after_postnameArr );
    					if( !empty( $after_postnameArr ) && $last_index > 0 && isset( $after_postnameArr[$last_index - 1] ) ){
    						$after_home_uri = str_replace( $after_postnameArr[$last_index - 1],'',$after_home_uri );
    					}
    					$p = false;
    					$post_types_query = $post_types;
    					if( '' !== $after_home_uri ){
    						if( false !== strpos( $after_home_uri,'/' ) ){
    							//the URL looks like https://example-dommain.com/level1/level2/ or https://example-dommain.com/level1/level2/level3/...
    							//Maybe child page or post or custom post
    							if( str_replace( '\\','',str_replace( '/','',dirname( $permalink_structure ) ) ) === dirname( $after_home_uri ) && '' !== dirname( $after_home_uri ) ){
    								//The URL looks like https://example-dommain.com/blog/level2/ with a permalink structure that looks like /blog/%postname%/
    								//Blog post
    								$p = get_page_by_path( basename( $after_home_uri ),'OBJECT',array( 'post' ) );
    								if( is_object( $p ) ){
    									$eos_page_id =  $p->ID;
    								}
    							}
    							else{
    								//the URL looks like https://example-dommain.com/level1/level2/ or https://example-dommain.com/level1/level2/level3/...
    								//but level1 is not included in the permalink structure
    								//Maybe child page or custom post
    								if( in_array( 'post',array_values( $post_types_query ) ) ){
    									unset( $post_types_query[array_search( 'post',$post_types_query )] );
    								}
    								//First we try with child page or child post
    								$p = get_page_by_path( $after_home_uri,'OBJECT',$post_types_query );
    								if( is_object( $p ) && isset( $p->post_type ) && 'page' === $p->post_type && isset( $p->post_parent ) && absint( $p->post_parent ) > 0 ){
    									//It's a child page or a child post
    									$eos_page_id =  $p->ID;
    									// $info[] = sprintf( 'Plugins disabled according to Singles Settings. ID: %s. Post type: %s',$p->ID,$p->post_type );
    								}
    								else{
    									//Maybe custom post
    									if( in_array( 'page',array_values( $post_types_query ) ) ){
    										unset( $post_types_query[array_search( 'page',$post_types_query )] );
    									}									
    									$p = get_page_by_path( basename( $after_home_uri ),'OBJECT',$post_types_query );
    									if( is_object( $p ) && isset( $p->post_type ) ){
    										$first_id = $p->ID;
    										//We have retrieved a custom post type, we still need to check if different custom post types have the same slug
    										unset( $post_types_query[array_search( $p->post_type,$post_types_query )] );
    										$second_p = get_page_by_path( basename( $after_home_uri ),'OBJECT',$post_types_query );
    										if( !is_object( $second_p ) ){
    											//Only a customm post type is retrieved
    											$eos_page_id =  $p->ID;
    											$info[] = sprintf( 'Evaluated Singles Settings. ID: %s. Post type: %s',$p->ID,$p->post_type );
    										}
    										else{
    											//More than a custom post type has the same slug, and we still don't know wich one is the right one
    											$error[] = sprintf( 'No plugin was disabled because more than a custom post type have the same slug. IDs: %s (%s), %s (%s)',$first_id,$p->post_type,$second_p->ID,$second_p->post_type );
    											$eos_dp_debug['error'] = $error;
    										}									
    									}
    								}	
    							}
    						}
    						else{
    							//The URL looks like https://example-domain.com/page-example/
    							$first_id = $second_id = false;
    							//It's a blog post or a page
    							$p = get_page_by_path( $after_home_uri,'OBJECT',array( 'post','page' ) );
    							if( is_object( $p ) && isset( $p->post_type ) ){
    								$first_id = $p->ID;
    								$first_post_type = $p->post_type;
    								//We still need to check if both a page and a post have the same slug
    								unset( $post_types_query[array_search( $p->post_type,$post_types_query )] );
    								$second_p = get_page_by_path( $after_home_uri,'OBJECT',$post_types_query );
    								if( !is_object( $second_p ) ){
    										$eos_page_id =  $p->ID;
    										$info[] = sprintf( 'Evaluated Singles Settings. ID %s',$p->ID );
    								}
    								else{
    									$second_id = $second_p->ID;
    									$second_post_type = $second_p->post_type;
    									$double_solved = false;
    									if( $first_id && $second_id ){
    										$doublesIDs = array( $first_post_type => $first_id,$second_post_type => $second_id );
    										$doublesObj = array( $first_post_type => $p,$second_post_type => $second_p );
    										if( isset( $doublesIDs['post'] ) && isset( $doublesObj['post'] ) ){
    											//A blog post and a page have the same slug
    											$double_solved = false;
    										}
    									}
    									if( !$double_solved ){
    										//A page and a post have the same slug. Impossible to decide which one is the right one
    										$ids = $first_id && $second_id ? sprintf( ' IDs: %s (%s), %s (%s)',$first_id,$first_post_type,$second_id,$second_post_type ) : '';
    										$error[] = 'No plugin was disabled because a page and a post have the same slug and it is not possible to know which one is the right one.'.$ids;
    										$eos_dp_debug['error'] = $error;
    									}
    								}
    							}
    						}
    					}
    				}
    				else{

    Replace the lines and I do not get errors in variations.

    if( !$from_url && '%postname%' === basename( eos_dp_get_option( 'permalink_structure' ) ) ){
    			$uriArr = explode( '?',$uri );
    			$uri = $clean_uri = $uriArr[0];
    			if( !isset( $_GET['page_id'] ) && !isset( $_GET['p'] ) ){
    				$home_uri = str_replace( 'https://','',str_replace( 'http://','',home_url( '/' ) ) );		
    				if( $uri !== $home_uri ){
    					$arr = array_filter( explode( '/',$uri ) );
    					$after_home_uri = str_replace( $home_uri,'',implode( '/',$arr ) );
    					$after_home_uriArr = explode( '?',$after_home_uri );
    					$after_home_uri = $after_home_uriArr[0];
    					$after_home_uriArr = explode( '#',$after_home_uri );
    					$after_home_uri = untrailingslashit( $after_home_uriArr[0] );
    					$p = false;
    					$p = $after_home_uri !== '' ? get_page_by_path( $after_home_uri,'OBJECT',$post_types ) : false;
    					$p = $after_home_uri !== '' && !is_object( $p ) ? get_page_by_path( basename( $after_home_uri ),'OBJECT',$post_types ) : $p;
    					if( is_object( $p ) && ( false === strpos( $after_home_uri,'/' ) || ( $p->post_parent || 'page' !== $p->post_type ) ) ){
    						$eos_page_id =  $p->ID;
    					}
    					else{
    						$eos_page_id =  false;
    						global $wpdb;
    						if( is_object( $wpdb ) ){
    							if( isset( $wpdb->last_result ) ){
    								$last_result = $wpdb->last_result;
    								if( isset( $last_result[0] ) && is_object( $last_result[0] ) ){
    									$resObj = $last_result[0];
    									$eos_page_id =  isset( $resObj->ID ) && absint( $resObj->ID ) > 0 ? $resObj->ID : false;
    								}
    							}
    						}
    					}
    				}
    				else{
    Thread Starter lgokul

    (@lgokul)

    I should clarify that I have the modified permalinks in my woocommerce store in some way sure they cause the error.

    This is the file that works for my modified | eos-deactivate-plugins.php

    <?php
    /*
      Plugin Name: freesoul deactivate plugins [fdp]
      Description: mu-plugin automatically installed by freesoul deactivate plugins
      Version: 1.8.8.3
      Plugin URI: https://freesoul-deactivate-plugins.com/
      Author: Jose Mortellaro
      Author URI: https://josemortellaro.com/
      License: GPLv2
    */
    defined( 'ABSPATH' ) || exit; // Exit if accessed directly
    
    define( 'EOS_DP_MU_VERSION','1.8.8.3' );
    define( 'EOS_DP_MU_PLUGIN_DIR',untrailingslashit( dirname( __FILE__ ) ) );
    
    foreach( array( 'activate_plugin','deactivate_plugin','deactivated_plugin','pre_update_option_active_plugins' ) as $action ){
    	//Prevent saving wrong set of active plugins if programmatically activating or deactivating plugins
    	if( did_action( $action ) ) return;
    }
    if( ( defined( 'WP_CLI' ) && WP_CLI ) || ( defined( 'WP_SANDBOX_SCRAPING' ) && true === WP_SANDBOX_SCRAPING ) ) return;
    if( !isset( $_SERVER['HTTP_HOST'] ) || !isset( $_SERVER['REQUEST_URI'] ) ) return;
    if( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'],array( 'eos_dp_save_firing_order' ) ) ) return;
    if( isset( $_REQUEST['action'] ) && isset( $_REQUEST['plugin'] ) && 'deactivate' === $_REQUEST['action'] ) return;
    $GLOBALS['eos_dp_debug'] = array( 'info' => array(),'log' => array(),'error' => array() );
    extract( $eos_dp_debug );
    if(
    	(
    		( !isset( $_REQUEST['s'] ) || ( defined( 'EOS_DP_URL_APPLY_ON_SEARCH' ) && true === EOS_DP_URL_APPLY_ON_SEARCH ) )
    		|| isset( $_GET['eos_dp_preview'] )
    	)
    	&& !defined( 'DOING_AJAX' )
    ){
    	$opts_by_path = false;
    	$eos_dp_disabled_plugins = array();
    	global $eos_dp_disabled_plugins;
    	$post_types_matrix = eos_dp_get_option( 'eos_post_types_plugins' );
    	$post_types = is_array( $post_types_matrix ) ? array_keys( $post_types_matrix ) : array();
    	if( !is_admin() && ( empty( $_POST ) || ( defined( 'EOS_DP_ALLOW_POST' ) && EOS_DP_ALLOW_POST ) ) && is_array( $post_types ) ){
    		$home_page = false;
    		$clean_uri = '';
    		$arr = array();
    		$uri = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    		$from_url = false;
    		$urlsA = eos_dp_get_option( 'eos_dp_by_url' );
    		if( !isset( $_GET['eos_dp_preview'] ) ){
    			if( is_array( $urlsA ) && !empty( is_array( $urlsA ) ) ){
    				foreach( $urlsA as $urlA ){
    					if( isset( $urlA['url'] ) ){
    						foreach( array( 'https://','http://','www.' ) as $search ){
    							$urlA['url'] = str_replace( $search,'',$urlA['url'] );
    						}
    						$pattern = '/'.str_replace( '/','\/',str_replace( '*','(.*)',str_replace( '**','*',$urlA['url'] ) ) ).'\s/';
    						$pattern = '/'.str_replace( '/','\/',str_replace( '*','(.*)',str_replace( '**','*',$urlA['url'] ) ) ).'\s/i';
    						$pattern = str_replace( '?','\?',$pattern );
    						$pattern = str_replace( '&','\&',$pattern );
    						preg_match( $pattern,$uri.' ',$matches );
    						if( !empty( $matches ) && count( $matches ) - 1 === substr_count( $pattern,'(.*)' ) ){
    							$eos_dp_paths = explode( ',',$urlA['plugins'] );
    							$from_url = true;
    							$maybe_singles = isset( $urlA['needs_url'] ) && absint( $urlA['needs_url'] ) > 0 ? ' Ignored URL query arguments because the post ID '.$urlA['needs_url'].' needs a custom URL.' : '';
    							$info[] = sprintf( 'Plugins disabled according to the Custom URLs settings. Matched %s.%s',$urlA['url'],$maybe_singles );
    							break;
    						}
    					}
    				}
    			}
    		}
    		$permalink_structure = eos_dp_get_option( 'permalink_structure' );
    		$permalink_structure_base = basename( $permalink_structure );
    		if( !$from_url && false !== strpos( $permalink_structure_base,'%postname%' ) ){
    			$uriArr = explode( '?',$uri );
    			$uri = $clean_uri = $uriArr[0];
    			if( !isset( $_GET['page_id'] ) && !isset( $_GET['p'] ) ){
    				$home_uri = str_replace( 'https://','',str_replace( 'http://','',home_url( '/' ) ) );
    				if( $uri !== $home_uri ){
    					$arr = array_filter( explode( '/',$uri ) );
    					$after_home_uri = str_replace( $home_uri,'',implode( '/',$arr ) );
    					$after_home_uriArr = explode( '?',$after_home_uri );
    					$after_home_uri = $after_home_uriArr[0];
    					$after_home_uriArr = explode( '#',$after_home_uri );
    					$after_home_uri = untrailingslashit( $after_home_uriArr[0] );
    					$p = false;
    					$p = $after_home_uri !== '' ? get_page_by_path( $after_home_uri,'OBJECT',$post_types ) : false;
    					$p = $after_home_uri !== '' && !is_object( $p ) ? get_page_by_path( basename( $after_home_uri ),'OBJECT',$post_types ) : $p;
    					if( is_object( $p ) && ( false === strpos( $after_home_uri,'/' ) || ( $p->post_parent || 'page' !== $p->post_type ) ) ){
    						$eos_page_id =  $p->ID;
    					}
    					else{
    						$eos_page_id =  false;
    						global $wpdb;
    						if( is_object( $wpdb ) ){
    							if( isset( $wpdb->last_result ) ){
    								$last_result = $wpdb->last_result;
    								if( isset( $last_result[0] ) && is_object( $last_result[0] ) ){
    									$resObj = $last_result[0];
    									$eos_page_id =  isset( $resObj->ID ) && absint( $resObj->ID ) > 0 ? $resObj->ID : false;
    								}
    							}
    						}
    					}
    				}
    				else{
    					//It's the front page
    					$eos_page_id = eos_dp_get_option( 'page_on_front' );
    					$info[] = sprintf( 'Plugins disabled according to the homepage ID %s.',$eos_page_id );
    					$p = get_page( $eos_page_id );
    					$home_page = true;
    				}
    			}
    			else{
    				$eos_page_id = isset( $_GET['page_id'] ) ? absint( $_GET['page_id'] ) : absint( $_GET['p'] );
    				$p = get_page( $eos_page_id );
    				global $eos_page_id;
    			}
    			$eos_page_id = isset( $eos_page_id ) && absint( $eos_page_id ) !== 0 ? $eos_page_id : false;
    			if( eos_dp_is_mobile() ){
    				$mobile_page_id = absint( get_post_meta( $eos_page_id,'eos_scfm_mobile_post_id',true ) );
    				if( $mobile_page_id > 0 ){
    					$eos_page_id = $mobile_page_id;
    				}
    			}
    			$eos_dp_paths = '';
    			if( $eos_page_id || ( isset( $_REQUEST['fdp_post_id'] ) && isset( $_REQUEST['eos_dp_preview'] ) ) ){
    				if( isset( $_REQUEST['fdp_post_id'] ) && isset( $_REQUEST['eos_dp_preview'] ) ){
    					$eos_page_id = absint( $_REQUEST['fdp_post_id'] );
    					$cron = isset( $_REQUEST['internal_call'] ) && 'true' === $_REQUEST['internal_call'] ? 'cron_' : '';
    					$after_save = isset( $_REQUEST['after_save'] ) && 'true' === $_REQUEST['after_save'] ? 'after_save_' : '';
    					$gtmetrix = isset( $_REQUEST['gtmetrix'] ) && 'true' === $_REQUEST['gtmetrix'] ? 'gtmetrix_' : '';
    					$offset = isset( $_REQUEST['eos_dp_offset'] )? $_REQUEST['eos_dp_offset'] : '';
    					$transient_name = 'fdp_test_'.$after_save.$cron.$gtmetrix.sanitize_key( $_REQUEST['fdp_post_id'].$offset );
    					$eos_dp_paths = explode( ';pn:',esc_attr( get_transient( $transient_name ) ) );
    				}
    				else{
    					if( $opts_by_path ){
    						$post_type = $opts_by_path['post_type'];
    						$post_types_matrix_pt = $post_types_matrix[sanitize_key( $post_type )];
    					}
    					elseif( $post_types_matrix ){
    						$post_type = $p->post_type;
    						$post_types_matrix_pt = is_object( $p ) && isset( $post_types_matrix[$post_type] ) ? $post_types_matrix[$post_type] : 0;
    					}
    					$post_meta = $opts_by_path ? $opts_by_path['plugins'] : get_post_meta( $eos_page_id,'_eos_deactive_plugins_key',true );
    					if( isset( $post_types_matrix_pt ) && isset( $post_types_matrix_pt[0] ) && '0' == $post_types_matrix_pt[0] ){
    						$eos_dp_paths = explode( ',',$post_meta );
    
    					}
    					else{
    						if( ( $opts_by_path || is_object( $p ) ) && $post_types_matrix && isset( $post_types_matrix[$post_type] ) ){
    							if( isset( $post_types_matrix_pt[3] ) ){
    								$ids = $post_types_matrix_pt[3];
    								if( in_array( $eos_page_id,$ids ) ){
    									$eos_dp_paths = explode( ',',$post_meta );
    									$info[] = sprintf( 'Plugins disabled according to Singles Settings. ID: %s.',$eos_page_id );
    								}
    								else{
    									$eos_dp_paths = explode( ',',$post_types_matrix_pt[1] );
    									$info[] = sprintf( 'Plugins disabled according to the Post Types settings. Post type: %s.',$post_type );
    								}
    							}
    							else{
    								$eos_dp_paths = explode( ',',$post_types_matrix_pt[1] );
    								$info[] = sprintf( 'Settings overridden by the Post Types Settings. Post type: %s.',$post_type );
    							}
    						}
    					}
    				}
    				global $eos_page_id,$eos_dp_paths;
    			}
    			else{
    				//It's an archive page
    				if( $opts_by_path && isset( $opts_by_path['post_id'] ) && 'archive' === $opts_by_path['post_id'] ){
    					$eos_dp_paths = explode( ',',esc_attr( $opts_by_path['plugins'] ) );
    					$info[] = sprintf( 'Plugins disabled according to the archive settings, archive: %s',$opts_by_path['post_type'] );
    				}
    				else{
    					$archives = eos_dp_get_option( 'eos_dp_archives' );
    					$clean_uri = str_replace( '/','__',rtrim( $clean_uri,'/' ) );
    					$key = sanitize_key( $clean_uri );
    					if( isset( $_GET['fdp_post_type'] ) && isset( $_GET['eos_dp_preview'] ) ){
    						$eos_dp_paths = explode( ';pn:',esc_attr( get_transient( 'fdp_test_'.sanitize_key( $_GET['fdp_post_type'] ) ) ) );
    					}
    					elseif( isset( $_GET['fdp_tax'] ) && isset( $_GET['eos_dp_preview'] ) ){
    						$eos_dp_paths = explode( ';pn:',esc_attr( get_transient( 'fdp_test_'.sanitize_key( $_GET['fdp_tax'] ) ) ) );
    					}
    					elseif( isset( $archives[$key] ) ){
    						$eos_dp_paths = explode( ',',$archives[$key] );
    						$info[] = 'Plugins disabled according to the archive settings';
    					}
    				}
    
    			}
    			if( !is_array( $eos_dp_paths ) && '' === $eos_dp_paths && isset( $after_home_uri ) ){
    				//Let's check if it's a translated post
    				$eos_page_id = eos_dp_translated_id( $uri,$after_home_uri,$urlsA,$post_types );
    				if( $eos_page_id ){
    					$pt = get_post_type( $eos_page_id );
    					$post_types_matrix_pt = $pt && isset( $post_types_matrix[$pt] ) ? $post_types_matrix[$pt] : 0;
    					if( isset( $post_types_matrix_pt[3] ) ){
    						$ids = $post_types_matrix_pt[3];
    						if( in_array( $eos_page_id,$ids ) ){
    							$post_meta = get_post_meta( $eos_page_id,'_eos_deactive_plugins_key',true );
    							$eos_dp_paths = explode( ',',$post_meta );
    							$info[] = sprintf( 'Plugins disabled according to Singles Settings. ID: %s.',$eos_page_id );
    						}
    						else{
    							$eos_dp_paths = explode( ',',$post_types_matrix_pt[1] );
    							$info[] = sprintf( 'Plugins disabled according to the Post Types settings. Post type: %s.',$pt );
    						}
    					}
    					else{
    						$eos_dp_paths = explode( ',',$post_types_matrix_pt[1] );
    						$info[] = sprintf( 'Settings overridden by the Post Types Settings. Post type: %s.',$pt );
    					}
    					global $eos_page_id;
    				}
    			}
    		}
    		global $eos_dp_paths;
    		if( !defined( 'EOS_DEACTIVE_PLUGINS' ) ) define( 'EOS_DEACTIVE_PLUGINS',true );
    		add_filter( 'option_active_plugins', 'eos_option_active_plugins',0,1 );
    		eos_dp_pro_remove_hooks();
    	}
    	$eos_dp_debug['info'] = $info;
    }
    
    if( is_admin()
    	&& ( !isset( $_GET['page'] ) || 'eos_dp_admin' !== $_GET['page'] || defined( 'FDP_DISABLE_IN_FDP_PAGE' ) )
    	&& isset( $_SERVER['HTTP_HOST'] )
    	&& isset( $_SERVER['REQUEST_URI'] )
    	&& empty( $_POST )
    	&& !defined( 'DOING_AJAX' )
    ){
    	add_action( 'wp_loaded',function(){
    		$GLOBALS['eos_dp_wp_loaded'] = round( microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 );
    	} );
    	add_filter( 'option_active_plugins','eos_dp_admin_option_active_plugins',0,1 );
    	$adminTheme = eos_dp_get_option( 'eos_dp_admin_theme' );
    	$adminThemeUrl = eos_dp_get_option( 'eos_dp_admin_url_theme' );
    	$base_url = basename( $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] );
    	if( isset( $adminTheme[$base_url] ) && !$adminTheme[$base_url] ){
    		add_action( 'plugins_loaded','eos_dp_replace_theme',99 );
    	}
    }
    function eos_dp_admin_option_active_plugins( $plugins ){
    	if( !is_array( $plugins ) ) return $plugins;
    	if( !in_array( 'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php',$plugins )  ){
    		add_action( 'admin_notices','eos_dp_missing_fdp_notice' );
    	}
    	if( isset( $_GET['page'] ) && false !== strpos( $_GET['page'],'eos_dp_' ) ){
    		if( defined( 'FDP_DISABLE_IN_FDP_PAGE' ) ){
    			if( is_string( FDP_DISABLE_IN_FDP_PAGE ) && is_array( $plugins ) && in_array( FDP_DISABLE_IN_FDP_PAGE,$plugins ) ){
    				unset( $plugins[array_search( FDP_DISABLE_IN_FDP_PAGE,$plugins )] );
    			}
    			elseif( is_array( FDP_DISABLE_IN_FDP_PAGE ) ){
    				foreach( FDP_DISABLE_IN_FDP_PAGE as $disable_on_fdp_page ){
    					if( is_string( $disable_on_fdp_page ) && in_array( $disable_on_fdp_page,$plugins ) ){
    						unset( $plugins[array_search( $disable_on_fdp_page,$plugins )] );
    					}
    				}
    			}
    		}
    		return $plugins;
    	}
    	eos_dp_unshift_fdp( $plugins );
    	$all_plugins = $plugins;
    	foreach( $plugins as $p => $const ){
    		$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    		if( !defined( 'EOS_ADMIN_'.$const.'_ACTIVE' ) ) define( 'EOS_ADMIN_'.$const.'_ACTIVE','true' );
    	}
    	if( isset( $_REQUEST['eos_dp_preview'] ) && isset( $_REQUEST['admin_page_key'] ) ){
    		add_action( 'wp_loaded',function(){
    			$GLOBALS['eos_dp_wp_loaded'] = round( microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 );
    		} );
    		$GLOBALS['eos_dp_all_plugins'] = array_filter( $all_plugins );
    		register_shutdown_function( 'eos_dp_display_usage' );
    		if( isset( $_REQUEST['eos_dp_debug'] ) ){
    			if( 'no_error' === $_REQUEST['eos_dp_debug'] ){
    				@ini_set( 'display_error',0 );
    			}
    		}
    		$disabled_plugins = explode( ';pn:',esc_attr( get_transient( 'fdp_test_'.sanitize_key( $_REQUEST['admin_page_key'] ) ) ) );
    		foreach( $disabled_plugins as $path ){
    			$k = array_search( $path, $plugins );
    			if( false !== $k ){
    				$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    				if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE','true' );
    				unset( $plugins[$k] );
    			}
    		}
    		$last = $disabled_plugins[absint( count( $disabled_plugins ) - 1 )];
    		if( 'undefined' === $last ){
    			unset( $disabled_plugins[absint( count( $disabled_plugins ) - 1 )] );
    		}
    		if( isset( $_REQUEST['theme'] ) && 'false' === $_REQUEST['theme'] ){
    			eos_dp_replace_theme();
    		}
    		$GLOBALS['eos_dp_paths'] = array_filter( $disabled_plugins );
    		return $plugins;
    	}
    	$base_url = basename( $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] );
    	$admin_page = false !== strpos( $base_url,'.php' ) ?  admin_url( $base_url ) : admin_url( 'admin.php'.$base_url );
    	$from_admin_url = false;
    	$urlsA = eos_dp_get_option( 'eos_dp_by_admin_url' );
    	$admin_plugins = array();
    	if( is_array( $urlsA ) && !empty( is_array( $urlsA ) ) ){
    		foreach( $urlsA as $urlA ){
    			if( isset( $urlA['url'] ) ){
    				foreach( array( 'https://','http://','www.' ) as $search ){
    					$urlA['url'] = str_replace( $search,'',$urlA['url'] );
    				}
    
    				$pattern = '/'.str_replace( '/','\/',str_replace( '*','(.*)',str_replace( '**','*',$urlA['url'] ) ) ).'\s/i';
    				$pattern = str_replace( '?','\?',$pattern );
    				$pattern = str_replace( '&','\&',$pattern );
    				preg_match( $pattern,$admin_page.' ',$matches );
    				if( !empty( $matches ) && count( $matches ) - 1 === substr_count( $pattern,'(.*)' ) ){
    					$admin_plugins[$admin_page] = $urlA['plugins'];
    					$from_admin_url = true;
    					break;
    				}
    			}
    		}
    	}
    	if( !$from_admin_url ){
    		$admin_plugins = eos_dp_get_option( 'eos_dp_admin_setts' );
    	}
    	if( isset( $_GET['page'] ) || isset( $admin_plugins[$admin_page] ) || isset( $admin_plugins[$base_url] ) ){
    		if( isset( $_GET['page'] ) && isset( $admin_plugins[$_GET['page']] ) ){
    			$key = $admin_plugins[$_GET['page']];
    		}
    		else{
    			if( !isset( $admin_plugins[$admin_page] ) && !isset( $admin_plugins[$base_url] ) ){
    				return $plugins;
    			}
    			$key = isset( $admin_plugins[$admin_page] ) ? $admin_plugins[$admin_page] : $admin_plugins[$base_url];
    		}
    		$disabled_plugins = explode( ',',$key );
    		foreach( $disabled_plugins as $path ){
    			$k = array_search( $path, $plugins );
    			if( false !== $k ){
    				$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    				if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE','true' );
    				unset( $plugins[$k] );
    			}
    		}
    	}
    	$GLOBALS['eos_dp_paths'] = array_diff( $all_plugins,$plugins );
    	add_action( 'admin_footer','eos_dp_print_disabled_plugins',9999 );
    	return $plugins;
    }
    
    //Return active plugins in according with the options
    function eos_option_active_plugins( $plugins ){
    	if( !is_array( $plugins ) || is_admin() || defined( 'DOING_AJAX' ) || isset( $_REQUEST['wc-ajax'] ) || class_exists( 'FS_Plugin_Updater' ) ) return $plugins;
    	eos_dp_unshift_fdp( $plugins );
    	if( isset( $_REQUEST['eos_dp_preview'] ) ){
    		$GLOBALS['eos_dp_all_plugins'] = $plugins;
    		if( isset( $_REQUEST['eos_dp_debug'] ) ){
    			if( 'no_error' === $_REQUEST['eos_dp_debug'] ){
    				@ini_set( 'display_error',0 );
    				@ini_set( 'log_errors',0 );
    			}
    		}
    		add_action( 'plugins_loaded','eos_check_dp_preview_nonce' );
    		if( isset( $_REQUEST['eos_dp_display_error'] ) && 'display_error' === $_REQUEST['eos_dp_display_error'] ){
    			@ini_set( 'display_error',1 );
    		}
    		add_action( 'wp_loaded',function(){
    			$GLOBALS['eos_dp_wp_loaded'] = round( microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 );
    		} );
    		register_shutdown_function( 'eos_dp_display_usage' );
    		$themeA = explode( '&theme=',parse_url( urldecode( basename( $_SERVER['REQUEST_URI'] ) ),PHP_URL_QUERY ) );
    		if( isset( $themeA[1] ) ){
    			$themeA = explode( '&',$themeA[1] );
    			if( '' !== $themeA[0] ){
    				if( 'empty_theme' === $themeA[0] ){
    					eos_dp_replace_theme();
    				}
    				else{
    					if( 'false' !== $themeA[0] ){
    						$GLOBALS['eos_dp_theme'] = $themeA[0];
    						add_filter( 'stylesheet','eos_dp_get_theme' );
    						add_filter( 'template','eos_dp_get_parent_theme' );
    					}
    				}
    			}
    		}
    		if( isset( $_GET['js'] ) && 'off' === $_GET['js'] ){
    			add_action( 'wp_head','eos_dp_disable_javascript',10 );
    		}
    	}
    	else{
    		if( defined( 'EOS_DP_DEBUG' ) && true === EOS_DP_DEBUG || ( isset( $_SERVER['REMOTE_ADDR'] ) && isset( $_GET['show_disabled_plugins'] ) && $_GET['show_disabled_plugins'] === md5( $_SERVER['REMOTE_ADDR'].( absint( time()/1000 ) ) ) ) ){
    			$GLOBALS['eos_dp_user_can_preview'] = true;
    			add_action( 'wp_footer','eos_dp_print_disabled_plugins',9999 );
    		}
    		if( isset( $_REQUEST['eos_dp_debug_options'] ) ){
    			add_action( 'wp_footer','eos_dp_debug_options_wrapper',9999 );
    		}
    	}
    	global $eos_dp_paths;
    	global $eos_dp_disabled_plugins;
    	if( $eos_dp_paths === '' ) return $plugins;
    	$eos_dp_paths = $eos_dp_paths ? $eos_dp_paths : array();
    	$e = 0;
    	foreach( $eos_dp_paths as $path ){
    		$k = array_search( $path, $plugins );
    		if( false !== $k ){
    			$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $path ) ) ) );
    			if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE',true );
    			unset( $plugins[$k] );
    			if( in_array( $path,$plugins ) ){
    				$eos_dp_disabled_plugins[] = $path;
    			}
    		}
    		else{
    			unset( $eos_dp_paths[$e] );
    		}
    		++$e;
    	}
    	add_action( 'wp_footer','eos_dp_comment' );
    	return $plugins;
    }
    
    //Replace theme for preview
    function eos_dp_get_theme( $stylesheet ){
    	if( !isset( $GLOBALS['eos_dp_theme'] ) ) return $stylesheet;
    	return esc_attr( $GLOBALS['eos_dp_theme'] );
    }
    //Return parent theme
    function eos_dp_get_parent_theme( $template ){
    	if( !isset( $GLOBALS['eos_dp_theme'] ) ) return $stylesheet;
    	$themes = wp_get_themes();
    	$child_theme = sanitize_key( $GLOBALS['eos_dp_theme'] );
    	if( !isset( $themes[$child_theme] ) ) return $template;
    	$theme = $themes[$child_theme];
    	if( isset( $theme->template ) ){
    		return $theme->template;
    	}
    	return $template;
    }
    
    //It replaces the theme with an almost empty theme provided by FDP
    function eos_dp_replace_theme(){
    	if( defined( 'EOS_DP_PLUGIN_DIR' ) ){
    		add_filter( 'stylesheet_directory','eos_dp_stylesheet_directory',20,3 );
    		add_filter( 'theme_root','eos_dp_theme_root',20 );
    		add_filter( 'stylesheet','eos_dp_template',20 );
    		add_filter( 'template','eos_dp_template',20 );
    	}
    }
    //Replace theme with ultralight theme given by FDP
    function eos_dp_stylesheet_directory( $stylesheet_dir,$stylesheet,$theme_root ){
    	return EOS_DP_PLUGIN_DIR.'/fdp-theme';
    }
    function eos_dp_theme_root( $theme_root ){
    	return EOS_DP_PLUGIN_DIR;
    }
    function eos_dp_template( $template ){
    	return 'fdp-theme';
    }
    
    //Check preview nonce
    function eos_check_dp_preview_nonce(){
    	if( defined( 'EOS_DP_PRO_TESTING_UNIQUE_ID' ) ){
    		if( isset( $_REQUEST['eos_dp_pro_id' ] ) && md5( EOS_DP_PRO_TESTING_UNIQUE_ID ) === $_REQUEST['eos_dp_pro_id'] ){
    			$GLOBALS['eos_dp_user_can_preview'] = true;
    			return true;
    		}
    	}
    	if( !wp_verify_nonce( $_REQUEST['eos_dp_preview'],'eos_dp_preview' ) ){
    		$nonce = get_transient( 'fdp_psi_nonce_'.sanitize_key( $_REQUEST['fdp_post_id'] ) );
    		if( $nonce ){
    			if( 1000*absint( time()/1000 ) === absint( $nonce ) ){
    				$GLOBALS['eos_dp_user_can_preview'] = true;
    				return true;
    			}
    		}
    		echo '<p>It looks you are not allowed to see this preview.</p>';
    		echo '<p>Check if you have the rights to activate and deactivate plugins.</p>';
    		echo '<p>If you are sure you have the rights, try to log out, log in, and try again.</p>';
    		echo '<p>If you still have problems, ask for help on the <a href="https://wordpress.org/support/plugin/freesoul-deactivate-plugins/">Freesoul Deactivate Plugins support forum</a>.</p>';
    		exit; //Exit after warning the user
    	}
    	$GLOBALS['eos_dp_user_can_preview'] = true;
    }
    //Display memory usage
    function eos_dp_display_usage(){
    	if( isset( $_REQUEST['display_usage'] ) && 'false' === $_REQUEST['display_usage'] ){
    		return;
    	}
    	if( !isset( $GLOBALS['eos_dp_wp_loaded'] ) ) return;
    	if( isset( $_REQUEST['fdp-assets'] ) ) return;
      static $foo_called = false;
      if( $foo_called ) return;
      $foo_called = true;
    	global $wpdb;
    	$precision = 0;
    	$memory_usage = memory_get_peak_usage() / 1048576;
    	if( $memory_usage < 10 ){
    		$precision = 3;
    	}
    	else if( $memory_usage < 100 ) {
    		$precision = 2;
    	}
    	$usage = array(
    		'queries' => array( 'Number of database queries','Q',$wpdb->num_queries ),
    		'wp_loaded' => array( 'Initialization Time. At this time WordPress, all plugins, and the theme are fully loaded and instantiated','IT',$GLOBALS['eos_dp_wp_loaded'].'s' ),
    		'loading_time' => array( 'Page Generation Time. At this time the server has generated the entire HTML.','PGT',( strval( round(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 ) ) ).'s' ),
    		'memory' => array( 'Memory Usage. This is the memory consumed for generating the entire HTML.','MU',sprintf( '%s %s (%s)',round( $memory_usage, $precision ),'M',round( 100*$memory_usage/absint( ini_get( 'memory_limit' ) ),1 ).'%' ) )
    	);
    	echo '<div id="eos-dp-usage" style="z-index:9999999999;text-align:center;position:fixed;bottom:0;left:0;right:0">';
    	echo '<div style="display:inline-block;padding:10px;background-color:#e5dada;background-color:rgba(229,218,218,0.8)">';
    	$n = 0;
    	$separators = array( ' | ',' | ',' | ','' );
    	global $eos_dp_paths,$eos_dp_all_plugins;
    	$plugins_str = '[p]DISABLED PLUGINS ('.count( $eos_dp_paths ).'):[pp]';
    	foreach( $eos_dp_paths as $plugin ){
    		if( false === strpos( $plugin,'freesoul-deactivate-plugins' ) ){
    			$plugins_str .= '[p]'.ucwords( str_replace( '-',' ',dirname( $plugin ) ) ).'[pp]';
    		}
    	}
    	if( is_array( $eos_dp_all_plugins ) && array( $eos_dp_paths ) ){
    		$still_enable = array_diff( $eos_dp_all_plugins,$eos_dp_paths );
    		$plugins_str .= '[br][br][p]ACTIVE PLUGINS ('.count( $still_enable ).'):[pp]';
    		foreach( $still_enable as $plugin ){
    			if( false === strpos( $plugin,'freesoul-deactivate-plugins' ) ){
    				$plugins_str .= '[p]'.ucwords( str_replace( '-',' ',dirname( $plugin ) ) ).'[pp]';
    			}
    		}
    		$plugins_str .= '[br]';
    	}
    	$left = is_rtl() ? 'right' : 'left';
    	$right = is_rtl() ? 'left' : 'right';
    	echo '<span title="Disabled plugins" data-content="'.esc_attr( $plugins_str ).'" style="cursor:pointer;color:#000;font-size:20px;font-family:Arial" class="eos-dp-open-win eos-dp-disabled-plugins">Disabled Plugins: '.count( $eos_dp_paths ).'</span>';
    	if( !isset( $_REQUEST['show_files'] ) || 'true' !== $_REQUEST['show_files'] ){
    		echo '<span style="color:#000;font-size:20px;font-family:Arial" class="eos-dp-separator">'.$separators[$n].'</span>';
    		foreach( $usage as $key => $arr ){
    			$value = $arr[2];
    
    			$desc = $arr[0];
    
    			echo '<span title="'.esc_attr( $desc ).'" style="cursor:pointer;color:#000;font-size:20px;font-family:Arial" class="eos-dp-'.$key.'">'.esc_html( sprintf( '%s: %s',$arr[1],$value ) ).'</span>';
    			echo '<span style="color:#000;font-size:20px;font-family:Arial" class="eos-dp-separator">'.$separators[$n].'</span>';
    			++$n;
    		}
    	}
    	else{
    		global $template;
    		$called_by_pluginsA = array();
    		$template_file_name = basename( $template );
    		$included_files = get_included_files();
    		$plugindir = defined( PLUGINDIR ) ? PLUGINDIR.'/' : 'wp-content/plugins/';
    		$plugins_folder_name = basename( $plugindir );
    		$themedir = str_replace( ABSPATH,'',get_theme_root() );
    		$wp_content_name = dirname( $plugindir );
    		$template_relative_path  = str_replace( ABSPATH.$wp_content_name.'/','',$template );
    		sort( $included_files );
    		$theme_files = $plugin_files = '';
    		$plugin_names = array();
    		$n = $tn = $pn = 0;
    		$called_by_plugins = '';
    		foreach ( $included_files as $filename ) {
    			if ( strstr( $filename,$themedir ) || strstr( $filename, str_replace( '/','\\',$themedir ) ) ){
    				$filepath = strstr( $filename,$wp_content_name );
    				if ( $template_relative_path !== $filepath ) {
    					$theme_files .=  '[p]'.$filepath.'[pp]';
    					++$tn;
    				}
    			}
    			elseif ( strstr( $filename,$plugins_folder_name ) ) {
    				$slugA = explode( $plugindir,str_replace( '\\','/',$filename ) );
    				if( isset( $slugA[1] ) ){
    					$slugA = explode( '/',$slugA[1] );
    					$plugin_slug = $slugA[0];
    					if( !in_array( $plugin_slug,array_keys( $called_by_pluginsA ) ) ){
    						$plugin_files .=  '[br][br][p][b]'.strtoupper( str_replace( '-',' ',$plugin_slug ) ).'[bb][pp]';
    					}
    					$called_by_pluginsA[$plugin_slug] = isset( $called_by_pluginsA[$plugin_slug] ) ? $called_by_pluginsA[$plugin_slug] + 1 : 1;
    				}
    				$filepath = strstr( $filename,'wp-content' );
    				$plugin_files .=  '[p]'.$filepath.'[pp]';
    				++$pn;
    			}
    		}
    		foreach( $called_by_pluginsA as $plugin_slug => $cbpn ){
    			$called_by_plugins .= '[p]'.ucwords( str_replace( '-',' ',$plugin_slug ) ).' ('.$cbpn.')[pp]';
    		}
    		$n = $tn + $pn;
    		$included_plugins = '[p][b]FILES CALLED BY THE THEME:[bb][pp][d]'.$theme_files.'[dd][br][br][p][b]FILES CALLED BY PLUGINS ('.( $pn - 1 ).'):[bb]'.$called_by_plugins.'[br][br][pp][d]'.$plugin_files.'[dd]';
    		echo ' | <span id="eos-dp-files" title="Files called by the theme and plugins" data-title="Included files" data-content="'.esc_attr( $included_plugins ).'" style="cursor:pointer;color:#000;font-size:20px;font-family:Arial" class="eos-dp-open-win eos-dp-files">Included Files: '.( $n - 1 ).'<input class="buttton" style="margin:0 10px" type="submit" value="Show Files" /></span>';
    	}
    	echo '<span title="Close" style="position:relative;margin-'.$right.':-8px;margin-'.$left.':20px;display:inline-block;top:-8px;padding:4px 8px 8px 8px;cursor:pointer;color:#000;font-size:20px;font-family:Arial" class="eos-dp-close" onclick="javascript:this.parentNode.parentNode.style.display = \'none\'">X</span>';
    	echo '</div>';
    	echo '</div>';
    	echo '<script>var eos_open_wins = document.getElementsByClassName("eos-dp-open-win");for(var n=0;n<eos_open_wins.length;++n){eos_open_wins[n].addEventListener("click",function(){eos_dp_open_window(this);});}';
    	echo 'function eos_dp_open_window(el){var win=window.open("",el.dataset.title,"toolbar=0,location=0,menubar=0");win.document.write(el.dataset.content.split("[p]").join("<p>").split("[pp]").join("</p>").split("[d]").join("<div>").split("[dd]").join("</div>").split("[br]").join("<br/>").split("[b]").join("<strong>").split("[bb]").join("</strong>"));setTimeout(function(){win.document.title = el.dataset.title;},200);}';
    	echo '</script>';
    	eos_dp_print_disabled_plugins();
    }
    
    //Print usage in the JS console
    function eos_dp_console_usage(){
    	if( defined( 'DOING_AJAX' ) && DOING_AJAX ) return;
        static $cu_called = false;
        if( $cu_called ) return;
        $cu_called = true;
    	global $wpdb;
    	$precision = 0;
    	$memory_usage = memory_get_peak_usage() / 1048576;
    	if( $memory_usage < 10 ){
    		$precision = 2;
    	}
    	else if( $memory_usage < 100 ) {
    		$precision = 1;
    	}
    	$usage = array(
    		'queries' => sprintf( 'Queries: %s',$wpdb->num_queries ),
    		'wp_loaded' => sprintf( 'Initialization Time: %s %s',$GLOBALS['eos_dp_wp_loaded'],'s' ),
    		'loading_time' => sprintf( 'Page Generation Time: %s %s',strval( round(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 ) ),'s' ),
    		'memory' => sprintf( 'Memory Usage: %s %s (%s)',round( $memory_usage, $precision ),'M',round( 100*$memory_usage/absint( ini_get( 'memory_limit' ) ),1 ).'%' )
    	);
    	$n = 0;
    	$output = PHP_EOL.'*************************************'.PHP_EOL;
    	$output .= 'Usage measured by Freesoul Deactivate Plugins'.PHP_EOL.PHP_EOL;
    	foreach( $usage as $key => $value ){
    		$output .= esc_html( $value ).PHP_EOL;
    		++$n;
    	}
    	$output .= '************************************'.PHP_EOL;
    	echo '<script>if("undefined" === typeof(window.eos_dp_printed))console.log("'.esc_js( $output ).'");window.eos_dp_printed = true;</script>';
    }
    
    //Display HTML comment in the footer
    function eos_dp_comment(){
    	static $comment = false;
    	if( $comment ) return;
    	global $eos_dp_paths;
    	if( is_array( $eos_dp_paths ) ){
    		$disabled = !empty( $eos_dp_paths ) ? '.('.implode( '-',array_keys( $eos_dp_paths ) ).')' : false;
    		if( $disabled ){
    			$comment = sprintf( 'Freesoul Deactivate Plugins has disabled %s plugins on this page %s',count( $eos_dp_paths ),$disabled );
    		}
    		else{
    			$comment = 'Freesoul Deactivate Plugins has disabled no plugins on this page';
    		}
    		?>
    		<!-- <?php echo esc_html( $comment ); ?> -->
    		<?php
    	}
    }
    
    //Get options in case of single or multisite installation.
    function eos_dp_get_option( $option ){
    	if( !is_multisite() ){
    		return get_option( $option );
    	}
    	else{
    		return get_blog_option( get_current_blog_id(),$option );
    	}
    }
    
    //It checks if it's a mobile device
    function eos_dp_is_mobile() {
    	if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) return false;
    	if ( strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'mobile' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'android' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'silk/' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'kindle' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'blackBerry' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'opera mini' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'opera mobi' ) !== false
    	) {
    		return true;
    	}
    	return false;
    }
    
    //It returns the disabled plugins according to the mobile options
    function eos_dp_disabled_plugins_on_mobile() {
    	$mobile_options = eos_dp_get_option( 'eos_dp_mobile' );
    	if( $mobile_options ){
    		return array_values( eos_dp_get_option( 'eos_dp_mobile' ) );
    	}
    	return false;
    }
    
    //It returns the disabled plugins according to the search options
    function eos_dp_disabled_plugins_on_search() {
    	$search_options = eos_dp_get_option( 'eos_dp_search' );
    	if( $search_options ){
    		return array_values( eos_dp_get_option( 'eos_dp_search' ) );
    	}
    	return false;
    }
    
    add_filter( 'option_active_plugins', 'eos_dp_disabled_plugins_on_mobile_filter',10,1 );
    //It filters the disabled plugins on mobile
    function eos_dp_disabled_plugins_on_mobile_filter( $plugins ) {
    	if ( defined( 'DOING_AJAX' ) || !eos_dp_is_mobile() || is_admin() || class_exists( 'FS_Plugin_Updater' ) ) {
    		return $plugins; // for desktops we do nothing
    	}
    	eos_dp_unshift_fdp( $plugins );
    	global $eos_dp_debug;
    	extract( $eos_dp_debug );
    	$disabled_on_mobile = eos_dp_disabled_plugins_on_mobile();
    	if( $disabled_on_mobile ){
    		$info_mobile = '';
    		foreach( $disabled_on_mobile as $p => $const ){
    			$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    			if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE',true );
    		}
    		if( isset( $GLOBALS['eos_dp_paths'] ) && is_array( $GLOBALS['eos_dp_paths'] ) && is_array( $disabled_on_mobile ) ){
    			foreach( $disabled_on_mobile as $mob_plug ){
    				$info_mobile .= PHP_EOL.ucwords( str_replace( '-',' ',dirname( $mob_plug ) ) ).' disabled cause the mobile settings';
    			}
    			$GLOBALS['eos_dp_paths'] = array_unique( array_merge( $GLOBALS['eos_dp_paths'],$disabled_on_mobile ) );
    		}
    		$info[] = $info_mobile;
    		$eos_dp_debug['info'] = array_unique( $info );
    		return array_values( array_diff( $plugins,$disabled_on_mobile ) );
    	}
    	return $plugins;
    }
    
    add_filter( 'option_active_plugins', 'eos_dp_disabled_plugins_on_search_filter',20,1 );
    //It filters the disabled plugins on search
    function eos_dp_disabled_plugins_on_search_filter( $plugins ) {
    	if ( !isset( $_REQUEST['s'] ) || is_admin() || class_exists( 'FS_Plugin_Updater' ) ) {
    		return $plugins;
    	}
    	eos_dp_unshift_fdp( $plugins );
    	$disabled_on_search = eos_dp_disabled_plugins_on_search();
    	if( $disabled_on_search ){
    		foreach( $disabled_on_search as $p => $const ){
    			$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    			if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE',true );
    		}
    		if( isset( $GLOBALS['eos_dp_paths'] ) && is_array( $GLOBALS['eos_dp_paths'] ) && is_array( $disabled_on_search ) ){
    			$GLOBALS['eos_dp_paths'] = array_unique( array_merge( $GLOBALS['eos_dp_paths'],$disabled_on_search ) );
    		}
    		else{
    			$GLOBALS['eos_dp_paths'] = $disabled_on_search;
    		}
    		if( defined( 'EOS_DP_DEBUG' ) && true === EOS_DP_DEBUG || ( isset( $_SERVER['REMOTE_ADDR'] ) && isset( $_GET['show_disabled_plugins'] ) && $_GET['show_disabled_plugins'] === md5( $_SERVER['REMOTE_ADDR'] ) ) ){
    			$GLOBALS['eos_dp_user_can_preview'] = true;
    			add_action( 'wp_footer','eos_dp_print_disabled_plugins',9999 );
    		}
    		return array_values( array_diff( $plugins,$disabled_on_search ) );
    	}
    	return $plugins;
    }
    
    if( defined( 'DOING_AJAX' ) && 'DOING_AJAX' || isset( $_REQUEST['wc-ajax'] ) ){
    	$action = false;
    	if( isset( $_REQUEST['action'] ) ){
    		$action = $_REQUEST['action'];
    	}
    	elseif( isset( $_REQUEST['wc-ajax'] ) ){
    		$action = $_REQUEST['wc-ajax'];
    	}
    	if( $action && in_array( $action,array(
    				'eos_dp_save_settings',
    				'eos_dp_save_post_type_settings',
    				'eos_dp_save_archives_settings',
    				'eos_dp_save_url_settings',
    				'eos_dp_save_mobile_settings',
    				'eos_dp_save_search_settings',
    				'eos_dp_save_admin_settings',
    				'eos_dp_save_admin_url_settings',
    				'eos_dp_save_firing_order',
    				'eos_dp_pro_auto_settings_admin',
    				'eos_dp_preview',
    				// 'eos_dp_updated_key_for_preview',
    				'eos_dp_msg_never_again'
    			)
    		)
    		|| ( 'eos_dp_pro_auto_settings' === $action && !isset( $_REQUEST['post_type'] ) )
    	){
    		add_filter( 'option_active_plugins', 'eos_dp_only_fdp',0,1 );
    		add_action( 'plugins_loaded','eos_dp_replace_theme',99 );
    	}
    	else{
    		add_filter( 'option_active_plugins', 'eos_dp_integration_actions_plugins',0,1 );
    		$integration_actions_theme = eos_dp_get_option( 'eos_dp_integretion_actions_theme' );
    		if( isset( $integration_actions_theme[$action] ) && !$integration_actions_theme[$action] ){
    			add_action( 'plugins_loaded','eos_dp_replace_theme',99 );
    		}
    	}
    	function eos_dp_integration_actions_plugins( $plugins ){
    		$plugins_actions = eos_dp_get_option( 'eos_dp_integration_actions' );
    		eos_dp_unshift_fdp( $plugins );
    		$action = false;
    		if( isset( $_REQUEST['action'] ) ){
    			$action = $_REQUEST['action'];
    		}
    		elseif( isset( $_REQUEST['wc-ajax'] ) ){
    			$action = $_REQUEST['wc-ajax'];
    		}
    		if( $action && is_array( $plugins_actions ) && in_array( $action,array_keys( $plugins_actions ) ) && isset( $_REQUEST['action'] ) && isset( $plugins_actions[$_REQUEST['action']] ) ){
    			$disabled_plugins = array_filter( explode( ',',$plugins_actions[sanitize_key( $_REQUEST['action'] )] ) );
    			return array_values( array_diff( $plugins,$disabled_plugins ) );
    		}
    		return $plugins;
    	}
    	//Exclude all other plugins during Singles options saving process
    	function eos_dp_only_fdp( $plugins ){
    		$fdp_plugins = array();
    		if( is_array( $plugins ) && in_array( 'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php',$plugins ) ){
    			$fdp_plugins[] = 'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php';
    		}
    		if( is_array( $plugins ) && in_array( 'freesoul-deactivate-plugins-pro/freesoul-deactivate-plugins-pro.php',$plugins ) ){
    			$fdp_plugins[] = 'freesoul-deactivate-plugins-pro/freesoul-deactivate-plugins-pro.php';
    		}
    		if( !empty( $fdp_plugins ) ){
    			return $fdp_plugins;
    		}
    		return $plugins;
    	}
    }
    
    add_filter( 'option_active_plugins', 'eos_dp_disabled_plugins_on_ajax_filter',999,1 );
    //It filters the disabled plugins on ajax
    function eos_dp_disabled_plugins_on_ajax_filter( $plugins ) {
    	if ( defined( 'DOING_AJAX' ) && DOING_AJAX  && isset( $_REQUEST['action'] ) ){
    		$disabled_on_ajax = eos_dp_disabled_plugins_on_ajax();
    		if( is_array( $plugins ) && $disabled_on_ajax ){
    			eos_dp_unshift_fdp( $plugins );
    			foreach( $disabled_on_ajax as $path ){
    				$k = array_search( $path, $plugins );
    				if( false !== $k ){
    					unset( $plugins[$k] );
    				}
    			}
    		}
    	}
    	return $plugins;
    }
    
    //It returns the disabled plugins according to the ajax options
    function eos_dp_disabled_plugins_on_ajax() {
    	$ajax_options = eos_dp_get_option( 'eos_dp_pro_ajax_setts' );
    	if( $ajax_options && '' !== $ajax_options ){
    		$actions = json_decode( str_replace( '\\','',$ajax_options ),true );
    	}
    	$a1 = isset( $actions['nopriv'] ) ? $actions['nopriv'] : array();
    	$a2 = isset( $actions['logged'] ) ? $actions['logged'] : array();
    	$actions = array_merge( $a1,$a2 );
    	if( isset( $actions[$_REQUEST['action']] ) ){
    		$disabled_plugins = array_filter( explode( ',',$actions[$_REQUEST['action']] ),'strlen' );
    		return $disabled_plugins;
    	}
    	return false;
    }
    
    if ( defined( 'DOING_AJAX' ) && DOING_AJAX ){
    	if( isset( $_REQUEST['action'] ) ){
    		$ajaxTheme = eos_dp_get_option( 'eos_dp_pro_ajax_theme' );
    		if( isset( $ajaxTheme[$_REQUEST['action']] ) && !$ajaxTheme[$_REQUEST['action']] ){
    			add_action( 'plugins_loaded','eos_dp_replace_theme',99 );
    		}
    	}
    }
    if( defined( 'FDP_PRO_ACTIVE' ) && FDP_PRO_ACTIVE ){
    	add_filter( 'option_active_plugins', 'eos_dp_disabled_plugins_for_logged_users',40,1 );
    }
    //It filters the disabled plugins on mobile
    function eos_dp_disabled_plugins_for_logged_users( $plugins ) {
    	$post_types_matrix = eos_dp_get_option( 'eos_post_types_plugins' );
    	if(
    		( defined( 'DOING_AJAX' ) && DOING_AJAX )
    		|| ( defined( 'WP_CLI' ) && WP_CLI ) || ( defined( 'WP_SANDBOX_SCRAPING' ) && true === WP_SANDBOX_SCRAPING )
    	){
    		return $plugins;
    	}
    	if( isset( $_COOKIE['wordpress_test_cookie'] ) && false !== strpos( implode( '',array_keys( $_COOKIE ) ),'wordpress_logged_in' ) ){
    		$opts = eos_dp_get_option( 'eos_dp_pro_main' );
    		if( $opts && isset( $opts['eos_dp_logged_conditions'] ) && is_array( $opts['eos_dp_logged_conditions'] ) && !empty( $opts['eos_dp_logged_conditions'] ) ){
    			$conditions_opts = $opts['eos_dp_logged_conditions'];
    			$disabled_plugins_for_user = array();
    			$user = eos_dp_get_current_user();
    			if( $user ){
    					$disabled_plugins = array();
    					$conditions = eos_dp_logged_user_conditions();
    					foreach( $conditions_opts as $e => $string ){
    						if( '' === $e || false !== strpos( $e,'_off' ) || '' === $string ) continue;
    						$arr = json_decode( str_replace( '\\','',$string ),true );
    						if( !is_array( $arr ) || !isset( $arr['value'] ) || !isset( $arr['plugins'] ) ) continue;
    						$expression = $arr['value'];
    						if( $expression && '' !== $expression && substr_count( $expression,'(' ) === substr_count( $expression,')' ) ){
    							if( eos_dp_parse_expression( $expression,$user ) ){
    								$disabled_plugins = array_unique( explode( ';',str_replace( 'pn:','',$arr['plugins'] ) ) );
    								$plugins = array_diff( $plugins,$disabled_plugins );
    								if( isset( $conditions_opts[$e.'_off'] ) && 'true' === $conditions_opts[$e.'_off'] ){
    									$disabled_plugins_for_user = array_merge( $disabled_plugins_for_user,$disabled_plugins );
    								}
    							}
    						}
    					}
    					if( !is_array( $disabled_plugins ) ) $disabled_plugins = array();
    					if( !isset( $GLOBALS['eos_dp_paths'] ) || !is_array( $GLOBALS['eos_dp_paths'] ) ) $GLOBALS['eos_dp_paths'] = array();
    					$GLOBALS['eos_dp_paths'] = isset( $GLOBALS['eos_dp_paths'] ) ? array_unique( array_merge( $GLOBALS['eos_dp_paths'],$disabled_plugins ) ) : $disabled_plugins;
    					global $fdp_disabled_plugins_for_user;
    					$fdp_disabled_plugins_for_user = array_unique( array_filter( $disabled_plugins_for_user ) );
    			}
    		}
    	}
    	return $plugins;
    }
    add_action( 'plugins_loaded','eos_dp_remove_filters',9999 );
    add_action( 'activate_plugin','eos_dp_remove_filters',9999 );
    add_action( 'deactivated_plugin','eos_dp_remove_filters',9999 );
    //It removes the active plugins filters to avoid any issue with plugins that save the active_plugins option in the database
    function eos_dp_remove_filters(){
    	remove_filter( 'option_active_plugins','eos_dp_only_fdp',0 );
    	remove_filter( 'option_active_plugins','eos_option_active_plugins',0 );
    	remove_filter( 'option_active_plugins','eos_dp_integration_actions_plugins',0,1 );
    	remove_filter( 'option_active_plugins','eos_dp_admin_option_active_plugins',0,1 );
    	remove_filter( 'option_active_plugins','eos_dp_disabled_plugins_on_mobile_filter',10 );
    	remove_filter( 'option_active_plugins','eos_dp_disabled_plugins_on_search_filter',20 );
    	remove_filter( 'option_active_plugins','eos_dp_disabled_plugins_on_ajax_filter',30,1 );
    	remove_filter( 'option_active_plugins','eos_dp_disabled_plugins_for_logged_users',40,1 );
    }
    
    //It prints the disabled plugins in the JavaScript console in case of preview and debug.
    function eos_dp_print_disabled_plugins(){
    	if( defined( 'EOS_DP_DEBUG_PLUGIN' ) && EOS_DP_DEBUG_PLUGIN && !is_admin() ) return;
    	if( isset( $GLOBALS['eos_dp_paths'] ) && is_array( $GLOBALS['eos_dp_paths'] ) ){
    		echo '<script>';
    		echo 'if("undefined" === typeof(window.fdp_printed)){';
    		echo 'console.log("*** PLUGINS DISABLED BY FREESOUL DEACTIVATE PLUGINS ***\n\r");';
    		$n = 1;
    		foreach( $GLOBALS['eos_dp_paths'] as $path ){
    			echo '' !== $path ? 'console.log("'.esc_attr( esc_js( $n.') '.$path ) ).'");' : '';
    			++$n;
    		}
    		echo 'console.log("\n\r*************************************\n\r");';
    		echo 'window.fdp_printed = true;}';
    		echo '</script>';
    	}
    }
    //Print disabled plugins in a hidden div if the page is called by the debug  button
    function eos_dp_debug_options_wrapper(){
    	$disabled = array();
    	global $eos_dp_debug;
    	?>
    	<div id="eos-dp-debug-options-wrapper" style="display:none;opacity:0;visibility:hidden;height:0;position:absolute;left:-99999px">
    	<?php
    	if( isset( $GLOBALS['eos_dp_paths'] ) && is_array( $GLOBALS['eos_dp_paths'] ) ){
    		$n = 1;
    		foreach( $GLOBALS['eos_dp_paths'] as $path ){
    			if( '' !== $path ){
    				$disabled[] = esc_attr( ucwords( str_replace( '-',' ',dirname( $path ) ) ) );
    			}
    			++$n;
    		}
    	}
    	echo json_encode( array( 'disabled' => $disabled,'eos_dp_debug' => $eos_dp_debug ) );
    	?>
    	</div>
    	<?php
    }
    
    //Send JavaScript on modern browsers with the Content Security Policy
    function eos_dp_disable_javascript(){
    	?>
    	<meta http-equiv="Content-Security-Policy" content="script-src 'none'">
    	<?php
    }
    
    function eos_dp_translated_id( $page_path,$after_home_uri,$urlsA,$post_types ) {
    	global $wpdb;
        $page_path     = rawurlencode( urldecode( $page_path ) );
        $page_path     = str_replace( '%2F', '/', $page_path );
        $page_path     = str_replace( '%20', ' ', $page_path );
        $parts         = explode( '/', trim( $page_path, '/' ) );
        $parts         = array_map( 'sanitize_title_for_query', $parts );
        $escaped_parts = esc_sql( $parts );
        $in_string = "'" . implode( "','", $escaped_parts ) . "'";
        $post_types          = esc_sql( $post_types );
        $post_type_in_string = "'" . implode( "','", $post_types ) . "'";
        $sql                 = "
            SELECT ID, post_name, post_parent, post_type
            FROM $wpdb->posts
            WHERE post_name IN ($in_string)
            AND post_type IN ($post_type_in_string)
        ";
    	$unsets = array();
        $pages = $wpdb->get_results( $sql, OBJECT_K );
    	foreach( (array) $pages as &$page ){
    		if( $page->post_name !== basename( $page_path ) ){
    			$unsets[] = $page->ID;
    		}
    		elseif( isset( $pages[$page->post_parent] ) ){
    			$page_parent = $pages[$page->post_parent];
    			$page->post_parent_name = $page_parent->post_name;
    		}
    	}
    	foreach( $unsets as $unset ){
    		if( isset( $pages[$unset] ) ){
    			unset( $pages[$unset] );
    		}
    	}
        $revparts = array_reverse( $parts );
        $foundid = 0;
    	$foundids = array();
    	$arr = array( $_SERVER['HTTP_HOST'] );
        foreach ( (array) $pages as $page ) {
    		$arr[] = isset( $page->post_parent_name ) ? $page->post_parent_name : $page->post_name;
        }
    	$requestA = explode( '/',$_SERVER['REQUEST_URI'] );
    	if( isset( $requestA[1] ) ){
    		$arr[] = $requestA[1];
    	}
    	$diff = array_diff( $parts,$arr );
    	if( isset( $urlsA['need_url'] ) && !empty( $diff ) ){
    		$need_url = $urlsA['need_url'];
    		$maybe_lang = implode( '',$diff );
    		$ids = array_keys( $pages );
    		foreach( $ids as $id ){
    			if( isset( $need_url[$id] ) ){
    				$url = $need_url[$id];
    				foreach( array( 'https://','http://','www.' ) as $search ){
    					$url = str_replace( $search,'',$url );
    				}
    				if( $url === $page_path ) return $id;
    			}
    		}
    	}
    	return false;
    }
    
    //Move FDP to the first position in the plugins array
    function eos_dp_unshift_fdp( $plugins ){
    	if( is_array( $plugins ) && in_array( 'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php',$plugins ) ){
    		array_unshift( $plugins,'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php' );
    		$plugins = array_unique( $plugins );
    	}
    	return $plugins;
    }
    
    //Return array of $conditions
    function eos_dp_logged_user_conditions(){
    	return array(
    		array( 'role','hammer','Role' ),
    		array( 'capability','admin-tools','Capability' ),
    		array( 'username','businessperson','Username' ),
    		array( 'email','email','Email' ),
    		array( 'language','translation','Language' ),
    		array( 'registered_before','backup','Registered before' ),
    		array( 'registered_after','clock','Registered after' ),
    		array( 'has_bought','cart','Has bought' )
    	);
    }
    
    //Return $a or $b
    function eos_dp_or( $a,$b ){
    	return $a || $b;
    }
    
    //Return $a or $b
    function eos_dp_and( $a,$b ){
    	return $a && $b;
    }
    
    //Return not of $a
    function eos_dp_not( $a ){
    	return !$a;
    }
    
    function eos_dp_get_current_user() {
    		if( function_exists( 'wp_get_current_user' ) ) return wp_get_current_user(); //If the core function is availablle we use it and return
    		if( !defined( 'LOGGED_IN_COOKIE' ) || !isset( $_COOKIE[LOGGED_IN_COOKIE] ) ) return false;
    		$cookie = $_COOKIE[LOGGED_IN_COOKIE];
        if ( empty( $cookie ) ) {
            if ( empty( $_COOKIE[ LOGGED_IN_COOKIE] ) ) {
                return false;
            }
        }
        $cookie_elements = explode( '|', $cookie );
        if ( count( $cookie_elements ) !== 4 ) {
            return false;
        }
    		if( isset( $cookie_elements[0] ) && $cookie_elements[0] && '' !== $cookie_elements[0] ){
    			global $wpdb;
    			$user = $wpdb->get_row(
    				$wpdb->prepare(
    					"SELECT * FROM $wpdb->users WHERE user_login = %s LIMIT 1",
    					sanitize_user( $cookie_elements[0] )
    				)
    			);
    			if(
    				$user
    				&& is_object( $user )
    				&& isset( $user->user_login )
    				&& sanitize_user( $user->user_login ) === $user->user_login
    				&& isset( $user->user_email )
    				&& $user->user_email === sanitize_email( $user->user_email )
    				&& isset( $user->ID )
    				&& ''.absint( $user->ID ) === ''.$user->ID
    			){
    				return $user;
    			}
    		}
    		return false;
    }
    
    //Parse expression for logged-in user_status
    function eos_dp_parse_expression( $expression,$user ){
    	$f= substr( $expression,0,strpos( $expression,'(' ) );
    	$not = $f === 'not';
    	if( $not ){
    		$expression = rtrim( ltrim( $expression,'not(' ),')' );
    		$f= substr( $expression,0,strpos( $expression,'(' ) );
    	}
    	if( !in_array( $f,array( 'and','or' ) ) ){
    		$value = str_replace( ')','',str_replace( '(','',ltrim( $expression,$f ) ) );
    		switch( $f ){
    			case 'role':
    			case 'capability':
    				$roles = get_user_meta( $user->ID,'wp_capabilities' );
    				if( 'role' === $f ){
    					foreach( $roles as $roleA ){
    						if( in_array( $value,$roleA ) && $roleA[$value] ){
    							return true;
    						}
    					}
    				}
    				elseif( 'capability' === $f ){
    					$user_roles = eos_dp_get_option( 'wp_user_roles' );
    					$roleA = array_keys( $roles[0] );
    					$role = $roleA[0];
    					if( isset( $user_roles[$role] ) ){
    						$caps = $user_roles[$role];
    						if( isset( $caps['capabilities'] ) ){
    							$caps = $caps['capabilities'];
    							if( isset( $caps[$value] ) && $caps[$value] ){
    								return true;
    							}
    						}
    					}
    				}
    				break;
    			case 'username':
    				return !$not && strtolower( $user->user_login ) === strtolower( $value );
    				break;
    			case 'email':
    				return !$not && $user->user_email === $value;
    				break;
    			case 'language':
    				$user_locale = get_usermeta( $user->ID,'locale' );
    				return !$not && $user_locale && $user_locale === $value;
    				break;
    			case 'registered_before':
    				return !$not && strtotime( $user->user_registered ) < strtotime( $value );
    				break;
    			case 'registered_after':
    				return !$not && strtotime( $user->user_registered ) > strtotime( $value );
    				break;
    			case 'has_bought':
    				return !$not && eos_dp_user_has_bought( $user->ID );
    				break;
    		}
    	}
    }
    
    //Check if current user has ever bought anything with woocommerce
    function eos_dp_user_has_bought( $user_id ){
        $customer_orders = get_posts( array(
            'numberposts' => 1,
            'meta_key' => '_customer_user',
            'meta_value' => $user_id,
            'post_type' => 'shop_order',
            'post_status' => 'wc-completed',
            'fields' => 'ids',
        ) );
       return $customer_orders && count( $customer_orders ) > 0 ? true : false;
    }
    
    //Warn the user the mu-plugin is still installed
    function eos_dp_missing_fdp_notice(){
    	?>
    	<div class="notice notice-error">
    		<p style="font-size:20px;font-weight:bold">Freesoul Deactivate Plugins is not active, but its mu-plugin was not deleted.</p>
    		<p>Normally, when you deactivate FDP, it deletes its  mu-plugin file.</p>
    		<p>If you still have that file, it means you disabed FDP via FTP or something went wrong during the deactivation process.</p>
    		<?php if( current_user_can( 'manage_options') ){ ?>
    		<p style="font-size:20px;font-weight:bold">Delete the file <?php echo WPMU_PLUGIN_DIR.'/eos-deactivate-plugins.php'; ?></p>
    		<?php }else{ ?>
    		<p style="font-size:20px;font-weight:bold">Delete the file wp-content/mu-plugins/eos-deactivate-plugins.php</p>
    		<?php } ?>
    		<p>Then, FDP will not exist anymore in your installation.</p>
    	</div>
    	<?php
    }
    
    //Remove hooks
    function eos_dp_pro_remove_hooks(){
    	if( isset( $_GET['fdp-hooks'] ) ) return;
    	$fdp_pro_opts = eos_dp_get_option( 'eos_dp_pro_main' );
    	if( $fdp_pro_opts && isset( $fdp_pro_opts['fdp_hooks'] ) ){
    		$hooks = $fdp_pro_opts['fdp_hooks'];
    		if( !empty( $hooks ) ){
    			global $eos_page_id;
    			$removed_hooks = json_decode( sanitize_text_field( stripslashes( $hooks ) ),true );
    			foreach( $removed_hooks as $hook_name => $arr ){
    				foreach( $arr as $arr2 ){
    					if( absint( $eos_page_id ) !== absint( $arr2[2] ) ) continue;
    					$hook_function = $arr2[0];
    					$hook_priority = $arr2[1];
    					$remove = new FDP_pro_remove_hook( $hook_name,$hook_function,$hook_priority );
    				}
    			}
    		}
    	}
    }
    
    //Remove hook onject
    class FDP_pro_remove_hook {
      public $hook_name;
      public $hook_function;
      public $priority;
      function __construct( $hook_name,$hook_function,$priority ){
        $this->hook_name = $hook_name;
        $this->hook_function = $hook_function;
        $this->priority = $priority;
        foreach( array( 'muplugins_loaded','plugins_loaded','after_setup_theme' ) as $action ){
          add_action( $action,function(){
            $this->remove_hook_action();
          } );
        }
      }
      function remove_hook_action(){
        add_action( $this->hook_name,$this->remove_hook(),absint( $this->priority - 1 ) );
      }
      function remove_hook(){
        if( false !== strpos( $this->hook_function,'–>' ) ){
          $arr = explode( '–>',str_replace( ' ','',$this->hook_function ) );
          $this->remove_class_filter( $this->hook_name,$arr[0],$arr[1],$this->priority );
        }
        else{
          remove_action( $this->hook_name,$this->hook_function,$this->priority );
        }
      }
      function remove_class_filter( $tag,$class_name,$method_name,$priority ) {
          global $wp_filter;
          // Check that filter actually exists first
          if ( ! isset( $wp_filter[ $tag ] ) ) {
              return FALSE;
          }
          if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) {
              // Create $fob object from filter tag, to use below
              $fob       = $wp_filter[ $tag ];
              $callbacks = &$wp_filter[ $tag ]->callbacks;
          } else {
              $callbacks = &$wp_filter[ $tag ];
          }
          // Exit if there aren't any callbacks for specified priority
          if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) {
              return FALSE;
          }
          // Loop through each filter for the specified priority, looking for our class & method
          foreach ( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
              // Filter should always be an array - array( $this, 'method' ), if not goto next
              if ( ! isset( $filter['function'] ) || ! is_array( $filter['function'] ) ) {
                  continue;
              }
              // If first value in array is not an object, it can't be a class
              if ( ! is_object( $filter['function'][0] ) ) {
                  continue;
              }
              // Method doesn't match the one we're looking for, goto next
              if ( $filter['function'][1] !== $method_name ) {
                  continue;
              }
              // Method matched, now let's check the Class
              if ( get_class( $filter['function'][0] ) === $class_name ) {
                  // WordPress 4.7+ use core remove_filter() since we found the class object
                  if ( isset( $fob ) ) {
                      // Handles removing filter, reseting callback priority keys mid-iteration, etc.
                      $fob->remove_filter( $tag, $filter['function'], $priority );
                  } else {
                      // Use legacy removal process (pre 4.7)
                      unset( $callbacks[ $priority ][ $filter_id ] );
                      // and if it was the only filter in that priority, unset that priority
                      if ( empty( $callbacks[ $priority ] ) ) {
                          unset( $callbacks[ $priority ] );
                      }
                      // and if the only filter for that tag, set the tag to an empty array
                      if ( empty( $callbacks ) ) {
                          $callbacks = array();
                      }
                      // Remove this filter from merged_filters, which specifies if filters have been sorted
                      unset( $GLOBALS['merged_filters'][ $tag ] );
                  }
                  return TRUE;
              }
          }
          return FALSE;
        }
    }
    
    //Get options by URL
    function eos_dp_get_opts_by_url( $url ){
    	if( false !== strpos( $url,basename( dirname( EOS_DP_MU_PLUGIN_DIR ) ) ) ) return false;
    	$url = str_replace( 'www.','',$url );
    	$arr = explode( '?',$url );
    	$upload_dirs = wp_upload_dir();
    	$path = ltrim( rtrim( $url,'/' ),'/' );
    	if( eos_dp_is_mobile() ){
    		$path .= '-mobile';
    	}
    	$parts = explode( '/',$path );
    	$path = $upload_dirs['basedir'].'/FDP/fdp-single-options';
    	foreach( $parts as $part ){
    		$path .= '/'.substr( md5( $part ),0,8 );
    	}
    	if( file_exists( $path.'/opts.json' ) ){
    		return json_decode( stripslashes( sanitize_text_field( file_get_contents( $path.'/opts.json' ) ) ),true );
    	}
    	return false;
    }
    
    Thread Starter lgokul

    (@lgokul)

    I found the solution, dear Jose, I published it, but I get this message when I share it.

    “This post has been held for moderation by our automated system and will be manually reviewed by a moderator.”

    I’d like to explain the bug to you by teamviewer if you have time.
    Thank you very much for answering.

    • This reply was modified 2 years, 11 months ago by lgokul.
    Plugin Author Jose

    (@giuse)

    Hi @lgokul

    sorry for my late answer.

    Try first to save the options of Singles where you have those products, and let me know if it works with the last version.
    I know the differences between the versions, but the last version should work if you save the options. The last version has fewer calls to the database and solves some problems that occurred when you had a blog post with exactly the same name of a product, so it’s important to keep the method of the last version.
    I know it works, but it’s possible that until you don’t save you have the issue that you have now.
    To be sure the database and files system is updated, change something in the Singles settings (e.g. activating a plugin more), save, and then restore again the original settings and save again. In another case, FDP will think you didn’t change anything and nothing will be updated.

    Let me know.

    Plugin Author Jose

    (@giuse)

    Hi @lgokul

    I’m closing this thread, but if you still need help don’t hesitate to open a new thread.

    Thread Starter lgokul

    (@lgokul)

    Hello dear Jose sorry for the late response, I did not see the previous notification of your response.
    Right away I check with the new version of the plugin.

    Thread Starter lgokul

    (@lgokul)

    The error continues in the latest versions of the plugin esteemed Jose
    But this time it happens in some variations and not in others.
    Why does this happen?

    Edit: After entering woocommerce and saving the product without making any changes, free soul started working.

    The point is that I have to do the same in most products where free soul does not work.

    Why is this happening dear Jose?`

    • This reply was modified 2 years, 10 months ago by lgokul.
    • This reply was modified 2 years, 10 months ago by lgokul.
    Thread Starter lgokul

    (@lgokul)

    Modify this file eos-deactivate-plugins.php
    Compare it to the current one and the variations started to work.

    <?php
    /*
      Plugin Name: freesoul deactivate plugins [fdp]
      Description: mu-plugin automatically installed by freesoul deactivate plugins
      Version: 1.8.8.6
      Plugin URI: https://freesoul-deactivate-plugins.com/
      Author: Jose Mortellaro
      Author URI: https://josemortellaro.com/
      License: GPLv2
    */
    defined( 'ABSPATH' ) || exit; // Exit if accessed directly
    define( 'EOS_DP_MU_VERSION','1.8.8.6' );
    define( 'EOS_DP_MU_PLUGIN_DIR',untrailingslashit( dirname( __FILE__ ) ) );
    
    foreach( array( 'activate_plugin','deactivate_plugin','deactivated_plugin','pre_update_option_active_plugins' ) as $action ){
    	//Prevent saving wrong set of active plugins if programmatically activating or deactivating plugins
    	if( did_action( $action ) ) return;
    }
    if( ( defined( 'WP_CLI' ) && WP_CLI ) || ( defined( 'WP_SANDBOX_SCRAPING' ) && true === WP_SANDBOX_SCRAPING ) ) return;
    if( !isset( $_SERVER['HTTP_HOST'] ) || !isset( $_SERVER['REQUEST_URI'] ) ) return;
    if( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'],array( 'eos_dp_save_firing_order' ) ) ) return;
    if( isset( $_REQUEST['action'] ) && isset( $_REQUEST['plugin'] ) && 'deactivate' === $_REQUEST['action'] ) return;
    $GLOBALS['eos_dp_debug'] = array( 'info' => array(),'log' => array(),'error' => array() );
    extract( $eos_dp_debug );
    if(
    	(
    		( !isset( $_REQUEST['s'] ) || ( defined( 'EOS_DP_URL_APPLY_ON_SEARCH' ) && true === EOS_DP_URL_APPLY_ON_SEARCH ) )
    		|| isset( $_GET['eos_dp_preview'] )
    	)
    	&& !defined( 'DOING_AJAX' )
    ){
    	$opts_by_path = false;
    	$eos_dp_disabled_plugins = array();
    	global $eos_dp_disabled_plugins;
    	$post_types_matrix = eos_dp_get_option( 'eos_post_types_plugins' );
    	$post_types = is_array( $post_types_matrix ) ? array_keys( $post_types_matrix ) : array();
    	if( !is_admin() && ( empty( $_POST ) || ( defined( 'EOS_DP_ALLOW_POST' ) && EOS_DP_ALLOW_POST ) ) && is_array( $post_types ) ){
    		$home_page = false;
    		$clean_uri = '';
    		$arr = array();
    		$uri = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    		$from_url = false;
    		$urlsA = eos_dp_get_option( 'eos_dp_by_url' );
    		if( !isset( $_GET['eos_dp_preview'] ) ){
    			if( is_array( $urlsA ) && !empty( is_array( $urlsA ) ) ){
    				foreach( $urlsA as $urlA ){
    					if( isset( $urlA['url'] ) ){
    						foreach( array( 'https://','http://','www.' ) as $search ){
    							$urlA['url'] = str_replace( $search,'',$urlA['url'] );
    						}
    						$pattern = '/'.str_replace( '/','\/',str_replace( '*','(.*)',str_replace( '**','*',$urlA['url'] ) ) ).'\s/';
    						$pattern = '/'.str_replace( '/','\/',str_replace( '*','(.*)',str_replace( '**','*',$urlA['url'] ) ) ).'\s/i';
    						$pattern = str_replace( '?','\?',$pattern );
    						$pattern = str_replace( '&','\&',$pattern );
    						preg_match( $pattern,$uri.' ',$matches );
    						if( !empty( $matches ) && count( $matches ) - 1 === substr_count( $pattern,'(.*)' ) ){
    							$eos_dp_paths = explode( ',',$urlA['plugins'] );
    							$from_url = true;
    							$maybe_singles = isset( $urlA['needs_url'] ) && absint( $urlA['needs_url'] ) > 0 ? ' Ignored URL query arguments because the post ID '.$urlA['needs_url'].' needs a custom URL.' : '';
    							$info[] = sprintf( 'Plugins disabled according to the Custom URLs settings. Matched %s.%s',$urlA['url'],$maybe_singles );
    							break;
    						}
    					}
    				}
    			}
    		}
    		$permalink_structure = eos_dp_get_option( 'permalink_structure' );
    		$permalink_structure_base = basename( $permalink_structure );
    		if( !$from_url && false !== strpos( $permalink_structure_base,'%postname%' ) ){
    			$uriArr = explode( '?',$uri );
    			$uri = $clean_uri = $uriArr[0];
    			if( !isset( $_GET['page_id'] ) && !isset( $_GET['p'] ) ){
    				$home_uri = str_replace( 'https://','',str_replace( 'http://','',home_url( '/' ) ) );
    				if( $uri !== $home_uri ){
    					$arr = array_filter( explode( '/',$uri ) );
    					$after_home_uri = str_replace( $home_uri,'',implode( '/',$arr ) );
    					$after_home_uriArr = explode( '?',$after_home_uri );
    					$after_home_uri = $after_home_uriArr[0];
    					$after_home_uriArr = explode( '#',$after_home_uri );
    					$after_home_uri = untrailingslashit( $after_home_uriArr[0] );
    					$p = false;
    					$p = $after_home_uri !== '' ? get_page_by_path( $after_home_uri,'OBJECT',$post_types ) : false;
    					$p = $after_home_uri !== '' && !is_object( $p ) ? get_page_by_path( basename( $after_home_uri ),'OBJECT',$post_types ) : $p;
    					if( is_object( $p ) && ( false === strpos( $after_home_uri,'/' ) || ( $p->post_parent || 'page' !== $p->post_type ) ) ){
    						$eos_page_id =  $p->ID;
    					}
    					else{
    						$eos_page_id =  false;
    						global $wpdb;
    						if( is_object( $wpdb ) ){
    							if( isset( $wpdb->last_result ) ){
    								$last_result = $wpdb->last_result;
    								if( isset( $last_result[0] ) && is_object( $last_result[0] ) ){
    									$resObj = $last_result[0];
    									$eos_page_id =  isset( $resObj->ID ) && absint( $resObj->ID ) > 0 ? $resObj->ID : false;
    								}
    							}
    						}
    					}
    				}
    				else{
    					//It's the front page
    					if( isset( $_REQUEST ) && !empty( $_REQUEST ) && !isset( $_REQUEST['eos_dp_preview'] ) && !isset( $_REQUEST['show_disabled_plugins'] ) && !isset( $_REQUEST['fdp_post_id'] ) && !isset( $_REQUEST['fdp_assets'] ) && !isset( $_REQUEST['fdp_assets'] ) && !isset( $_GET['fbclid'] ) ) return;
    					$eos_page_id = eos_dp_get_option( 'page_on_front' );
    					$info[] = sprintf( 'Plugins disabled according to the homepage ID %s.',$eos_page_id );
    					$p = get_page( $eos_page_id );
    					$home_page = true;
    				}
    			}
    			else{
    				$eos_page_id = isset( $_GET['page_id'] ) ? absint( $_GET['page_id'] ) : absint( $_GET['p'] );
    				$p = get_page( $eos_page_id );
    				global $eos_page_id;
    			}
    			$eos_page_id = isset( $eos_page_id ) && absint( $eos_page_id ) !== 0 ? $eos_page_id : false;
    			if( eos_dp_is_mobile() ){
    				$mobile_page_id = absint( get_post_meta( $eos_page_id,'eos_scfm_mobile_post_id',true ) );
    				if( $mobile_page_id > 0 ){
    					$eos_page_id = $mobile_page_id;
    				}
    			}
    			$eos_dp_paths = '';
    			if( $eos_page_id || ( isset( $_REQUEST['fdp_post_id'] ) && isset( $_REQUEST['eos_dp_preview'] ) ) ){
    				if( isset( $_REQUEST['fdp_post_id'] ) && isset( $_REQUEST['eos_dp_preview'] ) ){
    					$eos_page_id = absint( $_REQUEST['fdp_post_id'] );
    					$cron = isset( $_REQUEST['internal_call'] ) && 'true' === $_REQUEST['internal_call'] ? 'cron_' : '';
    					$after_save = isset( $_REQUEST['after_save'] ) && 'true' === $_REQUEST['after_save'] ? 'after_save_' : '';
    					$gtmetrix = isset( $_REQUEST['gtmetrix'] ) && 'true' === $_REQUEST['gtmetrix'] ? 'gtmetrix_' : '';
    					$offset = isset( $_REQUEST['eos_dp_offset'] )? $_REQUEST['eos_dp_offset'] : '';
    					$transient_name = 'fdp_test_'.$after_save.$cron.$gtmetrix.sanitize_key( $_REQUEST['fdp_post_id'].$offset );
    					$eos_dp_paths = explode( ';pn:',esc_attr( get_transient( $transient_name ) ) );
    				}
    				else{
    					if( $opts_by_path ){
    						$post_type = $opts_by_path['post_type'];
    						$post_types_matrix_pt = $post_types_matrix[sanitize_key( $post_type )];
    					}
    					elseif( $post_types_matrix ){
    						$post_type = $p->post_type;
    						$post_types_matrix_pt = is_object( $p ) && isset( $post_types_matrix[$post_type] ) ? $post_types_matrix[$post_type] : 0;
    					}
    					$post_meta = $opts_by_path ? $opts_by_path['plugins'] : get_post_meta( $eos_page_id,'_eos_deactive_plugins_key',true );
    					if( isset( $post_types_matrix_pt ) && isset( $post_types_matrix_pt[0] ) && '0' == $post_types_matrix_pt[0] ){
    						$eos_dp_paths = explode( ',',$post_meta );
    
    					}
    					else{
    						if( ( $opts_by_path || is_object( $p ) ) && $post_types_matrix && isset( $post_types_matrix[$post_type] ) ){
    							if( isset( $post_types_matrix_pt[3] ) ){
    								$ids = $post_types_matrix_pt[3];
    								if( in_array( $eos_page_id,$ids ) ){
    									$eos_dp_paths = explode( ',',$post_meta );
    									$info[] = sprintf( 'Plugins disabled according to Singles Settings. ID: %s.',$eos_page_id );
    								}
    								else{
    									$eos_dp_paths = explode( ',',$post_types_matrix_pt[1] );
    									$info[] = sprintf( 'Plugins disabled according to the Post Types settings. Post type: %s.',$post_type );
    								}
    							}
    							else{
    								$eos_dp_paths = explode( ',',$post_types_matrix_pt[1] );
    								$info[] = sprintf( 'Settings overridden by the Post Types Settings. Post type: %s.',$post_type );
    							}
    						}
    					}
    				}
    				global $eos_page_id,$eos_dp_paths;
    			}
    			else{
    				//It's an archive page
    				if( $opts_by_path && isset( $opts_by_path['post_id'] ) && 'archive' === $opts_by_path['post_id'] ){
    					$eos_dp_paths = explode( ',',esc_attr( $opts_by_path['plugins'] ) );
    					$info[] = sprintf( 'Plugins disabled according to the archive settings, archive: %s',$opts_by_path['post_type'] );
    				}
    				else{
    					$archives = eos_dp_get_option( 'eos_dp_archives' );
    					$clean_uri = str_replace( '/','__',rtrim( $clean_uri,'/' ) );
    					$key = sanitize_key( $clean_uri );
    					if( isset( $_GET['fdp_post_type'] ) && isset( $_GET['eos_dp_preview'] ) ){
    						$eos_dp_paths = explode( ';pn:',esc_attr( get_transient( 'fdp_test_'.sanitize_key( $_GET['fdp_post_type'] ) ) ) );
    					}
    					elseif( isset( $_GET['fdp_tax'] ) && isset( $_GET['eos_dp_preview'] ) ){
    						$eos_dp_paths = explode( ';pn:',esc_attr( get_transient( 'fdp_test_'.sanitize_key( $_GET['fdp_tax'] ) ) ) );
    					}
    					elseif( isset( $archives[$key] ) ){
    						$eos_dp_paths = explode( ',',$archives[$key] );
    						$info[] = 'Plugins disabled according to the archive settings';
    					}
    				}
    
    			}
    			if( !is_array( $eos_dp_paths ) && '' === $eos_dp_paths && isset( $after_home_uri ) ){
    				//Let's check if it's a translated post
    				$eos_page_id = eos_dp_translated_id( $uri,$after_home_uri,$urlsA,$post_types );
    				if( $eos_page_id ){
    					$pt = get_post_type( $eos_page_id );
    					$post_types_matrix_pt = $pt && isset( $post_types_matrix[$pt] ) ? $post_types_matrix[$pt] : 0;
    					if( isset( $post_types_matrix_pt[3] ) ){
    						$ids = $post_types_matrix_pt[3];
    						if( in_array( $eos_page_id,$ids ) ){
    							$post_meta = get_post_meta( $eos_page_id,'_eos_deactive_plugins_key',true );
    							$eos_dp_paths = explode( ',',$post_meta );
    							$info[] = sprintf( 'Plugins disabled according to Singles Settings. ID: %s.',$eos_page_id );
    						}
    						else{
    							$eos_dp_paths = explode( ',',$post_types_matrix_pt[1] );
    							$info[] = sprintf( 'Plugins disabled according to the Post Types settings. Post type: %s.',$pt );
    						}
    					}
    					else{
    						$eos_dp_paths = explode( ',',$post_types_matrix_pt[1] );
    						$info[] = sprintf( 'Settings overridden by the Post Types Settings. Post type: %s.',$pt );
    					}
    					global $eos_page_id;
    				}
    			}
    		}
    		global $eos_dp_paths;
    		if( !defined( 'EOS_DEACTIVE_PLUGINS' ) ) define( 'EOS_DEACTIVE_PLUGINS',true );
    		add_filter( 'option_active_plugins', 'eos_option_active_plugins',0,1 );
    		eos_dp_pro_remove_hooks();
    	}
    	$eos_dp_debug['info'] = $info;
    }
    
    if( is_admin()
    	&& ( !isset( $_GET['page'] ) || 'eos_dp_admin' !== $_GET['page'] || defined( 'FDP_DISABLE_IN_FDP_PAGE' ) )
    	&& isset( $_SERVER['HTTP_HOST'] )
    	&& isset( $_SERVER['REQUEST_URI'] )
    	&& empty( $_POST )
    	&& !defined( 'DOING_AJAX' )
    ){
    	add_action( 'wp_loaded',function(){
    		$GLOBALS['eos_dp_wp_loaded'] = round( microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 );
    	} );
    	add_filter( 'option_active_plugins','eos_dp_admin_option_active_plugins',0,1 );
    	$adminTheme = eos_dp_get_option( 'eos_dp_admin_theme' );
    	$adminThemeUrl = eos_dp_get_option( 'eos_dp_admin_url_theme' );
    	$base_url = basename( $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] );
    	if( isset( $adminTheme[$base_url] ) && !$adminTheme[$base_url] ){
    		add_action( 'plugins_loaded','eos_dp_replace_theme',99 );
    	}
    }
    function eos_dp_admin_option_active_plugins( $plugins ){
    	if( !is_array( $plugins ) ) return $plugins;
    	if( !in_array( 'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php',$plugins )  ){
    		add_action( 'admin_notices','eos_dp_missing_fdp_notice' );
    	}
    	if( isset( $_GET['page'] ) && false !== strpos( $_GET['page'],'eos_dp_' ) ){
    		if( defined( 'FDP_DISABLE_IN_FDP_PAGE' ) ){
    			if( is_string( FDP_DISABLE_IN_FDP_PAGE ) && is_array( $plugins ) && in_array( FDP_DISABLE_IN_FDP_PAGE,$plugins ) ){
    				unset( $plugins[array_search( FDP_DISABLE_IN_FDP_PAGE,$plugins )] );
    			}
    			elseif( is_array( FDP_DISABLE_IN_FDP_PAGE ) ){
    				foreach( FDP_DISABLE_IN_FDP_PAGE as $disable_on_fdp_page ){
    					if( is_string( $disable_on_fdp_page ) && in_array( $disable_on_fdp_page,$plugins ) ){
    						unset( $plugins[array_search( $disable_on_fdp_page,$plugins )] );
    					}
    				}
    			}
    		}
    		return $plugins;
    	}
    	eos_dp_unshift_fdp( $plugins );
    	$all_plugins = $plugins;
    	foreach( $plugins as $p => $const ){
    		$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    		if( !defined( 'EOS_ADMIN_'.$const.'_ACTIVE' ) ) define( 'EOS_ADMIN_'.$const.'_ACTIVE','true' );
    	}
    	if( isset( $_REQUEST['eos_dp_preview'] ) && isset( $_REQUEST['admin_page_key'] ) ){
    		add_action( 'wp_loaded',function(){
    			$GLOBALS['eos_dp_wp_loaded'] = round( microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 );
    		} );
    		$GLOBALS['eos_dp_all_plugins'] = array_filter( $all_plugins );
    		register_shutdown_function( 'eos_dp_display_usage' );
    		if( isset( $_REQUEST['eos_dp_debug'] ) ){
    			if( 'no_error' === $_REQUEST['eos_dp_debug'] ){
    				@ini_set( 'display_error',0 );
    			}
    		}
    		$disabled_plugins = explode( ';pn:',esc_attr( get_transient( 'fdp_test_'.sanitize_key( $_REQUEST['admin_page_key'] ) ) ) );
    		foreach( $disabled_plugins as $path ){
    			$k = array_search( $path, $plugins );
    			if( false !== $k ){
    				$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    				if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE','true' );
    				unset( $plugins[$k] );
    			}
    		}
    		$last = $disabled_plugins[absint( count( $disabled_plugins ) - 1 )];
    		if( 'undefined' === $last ){
    			unset( $disabled_plugins[absint( count( $disabled_plugins ) - 1 )] );
    		}
    		if( isset( $_REQUEST['theme'] ) && 'false' === $_REQUEST['theme'] ){
    			eos_dp_replace_theme();
    		}
    		$GLOBALS['eos_dp_paths'] = array_filter( $disabled_plugins );
    		return $plugins;
    	}
    	$base_url = basename( $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] );
    	$admin_page = false !== strpos( $base_url,'.php' ) ?  admin_url( $base_url ) : admin_url( 'admin.php'.$base_url );
    	$from_admin_url = false;
    	$urlsA = eos_dp_get_option( 'eos_dp_by_admin_url' );
    	$admin_plugins = array();
    	if( is_array( $urlsA ) && !empty( is_array( $urlsA ) ) ){
    		foreach( $urlsA as $urlA ){
    			if( isset( $urlA['url'] ) ){
    				foreach( array( 'https://','http://','www.' ) as $search ){
    					$urlA['url'] = str_replace( $search,'',$urlA['url'] );
    				}
    
    				$pattern = '/'.str_replace( '/','\/',str_replace( '*','(.*)',str_replace( '**','*',$urlA['url'] ) ) ).'\s/i';
    				$pattern = str_replace( '?','\?',$pattern );
    				$pattern = str_replace( '&','\&',$pattern );
    				preg_match( $pattern,$admin_page.' ',$matches );
    				if( !empty( $matches ) && count( $matches ) - 1 === substr_count( $pattern,'(.*)' ) ){
    					$admin_plugins[$admin_page] = $urlA['plugins'];
    					$from_admin_url = true;
    					break;
    				}
    			}
    		}
    	}
    	if( !$from_admin_url ){
    		$admin_plugins = eos_dp_get_option( 'eos_dp_admin_setts' );
    	}
    	if( isset( $_GET['page'] ) || isset( $admin_plugins[$admin_page] ) || isset( $admin_plugins[$base_url] ) ){
    		if( isset( $_GET['page'] ) && isset( $admin_plugins[$_GET['page']] ) ){
    			$key = $admin_plugins[$_GET['page']];
    		}
    		else{
    			if( !isset( $admin_plugins[$admin_page] ) && !isset( $admin_plugins[$base_url] ) ){
    				return $plugins;
    			}
    			$key = isset( $admin_plugins[$admin_page] ) ? $admin_plugins[$admin_page] : $admin_plugins[$base_url];
    		}
    		$disabled_plugins = explode( ',',$key );
    		foreach( $disabled_plugins as $path ){
    			$k = array_search( $path, $plugins );
    			if( false !== $k ){
    				$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    				if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE','true' );
    				unset( $plugins[$k] );
    			}
    		}
    	}
    	$GLOBALS['eos_dp_paths'] = array_diff( $all_plugins,$plugins );
    	add_action( 'admin_footer','eos_dp_print_disabled_plugins',9999 );
    	return $plugins;
    }
    
    //Return active plugins in according with the options
    function eos_option_active_plugins( $plugins ){
    	if( !is_array( $plugins ) || is_admin() || defined( 'DOING_AJAX' ) || isset( $_REQUEST['wc-ajax'] ) || class_exists( 'FS_Plugin_Updater' ) ) return $plugins;
    	eos_dp_unshift_fdp( $plugins );
    	if( isset( $_REQUEST['eos_dp_preview'] ) ){
    		$GLOBALS['eos_dp_all_plugins'] = $plugins;
    		if( isset( $_REQUEST['eos_dp_debug'] ) ){
    			if( 'no_error' === $_REQUEST['eos_dp_debug'] ){
    				@ini_set( 'display_error',0 );
    				@ini_set( 'log_errors',0 );
    			}
    		}
    		add_action( 'plugins_loaded','eos_check_dp_preview_nonce' );
    		if( isset( $_REQUEST['eos_dp_display_error'] ) && 'display_error' === $_REQUEST['eos_dp_display_error'] ){
    			@ini_set( 'display_error',1 );
    		}
    		add_action( 'wp_loaded',function(){
    			$GLOBALS['eos_dp_wp_loaded'] = round( microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 );
    		} );
    		register_shutdown_function( 'eos_dp_display_usage' );
    		$themeA = explode( '&theme=',parse_url( urldecode( basename( $_SERVER['REQUEST_URI'] ) ),PHP_URL_QUERY ) );
    		if( isset( $themeA[1] ) ){
    			$themeA = explode( '&',$themeA[1] );
    			if( '' !== $themeA[0] ){
    				if( 'empty_theme' === $themeA[0] ){
    					eos_dp_replace_theme();
    				}
    				else{
    					if( 'false' !== $themeA[0] ){
    						$GLOBALS['eos_dp_theme'] = $themeA[0];
    						add_filter( 'stylesheet','eos_dp_get_theme' );
    						add_filter( 'template','eos_dp_get_parent_theme' );
    					}
    				}
    			}
    		}
    		if( isset( $_GET['js'] ) && 'off' === $_GET['js'] ){
    			add_action( 'wp_head','eos_dp_disable_javascript',10 );
    		}
    	}
    	else{
    		if( defined( 'EOS_DP_DEBUG' ) && true === EOS_DP_DEBUG || ( isset( $_SERVER['REMOTE_ADDR'] ) && isset( $_GET['show_disabled_plugins'] ) && $_GET['show_disabled_plugins'] === md5( $_SERVER['REMOTE_ADDR'].( absint( time()/1000 ) ) ) ) ){
    			$GLOBALS['eos_dp_user_can_preview'] = true;
    			add_action( 'wp_footer','eos_dp_print_disabled_plugins',9999 );
    		}
    		if( isset( $_REQUEST['eos_dp_debug_options'] ) ){
    			add_action( 'wp_footer','eos_dp_debug_options_wrapper',9999 );
    		}
    	}
    	global $eos_dp_paths;
    	global $eos_dp_disabled_plugins;
    	if( $eos_dp_paths === '' ) return $plugins;
    	$eos_dp_paths = $eos_dp_paths ? $eos_dp_paths : array();
    	$e = 0;
    	foreach( $eos_dp_paths as $path ){
    		$k = array_search( $path, $plugins );
    		if( false !== $k ){
    			$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $path ) ) ) );
    			if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE',true );
    			unset( $plugins[$k] );
    			if( in_array( $path,$plugins ) ){
    				$eos_dp_disabled_plugins[] = $path;
    			}
    		}
    		else{
    			unset( $eos_dp_paths[$e] );
    		}
    		++$e;
    	}
    	add_action( 'wp_footer','eos_dp_comment' );
    	return $plugins;
    }
    
    //Replace theme for preview
    function eos_dp_get_theme( $stylesheet ){
    	if( !isset( $GLOBALS['eos_dp_theme'] ) ) return $stylesheet;
    	return esc_attr( $GLOBALS['eos_dp_theme'] );
    }
    //Return parent theme
    function eos_dp_get_parent_theme( $template ){
    	if( !isset( $GLOBALS['eos_dp_theme'] ) ) return $stylesheet;
    	$themes = wp_get_themes();
    	$child_theme = sanitize_key( $GLOBALS['eos_dp_theme'] );
    	if( !isset( $themes[$child_theme] ) ) return $template;
    	$theme = $themes[$child_theme];
    	if( isset( $theme->template ) ){
    		return $theme->template;
    	}
    	return $template;
    }
    
    //It replaces the theme with an almost empty theme provided by FDP
    function eos_dp_replace_theme(){
    	if( defined( 'EOS_DP_PLUGIN_DIR' ) ){
    		add_filter( 'stylesheet_directory','eos_dp_stylesheet_directory',20,3 );
    		add_filter( 'theme_root','eos_dp_theme_root',20 );
    		add_filter( 'stylesheet','eos_dp_template',20 );
    		add_filter( 'template','eos_dp_template',20 );
    	}
    }
    //Replace theme with ultralight theme given by FDP
    function eos_dp_stylesheet_directory( $stylesheet_dir,$stylesheet,$theme_root ){
    	return EOS_DP_PLUGIN_DIR.'/fdp-theme';
    }
    function eos_dp_theme_root( $theme_root ){
    	return EOS_DP_PLUGIN_DIR;
    }
    function eos_dp_template( $template ){
    	return 'fdp-theme';
    }
    
    //Check preview nonce
    function eos_check_dp_preview_nonce(){
    	if( defined( 'EOS_DP_PRO_TESTING_UNIQUE_ID' ) ){
    		if( isset( $_REQUEST['eos_dp_pro_id' ] ) && md5( EOS_DP_PRO_TESTING_UNIQUE_ID ) === $_REQUEST['eos_dp_pro_id'] ){
    			$GLOBALS['eos_dp_user_can_preview'] = true;
    			return true;
    		}
    	}
    	if( !wp_verify_nonce( $_REQUEST['eos_dp_preview'],'eos_dp_preview' ) ){
    		$nonce = get_transient( 'fdp_psi_nonce_'.sanitize_key( $_REQUEST['fdp_post_id'] ) );
    		if( $nonce ){
    			if( 1000*absint( time()/1000 ) === absint( $nonce ) ){
    				$GLOBALS['eos_dp_user_can_preview'] = true;
    				return true;
    			}
    		}
    		echo '<p>It looks you are not allowed to see this preview.</p>';
    		echo '<p>Check if you have the rights to activate and deactivate plugins.</p>';
    		echo '<p>If you are sure you have the rights, try to log out, log in, and try again.</p>';
    		echo '<p>If you still have problems, ask for help on the <a href="https://wordpress.org/support/plugin/freesoul-deactivate-plugins/">Freesoul Deactivate Plugins support forum</a>.</p>';
    		exit; //Exit after warning the user
    	}
    	$GLOBALS['eos_dp_user_can_preview'] = true;
    }
    //Display memory usage
    function eos_dp_display_usage(){
    	if( isset( $_REQUEST['display_usage'] ) && 'false' === $_REQUEST['display_usage'] ){
    		return;
    	}
    	if( !isset( $GLOBALS['eos_dp_wp_loaded'] ) ) return;
    	if( isset( $_REQUEST['fdp-assets'] ) ) return;
      static $foo_called = false;
      if( $foo_called ) return;
      $foo_called = true;
    	global $wpdb;
    	$precision = 0;
    	$memory_usage = memory_get_peak_usage() / 1048576;
    	if( $memory_usage < 10 ){
    		$precision = 3;
    	}
    	else if( $memory_usage < 100 ) {
    		$precision = 2;
    	}
    	$usage = array(
    		'queries' => array( 'Number of database queries','Q',$wpdb->num_queries ),
    		'wp_loaded' => array( 'Initialization Time. At this time WordPress, all plugins, and the theme are fully loaded and instantiated','IT',$GLOBALS['eos_dp_wp_loaded'].'s' ),
    		'loading_time' => array( 'Page Generation Time. At this time the server has generated the entire HTML.','PGT',( strval( round(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 ) ) ).'s' ),
    		'memory' => array( 'Memory Usage. This is the memory consumed for generating the entire HTML.','MU',sprintf( '%s %s (%s)',round( $memory_usage, $precision ),'M',round( 100*$memory_usage/absint( ini_get( 'memory_limit' ) ),1 ).'%' ) )
    	);
    	echo '<div id="eos-dp-usage" style="z-index:9999999999;text-align:center;position:fixed;bottom:0;left:0;right:0">';
    	echo '<div style="display:inline-block;padding:10px;background-color:#e5dada;background-color:rgba(229,218,218,0.8)">';
    	$n = 0;
    	$separators = array( ' | ',' | ',' | ','' );
    	global $eos_dp_paths,$eos_dp_all_plugins;
    	$plugins_str = '[p]DISABLED PLUGINS ('.count( $eos_dp_paths ).'):[pp]';
    	foreach( $eos_dp_paths as $plugin ){
    		if( false === strpos( $plugin,'freesoul-deactivate-plugins' ) ){
    			$plugins_str .= '[p]'.ucwords( str_replace( '-',' ',dirname( $plugin ) ) ).'[pp]';
    		}
    	}
    	if( is_array( $eos_dp_all_plugins ) && array( $eos_dp_paths ) ){
    		$still_enable = array_diff( $eos_dp_all_plugins,$eos_dp_paths );
    		$plugins_str .= '[br][br][p]ACTIVE PLUGINS ('.count( $still_enable ).'):[pp]';
    		foreach( $still_enable as $plugin ){
    			if( false === strpos( $plugin,'freesoul-deactivate-plugins' ) ){
    				$plugins_str .= '[p]'.ucwords( str_replace( '-',' ',dirname( $plugin ) ) ).'[pp]';
    			}
    		}
    		$plugins_str .= '[br]';
    	}
    	$left = is_rtl() ? 'right' : 'left';
    	$right = is_rtl() ? 'left' : 'right';
    	echo '<span title="Disabled plugins" data-content="'.esc_attr( $plugins_str ).'" style="cursor:pointer;color:#000;font-size:20px;font-family:Arial" class="eos-dp-open-win eos-dp-disabled-plugins">Disabled Plugins: '.count( $eos_dp_paths ).'</span>';
    	if( !isset( $_REQUEST['show_files'] ) || 'true' !== $_REQUEST['show_files'] ){
    		echo '<span style="color:#000;font-size:20px;font-family:Arial" class="eos-dp-separator">'.$separators[$n].'</span>';
    		foreach( $usage as $key => $arr ){
    			$value = $arr[2];
    
    			$desc = $arr[0];
    
    			echo '<span title="'.esc_attr( $desc ).'" style="cursor:pointer;color:#000;font-size:20px;font-family:Arial" class="eos-dp-'.$key.'">'.esc_html( sprintf( '%s: %s',$arr[1],$value ) ).'</span>';
    			echo '<span style="color:#000;font-size:20px;font-family:Arial" class="eos-dp-separator">'.$separators[$n].'</span>';
    			++$n;
    		}
    	}
    	else{
    		global $template;
    		$called_by_pluginsA = array();
    		$template_file_name = basename( $template );
    		$included_files = get_included_files();
    		$plugindir = defined( PLUGINDIR ) ? PLUGINDIR.'/' : 'wp-content/plugins/';
    		$plugins_folder_name = basename( $plugindir );
    		$themedir = str_replace( ABSPATH,'',get_theme_root() );
    		$wp_content_name = dirname( $plugindir );
    		$template_relative_path  = str_replace( ABSPATH.$wp_content_name.'/','',$template );
    		sort( $included_files );
    		$theme_files = $plugin_files = '';
    		$plugin_names = array();
    		$n = $tn = $pn = 0;
    		$called_by_plugins = '';
    		foreach ( $included_files as $filename ) {
    			if ( strstr( $filename,$themedir ) || strstr( $filename, str_replace( '/','\\',$themedir ) ) ){
    				$filepath = strstr( $filename,$wp_content_name );
    				if ( $template_relative_path !== $filepath ) {
    					$theme_files .=  '[p]'.$filepath.'[pp]';
    					++$tn;
    				}
    			}
    			elseif ( strstr( $filename,$plugins_folder_name ) ) {
    				$slugA = explode( $plugindir,str_replace( '\\','/',$filename ) );
    				if( isset( $slugA[1] ) ){
    					$slugA = explode( '/',$slugA[1] );
    					$plugin_slug = $slugA[0];
    					if( !in_array( $plugin_slug,array_keys( $called_by_pluginsA ) ) ){
    						$plugin_files .=  '[br][br][p][b]'.strtoupper( str_replace( '-',' ',$plugin_slug ) ).'[bb][pp]';
    					}
    					$called_by_pluginsA[$plugin_slug] = isset( $called_by_pluginsA[$plugin_slug] ) ? $called_by_pluginsA[$plugin_slug] + 1 : 1;
    				}
    				$filepath = strstr( $filename,'wp-content' );
    				$plugin_files .=  '[p]'.$filepath.'[pp]';
    				++$pn;
    			}
    		}
    		foreach( $called_by_pluginsA as $plugin_slug => $cbpn ){
    			$called_by_plugins .= '[p]'.ucwords( str_replace( '-',' ',$plugin_slug ) ).' ('.$cbpn.')[pp]';
    		}
    		$n = $tn + $pn;
    		$included_plugins = '[p][b]FILES CALLED BY THE THEME:[bb][pp][d]'.$theme_files.'[dd][br][br][p][b]FILES CALLED BY PLUGINS ('.( $pn - 1 ).'):[bb]'.$called_by_plugins.'[br][br][pp][d]'.$plugin_files.'[dd]';
    		echo ' | <span id="eos-dp-files" title="Files called by the theme and plugins" data-title="Included files" data-content="'.esc_attr( $included_plugins ).'" style="cursor:pointer;color:#000;font-size:20px;font-family:Arial" class="eos-dp-open-win eos-dp-files">Included Files: '.( $n - 1 ).'<input class="buttton" style="margin:0 10px" type="submit" value="Show Files" /></span>';
    	}
    	echo '<span title="Close" style="position:relative;margin-'.$right.':-8px;margin-'.$left.':20px;display:inline-block;top:-8px;padding:4px 8px 8px 8px;cursor:pointer;color:#000;font-size:20px;font-family:Arial" class="eos-dp-close" onclick="javascript:this.parentNode.parentNode.style.display = \'none\'">X</span>';
    	echo '</div>';
    	echo '</div>';
    	echo '<script>var eos_open_wins = document.getElementsByClassName("eos-dp-open-win");for(var n=0;n<eos_open_wins.length;++n){eos_open_wins[n].addEventListener("click",function(){eos_dp_open_window(this);});}';
    	echo 'function eos_dp_open_window(el){var win=window.open("",el.dataset.title,"toolbar=0,location=0,menubar=0");win.document.write(el.dataset.content.split("[p]").join("<p>").split("[pp]").join("</p>").split("[d]").join("<div>").split("[dd]").join("</div>").split("[br]").join("<br/>").split("[b]").join("<strong>").split("[bb]").join("</strong>"));setTimeout(function(){win.document.title = el.dataset.title;},200);}';
    	echo '</script>';
    	eos_dp_print_disabled_plugins();
    }
    
    //Print usage in the JS console
    function eos_dp_console_usage(){
    	if( defined( 'DOING_AJAX' ) && DOING_AJAX ) return;
        static $cu_called = false;
        if( $cu_called ) return;
        $cu_called = true;
    	global $wpdb;
    	$precision = 0;
    	$memory_usage = memory_get_peak_usage() / 1048576;
    	if( $memory_usage < 10 ){
    		$precision = 2;
    	}
    	else if( $memory_usage < 100 ) {
    		$precision = 1;
    	}
    	$usage = array(
    		'queries' => sprintf( 'Queries: %s',$wpdb->num_queries ),
    		'wp_loaded' => sprintf( 'Initialization Time: %s %s',$GLOBALS['eos_dp_wp_loaded'],'s' ),
    		'loading_time' => sprintf( 'Page Generation Time: %s %s',strval( round(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],2 ) ),'s' ),
    		'memory' => sprintf( 'Memory Usage: %s %s (%s)',round( $memory_usage, $precision ),'M',round( 100*$memory_usage/absint( ini_get( 'memory_limit' ) ),1 ).'%' )
    	);
    	$n = 0;
    	$output = PHP_EOL.'*************************************'.PHP_EOL;
    	$output .= 'Usage measured by Freesoul Deactivate Plugins'.PHP_EOL.PHP_EOL;
    	foreach( $usage as $key => $value ){
    		$output .= esc_html( $value ).PHP_EOL;
    		++$n;
    	}
    	$output .= '************************************'.PHP_EOL;
    	echo '<script>if("undefined" === typeof(window.eos_dp_printed))console.log("'.esc_js( $output ).'");window.eos_dp_printed = true;</script>';
    }
    
    //Display HTML comment in the footer
    function eos_dp_comment(){
    	static $comment = false;
    	if( $comment ) return;
    	global $eos_dp_paths;
    	if( is_array( $eos_dp_paths ) ){
    		$disabled = !empty( $eos_dp_paths ) ? '.('.implode( '-',array_keys( $eos_dp_paths ) ).')' : false;
    		if( $disabled ){
    			$comment = sprintf( 'Freesoul Deactivate Plugins has disabled %s plugins on this page %s',count( $eos_dp_paths ),$disabled );
    		}
    		else{
    			$comment = 'Freesoul Deactivate Plugins has disabled no plugins on this page';
    		}
    		?>
    		<!-- <?php echo esc_html( $comment ); ?> -->
    		<?php
    	}
    }
    
    //Get options in case of single or multisite installation.
    function eos_dp_get_option( $option ){
    	if( !is_multisite() ){
    		return get_option( $option );
    	}
    	else{
    		return get_blog_option( get_current_blog_id(),$option );
    	}
    }
    
    //It checks if it's a mobile device
    function eos_dp_is_mobile() {
    	if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) return false;
    	if ( strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'mobile' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'android' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'silk/' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'kindle' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'blackBerry' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'opera mini' ) !== false
    		|| strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ),'opera mobi' ) !== false
    	) {
    		return true;
    	}
    	return false;
    }
    
    //It returns the disabled plugins according to the mobile options
    function eos_dp_disabled_plugins_on_mobile() {
    	$mobile_options = eos_dp_get_option( 'eos_dp_mobile' );
    	if( $mobile_options ){
    		return array_values( eos_dp_get_option( 'eos_dp_mobile' ) );
    	}
    	return false;
    }
    
    //It returns the disabled plugins according to the search options
    function eos_dp_disabled_plugins_on_search() {
    	$search_options = eos_dp_get_option( 'eos_dp_search' );
    	if( $search_options ){
    		return array_values( eos_dp_get_option( 'eos_dp_search' ) );
    	}
    	return false;
    }
    
    add_filter( 'option_active_plugins', 'eos_dp_disabled_plugins_on_mobile_filter',10,1 );
    //It filters the disabled plugins on mobile
    function eos_dp_disabled_plugins_on_mobile_filter( $plugins ) {
    	if ( defined( 'DOING_AJAX' ) || !eos_dp_is_mobile() || is_admin() || class_exists( 'FS_Plugin_Updater' ) ) {
    		return $plugins; // for desktops we do nothing
    	}
    	eos_dp_unshift_fdp( $plugins );
    	global $eos_dp_debug;
    	extract( $eos_dp_debug );
    	$disabled_on_mobile = eos_dp_disabled_plugins_on_mobile();
    	if( $disabled_on_mobile ){
    		$info_mobile = '';
    		foreach( $disabled_on_mobile as $p => $const ){
    			$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    			if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE',true );
    		}
    		if( isset( $GLOBALS['eos_dp_paths'] ) && is_array( $GLOBALS['eos_dp_paths'] ) && is_array( $disabled_on_mobile ) ){
    			foreach( $disabled_on_mobile as $mob_plug ){
    				$info_mobile .= PHP_EOL.ucwords( str_replace( '-',' ',dirname( $mob_plug ) ) ).' disabled cause the mobile settings';
    			}
    			$GLOBALS['eos_dp_paths'] = array_unique( array_merge( $GLOBALS['eos_dp_paths'],$disabled_on_mobile ) );
    		}
    		$info[] = $info_mobile;
    		$eos_dp_debug['info'] = array_unique( $info );
    		return array_values( array_diff( $plugins,$disabled_on_mobile ) );
    	}
    	return $plugins;
    }
    
    add_filter( 'option_active_plugins', 'eos_dp_disabled_plugins_on_search_filter',20,1 );
    //It filters the disabled plugins on search
    function eos_dp_disabled_plugins_on_search_filter( $plugins ) {
    	if ( !isset( $_REQUEST['s'] ) || is_admin() || class_exists( 'FS_Plugin_Updater' ) ) {
    		return $plugins;
    	}
    	eos_dp_unshift_fdp( $plugins );
    	$disabled_on_search = eos_dp_disabled_plugins_on_search();
    	if( $disabled_on_search ){
    		foreach( $disabled_on_search as $p => $const ){
    			$const = str_replace( '-','_',strtoupper( str_replace( '.php','',basename( $const ) ) ) );
    			if( !defined( 'EOS_'.$const.'_ACTIVE' ) ) define( 'EOS_'.$const.'_ACTIVE',true );
    		}
    		if( isset( $GLOBALS['eos_dp_paths'] ) && is_array( $GLOBALS['eos_dp_paths'] ) && is_array( $disabled_on_search ) ){
    			$GLOBALS['eos_dp_paths'] = array_unique( array_merge( $GLOBALS['eos_dp_paths'],$disabled_on_search ) );
    		}
    		else{
    			$GLOBALS['eos_dp_paths'] = $disabled_on_search;
    		}
    		if( defined( 'EOS_DP_DEBUG' ) && true === EOS_DP_DEBUG || ( isset( $_SERVER['REMOTE_ADDR'] ) && isset( $_GET['show_disabled_plugins'] ) && $_GET['show_disabled_plugins'] === md5( $_SERVER['REMOTE_ADDR'] ) ) ){
    			$GLOBALS['eos_dp_user_can_preview'] = true;
    			add_action( 'wp_footer','eos_dp_print_disabled_plugins',9999 );
    		}
    		return array_values( array_diff( $plugins,$disabled_on_search ) );
    	}
    	return $plugins;
    }
    
    if( defined( 'DOING_AJAX' ) && 'DOING_AJAX' || isset( $_REQUEST['wc-ajax'] ) ){
    	$action = false;
    	if( isset( $_REQUEST['action'] ) ){
    		$action = $_REQUEST['action'];
    	}
    	elseif( isset( $_REQUEST['wc-ajax'] ) ){
    		$action = $_REQUEST['wc-ajax'];
    	}
    	if( $action && in_array( $action,array(
    				'eos_dp_save_settings',
    				'eos_dp_save_post_type_settings',
    				'eos_dp_save_archives_settings',
    				'eos_dp_save_url_settings',
    				'eos_dp_save_mobile_settings',
    				'eos_dp_save_search_settings',
    				'eos_dp_save_admin_settings',
    				'eos_dp_save_admin_url_settings',
    				'eos_dp_save_firing_order',
    				'eos_dp_pro_auto_settings_admin',
    				'eos_dp_preview',
    				// 'eos_dp_updated_key_for_preview',
    				'eos_dp_msg_never_again'
    			)
    		)
    		|| ( 'eos_dp_pro_auto_settings' === $action && !isset( $_REQUEST['post_type'] ) )
    	){
    		add_filter( 'option_active_plugins', 'eos_dp_only_fdp',0,1 );
    		add_action( 'plugins_loaded','eos_dp_replace_theme',99 );
    	}
    	else{
    		add_filter( 'option_active_plugins', 'eos_dp_integration_actions_plugins',0,1 );
    		$integration_actions_theme = eos_dp_get_option( 'eos_dp_integretion_actions_theme' );
    		if( isset( $integration_actions_theme[$action] ) && !$integration_actions_theme[$action] ){
    			add_action( 'plugins_loaded','eos_dp_replace_theme',99 );
    		}
    	}
    	function eos_dp_integration_actions_plugins( $plugins ){
    		$plugins_actions = eos_dp_get_option( 'eos_dp_integration_actions' );
    		eos_dp_unshift_fdp( $plugins );
    		$action = false;
    		if( isset( $_REQUEST['action'] ) ){
    			$action = $_REQUEST['action'];
    		}
    		elseif( isset( $_REQUEST['wc-ajax'] ) ){
    			$action = $_REQUEST['wc-ajax'];
    		}
    		if( $action && is_array( $plugins_actions ) && in_array( $action,array_keys( $plugins_actions ) ) && isset( $_REQUEST['action'] ) && isset( $plugins_actions[$_REQUEST['action']] ) ){
    			$disabled_plugins = array_filter( explode( ',',$plugins_actions[sanitize_key( $_REQUEST['action'] )] ) );
    			return array_values( array_diff( $plugins,$disabled_plugins ) );
    		}
    		return $plugins;
    	}
    	//Exclude all other plugins during Singles options saving process
    	function eos_dp_only_fdp( $plugins ){
    		$fdp_plugins = array();
    		if( is_array( $plugins ) && in_array( 'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php',$plugins ) ){
    			$fdp_plugins[] = 'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php';
    		}
    		if( is_array( $plugins ) && in_array( 'freesoul-deactivate-plugins-pro/freesoul-deactivate-plugins-pro.php',$plugins ) ){
    			$fdp_plugins[] = 'freesoul-deactivate-plugins-pro/freesoul-deactivate-plugins-pro.php';
    		}
    		if( !empty( $fdp_plugins ) ){
    			return $fdp_plugins;
    		}
    		return $plugins;
    	}
    }
    
    add_filter( 'option_active_plugins', 'eos_dp_disabled_plugins_on_ajax_filter',999,1 );
    //It filters the disabled plugins on ajax
    function eos_dp_disabled_plugins_on_ajax_filter( $plugins ) {
    	if ( defined( 'DOING_AJAX' ) && DOING_AJAX  && isset( $_REQUEST['action'] ) ){
    		$disabled_on_ajax = eos_dp_disabled_plugins_on_ajax();
    		if( is_array( $plugins ) && $disabled_on_ajax ){
    			eos_dp_unshift_fdp( $plugins );
    			foreach( $disabled_on_ajax as $path ){
    				$k = array_search( $path, $plugins );
    				if( false !== $k ){
    					unset( $plugins[$k] );
    				}
    			}
    		}
    	}
    	return $plugins;
    }
    
    //It returns the disabled plugins according to the ajax options
    function eos_dp_disabled_plugins_on_ajax() {
    	$ajax_options = eos_dp_get_option( 'eos_dp_pro_ajax_setts' );
    	if( $ajax_options && '' !== $ajax_options ){
    		$actions = json_decode( str_replace( '\\','',$ajax_options ),true );
    	}
    	$a1 = isset( $actions['nopriv'] ) ? $actions['nopriv'] : array();
    	$a2 = isset( $actions['logged'] ) ? $actions['logged'] : array();
    	$actions = array_merge( $a1,$a2 );
    	if( isset( $actions[$_REQUEST['action']] ) ){
    		$disabled_plugins = array_filter( explode( ',',$actions[$_REQUEST['action']] ),'strlen' );
    		return $disabled_plugins;
    	}
    	return false;
    }
    
    if ( defined( 'DOING_AJAX' ) && DOING_AJAX ){
    	if( isset( $_REQUEST['action'] ) ){
    		$ajaxTheme = eos_dp_get_option( 'eos_dp_pro_ajax_theme' );
    		if( isset( $ajaxTheme[$_REQUEST['action']] ) && !$ajaxTheme[$_REQUEST['action']] ){
    			add_action( 'plugins_loaded','eos_dp_replace_theme',99 );
    		}
    	}
    }
    if( defined( 'FDP_PRO_ACTIVE' ) && FDP_PRO_ACTIVE ){
    	add_filter( 'option_active_plugins', 'eos_dp_disabled_plugins_for_logged_users',40,1 );
    }
    //It filters the disabled plugins on mobile
    function eos_dp_disabled_plugins_for_logged_users( $plugins ) {
    	$post_types_matrix = eos_dp_get_option( 'eos_post_types_plugins' );
    	if(
    		( defined( 'DOING_AJAX' ) && DOING_AJAX )
    		|| ( defined( 'WP_CLI' ) && WP_CLI ) || ( defined( 'WP_SANDBOX_SCRAPING' ) && true === WP_SANDBOX_SCRAPING )
    	){
    		return $plugins;
    	}
    	if( isset( $_COOKIE['wordpress_test_cookie'] ) && false !== strpos( implode( '',array_keys( $_COOKIE ) ),'wordpress_logged_in' ) ){
    		$opts = eos_dp_get_option( 'eos_dp_pro_main' );
    		if( $opts && isset( $opts['eos_dp_logged_conditions'] ) && is_array( $opts['eos_dp_logged_conditions'] ) && !empty( $opts['eos_dp_logged_conditions'] ) ){
    			$conditions_opts = $opts['eos_dp_logged_conditions'];
    			$disabled_plugins_for_user = array();
    			$user = eos_dp_get_current_user();
    			if( $user ){
    					$disabled_plugins = array();
    					$conditions = eos_dp_logged_user_conditions();
    					foreach( $conditions_opts as $e => $string ){
    						if( '' === $e || false !== strpos( $e,'_off' ) || '' === $string ) continue;
    						$arr = json_decode( str_replace( '\\','',$string ),true );
    						if( !is_array( $arr ) || !isset( $arr['value'] ) || !isset( $arr['plugins'] ) ) continue;
    						$expression = $arr['value'];
    						if( $expression && '' !== $expression && substr_count( $expression,'(' ) === substr_count( $expression,')' ) ){
    							if( eos_dp_parse_expression( $expression,$user ) ){
    								$disabled_plugins = array_unique( explode( ';',str_replace( 'pn:','',$arr['plugins'] ) ) );
    								$plugins = array_diff( $plugins,$disabled_plugins );
    								if( isset( $conditions_opts[$e.'_off'] ) && 'true' === $conditions_opts[$e.'_off'] ){
    									$disabled_plugins_for_user = array_merge( $disabled_plugins_for_user,$disabled_plugins );
    								}
    							}
    						}
    					}
    					if( !is_array( $disabled_plugins ) ) $disabled_plugins = array();
    					if( !isset( $GLOBALS['eos_dp_paths'] ) || !is_array( $GLOBALS['eos_dp_paths'] ) ) $GLOBALS['eos_dp_paths'] = array();
    					$GLOBALS['eos_dp_paths'] = isset( $GLOBALS['eos_dp_paths'] ) ? array_unique( array_merge( $GLOBALS['eos_dp_paths'],$disabled_plugins ) ) : $disabled_plugins;
    					global $fdp_disabled_plugins_for_user;
    					$fdp_disabled_plugins_for_user = array_unique( array_filter( $disabled_plugins_for_user ) );
    			}
    		}
    	}
    	return $plugins;
    }
    add_action( 'plugins_loaded','eos_dp_remove_filters',9999 );
    add_action( 'activate_plugin','eos_dp_remove_filters',9999 );
    add_action( 'deactivated_plugin','eos_dp_remove_filters',9999 );
    //It removes the active plugins filters to avoid any issue with plugins that save the active_plugins option in the database
    function eos_dp_remove_filters(){
    	remove_filter( 'option_active_plugins','eos_dp_only_fdp',0 );
    	remove_filter( 'option_active_plugins','eos_option_active_plugins',0 );
    	remove_filter( 'option_active_plugins','eos_dp_integration_actions_plugins',0,1 );
    	remove_filter( 'option_active_plugins','eos_dp_admin_option_active_plugins',0,1 );
    	remove_filter( 'option_active_plugins','eos_dp_disabled_plugins_on_mobile_filter',10 );
    	remove_filter( 'option_active_plugins','eos_dp_disabled_plugins_on_search_filter',20 );
    	remove_filter( 'option_active_plugins','eos_dp_disabled_plugins_on_ajax_filter',30,1 );
    	remove_filter( 'option_active_plugins','eos_dp_disabled_plugins_for_logged_users',40,1 );
    }
    
    //It prints the disabled plugins in the JavaScript console in case of preview and debug.
    function eos_dp_print_disabled_plugins(){
    	if( defined( 'EOS_DP_DEBUG_PLUGIN' ) && EOS_DP_DEBUG_PLUGIN && !is_admin() ) return;
    	if( isset( $GLOBALS['eos_dp_paths'] ) && is_array( $GLOBALS['eos_dp_paths'] ) ){
    		echo '<script>';
    		echo 'if("undefined" === typeof(window.fdp_printed)){';
    		echo 'console.log("*** PLUGINS DISABLED BY FREESOUL DEACTIVATE PLUGINS ***\n\r");';
    		$n = 1;
    		foreach( $GLOBALS['eos_dp_paths'] as $path ){
    			echo '' !== $path ? 'console.log("'.esc_attr( esc_js( $n.') '.$path ) ).'");' : '';
    			++$n;
    		}
    		echo 'console.log("\n\r*************************************\n\r");';
    		echo 'window.fdp_printed = true;}';
    		echo '</script>';
    	}
    }
    //Print disabled plugins in a hidden div if the page is called by the debug  button
    function eos_dp_debug_options_wrapper(){
    	$disabled = array();
    	global $eos_dp_debug;
    	?>
    	<div id="eos-dp-debug-options-wrapper" style="display:none;opacity:0;visibility:hidden;height:0;position:absolute;left:-99999px">
    	<?php
    	if( isset( $GLOBALS['eos_dp_paths'] ) && is_array( $GLOBALS['eos_dp_paths'] ) ){
    		$n = 1;
    		foreach( $GLOBALS['eos_dp_paths'] as $path ){
    			if( '' !== $path ){
    				$disabled[] = esc_attr( ucwords( str_replace( '-',' ',dirname( $path ) ) ) );
    			}
    			++$n;
    		}
    	}
    	echo json_encode( array( 'disabled' => $disabled,'eos_dp_debug' => $eos_dp_debug ) );
    	?>
    	</div>
    	<?php
    }
    
    //Send JavaScript on modern browsers with the Content Security Policy
    function eos_dp_disable_javascript(){
    	?>
    	<meta http-equiv="Content-Security-Policy" content="script-src 'none'">
    	<?php
    }
    
    function eos_dp_translated_id( $page_path,$after_home_uri,$urlsA,$post_types ) {
    	global $wpdb;
        $page_path     = rawurlencode( urldecode( $page_path ) );
        $page_path     = str_replace( '%2F', '/', $page_path );
        $page_path     = str_replace( '%20', ' ', $page_path );
        $parts         = explode( '/', trim( $page_path, '/' ) );
        $parts         = array_map( 'sanitize_title_for_query', $parts );
        $escaped_parts = esc_sql( $parts );
        $in_string = "'" . implode( "','", $escaped_parts ) . "'";
        $post_types          = esc_sql( $post_types );
        $post_type_in_string = "'" . implode( "','", $post_types ) . "'";
        $sql                 = "
            SELECT ID, post_name, post_parent, post_type
            FROM $wpdb->posts
            WHERE post_name IN ($in_string)
            AND post_type IN ($post_type_in_string)
        ";
    	$unsets = array();
        $pages = $wpdb->get_results( $sql, OBJECT_K );
    	foreach( (array) $pages as &$page ){
    		if( $page->post_name !== basename( $page_path ) ){
    			$unsets[] = $page->ID;
    		}
    		elseif( isset( $pages[$page->post_parent] ) ){
    			$page_parent = $pages[$page->post_parent];
    			$page->post_parent_name = $page_parent->post_name;
    		}
    	}
    	foreach( $unsets as $unset ){
    		if( isset( $pages[$unset] ) ){
    			unset( $pages[$unset] );
    		}
    	}
        $revparts = array_reverse( $parts );
        $foundid = 0;
    	$foundids = array();
    	$arr = array( $_SERVER['HTTP_HOST'] );
        foreach ( (array) $pages as $page ) {
    		$arr[] = isset( $page->post_parent_name ) ? $page->post_parent_name : $page->post_name;
        }
    	$requestA = explode( '/',$_SERVER['REQUEST_URI'] );
    	if( isset( $requestA[1] ) ){
    		$arr[] = $requestA[1];
    	}
    	$diff = array_diff( $parts,$arr );
    	if( isset( $urlsA['need_url'] ) && !empty( $diff ) ){
    		$need_url = $urlsA['need_url'];
    		$maybe_lang = implode( '',$diff );
    		$ids = array_keys( $pages );
    		foreach( $ids as $id ){
    			if( isset( $need_url[$id] ) ){
    				$url = $need_url[$id];
    				foreach( array( 'https://','http://','www.' ) as $search ){
    					$url = str_replace( $search,'',$url );
    				}
    				if( $url === $page_path ) return $id;
    			}
    		}
    	}
    	return false;
    }
    
    //Move FDP to the first position in the plugins array
    function eos_dp_unshift_fdp( $plugins ){
    	if( is_array( $plugins ) && in_array( 'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php',$plugins ) ){
    		array_unshift( $plugins,'freesoul-deactivate-plugins/freesoul-deactivate-plugins.php' );
    		$plugins = array_unique( $plugins );
    	}
    	return $plugins;
    }
    
    //Return array of $conditions
    function eos_dp_logged_user_conditions(){
    	return array(
    		array( 'role','hammer','Role' ),
    		array( 'capability','admin-tools','Capability' ),
    		array( 'username','businessperson','Username' ),
    		array( 'email','email','Email' ),
    		array( 'language','translation','Language' ),
    		array( 'registered_before','backup','Registered before' ),
    		array( 'registered_after','clock','Registered after' ),
    		array( 'has_bought','cart','Has bought' )
    	);
    }
    
    //Return $a or $b
    function eos_dp_or( $a,$b ){
    	return $a || $b;
    }
    
    //Return $a or $b
    function eos_dp_and( $a,$b ){
    	return $a && $b;
    }
    
    //Return not of $a
    function eos_dp_not( $a ){
    	return !$a;
    }
    
    function eos_dp_get_current_user() {
    		if( function_exists( 'wp_get_current_user' ) ) return wp_get_current_user(); //If the core function is availablle we use it and return
    		if( !defined( 'LOGGED_IN_COOKIE' ) || !isset( $_COOKIE[LOGGED_IN_COOKIE] ) ) return false;
    		$cookie = $_COOKIE[LOGGED_IN_COOKIE];
        if ( empty( $cookie ) ) {
            if ( empty( $_COOKIE[ LOGGED_IN_COOKIE] ) ) {
                return false;
            }
        }
        $cookie_elements = explode( '|', $cookie );
        if ( count( $cookie_elements ) !== 4 ) {
            return false;
        }
    		if( isset( $cookie_elements[0] ) && $cookie_elements[0] && '' !== $cookie_elements[0] ){
    			global $wpdb;
    			$user = $wpdb->get_row(
    				$wpdb->prepare(
    					"SELECT * FROM $wpdb->users WHERE user_login = %s LIMIT 1",
    					sanitize_user( $cookie_elements[0] )
    				)
    			);
    			if(
    				$user
    				&& is_object( $user )
    				&& isset( $user->user_login )
    				&& sanitize_user( $user->user_login ) === $user->user_login
    				&& isset( $user->user_email )
    				&& $user->user_email === sanitize_email( $user->user_email )
    				&& isset( $user->ID )
    				&& ''.absint( $user->ID ) === ''.$user->ID
    			){
    				return $user;
    			}
    		}
    		return false;
    }
    
    //Parse expression for logged-in user_status
    function eos_dp_parse_expression( $expression,$user ){
    	$f= substr( $expression,0,strpos( $expression,'(' ) );
    	$not = $f === 'not';
    	if( $not ){
    		$expression = rtrim( ltrim( $expression,'not(' ),')' );
    		$f= substr( $expression,0,strpos( $expression,'(' ) );
    	}
    	if( !in_array( $f,array( 'and','or' ) ) ){
    		$value = str_replace( ')','',str_replace( '(','',ltrim( $expression,$f ) ) );
    		switch( $f ){
    			case 'role':
    			case 'capability':
    				$roles = get_user_meta( $user->ID,'wp_capabilities' );
    				if( 'role' === $f ){
    					foreach( $roles as $roleA ){
    						if( in_array( $value,$roleA ) && $roleA[$value] ){
    							return true;
    						}
    					}
    				}
    				elseif( 'capability' === $f ){
    					$user_roles = eos_dp_get_option( 'wp_user_roles' );
    					$roleA = array_keys( $roles[0] );
    					$role = $roleA[0];
    					if( isset( $user_roles[$role] ) ){
    						$caps = $user_roles[$role];
    						if( isset( $caps['capabilities'] ) ){
    							$caps = $caps['capabilities'];
    							if( isset( $caps[$value] ) && $caps[$value] ){
    								return true;
    							}
    						}
    					}
    				}
    				break;
    			case 'username':
    				return !$not && strtolower( $user->user_login ) === strtolower( $value );
    				break;
    			case 'email':
    				return !$not && $user->user_email === $value;
    				break;
    			case 'language':
    				$user_locale = get_usermeta( $user->ID,'locale' );
    				return !$not && $user_locale && $user_locale === $value;
    				break;
    			case 'registered_before':
    				return !$not && strtotime( $user->user_registered ) < strtotime( $value );
    				break;
    			case 'registered_after':
    				return !$not && strtotime( $user->user_registered ) > strtotime( $value );
    				break;
    			case 'has_bought':
    				return !$not && eos_dp_user_has_bought( $user->ID );
    				break;
    		}
    	}
    }
    
    //Check if current user has ever bought anything with woocommerce
    function eos_dp_user_has_bought( $user_id ){
        $customer_orders = get_posts( array(
            'numberposts' => 1,
            'meta_key' => '_customer_user',
            'meta_value' => $user_id,
            'post_type' => 'shop_order',
            'post_status' => 'wc-completed',
            'fields' => 'ids',
        ) );
       return $customer_orders && count( $customer_orders ) > 0 ? true : false;
    }
    
    //Warn the user the mu-plugin is still installed
    function eos_dp_missing_fdp_notice(){
    	?>
    	<div class="notice notice-error">
    		<p style="font-size:20px;font-weight:bold">Freesoul Deactivate Plugins is not active, but its mu-plugin was not deleted.</p>
    		<p>Normally, when you deactivate FDP, it deletes its  mu-plugin file.</p>
    		<p>If you still have that file, it means you disabed FDP via FTP or something went wrong during the deactivation process.</p>
    		<?php if( current_user_can( 'manage_options') ){ ?>
    		<p style="font-size:20px;font-weight:bold">Delete the file <?php echo WPMU_PLUGIN_DIR.'/eos-deactivate-plugins.php'; ?></p>
    		<?php }else{ ?>
    		<p style="font-size:20px;font-weight:bold">Delete the file wp-content/mu-plugins/eos-deactivate-plugins.php</p>
    		<?php } ?>
    		<p>Then, FDP will not exist anymore in your installation.</p>
    	</div>
    	<?php
    }
    
    //Remove hooks
    function eos_dp_pro_remove_hooks(){
    	if( isset( $_GET['fdp-hooks'] ) ) return;
    	$fdp_pro_opts = eos_dp_get_option( 'eos_dp_pro_main' );
    	if( $fdp_pro_opts && isset( $fdp_pro_opts['fdp_hooks'] ) ){
    		$hooks = $fdp_pro_opts['fdp_hooks'];
    		if( !empty( $hooks ) ){
    			global $eos_page_id;
    			foreach( $hooks as $page_id => $hooks_arr ){
    				if( absint( $eos_page_id ) !== absint( $page_id ) ) continue;
    				$removed_hooks = json_decode( sanitize_text_field( stripslashes( $hooks_arr ) ),true );
    				foreach( $removed_hooks as $hook_name => $arr ){
    					foreach( $arr as $arr2 ){
    						$hook_function = $arr2[0];
    						$hook_priority = $arr2[1];
    						$remove = new FDP_pro_remove_hook( $hook_name,$hook_function,$hook_priority );
    					}
    				}
    			}
    		}
    	}
    }
    
    //Remove hook onject
    class FDP_pro_remove_hook {
      public $hook_name;
      public $hook_function;
      public $priority;
      function __construct( $hook_name,$hook_function,$priority ){
        $this->hook_name = $hook_name;
        $this->hook_function = $hook_function;
        $this->priority = $priority;
        foreach( array( 'muplugins_loaded','plugins_loaded','after_setup_theme','wp_footer' ) as $action ){
          add_action( $action,function(){
            $this->remove_hook_action();
          } );
        }
      }
      function remove_hook_action(){
        add_action( $this->hook_name,$this->remove_hook(),absint( $this->priority + 1 ) );
      }
      function remove_hook(){
        if( false !== strpos( $this->hook_function,'–>' ) ){
          $arr = explode( '–>',str_replace( ' ','',$this->hook_function ) );
    			if( class_exists( $arr[0] ) ){
    				$MethodChecker = new ReflectionMethod( $arr[0],$arr[1] );
    				if( $MethodChecker->isStatic() ){
    	      	remove_action( $this->hook_name,array( $arr[0],$arr[1] ),$this->priority );
    				}
    				else{
    					$class = new ReflectionClass( $arr[0] );
    					remove_action( $this->hook_name,array( $class,$arr[1] ),$this->priority );
    				}
    			}
        }
        else{
          remove_action( $this->hook_name,$this->hook_function,$this->priority );
        }
      }
    }
    
    //Get options by URL
    function eos_dp_get_opts_by_url( $url ){
    	if( false !== strpos( $url,basename( dirname( EOS_DP_MU_PLUGIN_DIR ) ) ) ) return false;
    	$url = str_replace( 'www.','',$url );
    	$arr = explode( '?',$url );
    	$upload_dirs = wp_upload_dir();
    	$path1 = ltrim( rtrim( $url,'/' ),'/' );
    	$arr = array(
    		array( $path1.'-mobile',eos_dp_is_mobile() ),
    		array( $path1,true )
    	);
    	foreach(  $arr as $arr2 ){
    		$path = $arr2[0];
    		$parts = explode( '/',$path );
    		$path = $upload_dirs['basedir'].'/FDP/fdp-single-options';
    		foreach( $parts as $part ){
    			$path .= '/'.substr( md5( $part ),0,8 );
    		}
    		if( $arr2[1] && file_exists( $path.'/opts.json' ) ){
    			return json_decode( stripslashes( sanitize_text_field( file_get_contents( $path.'/opts.json' ) ) ),true );
    		}
    	}
    	return false;
    }
    if( isset( $_REQUEST['eos_dp_pro_id'] ) ){
    	add_filter( 'show_admin_bar','__return_false',999999 );
    }
    
    • This reply was modified 2 years, 10 months ago by lgokul.
    • This reply was modified 2 years, 10 months ago by lgokul.
    • This reply was modified 2 years, 10 months ago by lgokul.
    • This reply was modified 2 years, 10 months ago by lgokul.
    • This reply was modified 2 years, 10 months ago by lgokul.
    Plugin Author Jose

    (@giuse)

    Hi @lgokul

    Your suggestions were always very useful and I remember you were interested in being a beta tester. Are you still interested?

    If so, just fill the form that you find here: https://josemortellaro.com/beta-testing/, and I will contact you for the details.

    Have a great day

    Jose

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Products Variations’ is closed to new replies.