Plugin Directory

Changeset 1602135


Ignore:
Timestamp:
02/23/2017 01:29:08 PM (9 years ago)
Author:
ishaijaffe
Message:

version 2.4
fix subdir links in wordpress,
change namespace of storage,
registration nice page

Location:
bablic
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • bablic/trunk/Bablic.php

    r1529702 r1602135  
    44class wp_store {
    55    public function get($key){
    6         return get_option($key);
     6        $value = get_option('bablic.'.$key);
     7        if(empty($value)){
     8            $value = get_option($key);
     9            if(!empty($value)){
     10                update_option('bablic.'.$key, $value);
     11                delete_option($key);
     12            }
     13        }
     14        return $value;
    715    }
    816    public function set($key, $value){
    9         update_option($key, $value);
     17        update_option('bablic.'.$key, $value);
    1018    }
    1119}
     
    1624Plugin URI: https://www.bablic.com/docs#wordpress'
    1725Description: Integrates your site with Bablic localization cloud service.
    18 Version: 2.3
     26Version: 2.4
    1927Author: Ishai Jaffe
    2028Author URI: https://www.bablic.com
     
    3341    var $bablic_version = '3.3';
    3442    var $query_var = 'bablic_locale';
    35     var $bablic_plugin_version = '2.2.5';
     43    var $bablic_plugin_version = '2.4.0';
    3644   
    3745   
     
    295303
    296304    function addAdminScripts($hook_suffix){
    297         wp_enqueue_style('bablic-admin-css','//cdn2.bablic.com/addons/wp2.css');
    298         wp_enqueue_script('bablic-admin-sdk','//cdn2.bablic.com/addons/wp2.js');
     305        wp_enqueue_style('bablic-admin-css','//cdn2.bablic.com/addons/wp24.css');
     306        wp_enqueue_script('bablic-admin-sdk','//cdn2.bablic.com/addons/wp24.js');
    299307    } 
    300308   
     
    326334        $site = $this->sdk->get_site();
    327335    ?>
    328         <div class="bablic-wp">
    329             <h2>Bablic</h2>
    330             <label>
     336        <div class="bablic-wp tw-bs" id="bablic_all">
     337             
     338            <label id="bablic-subdir">
    331339                <input type="checkbox" id="bablic_dont_permalink" <?php checked( 'no', $options['dont_permalink'], true ) ?>  > Generate sub-directory urls (for example: /es/, /fr/about, ...)
    332340            </label>
    333             <div style="display:none;">
    334                 <?php if(isset($options['uninstalled']) && $options['uninstalled'] == '1') echo '<input type="hidden" id="bablic_was_uninstalled" />'  ?>
    335                 <input type="hidden" value="<?php echo $site['site_id'] ?>" id="bablic_site_id" />
    336                 <input type="hidden" value="<?php echo $site['access_token'] ?>" id="bablic_access_token" />
    337                 <textarea  id="bablic_item_meta"><?php echo $site['meta'] ?></textarea>
    338                 <input type="hidden" value="<?php echo ($site['trial_started'] ? '1' : '') ?>" id="bablic_trial" />
    339             </div>
    340             <div id="bablic_form"></div>
     341
     342        <div style="display:none;">
     343            <?php if(isset($options['uninstalled']) && $options['uninstalled'] == '1') echo '<input type="hidden" id="bablic_was_uninstalled" />'  ?>
     344            <input type="hidden" value="<?php echo $site['site_id'] ?>" id="bablic_site_id" />
     345            <input type="hidden" value="<?php echo $site['access_token'] ?>" id="bablic_access_token" />
     346            <textarea  id="bablic_item_meta"><?php echo $site['meta'] ?></textarea>
     347            <input type="hidden" value="<?php echo ($site['trial_started'] ? '1' : '') ?>" id="bablic_trial" />
    341348        </div>
    342 
     349        <div id="bablic-register-step">
     350        <div class='panel bablic_info'>
     351          <img class='row' src="https://s.bablic.com/images/4/assets/logo-onwhite.png" alt="Bablic Website Translation"/>
     352            <div class='info_container row'>
     353                    <h2 class='header row'> Do it yourself website translation - no programming required! </h2>
     354                    <h4 class='subheader row'>That's how it works: </h4>
     355                <div class='left_side col-xs-12 col-md-6'>
     356                    <ol>
     357                        <li> <span> Select a language & instantly preview your translated site using machine translation </span> </li>
     358                        <li> <span> Edit/improve the machine translation or order professional human translation with just a click </span> </li>
     359                        <li> <span> Easily replace images & fix style/CSS issues in a user-friendly, in-context, visual editor </span> </li>
     360                        <li> <span> Customize the language selector color, position and style to match your Prestashop site's look and feel </span> </li>
     361                        <li> <span> Click Publish when ready to go live </span> </li>
     362                    </ol>
     363                <div id='bablic_form'> </div>
     364                </div>
     365                <div class='right_side col-xs-12 col-md-6'>
     366                    <div><span></span> Reach new customers globally in a matter of minutes & increase sales</div>
     367                    <div><span></span> Start ranking on leading search engines for your new languages with Bablic's SEO-friendly solution</div>
     368                    <div><span></span> Immediately compete with the big guys using your fully localized Prestashop store</div>
     369                    <div><span></span> Free dedicated support on all plans</div>
     370                </div>
     371            </div>
     372                <div class="clear"></div>
     373        </div>
     374<div class="panel">                                         
     375    <div class="panel-heading bablic">
     376                                                                For more information visit <a href="https://www.bablic.com">Bablic.com</a> or contact us at <a href="mailto: [email protected]">[email protected]</a>
     377    </div>
     378        <div class="clear"></div>
     379</div>
     380  </div>
     381        </div>
    343382        <?php
    344383       
  • bablic/trunk/sdk.php

    r1529702 r1602135  
    5959    private $version = '';
    6060    private $meta = '';
    61     private $trial_started = false;
     61    public $trial_started = false;
    6262    private $_body = '';
    6363    private $pos = 0;
    6464    private $timestamp = 0;
     65    private $use_snippet_url = false;
    6566
    6667    function __construct($options) {
     
    9495            }
    9596        }
     97        if(isset($options['use_snippet_url']))
     98            $this->use_snippet_url = true;
    9699    }
    97100
     
    158161        $payload = array(
    159162            'url' => $options['site_url'],
    160             'email'=> $options['email'],
    161             'original' => $options['original_locale'],
    162             'callback' => $options['callback'],
     163            'email'=> isset($options['email']) ? $options['email'] : '',
     164            'original' => isset($options['original_locale']) ? $options['original_locale'] : '',
     165            'callback' => isset($options['callback']) ? $options['callback'] : '',
    163166        );
    164167        $ch = curl_init($url);
     
    177180        $this->access_token = $result['access_token'];
    178181        $this->site_id = $result['id'];
    179         $this->snippet = $result['snippet'];
     182        $this->snippet = $this->use_snippet_url ? $result['snippetURL'] : $result['snippet'];
    180183        $this->version = $result['version'];
    181184        $this->trial_started = false;
     
    203206            $this->access_token = $result['access_token'];
    204207        $this->site_id = $result['id'];
    205         $this->snippet = $result['snippet'];
     208        $this->snippet = $this->use_snippet_url ? $result['snippetURL'] : $result['snippet'];
    206209        $this->version = $result['version'];
    207210        $this->trial_started = $result['trialStarted'];
     
    223226        array_map('unlink', glob("$folder/*"));
    224227    }
    225 
     228   
     229    public function get_meta() {
     230      return $this->meta;
     231    }
    226232    public function get_site(){
    227233        return array (
     
    343349
    344350    public function get_link($locale, $url) {
     351        if($url[0] != '/' && $url[0] != 'h')
     352            return $url;
    345353        $parsed = parse_url($url);
    346354        $scheme = isset($parsed['scheme']) ? $parsed['scheme'] . '://' : '';
     
    388396                $locale_keys = $meta['localeKeys'];
    389397                $locale_regex = "(" . implode("|",$locale_keys) . ")";
    390                 $path = preg_replace('/^'.preg_quote($this->subdir_base,'/').'\/'.$locale_regex.'\//','/',$path);
     398                if($this->subdir_base != "")
     399                     $path = preg_replace('/^'.preg_quote($this->subdir_base,'/').'\//','/',$path);
     400                $path =  preg_replace('/^'.$locale_regex.'\//','/',$path);
    391401                $prefix = $locale == $meta['original'] ? '' : '/' . $locale;
    392402                return $scheme.$host.$port.$this->subdir_base.$prefix.$path.$query.$fragment;
     
    453463            case 'subdir':
    454464                $path = $parsed_url['path'];
    455                 preg_match("/^".preg_quote($this->subdir_base,'/')."(\/(\w\w(_\w\w)?))(?:\/|$)/", $path, $matches);
     465                preg_match("/^(?:".preg_quote($this->subdir_base,'/').")?(\/(\w\w(_\w\w)?))(?:\/|$)/", $path, $matches);
    456466                if ($matches) return $matches[2];
    457467                if ($from_cookie)
Note: See TracChangeset for help on using the changeset viewer.