Skip to content
This repository has been archived by the owner on Nov 11, 2017. It is now read-only.

Commit

Permalink
WordPress Mu
Browse files Browse the repository at this point in the history
 * child blogs have the plugin enabled by default (no fear for activation, as it's already active on the main one)
 * child blogs are configured by default

git-svn-id: http://plugins.svn.wordpress.org/amazon-widgets-shortcodes/trunk@187917 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information
oncletom committed Dec 29, 2009
1 parent fdd09dd commit b3fbfca
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 16 deletions.
3 changes: 2 additions & 1 deletion amazon-widgets-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
$class = 'AmazonWidgetsShortcodesAdmin';
require_once(AWS_PLUGIN_BASEPATH.'/lib/'.$class.'.class.php');
add_action('admin_menu', array($class, 'setupAdminMenu'));
add_action('wpmu_new_blog', array($class, 'setupNewMuBlog'), 20, 2);
add_filter('whitelist_options', array($class, 'setupOptionsWhitelist'));

if (get_option('awshortcode_inline_documentation'))
Expand Down Expand Up @@ -72,7 +73,7 @@
* We enqueue Amazon JS at the bottom
* Why the bottom ? Because it is recommended for external scripts
* And it is one ;-)
*
*
* @see http://developer.yahoo.net/blog/archives/2007/07/high_performanc_5.html
*/
if (get_option('awshortcode_context_links'))
Expand Down
15 changes: 8 additions & 7 deletions lib/AmazonWidgetsShortcodePlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AmazonWidgetsShortCodePlugin
{
/**
* Register main functions for plugin's sake
*
*
* @static
* @author oncletom
* @version 1.0
Expand All @@ -25,19 +25,20 @@ function bootstrap($plugin_home_path)
add_filter('plugin_action_links_'.$pluginfile, array($class, 'executeFilterPluginActionLinks'));
define('AWS_PLUGIN_BASEPATH', dirname($filename));
define('AWS_PLUGIN_PLUGINFILE', $pluginfile);
}
/**
* Returns plugin location
*
*
* In case of symlink, it assumes you linked it with its original plugin name
* eg: `ln -s /path/to/plugins/amazon-widgets-shortcodes /real/path/to/aws-plugin`
*
*
* Array returned contains 3 fields:
* - fixed filename (for relocated wordpress ABSPATH ; like SVN install/symlinked plugin)
* - relative path to i18n folder (from abspath ; will fail on 2.7 if WP is relocated)
* - plugin relative path to i18n folder (from plugin dir) (supported since WP 2.7)
*
*
* @static
* @author oncletom
* @version 2.1
Expand Down Expand Up @@ -70,7 +71,7 @@ function getLocation($filepath)
/**
* Plugin activation processing
*
*
* @static
* @author oncletom
* @version 2.0
Expand Down Expand Up @@ -109,7 +110,7 @@ function executeActivation()
/**
* Filter action plugin action links to add context links
*
*
* @author oncletom
* @version 1.0
* @since 1.4
Expand All @@ -123,7 +124,7 @@ function executeFilterPluginActionLinks($action_links)

/**
* Register shortcode class & syntax
*
*
* @author oncletom
* @version 1.0
* @since 1.3
Expand Down
52 changes: 45 additions & 7 deletions lib/AmazonWidgetsShortcodesAdmin.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Admin functions
*
*
* @author oncletom
* @version 1.0
* @since 1.0 alpha 2
Expand All @@ -10,7 +10,7 @@ class AmazonWidgetsShortcodesAdmin
{
/**
* Display tags help
*
*
* @author oncletom
* @since 1.0 beta 1
* @return null
Expand All @@ -22,7 +22,7 @@ function displayDocumentation()

/**
* Display options page
*
*
* @author oncletom
* @since 1.0 alpha 2
* @return null
Expand Down Expand Up @@ -58,7 +58,7 @@ function printJavaScript()

/**
* Show a notice to the user if (s)he has not setup the plugin yet
*
*
* @author oncletom
* @since 1.0 alpha 2
* @return null
Expand Down Expand Up @@ -89,10 +89,10 @@ function printStylesheet()

/**
* Setup admin pages
*
*
* Includes menu
* Hook scripts & stylesheets
*
*
* @author oncletom
* @version 1.1
* @since 1.0 alpha 2
Expand All @@ -118,9 +118,47 @@ function setupAdminMenu()
add_action('admin_print_scripts-'.$options_page, array('AmazonWidgetsShortcodesAdmin', 'printJavascript'));
}

/**
* Copying master informations and activate plugin
*
* @since 1.5.3
* @author oncletom
* @param $blog_id integer
* @param $user_id integer
*/
function setupNewMuBlog($blog_id, $user_id)
{
$dashblog = get_dashboard_blog();
$copy_options = array('tracking_id', 'region');
$copied_values = array();

if (!(int)$blog_id || (int)$blog_id === (int)$dashblog->blog_id)
{
return false;
}

/*
* Options to copy
*/
foreach ($copy_options as $option_id)
{
$copied_values['awshortcode_'.$option_id] = get_option('awshortcode_'.$option_id);
}

switch_to_blog($blog_id);

activate_plugin(AWS_PLUGIN_PLUGINFILE);
foreach ($copied_values as $option_id => $option_value)
{
update_option($option_id, $option_value);
}

restore_current_blog();
}

/**
* Add whitelist options for WPMU
*
*
* @see http://wordpress.org/support/topic/191773#post-876524
* @see http://mu.wordpress.org/forums/topic.php?id=9210
* @author oncletom
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: oncletom
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=752034
Tags: amazon, affiliate, shortcode, shortcodes, monetization, context, links, product, preview, carrousel, documentation, plugin, slideshow, admin, post, page, tinymce, wysiwyg, wpmu
Requires at least: 2.5
Tested up to: 2.8.x
Tested up to: 2.9.x
Stable tag: 1.5.2


Expand Down Expand Up @@ -86,6 +86,10 @@ Please notice that this forthcoming version **will require at least**:
* PHP 5.1.2 (so that the `spl_autoload` function is available)
* WordPress 2.8

= Version 1.5.3 =
* wordpress-mu: by default, all new blogs have the plugin enabled
* wordpress-mu: by default, a new blog import your Tracking ID and region

= Version 1.5.2 =
* i18n: added Russian translation
* i18n: added Uzbek translation
Expand Down

0 comments on commit b3fbfca

Please sign in to comment.