Created
May 29, 2016 18:34
-
-
Save fergbrain/de837016491186c543e7a2f7503c2899 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Subscribe2 HTML License Propagater | |
Plugin URI: http://semperplugins.com/plugins/subscribe2-html/ | |
Description: Propagates a Subscribe2 HTML License Key over a Multisite Install | |
Version: 1.0a | |
Author: Matthew Robinson | |
Author URI: http://semperplugins.com/plugins/subscribe2-html/ | |
Licence: GPL3 | |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2387904 | |
*/ | |
define( 'S2LICENCEKEY', '' ); | |
register_activation_hook(__FILE__, 'propagate_s2_init'); | |
add_action('propagate_s2_cron', 'propagate_s2_license'); | |
function propagate_s2_init() { | |
$propagate_scheduled = wp_next_scheduled('propagate_s2_cron'); | |
// add the cron event on upgrade if it does not exist | |
if ( $propagate_scheduled === false ) { | |
wp_schedule_event(current_time('timestamp'), 'every12hours', 'propagate_s2_cron'); | |
} | |
} // end propagate_s2_init() | |
function propagate_s2_license() { | |
global $wpdb, $mysubscribe2; | |
if ( !$mysubscribe2->s2_mu ) { return; } | |
$blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}"); | |
if ( !function_exists('is_plugin_active') ) { | |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
} | |
foreach ( $blogs as $blog ) { | |
switch_to_blog($blog); | |
if ( is_plugin_active('subscribe2_html/subscribe2.php') ) { | |
$subscribe2_options = get_option('subscribe2_options'); | |
} | |
$subscribe2_options['s2_license_key'] = S2LICENCEKEY; | |
update_option('subscribe2_options', $subscribe2_options); | |
restore_current_blog(); | |
} | |
} // end propagate_s2_license() | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment