Plugin Directory

Changeset 1811729


Ignore:
Timestamp:
01/30/2018 09:57:24 AM (8 years ago)
Author:
nicolaspro14
Message:

1.1.0 release

Location:
clipr/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • clipr/trunk/clipr.php

    r1805048 r1811729  
    44Plugin Name: Clipr
    55Description: Mobile experience that converts. Connect your Woocommerce e-shop with Clipr platform now !
    6 Version: 1.0.3
     6Version: 1.1.0
    77Author: Clipr
    88Author URI: https://clipr.co
     
    1111*/
    1212
    13 define( 'CLIPR__VERSION',            '1.0.3' );
     13define( 'CLIPR__VERSION',            '1.1.0' );
    1414define( 'CLIPR__PLUGIN_DIR',         __DIR__ );
    1515define( 'CLIPR__PLUGIN_FILE',        __FILE__ );
     
    4040                // Add products to cart then redirect to checkout
    4141                $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);
    4344                break;
    4445            case "productData":
     
    6061
    6162    $cnv_cap_id = isset($_GET['cnv_cap_id']) ? htmlspecialchars( $_GET['cnv_cap_id'] ) : "";
    62 
    6363    if (!empty($cnv_cap_id)) {
    6464
     
    7171    }
    7272}
     73
     74/*
     75 * Add script for embedded clip support
     76 */
     77
     78// API Key
     79add_action ( 'wp_head', 'clipr_js_variables' );
     80function 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
     91add_action( 'wp_enqueue_scripts', 'wpb_adding_clipr_scripts' );
     92function 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
     116add_action( 'admin_menu', 'Clipr_add_admin_menu' );
     117function Clipr_add_admin_menu(  ) {
     118    add_options_page( 'Clipr', 'Clipr', 'manage_options', 'clipr', 'Clipr_options_page' );
     119}
     120
     121// Second step : Content template
     122function 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
     141add_action( 'admin_init', 'Clipr_settings_init' );
     142function 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  
    77 */
    88
    9 function cp_conv_cart_builder($cnv_cart_id, $env) {
     9function cp_conv_cart_builder($cnv_cart_id, $env, $redirect_url) {
    1010
    1111    global $woocommerce;
     
    2121
    2222        // 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
    2425
    2526
     
    3940    }
    4041
    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    }
    4348    exit;
    4449}
  • clipr/trunk/readme.txt

    r1805045 r1811729  
    55Tested up to: 4.9
    66Requires PHP : 5.4
    7 Stable tag: 1.0.3
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5353= 1.0.3 =
    5454* 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.