WordPress.org

Ready to get started?Download WordPress

Forums

Ad Injection
[proposal] Multi-Site mfunc compatibility (4 posts)

  1. Andre Cimander
    Member
    Posted 1 year ago #

    Hello everybody,

    [edit]
    still need to fix a fresh-caching issue - working on it.

    [edit2] disregard that, just a stupid me who apparently can't use vim x) Anyway: This hack comes without any warrants, so you are on your own if you run into trouble :)
    [/edit]

    since our team wanted this plugin for one of our multi-site installations, I was given permission to add the missing mfunc compatibility. It's not 100% clean, but it works and should be easily incorporated by reviewmyfile (who actually pointed out the to-dos here: https://wordpress.org/support/topic/plugin-ad-injection-multi-site-problems?replies=7).

    Enjoy :-)

    ====

    In ad-injection.php find&replace:

    1)

    define('ADINJ_AD_PATH', WP_PLUGIN_DIR.'/ad-injection-data');

    if (function_exists('is_multisite') && is_multisite()) {
    	define('ADINJ_AD_PATH', WP_PLUGIN_DIR.'/ad-injection-data/'.$GLOBALS['current_blog']->blog_id);
    } else {
    	define('ADINJ_AD_PATH', WP_PLUGIN_DIR.'/ad-injection-data');
    }

    2)

    <!--Ad Injection mfunc mode ad include code--><!--mfunc include_once('$plugin_dir/adshow.php') --><?php include_once('$plugin_dir/adshow.php'); ?><!--/mfunc-->

    <!--Ad Injection mfunc mode ad include code--><!--mfunc ".'$GLOBALS["current_blog_id"]'." = '".$GLOBALS['current_blog']->blog_id."'; include_once('$plugin_dir/adshow.php') --><?php ".'$GLOBALS["current_blog_id"]'." = '".$GLOBALS['current_blog']->blog_id."'; include_once('$plugin_dir/adshow.php'); ?><!--/mfunc-->

    ===

    In adshow.php find&replace:

    $ad_path = dirname($plugin_dir).'/ad-injection-data/'.$adfile;

    if (function_exists('is_multisite') && is_multisite()) {
        $blog_id = if(isset($GLOBALS['current_blog_id']))?$GLOBALS['current_blog_id']:$GLOBALS['current_blog']->blog_id;
            $ad_path = dirname($plugin_dir).'/ad-injection-data/'.$blog_id.'/'.$adfile;
        } else {
            $ad_path = dirname($plugin_dir).'/ad-injection-data/'.$adfile;
    }

    http://wordpress.org/extend/plugins/ad-injection/

  2. reviewmylife
    Member
    Plugin Author

    Posted 1 year ago #

    Hi AndreCimander,

    Thanks a lot for sharing that. I'll make a note of your changes, and hopefully one day I'll get time to test them, and then add them to the plugin.

    One question. In section 2) did you mean to put each of the adshow.php lines twice?

  3. Andre Cimander
    Member
    Posted 1 year ago #

    Sorry for the delayed response, the last days were a little too busy (as always...)

    I wasn't too sure about the mfunc syntax, I think it wasn't working without both includes, but I might be wrong here - since I had limited time I though better safe than sorry :)

    More important, I deployed the changes on another install today and forgot to commit a fix in the posted version:

    $blog_id = if(isset($GLOBALS['current_blog_id']))?$GLOBALS['current_blog_id']:$GLOBALS['current_blog']->blog_id;

    should be

    $blog_id = (isset($GLOBALS['current_blog_id']))?$GLOBALS['current_blog_id']:$GLOBALS['current_blog']->blog_id;
  4. Handoko
    Member
    Posted 1 year ago #

    Any luck for the multisite support?

    I really like this plugin, and I'm going to build a multisite environment, it will be great if I can still use it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.