Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support angelagrey

    (@angelagrey)

    Hello,

    Please use the array below.
    !is_account_page()

    Best regards.

    I wrote a simple “Must Use” plugin to give fine-control of the (brilliant) CURCY plugin that you could also try. Works for me ??

    It removes the CURCY plugin from all pages except those that you specify, so I leave the plugin’s own filters alone. I tested that it removes CURCY from the /my-account/ area as I also use this.

    Here’s the self–documented code. It should work, I tested it quite deeply, but I only wrote it today so … give it a go if you need to ??
    Duncan

    <?php
    /*
    	Curcy filter
    	- Fine control over where the CURCY plugin is displayed.
    	- Removes from all pages/posts except those specified in line 25 below.
    	- Place this file in wp-content/mu-plugins 
    		-- The file can have any name, but curcy-control.php is good choice.			
    	- This code is based on the superb article from Kinsta below (due thanks and respect there!)
    
    	Ref: 
    		- https://kinsta.com/blog/disable-wordpress-plugins-loading/
    	
    	Last Update: 18.02.2022
    */
    
    /*	-- -- -- CONFIGURATION START -- -- --*/
    /*
    	Below you need to specify a list of URL paths where CURCY plugin SHOULD be loaded.
    	For example:
    		https://mysite.com/shop/ has allowed path of 'shop'
    		https://mysite.com/cart/ has allowed path of 'cart'
    		
    */	
    	$allowed_paths = array("shop","pricing","cart","basket","product","checkout");
    
    /* -- -- -- -- CONFIGURATION END -- -- -- */
    
    // Get path i.e. after web server name
    $current_page_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
    
    // Find out if user is accessing admin panel. If not, then can enable plugin filter safely.
    $is_admin= (strpos($current_page_path, 'wp-admin')) ? true: false;
    
    // If not admin panel ...
    if( !$is_admin ){
    	add_filter( 'option_active_plugins', function( $plugins ){
    		
    		// Get this variable defined outside the function.
    		global $current_page_path;
    
    		/*
    			Work out if on home page, which will not have anything after the server name. Little bit of a hack!:-)
    			- Not used in the code below but if you need CURCY on the home page, you might need to do some homepage detection.
    		*/	
    		$onhomepage = false;
    		if  ( ($current_page_path == '/') || ($current_page_path == '')){
    			$onhomepage = true;
    		}		
    
    		
    		/* 
    			- We create an array to holding active plugins that should be removed from the current post/page.
    			- This only holds the CURCY plugin but you can add more plugins to remove if desired.
    			
    			- Refer to the KINSTA article reference at the start of this code to find out, easily, how 
    				to get the plugin path and name you see below.
    		*/
    		$plugins_to_remove = array();
    		$plugins_to_remove [] =  "woo-multi-currency/woo-multi-currency.php";
    
    		// Set a default flag to remove the CURCY plugin. 
    		$remove_CURCY = true; 
    
    		/*
    			Now cycle through allowed_paths and see if any match the current page. 
    			If so, set the 'remove_CURCY' flag to false and break out the allowed_paths loop.
    		*/	
    		global $allowed_paths;	// Pick up the paths from outside this function, set at the start.
    		foreach ($allowed_paths as $allowed_path) {
    			// Syntax: if (some condition) value if true : value if false
    			$is_allowed_page = (strpos($current_page_path, $allowed_path)) ? true: false; 
    			if ($is_allowed_page){
    				$remove_CURCY = false;
    				break;
    			} 
    		  }
    		
    		/* Remove CURCY (or not :-) */		
    		if  ( $remove_CURCY == true ) {
    			$plugins = array_diff( $plugins, $plugins_to_remove);	
    		}
    	
    
    	// Finally return the filtered list of active plugins for this page/post, with CURCY removed if desired.
    	return $plugins;
    
    	} );
    
    }
    
    ?>
    
    • This reply was modified 2 years, 9 months ago by Duncan. Reason: Code update
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude from my account page’ is closed to new replies.