• Resolved Imageavobelle

    (@avobelle)


    Hi,

    I was using the following code in functions.php and it worked fine:

    if(isset($plugin_dpc) && is_object($plugin_dpc)){
    remove_action(‘wp_head’, array($plugin_dpc->getModuleInstance(‘professional_sharing’), ‘action_printOpenGraphMeta’), 10);
    remove_action(‘wp_head’, array($plugin_dpc->getModuleInstance(‘basic_metadata’), ‘action_printOpenGraphMeta’), 10);
    }

    After putting it in your plugin it is no longer working (no error or anything, just no impact). I also tried the approach mentioned here, but without success: https://wordpress.org/support/topic/code-working-in-functions-php-but-not-in-code-snippets-plugin/

    Any ideas?

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author ImageShea Bunge

    (@bungeshea)

    When you use remove_action code, generally you need to wrap it in some sort of late hook:

    add_action( 'after_setup_theme', function () {
    	if ( isset( $plugin_dpc ) && is_object( $plugin_dpc ) ) {
    		remove_action( 'wp_head', array( $plugin_dpc->getModuleInstance( 'professional_sharing' ), 'action_printOpenGraphMeta' ), 10 );
    		remove_action( 'wp_head', array( $plugin_dpc->getModuleInstance( 'basic_metadata' ), 'action_printOpenGraphMeta' ), 10 );
    	}
    }, 100 );

    Otherwise you’ll try to remove actions that don’t exist yet, as snippets run before theme code.

Viewing 1 replies (of 1 total)

The topic ‘Snippen working in functions.php but not in Code Snippets’ is closed to new replies.