• Resolved fusionplanet

    (@fusionplanet)


    I’m working on a blog were members can add posts via the front-end (not admin).

    From that page, members can click on a preview button to see their post. This clicks to a preview page. Then they have two options: click on a edit or publish button.

    Unfortunately, when I activate the plugin the preview page breaks and no buttons are displayed even though no Insert Post Ads content is shown either.

    I’ve inherited this project from a previous developer. The preview page calls:

    the_content();
    
    //and below it display the buttons
    
    if ( is_user_logged_in() && is_user_post_author($current_user->ID,$post) && !in_array($post->post_status, array('future','publish')) ){
      // display buttons
    }

    Is there a way to stop/disable IPA from doing anything on this preview page?

    https://ww.wp.xz.cn/plugins/insert-post-ads/

Viewing 1 replies (of 1 total)
  • Thread Starter fusionplanet

    (@fusionplanet)

    Answering my own question. Please see below for someone who may encounter this issue.

    Create an MU plugin:

    add_filter( 'option_active_plugins', 'disable_ipa_plugin' );
    
    function disable_ipa_plugin($plugins){
    	if(strpos($_SERVER['REQUEST_URI'], '/path-to-page-to-not-run-plugin/') !== FALSE AND strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === FALSE ) {
            $key = array_search( 'insert-post-ads/insert-post-ads.php' , $plugins );
            if ( false !== $key ) {
                unset( $plugins[$key] );
            }
        }
        return $plugins;
    }

    credits where credits are due: Modified from Kamil Grzegorczyk solution.

Viewing 1 replies (of 1 total)

The topic ‘Breaking post previews’ is closed to new replies.