Support » Plugin: Ad Injection » [proposal] Multi-Site mfunc compatibility

  • Andre Cimander

    (@andrecimander)


    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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author reviewmylife

    (@reviewmylife)

    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?

    Andre Cimander

    (@andrecimander)

    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;
    Handoko

    (@handoko-zhang)

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[proposal] Multi-Site mfunc compatibility’ is closed to new replies.