Last active
December 19, 2015 10:19
-
-
Save jgalea/5939198 to your computer and use it in GitHub Desktop.
Revisions
-
jgalea revised this gist
Jul 6, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php add_action( 'admin_init', 'wprss_et_activate_deactivate_license' ); /** * Handles the activation/deactivation process -
jgalea created this gist
Jul 6, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ 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( 'edd_sample_nonce', 'edd_sample_nonce' ) ) return; // get out if we didn't click the Activate/Deactivate button // retrieve the license from the database $license = trim( get_option( 'wprss_et_license_key' ) ); if ( isset( $_POST['wprss_et_license_activate'] ) ) { // data to send in our API request $api_params = array( 'edd_action'=> 'activate_license', 'license' => $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' => $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" update_option( 'wprss_et_license_status', $license_data->license ); } }