- <?php
- function android_ecommerce_admin_notices(){
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
- if ( is_plugin_active('woocommerce/woocommerce.php') == false ) {
- echo '<div id="message" class="error fade"><p style="line-height: 150%">';
- _e('<strong>VC App Settings & Checkout</strong></a> requires the WooCommerce to be activated. Please <a target="_blank" href="plugin-install.php?tab=plugin-information&plugin=woocommerce&TB_iframe=true&width=600&height=550">install / Activate</a> first.', 'VC App');
- echo '</p></div>';
- return;
- }
- if ( is_plugin_active( 'json-api/json-api.php' ) == false ) {
- echo '<div id="message" class="error fade"><p style="line-height: 150%">';
- _e('<strong>VC App Settings & Checkout</strong></a> requires the JSON API plugin to be activated. Please <a target="_blank" href="plugin-install.php?tab=plugin-information&plugin=json-api&TB_iframe=true&width=600&height=550">install / Activate </a> first.', 'VC App');
- echo '</p></div>';
- return;
- }
- }
- function android_ecommerce_add_app_admin_menu() {
- add_menu_page( __( 'Android Ecommerce Banner Settings' ), __( 'Android Ecommerce Banner Settings' ), 'manage_options', 'android-banner-settings', 'android_ecommerce_app_banner_setting', '' , 64 );
- }
- function android_ecommerce_add_app_admin_menu_activation() {
- add_menu_page( __( 'Android Ecommerce Activate' ), __( 'Android Ecommerce Activate' ), 'manage_options', 'android-banner-activate', 'android_ecommerce_activate', '' , 64 );
- }
- function android_curl( $url ) {
- if ( empty( $url) ) return false;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_VERBOSE, true);
- $result_cal = curl_exec($ch);
- curl_close($ch);
- return $result_cal;
- }
- function android_ecommerce_activate(){ ?>
- <div class="wrap">
- <style>
- #poststuff .inside {
- margin: 6px 0 0;
- }
- #newImageButton { background:#ccc; box-shadow:none; }
- .stuffbox label {
- line-height: 20px;
- font-size: 12px;
- text-align: left;
- padding: 0 15px 10px;
- font-weight: 700;
- }
- .inside input,
- .inside select {
- width: 50%;
- height: 35px;
- box-shadow: none;
- background: #fff;
- }
- #poststuff {
- padding-top: 10px;
- width: 100%;
- padding: 0 10px;
- }
- #poststuff .stuffbox>h3,
- #poststuff h2,
- #poststuff h3.hndle {
- font-size: 14px;
- padding: 8px 12px;
- margin: 0;
- line-height: 1.4;
- }
- .postbox,
- .stuffbox {
- margin-bottom: 20px;
- padding: 0;
- line-height: 1;
- background: #fff;
- padding: 8px 0 0 0;
- }
- #poststuff {
- width: 70%;
- background: #fff;
- padding: 20px;
- }
- #poststuff h4 {
- font-size: 18px;
- }
- .msg {
- color: #ff0000;
- text-align: center;
- font-size: 12px;
- line-height: 20px;
- }
- .bps {padding:2px 20px!important; height:34px!important;}
- @media only screen and (max-device-width : 768px) {
- #poststuff {width: 94%; padding: 20px 3%;}
- .inside input, .inside select { width: 100%; }
- }
- </style>
- <?php
- $api_url = 'http://api.themes-coder.com';
- if(isset($_REQUEST['purchase_code']) && $_REQUEST['purchase_code'] != ""){
- $purchase_code = $_REQUEST['purchase_code'];
- $purchase_code = urlencode( $purchase_code );
- $current_site_url = get_site_url();
- $url = $api_url . '/api.php?code=' . $purchase_code."&url=".$current_site_url;
- $response = android_curl( $url );
- $response = json_decode( $response, true );
- var_dump($response);
- if(isset($response['error']) && $response['error'] == '404'){
- //$msg = $response['description'];
- update_option('android_ecommerce_purchase_code' , $purchase_code);
- update_option('android_ecommerce_plugin_active' , 'active');
- update_option('android_ecommerce_purchase_detail' , $response);
- echo "<script>window.location.href='admin.php?page=android-ecommerce'</script>";
- }elseif(isset($response['purchase_code']) && $response['purchase_count'] >= 1 && $response['buyer'] != "" ){
- update_option('android_ecommerce_purchase_code' , $purchase_code);
- update_option('android_ecommerce_plugin_active' , 'active');
- update_option('android_ecommerce_purchase_detail' , $response);
- echo "<script>window.location.href='admin.php?page=android-ecommerce'</script>";
- }
- }
- if(get_option('android_ecommerce_plugin_active') == "active" && get_option('android_ecommerce_purchase_code') != ""){
- $android_ecommerce_purchase_code = get_option('android_ecommerce_purchase_code');
- $android_ecommerce_plugin_active = get_option('android_ecommerce_plugin_active');
- }
- ?>
- <h1 class="wp-heading-inline">Plugin Validation</h1>
- <?php if(isset($msg) && $msg != ""){ ?>
- <div id="message" class="notice notice-error is-dismissible">
- <p><?php echo $msg; ?>. </p>
- </div>
- <?php } ?>
- <div class="poststuff" id="poststuff">
- <form method="post" action="" id="plugin_validate" name="plugin_validate">
- <div class="stuffbox">
- <label for="name" class="col-sm-2 col-md-3 control-label">Please Enter Purchase Code </label>
- <div class="inside">
- <input required class="form-control field-validate" id="purchase_code" name="purchase_code" type="text" value="<?php if(isset($android_ecommerce_purchase_code) && $android_ecommerce_purchase_code != ""){ echo $android_ecommerce_purchase_code; } ?>">
- <br />
- <span class="help-block" style="font-weight: normal;font-size: 11px;margin-bottom: 0;">Enter Product Purchase Code.</span> </div>
- </div>
- <?php wp_nonce_field('action_settings_add_edit','add_edit_nonce'); ?>
- <div>
- <?php if(!isset($android_ecommerce_purchase_code) && $android_ecommerce_purchase_code == ""){ ?>
- <button type="submit" name="submit" id="btnsave" value="Submit" class="button-primary bps">Submit</button>
-
- <button type="button" name="button" onclick="location.href='admin.php?page=android-ecommerce-activate'" id="btnsave" value="true" class="button-primary bps">Cancel</button>
- <?php } else {?>
- <a href="admin.php?page=android-ecommerce" id="btnsave" class="button-primary">Settings</a>
- <?php } ?>
- </div>
- </form>
- </div>
- </div>
- <?php }
- function android_ecommerce_wp_rest_allow_all_cors() {
- remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
- add_filter( 'rest_pre_serve_request', function( $value ) {
- header("Cache-Control: no-cache, must-revalidate");
- header('Access-Control-Allow-Origin: *');
- header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
- header('Access-Control-Allow-Headers: Content-Type, X-Auth-Token, Origin, Authorization');
- return $value;
- });
- }
- function android_ecommerce_my_app_hook() {
- if(isset($_GET['mob']) && $_GET['mob'] == true ){?>
- <style>
- <?php if(isset($_GET['platform']) && $_GET['platform'] == 'ios' ) {
- echo "body{padding-top:50px;}";
- }
- global $wpdb;
- $all_settings = get_option( 'android_ecommerce_app_settings');
- $custom_css_for_checkout = $all_settings['custom_css_for_checkout'];
- echo $custom_css_for_checkout;
- ?>
- </style>
- <?php if(isset($_GET['one_page']) && $_GET['one_page'] == 2 ){?>
- <script>
- jQuery( document ).ready( readyFn );
- function readyFn( jQuery ) { jQuery("#place_order").trigger('click'); }
- </script>
- <style>
- body , .checkout {
- display: none;
- }
- </style>
- <?php }} add_filter( 'woocommerce_ship_to_different_address_checked', '__return_true'); } ?>