﻿

			
	

		Version ); ?>

		Description; ?>
		
		
		
			
				
				&lt;a href=&quot;/changelog.txt" target="_blank">
				
				
				
				
				
					
					
					
				
			
		
		
				
		
		
			
			
			

				
						
					
						
						
						
						
							
						
					
					
					
						
						
						
						
							&lt;a href=&quot;" class="button button-secondary">
						
					
					
					
						
						
						
		
							
							
							
								
										
										
											
										
										
											&lt;input id=&quot;courage_pro_license_key&quot; name=&quot;courage_pro_license_key&quot; type=&quot;text&quot; class=&quot;regular-text&quot; value=&quot;" />
											
										
									
									&lt;?php if( $license !== false &amp;&amp; $license  '' ) : ?>
										
											
											
												
											
											
												
												
													
													
												
													
													
													&lt;input type=&quot;submit&quot; class=&quot;button-secondary&quot; name=&quot;courage_pro_license_deactivate&quot; value=&quot;"/>
												
												
													
													&lt;input type=&quot;submit&quot; class=&quot;button-secondary&quot; name=&quot;courage_pro_license_activate&quot; value=&quot;"/>
												
												

											
										
										
									
									
									
								
								
							
						
						
						
					

				
				
				
					
					&lt;img src=&quot;/screenshot.png" />
					
				
				
			
			
		
		
		
		
		
			
			&lt;?php printf( __( &#039;Courage is proudly brought to you by %1s. If you like this theme, %2s :) &#039;, &#039;courage-pro&#039; ), 
				&#039;ThemeZee',
				'' . __( 'rate it', 'courage-pro' ) . ''); ?>
			
		
		
	
	

 'activate_license', 
			'license' 	=> $license, 
			'item_name' => urlencode( COURAGE_PRO_NAME ), // the name of our product in EDD
			'url'       => home_url()
		);
		
		// Call the custom API.
		$response = wp_remote_get( add_query_arg( $api_params, 'http://themezee.com' ), array( 'timeout' => 15, 'sslverify' => false ) );

		// 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 "valid" or "invalid"
		$theme_options['license_status'] = $license_data->license;
		
		// Update Theme Options
		update_option( 'courage_theme_options', $theme_options );

	}
}


// Deactivate License Key
add_action('admin_init', 'courage_pro_deactivate_license');

function courage_pro_deactivate_license() {

	// listen for our activate button to be clicked
	if( isset( $_POST['courage_pro_license_deactivate'] ) ) {

		// run a quick security check 
	 	if( ! check_admin_referer( 'courage_pro_nonce', 'courage_pro_nonce' ) ) 	
			return; // get out if we didn't click the Activate button
		
		// Get Theme Options from Database
		$theme_options = courage_pro_theme_options();
		
		// retrieve the license from the database
		$license = trim( get_option( 'courage_pro_license_key' ) );
			

		// data to send in our API request
		$api_params = array( 
			'edd_action'=> 'deactivate_license', 
			'license' 	=> $license, 
			'item_name' => urlencode( COURAGE_PRO_NAME ), // the name of our product in EDD
			'url'       => home_url()
		);
		
		// Call the custom API.
		$response = wp_remote_get( add_query_arg( $api_params, 'http://themezee.com' ), array( 'timeout' => 15, 'sslverify' => false ) );

		// 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 "deactivated" or "failed"
		if( $license_data->license == 'deactivated' )
			$theme_options['license_status'] = false;
			
		// Update Theme Options
		update_option( 'courage_theme_options', $theme_options );

	}
}


// Check for License Status
function courage_pro_check_license() {

	global $wp_version;

	$license = trim( get_option( 'courage_pro_license_key' ) );
		
	$api_params = array( 
		'edd_action' => 'check_license', 
		'license' => $license, 
		'item_name' => urlencode( COURAGE_PRO_NAME ),
		'url'       => home_url()
	);

	// Call the custom API.
	$response = wp_remote_get( add_query_arg( $api_params, 'http://themezee.com' ), array( 'timeout' => 15, 'sslverify' => false ) );


	if ( is_wp_error( $response ) )
		return false;

	$license_data = json_decode( wp_remote_retrieve_body( $response ) );

	if( $license_data->license == 'valid' ) {
		echo 'valid'; exit;
		// this license is still valid
	} else {
		echo 'invalid'; exit;
		// this license is no longer valid
	}
}


// Add CSS for Theme Info Panel
remove_action('admin_enqueue_scripts', 'courage_theme_info_page_css');
add_action('admin_enqueue_scripts', 'courage_pro_theme_info_page_css');

function courage_pro_theme_info_page_css($hook) { 

	// Load styles and scripts only on theme info page
	if ( 'appearance_page_courage' != $hook ) {
		return;
	}
	
	// Embed theme info css style
	wp_enqueue_style( 'courage-pro-theme-info-css', plugins_url('/css/theme-info.css', dirname(dirname(__FILE__)) ), array(), COURAGE_PRO_VERSION );

}


?>