Files
Testing/tbb/wp-content/plugins/wp-rss-excerpts-thumbnails/includes/licensing.php

77 lines
3.3 KiB
PHP
Raw Normal View History

2026-11-17 16:15:01 -05:00
<?php
// retrieve our license key from the DB
$licenses = get_option( 'wprss_settings_license_keys' );
$et_license_key = ( isset( $licenses['et_license_key'] ) ) ? $licenses['et_license_key'] : FALSE;
// setup the updater
if ( !class_exists( 'EDD_SL_Plugin_Updater' ) )
// load our custom updater
include ( WPRSS_ET_INC . 'libraries/EDD_licensing/EDD_SL_Plugin_Updater.php' );
$edd_updater = new EDD_SL_Plugin_Updater( WPRSS_ET_SL_STORE_URL, WPRSS_ET_PATH, array(
'version' => WPRSS_ET_VERSION, // current version number
'license' => $et_license_key, // license key (used get_option above to retrieve from DB)
'item_name' => WPRSS_ET_SL_ITEM_NAME, // name of this plugin
'author' => 'Jean Galea' // author of this plugin
)
);
add_action( 'admin_init', 'wprss_et_activate_deactivate_license' );
/**
* Handles the activation/deactivation process
*
* @since 1.1
*/
function wprss_et_activate_deactivate_license() {
// listen for our activate button to be clicked
if( isset( $_POST['wprss_et_license_activate'] ) || isset( $_POST['wprss_et_license_deactivate'] ) ) {
// run a quick security check
if( ! check_admin_referer( 'wprss_et_license_nonce', 'wprss_et_license_nonce' ) )
return; // get out if we didn't click the Activate/Deactivate button
// retrieve the license keys and statuses from the database
$license_keys = get_option( 'wprss_settings_license_keys' );
$et_license = trim( $license_keys['et_license_key'] );
$license_statuses = get_option( 'wprss_settings_license_statuses' );
if ( isset( $_POST['wprss_et_license_activate'] ) ) {
// data to send in our API request
$api_params = array(
'edd_action'=> 'activate_license',
'license' => $et_license,
'item_name' => urlencode( WPRSS_ET_SL_ITEM_NAME ) // the name of our product in EDD
);
}
else if ( isset( $_POST['wprss_et_license_deactivate'] ) ) {
// data to send in our API request
$api_params = array(
'edd_action'=> 'deactivate_license',
'license' => $et_license,
'item_name' => urlencode( WPRSS_ET_SL_ITEM_NAME ) // the name of our product in EDD
);
}
// Call the custom API.
$response = wp_remote_get( add_query_arg( $api_params, WPRSS_ET_SL_STORE_URL ) );
// make sure the response came back okay
if ( is_wp_error( $response ) )
return false;
// decode the license data
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
// $license_data->license will be either "active" or "inactive"
//wp_die(var_dump($license_data));
$license_statuses['et_license_status'] = $license_data->license;
update_option( 'wprss_settings_license_statuses', $license_statuses );
}
}