Last active
March 11, 2019 15:54
-
-
Save csalzano/621deacc33f2482da205f294b445485a to your computer and use it in GitHub Desktop.
A plugin that provides license keys to the EDD SL Updates on Multisite plugin for Inventory Presser add-ons
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 | |
defined( 'ABSPATH' ) OR exit; | |
/** | |
* Plugin Name: Make Licenses Available for Updates on Multisite | |
* Plugin URI: https://gist.github.com/csalzano/621deacc33f2482da205f294b445485a | |
* Description: A plugin that provides license keys to the EDD SL Updates on Multisite plugin for Inventory Presser add-ons | |
* Version: 1.0.0 | |
* Author: Corey Salzano | |
* Author URI: https://coreysalzano.com/ | |
* Text Domain: invp-make-licenses-available | |
* Domain Path: /languages | |
* License: GPLv2 or later | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
*/ | |
class Make_Licenses_Available_For_Updates{ | |
function populate_license_key( $args, $site_id ) { | |
$option = get_blog_option( $site_id, $this->find_option_name() ); | |
if( ! empty( $option['license_key'] ) ) { | |
$args['license'] = $option['license_key']; | |
} | |
return $args; | |
} | |
/** | |
* Extract the plugin slug from current_filter() and return the name of the | |
* option I'm using to store that plugins options and, most importantly, the | |
* license key. | |
* | |
* @return string The name of the option where plugin settings are stored | |
*/ | |
function find_option_name() { | |
/** | |
* Current_filter() is something like | |
* `edd_sl_multisite_updater_divert-contact-form-7-leads-to-friday-systems` | |
*/ | |
switch( substr( current_filter(), 25 ) ) { | |
case 'divert-contact-form-7-leads-to-friday-systems': | |
return 'divert_cf7_settings'; | |
case 'make-list-widget': | |
return 'make_list_widget_settings'; | |
case 'payment-calculator-widget': | |
return 'payment_calculator_widget_settings'; | |
case 'similar-vehicles-widget': | |
return 'similar_vehicles_widget_settings'; | |
case 'taxonomy-drop-down-search-widget': | |
return 'invp_drop_down_widget_settings'; | |
case 'taxonomy-filters-widget': | |
return 'invp_filters_widget_settings'; | |
} | |
return ''; | |
} | |
function hooks() { | |
add_action( 'init', 'wp_clean_plugins_cache' ); | |
add_filter( 'edd_sl_multisite_updater_divert-contact-form-7-leads-to-friday-systems', array( $this, 'populate_license_key' ), 10, 2 ); | |
add_filter( 'edd_sl_multisite_updater_make-list-widget', array( $this, 'populate_license_key' ), 10, 2 ); | |
add_filter( 'edd_sl_multisite_updater_payment-calculator-widget', array( $this, 'populate_license_key' ), 10, 2 ); | |
add_filter( 'edd_sl_multisite_updater_similar-vehicles-widget', array( $this, 'populate_license_key' ), 10, 2 ); | |
add_filter( 'edd_sl_multisite_updater_taxonomy-drop-down-search-widget', array( $this, 'populate_license_key' ), 10, 2 ); | |
add_filter( 'edd_sl_multisite_updater_taxonomy-filters-widget', array( $this, 'populate_license_key' ), 10, 2 ); | |
} | |
} | |
$make_licenses_available_239480723478234 = new Make_Licenses_Available_For_Updates(); | |
$make_licenses_available_239480723478234->hooks(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment