Changeset 1811729
- Timestamp:
- 01/30/2018 09:57:24 AM (8 years ago)
- Location:
- clipr/trunk
- Files:
-
- 3 edited
-
clipr.php (modified) (5 diffs)
-
inc/functions.cart-builder.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
clipr/trunk/clipr.php
r1805048 r1811729 4 4 Plugin Name: Clipr 5 5 Description: Mobile experience that converts. Connect your Woocommerce e-shop with Clipr platform now ! 6 Version: 1. 0.36 Version: 1.1.0 7 7 Author: Clipr 8 8 Author URI: https://clipr.co … … 11 11 */ 12 12 13 define( 'CLIPR__VERSION', '1. 0.3' );13 define( 'CLIPR__VERSION', '1.1.0' ); 14 14 define( 'CLIPR__PLUGIN_DIR', __DIR__ ); 15 15 define( 'CLIPR__PLUGIN_FILE', __FILE__ ); … … 40 40 // Add products to cart then redirect to checkout 41 41 $cnv_cart_id = isset($_GET['cnv_cart']) ? htmlspecialchars($_GET['cnv_cart']) : ""; 42 cp_conv_cart_builder($cnv_cart_id,$env); 42 $redirect_url = isset($_GET['redirect_url']) ? htmlspecialchars($_GET['redirect_url']) : ""; 43 cp_conv_cart_builder($cnv_cart_id,$env, $redirect_url); 43 44 break; 44 45 case "productData": … … 60 61 61 62 $cnv_cap_id = isset($_GET['cnv_cap_id']) ? htmlspecialchars( $_GET['cnv_cap_id'] ) : ""; 62 63 63 if (!empty($cnv_cap_id)) { 64 64 … … 71 71 } 72 72 } 73 74 /* 75 * Add script for embedded clip support 76 */ 77 78 // API Key 79 add_action ( 'wp_head', 'clipr_js_variables' ); 80 function clipr_js_variables(){ 81 82 $cliprSettings = get_option( 'CLIP_EMBEDDED' ); 83 $API_KEY = isset($cliprSettings['API_KEY']) ? $cliprSettings['API_KEY'] : ""; 84 ?> 85 <script type="text/javascript"> 86 var CLIP_EMBEDDED_API_KEY = "<?php echo($API_KEY); ?>"; 87 </script><?php 88 } 89 90 // Framework 91 add_action( 'wp_enqueue_scripts', 'wpb_adding_clipr_scripts' ); 92 function wpb_adding_clipr_scripts() { 93 94 // Path to script ? 95 $domain = "https://app.clipr.co"; 96 $clipr_env = isset($_GET['clipr_env']) ? htmlspecialchars($_GET['clipr_env']) : ""; 97 if ($clipr_env != null && $clipr_env == "staging") { 98 $domain = "https://test.clipr.co"; 99 } 100 101 // Version number ? Force refresh once per day 102 $version = date('Y.m.d'); 103 104 $scriptPath = $domain."/bundles/cnvpublicdisplay/js/clip-embedded.min.js?v=".$version; 105 106 // Add to page 107 wp_register_script('clipr_script', $scriptPath); 108 wp_enqueue_script('clipr_script'); 109 } 110 111 /** 112 * SETTINGS PAGE 113 */ 114 115 // First step : add submenu "Clipr" into "Settings" menu 116 add_action( 'admin_menu', 'Clipr_add_admin_menu' ); 117 function Clipr_add_admin_menu( ) { 118 add_options_page( 'Clipr', 'Clipr', 'manage_options', 'clipr', 'Clipr_options_page' ); 119 } 120 121 // Second step : Content template 122 function Clipr_options_page( ) { 123 124 ?> 125 <form <?php echo("action='options.php'"); ?> method='post'> 126 127 <h2>Clipr configuration page</h2> 128 129 <?php 130 settings_fields( 'CLIPR_SETTINGS' ); 131 do_settings_sections( 'Clipr_settings_page' ); 132 submit_button(); 133 ?> 134 135 136 </form> 137 <?php 138 } 139 140 // Third step : init data form 141 add_action( 'admin_init', 'Clipr_settings_init' ); 142 function Clipr_settings_init( ) { 143 144 // Group name, Option name, Callback to ensure right data type 145 register_setting('CLIPR_SETTINGS', 'CLIP_EMBEDDED', 'CLIP_EMBEDDED_callback' ); 146 function CLIP_EMBEDDED_callback($input) { 147 148 return strval($input); 149 } 150 151 // Prepare fields for our form 152 153 // Add section 154 155 add_settings_section( 156 'Clipr_first_section', // Section id 157 '', // Section Title 158 'Clipr_first_section_description', // Section description callback 159 'Clipr_settings_page' // Page name 160 ); 161 162 function Clipr_first_section_description( ) { 163 echo 'Please enter the API Key provided by your Clip configuration page.'; 164 } 165 166 // Add field 167 168 add_settings_field( 169 'API_KEY', // Field id 170 'API Key', // Field title 171 'Clipr_text_field_render', // Field render callback 172 'Clipr_settings_page', // page name 173 'Clipr_first_section' // Section id 174 ); 175 176 function Clipr_text_field_render( ) { 177 178 // Display saved key if any 179 $cliprSettings = get_option( 'CLIP_EMBEDDED' ); 180 ?> 181 <input type='text' name='CLIP_EMBEDDED[API_KEY]' value='<?php echo $cliprSettings['API_KEY']; ?>'> 182 <?php 183 } 184 } 185 186 ?> -
clipr/trunk/inc/functions.cart-builder.php
r1782872 r1811729 7 7 */ 8 8 9 function cp_conv_cart_builder($cnv_cart_id, $env ) {9 function cp_conv_cart_builder($cnv_cart_id, $env, $redirect_url) { 10 10 11 11 global $woocommerce; … … 21 21 22 22 // Create a new cart 23 $woocommerce->cart->empty_cart(); 23 // $woocommerce->cart->empty_cart(); // Better keep old cart content here (especially for embedded clip) 24 24 25 25 26 … … 39 40 } 40 41 41 // Redirect to checkout page 42 wp_redirect($woocommerce->cart->get_checkout_url()); 42 // Finally, redirect user to checkout (or product page if asked for) 43 if (!empty($redirect_url)) { 44 wp_redirect($redirect_url); 45 } else { 46 wp_redirect($woocommerce->cart->get_checkout_url()); 47 } 43 48 exit; 44 49 } -
clipr/trunk/readme.txt
r1805045 r1811729 5 5 Tested up to: 4.9 6 6 Requires PHP : 5.4 7 Stable tag: 1. 0.37 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 53 53 = 1.0.3 = 54 54 * Bug fix : support attribute not showing as variation 55 56 = 1.1.0 = 57 * Now supporting clip embedded in product page
Note: See TracChangeset
for help on using the changeset viewer.