• Hi,

    We are happily using the Contact Form 7 Signature Addon Plugin. This is done on 3 pages of our website.

    I noticed it seems to upload on all website pages.

    I would like this plugin to load, or possibly even Activate only on three certain pages, which I may identify, for example according to a fetching as below:

    global $post;
    
    if ($post->post_type == 'page'){
    	if ($post->ID == "2808") {
                   include ...
    

    And, at the same time possibly deactivate or have the plugin, not upload as usual, where that would have mean uploading on all website pages.

    I am now reading a possible general explanation on:

    https://kinsta.com/blog/disable-wordpress-plugins-loading/

    https://developer.wordpress.org/plugins/hooks/filters/

    May I ask, how could this goal be achieved?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ziegel

    (@ziegel)

    I have generated a solution according to the first above link.

    1. Create a MU-PLUGIN in the folder: wp-content/mu-plugins of the name active-plugins.php
    <?php
    /**
     * @package active-plugins
     * @version 1.0
     *
     * Plugin Name: Active Plugins
     * Plugin URI: http://wordpress.org/extend/plugins/#
     * Description: This is a development plugin 
     * Author: Example
     * Version: 1.0
     * Author URI: https://example.com/
     */
    
    
    // shortcode to list active plugins 
    add_shortcode( 'activeplugins', function(){
    	
    	$active_plugins = get_option( 'active_plugins' );
    	$plugins = "";
    	if( count( $active_plugins ) > 0 ){
    		$plugins = "<ul>";
    		foreach ( $active_plugins as $plugin ) {
    			$plugins .= "<li>" . $plugin . "</li>";
    		}
    		$plugins .= "</ul>";
    	}
    	return $plugins;
    });
    
    $request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
    
    $is_admin = strpos( $request_uri, '/wp-admin/' );
    
    if( false === $is_admin ){
    	add_filter( 'option_active_plugins', function( $plugins ){
    
    		global $request_uri;
    
    		$is_regs_form = strpos( $request_uri, '/registration-form/' );
    		$is_tran_form = strpos( $request_uri, '/transaction-form/' );
    		$is_auth_form = strpos( $request_uri, '/signature-form/' );		
    			
    		$myplugins = array( 
    			"contact-form-7-signature-addon/signature.php" ,
    			"contact-form-cfdb7/contact-form-cfdb-7.php" ,
    			"cf7-conditional-fields/contact-form-7-conditional-fields.php"
    		);
    		if( (false ===  $is_regs_form) && (false === $is_tran_form) && (false === $is_auth_form ) ){
    			$plugins = array_diff( $plugins, $myplugins );
    		}
    		return $plugins;
    	} );
    }
    1. Then via ACF create a text field of different names for each form page (theme).
    2. Go to the WordPress pages of the forms and in the newly created separate fields (different name for each form) add the short code snippet: [activeplugins]
    3. Clear cache, and test to see when you upload a form page, that under browser INSPECTION -> Networks (refresh when you switch to Networks), you can see an element with the name beginning with sign*…
    4. Resources are not seen on other pages.
    Thread Starter ziegel

    (@ziegel)

    Looks good!

    • This reply was modified 1 year, 5 months ago by ziegel.
    Thread Starter ziegel

    (@ziegel)

    This technique only seemed to work for me. Some functions.php tasks stopped working.

    Charles

    (@charlesrodmell)

    There’s a Freesoul plugin that lets you global disable plugins and then allow them on certain posts etc. I use it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Loading the Contact Form 7 Signature Addon Plugin Only on certain WordPress page’ is closed to new replies.