• Resolved makmerghen

    (@makmerghen)


    I used this code to stopped Ultimate member plugin script in all pages that don’t have ultimate member pages
    this code cause issue with beaver builder
    when try to add any bb block it appear empty without any text or tool only empty tabs
    so please check and advise

    /*
      Plugin Name: Ultimate Member - Maybe load assets
      Description: Remove CSS and JS on non UM pages
      Version: 1.0.2
      Author: Ultimate Member
      Author URI: https://ultimatemember.com/
     */
    
    add_action( 'wp_print_footer_scripts', 'um_remove_scripts_and_styles', 9 );
    add_action( 'wp_print_scripts', 'um_remove_scripts_and_styles', 9 );
    add_action( 'wp_print_styles', 'um_remove_scripts_and_styles', 9 );
    add_action( 'dynamic_sidebar', 'um_remove_scripts_and_styles_widget' );
    
    /**
     * Maybe remove Ultimate Member CSS and JS
     * @global WP_Post $post
     * @global bool $um_load_assets
     * @global WP_Scripts $wp_scripts
     * @global WP_Styles $wp_styles
     * @return NULL
     */
    function um_remove_scripts_and_styles() {
    	global $post, $um_load_assets, $wp_scripts, $wp_styles;
    
    	// Set here IDs of the pages, that use Ultimate Member scripts and styles
    	$um_posts = array(0);
    
    	// Set here URLs of the pages, that use Ultimate Member scripts and styles
    	$um_urls = array(
    		'/account/',
    		'/activity/',
    		'/groups/',
    		'/login/',
    		'/logout/',
    		'/members/',
    		'/my-groups/',
    		'/password-reset/',
    		'/register/',
    		'/user/',
    	);
    
    	if ( is_admin() || is_ultimatemember() ) {
    		return;
    	}
    	
    	$REQUEST_URI = $_SERVER['REQUEST_URI'];
    	if ( in_array( $REQUEST_URI, $um_urls ) ) {
    		return;
    	}
    	foreach ( $um_urls as $key => $um_url ) {
    		if ( strpos( $REQUEST_URI, $um_url ) !== FALSE ) {
    			return;
    		}
    	}
    
    	if ( !empty( $um_load_assets ) ) {
    		return;
    	}
    	
    	if ( isset( $post ) && is_a( $post, 'WP_Post' ) ) {
    		if ( in_array( $post->ID, $um_posts ) ) {
    			return;
    		}
    		if ( strpos( $post->post_content, '[ultimatemember_' ) !== FALSE ) {
    			return;
    		}
    		if ( strpos( $post->post_content, '[ultimatemember form_id' ) !== FALSE ) {
    			return;
    		}
    	}
    
    	if ( empty( $wp_scripts->queue ) || empty( $wp_styles->queue ) ) {
    		return;
    	}
    
    	foreach ( $wp_scripts->queue as $key => $script ) {
    		if ( strpos( $script, 'um_' ) === 0 || strpos( $script, 'um-' ) === 0 || strpos( $wp_scripts->registered[$script]->src, '/ultimate-member/assets/' ) !== FALSE ) {
    			unset( $wp_scripts->queue[$key] );
    		}
    	}
    
    	foreach ( $wp_styles->queue as $key => $style ) {
    		if ( strpos( $style, 'um_' ) === 0 || strpos( $style, 'um-' ) === 0 || strpos( $wp_styles->registered[$style]->src, '/ultimate-member/assets/' ) !== FALSE ) {
    			unset( $wp_styles->queue[$key] );
    		}
    	}
    }
    
    /**
     * Check whether Ultimate Member widget was used
     * @param array $widget
     */
    function um_remove_scripts_and_styles_widget( $widget ) {
    	if ( strpos( $widget['id'], 'um_' ) === 0 || strpos( $widget['id'], 'um-' ) === 0 ) {
    		$GLOBALS['um_load_assets'] = TRUE;
    	}
    }

    best regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Jamie

    (@codente)

    Was this plugin provided to you by the Ultimate Member team?

    I just tested it and it didn’t seem to create any problems for me in Beaver Builder.

    But I was testing with only Beaver Builder, Ultimate Member & then this plugin active.

    Have you tried to test with only those 3 plugins active?

    Thread Starter makmerghen

    (@makmerghen)

    yes its exist in their website
    I have a lot of plugins but I disabled all to know where is the issue I found it only come from this snippets
    regards

    Plugin Contributor Jamie

    (@codente)

    Unfortunately, we are not able to replicate it so we can’t look into it further. What theme are you using?

    Thread Starter makmerghen

    (@makmerghen)

    astra theme

    Plugin Contributor Jamie

    (@codente)

    Free Astra or Astra Pro? If Pro, what parts of the Pro version do you have enabled?

    Thread Starter makmerghen

    (@makmerghen)

    Colors & Background
    Typography
    Spacing
    Blog Pro
    Page Headers
    Custom Layouts
    Scroll To Top
    WooCommerce
    Ultimate Addons for Gutenberg

    but want to say that I disabled astra pro but also have same issue
    regards

    Plugin Contributor Jamie

    (@codente)

    Sorry for the delay in follow-up. I tried with Astra free and couldn’t replicate the issue using the above code.

    Thread Starter makmerghen

    (@makmerghen)

    Dear @codente thank you very much for the trying
    don’t worry I will disable the code
    thanks a lot for your care
    best regards and happy new year

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘this code do some issue’ is closed to new replies.