Plugin Directory

Changeset 1097525


Ignore:
Timestamp:
02/23/2015 08:14:25 PM (11 years ago)
Author:
ShopSite
Message:

Renamed options and variables to minimize potential conflict with other plugins. Minor UI changes. Delete data when deleting plugin.

Location:
shopsite-plugin/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • shopsite-plugin/trunk/populate_products.js

    r1085770 r1097525  
    1212    async: true,
    1313    type: 'POST',
    14     data: {ss_action:'get_data', shopsite_url:shopsite_url, id_list: id_list, identifier: identifier},
     14    data: {ss_action:'get_data', shopsite_url:ss_shopsite_url, id_list: ss_id_list, identifier: ss_identifier},
    1515    url: ss_path + "shopsite.php",
    1616    success: function(data) {
     
    2323            var id = rfc3986EncodeURIComponent(pair[0]);
    2424            //alert(id);
    25             for (j in product_map[id]) {
     25            for (j in ss_product_map[id]) {
    2626              if (jQuery.isNumeric(j))
    27                 $('#product_' + product_map[id][j]).html(pair[1]);
     27                $('#product_' + ss_product_map[id][j]).html(pair[1]);
    2828            }
    2929          }
  • shopsite-plugin/trunk/readme.txt

    r1085770 r1097525  
    33Tags: e-commerce, shopping, shopsite
    44Requires at least: 3.2.0
    5 Tested up to: 4.1
     5Tested up to: 4.1.1
    66Stable tag: trunk
    77
     
    2626
    2727== Changelog ==
     28= 1.5.1 =
     29* Renamed options and variables to minimize potential conflict with other plugins. Minor UI changes. Delete data when deleting plugin.
     30
    2831= 1.5.0 =
    2932* Changed UI for selecting a product.
  • shopsite-plugin/trunk/search_products.js

    r1079131 r1097525  
    121121 
    122122  var last_search_string = "";
    123   if (remembered_search_string == "*")
     123  if (ss_remembered_search_string == "*")
    124124    search_products('*', 'true');
    125125  else {
    126     last_search_string = remembered_search_string;
     126    last_search_string = ss_remembered_search_string;
    127127    $('#search').trigger('click');
    128128    $('#search_button').trigger('click');
  • shopsite-plugin/trunk/shopsite.css

    r1079131 r1097525  
    141141}
    142142
     143div.outdated {
     144  height: 80px;
     145  padding-top: 20px;
     146}
     147
    143148div.wp_product img {
    144149  max-width:130px;
     
    195200}
    196201
     202div#extra_message {
     203  margin-top: 5px;
     204  margin-bottom: -10px;
     205  margin-left: auto;
     206  margin-right: auto;
     207  text-align: center;
     208}
     209
    197210div#insert_button {
    198211  background-color: #2ea2cc;
    199212  border: 1px solid #0074a2;
    200213  color: white;
    201   width: 150px;
     214  width: 300px;
    202215  border-radius: 3px;
    203216  font-size: 13px;
  • shopsite-plugin/trunk/shopsite.php

    r1079131 r1097525  
    22/**
    33 * @package ShopSite
    4  * @version 1.5.0
     4 * @version 1.5.1
    55 */
    66/*
     
    99Description: ShopSite plugin to put products into your WordPress blog
    1010Author: ShopSite
    11 Version: 1.5.0
     11Version: 1.5.1
    1212Author URI: http://shopsite.com/
    1313*/
     14
     15
     16
    1417if (isset($_REQUEST['ss_action'])) {
    1518  //taken from http://plugins.svn.wordpress.org/limelight-networks/trunk/limelight_popup.php
     
    3942$wp_id;
    4043
     44
     45register_uninstall_hook(__FILE__, 'on_uninstall');
     46
    4147register_activation_hook( __FILE__, 'on_activate' );
    42 
    4348function on_activate() {
    44   add_option('Activated_Plugin','Plugin-Slug');
     49  add_option('ss_just_activated','yes');
     50}
     51
     52function on_uninstall() {
     53  $option_list = array('shopsite_url', 'config_dump', 'config_type', 'clientid', 'secretkey', 'code', 'authorizationurl', 'identifier', 'remember_search', 'remembered_search_string', 'media_url', 'version');
     54  foreach ($option_list as $option) {
     55    delete_option('ss_'.$option);
     56  }
    4557}
    4658
    4759function load_plugin() {
    48     if ( is_admin() && get_option( 'Activated_Plugin' ) == 'Plugin-Slug' ) {
    49         delete_option( 'Activated_Plugin' );
     60    $version = "1.5.1";
     61    if ( is_admin() ) { 
     62      $running_version = get_option('ss_version');
     63      if (!$running_version)
     64        $running_version = "1";
    5065       
    51         $shopsite_url = get_option('shopsite_url');
     66      update_option('ss_version', $version);
     67      if ($running_version < "1.5.1") {
     68       
     69        //updating, rename to ss_ options to prevent conflicts with other plugins
     70        {
     71          $option_list = array('shopsite_url', 'config_dump', 'config_type', 'clientid', 'secretkey', 'code', 'authorizationurl', 'identifier', 'remember_search', 'remembered_search_string', 'media_url');
     72          foreach ($option_list as $option) {
     73            $option_val = get_option($option);
     74            if ($option_val) {
     75              update_option('ss_'.$option, $option_val);
     76              delete_option($option);
     77            } else
     78              add_option('ss_'+$option);
     79          }
     80        }
     81      }
     82     
     83      if (get_option('ss_just_activated')) {
     84        delete_option( 'ss_just_activated' );
     85        $shopsite_url = get_option('ss_shopsite_url');
    5286        if ($shopsite_url == false || strlen($shopsite_url) < 10) {
    5387          add_action( 'admin_head', 'start_tutorial');
    5488        }
    55         /*else {
    56           $media_url = get_option('media_url');
    57           if ($media_url == false || strlen($media_url) < 10)
    58             add_action( 'admin_head', 'request_output_url');
    59         }*/
     89      }
     90
     91     
    6092    }
    6193}
     
    107139  $testing = false;
    108140  $state = 'new_config';
    109   add_option('config_dump');
    110  
    111   add_option('config_type');
    112 
    113     add_option('shopsite_url');
    114   add_option('clientid');
    115   add_option('secretkey');
    116   add_option('code');
    117   add_option('authorizationurl');
    118  
    119   add_option('identifier');
    120  
    121   add_option('remember_search');
    122   add_option('remembered_search_string');
     141 
     142  /*$option_list = array('shopsite_url', 'config_dump', 'config_type', 'clientid', 'secretkey', 'code', 'authorizationurl', 'identifier', 'remember_search', 'remembered_search_string', 'media_url');
     143  foreach ($option_list as $option) {
     144    echo "<br>$option  |".get_option($option)."| |".get_option('ss_'.$option)."|";
     145  }*/
    123146 
    124147 
     
    128151    //echo "<script>alert('$config_type');</script>";
    129152
    130     update_option('config_type', $config_type);
     153    update_option('ss_config_type', $config_type);
    131154    $state = 'settings_saved';
    132155   
    133156    if ($config_type == 'ss_12') {
    134       update_option('config_dump', trim($_REQUEST['config_dump']));
     157      update_option('ss_config_dump', trim($_REQUEST['config_dump']));
    135158     
    136159     
     
    138161      $decoded = explode('^',$decoded);
    139162     
    140       update_option('clientid', trim($decoded[0]));
    141       update_option('secretkey', trim($decoded[1]));
    142       update_option('code', trim($decoded[2]));
    143       update_option('authorizationurl', trim($decoded[3]));
    144       update_option('shopsite_url', trim($decoded[4]));
     163      update_option('ss_clientid', trim($decoded[0]));
     164      update_option('ss_secretkey', trim($decoded[1]));
     165      update_option('ss_code', trim($decoded[2]));
     166      update_option('ss_authorizationurl', trim($decoded[3]));
     167      update_option('ss_shopsite_url', trim($decoded[4]));
    145168    } else {
    146169     
    147       $clientid = trim($_REQUEST['clientid']); update_option('clientid', $clientid);
    148       $secretkey = trim($_REQUEST['secretkey']); update_option('secretkey', $secretkey);
    149       $code = trim($_REQUEST['code']); update_option('code', $code);
    150       $authorizationurl = trim($_REQUEST['authorizationurl']); update_option('authorizationurl', $authorizationurl);
    151       $shopsite_url = trim($_REQUEST['shopsite_url']); update_option('shopsite_url', $shopsite_url);
     170      $clientid = trim($_REQUEST['clientid']); update_option('ss_clientid', $clientid);
     171      $secretkey = trim($_REQUEST['secretkey']); update_option('ss_secretkey', $secretkey);
     172      $code = trim($_REQUEST['code']); update_option('ss_code', $code);
     173      $authorizationurl = trim($_REQUEST['authorizationurl']); update_option('ss_authorizationurl', $authorizationurl);
     174      $shopsite_url = trim($_REQUEST['shopsite_url']); update_option('ss_shopsite_url', $shopsite_url);
    152175      $config_dump = base64_encode("$clientid^$secretkey^$code^$authorizationurl^$shopsite_url");
    153       update_option('config_dump', $config_dump);
     176      update_option('ss_config_dump', $config_dump);
    154177    }
    155178  }
     
    161184  if (isset($_REQUEST['authorizationurl'])) update_option('authorizationurl', trim($_REQUEST['authorizationurl']));*/
    162185 
    163   if (isset($_REQUEST['identifier'])) update_option('identifier', trim($_REQUEST['identifier']));
     186  if (isset($_REQUEST['identifier'])) update_option('ss_identifier', trim($_REQUEST['identifier']));
    164187  if (isset($_REQUEST['test'])) {
    165188    $testing = true;
     
    168191  }
    169192 
    170   $config_type = get_option('config_type');
     193  $config_type = get_option('ss_config_type');
    171194  if (strlen($config_type) == 0)
    172195    $config_type = 'ss_12';
    173     $config_dump = get_option('config_dump');
    174     $shopsite_url = get_option('shopsite_url');
    175   $clientid = get_option('clientid');
    176   $secretkey = get_option('secretkey');
    177   $code = get_option('code');
    178   $authorizationurl = get_option('authorizationurl');
    179  
    180  
    181   $identifier = get_option('identifier');
     196    $config_dump = get_option('ss_config_dump');
     197    $shopsite_url = get_option('ss_shopsite_url');
     198  $clientid = get_option('ss_clientid');
     199  $secretkey = get_option('ss_secretkey');
     200  $code = get_option('ss_code');
     201  $authorizationurl = get_option('ss_authorizationurl');
     202 
     203 
     204  $identifier = get_option('ss_identifier');
    182205 
    183206  $SKU_selected = $GUID_selected = "";
     
    288311// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
    289312function add_shopsite_tinymce_plugin($plugin_array) {
    290  
    291   /*var shopsite_url='".get_option('shopsite_url')."';
    292   var includes_url='".includes_url()."';
    293   var clientid='".get_option('clientid')."';
    294   var secretkey='".get_option('secretkey')."';
    295   var code='".get_option('code')."';
    296   var authorizationurl='".get_option('authorizationurl')."'; */
    297  
    298   /*  var includes_path='".addslashes(ABSPATH.WPINC)."';
    299   var includes_url='".includes_url()."';
    300   var wp_path='$path';
    301   alert('$path');
    302 */
    303313  echo
    304314  "<script>
     
    326336  $selected_name = "";
    327337  $selected_sku = "";
    328   if (get_option('remember_search') == 'true') {
     338  if (get_option('ss_remember_search') == 'true') {
    329339      $remember_search = "checked";
    330340     
    331     if (strlen(get_option('remembered_search_string')))
    332       $search_string = get_option('remembered_search_string');
     341    if (strlen(get_option('ss_remembered_search_string')))
     342      $search_string = get_option('ss_remembered_search_string');
    333343   
    334344  }
     
    341351  echo"<script type='text/javascript' src='".$tinymce_url."'></script>\n
    342352  <script type='text/javascript' src='".plugin_dir_url(__FILE__)."search_products.js?".time()."'></script>
    343   <script type='text/javascript'> var remembered_search_string = '".$search_string."';</script>
     353  <script type='text/javascript'> var ss_remembered_search_string = '".$search_string."';</script>
    344354 
    345355 
    346356  </head>
    347357  <body>";
     358 
     359 
    348360 
    349361  echo "<div id=top_bar>";
     
    354366  echo "</div>";
    355367  echo "<div id=search_results></div>";
    356   echo "<div id=\"bottom_fix\"><div id=\"insert_button\">Insert into post</div></div>";
     368 
     369  $extra_space = "";
     370  $message = "";
     371  if (!get_option('ss_media_url'))
     372  {
     373    $extra_space = " style='height:80px;'";
     374    $message = "<div id=extra_message>Upgrade your store to ShopSite v12 sp1 or greater to see product images above.</div>";
     375  }
     376 
     377  echo "<div id=\"bottom_fix\"$extra_space>$message<div id=\"insert_button\">Insert selected products into post</div></div>";
    357378 
    358379  echo "
     
    373394 
    374395  ///debug_print("Updating remember_search to $remember_search");
    375   update_option('remember_search', $remember_search);
     396  update_option('ss_remember_search', $remember_search);
    376397 
    377398  if ($remember_search == 'true') {
    378     update_option('remembered_search_string', $search_string);
    379   }
    380 
    381  
    382   $shopsite_url = get_option('shopsite_url');
     399    update_option('ss_remembered_search_string', $search_string);
     400  }
     401
     402 
     403  $shopsite_url = get_option('ss_shopsite_url');
    383404
    384405 
    385406  $media_url = false;//get_option('media_url');
    386407  if (!$media_url) {
    387     $shopsite_url = get_option('shopsite_url');
     408    $shopsite_url = get_option('ss_shopsite_url');
    388409    $url = $shopsite_url."&operation=get_setting&setting=output_url"; 
    389410    $outputurl = curl_open($url);
    390411    if (strlen($outputurl) > 10) {
    391412      $media_url = $outputurl."/media/";
    392       add_option('media_url');
    393       update_option('media_url', $media_url);
     413      update_option('ss_media_url', $media_url);
    394414    }
    395415  }
     
    412432   
    413433  $products_xml = oauth(
    414     get_option('clientid'), get_option('secretkey'), get_option('code'), get_option('authorizationurl'),
     434    get_option('ss_clientid'), get_option('ss_secretkey'), get_option('ss_code'), get_option('ss_authorizationurl'),
    415435    DOWNLOAD,
    416436    array_merge(array('clientApp'=>'1', 'dbname'=>'products', 'version'=>'11.2', 'fields'=>'|Product GUID|Name|SKU|Graphic|', 'limit'=>$limit), $search_array)
     
    437457    $search_array = array('search_on'=>"sku", 'search_term'=>$search_string, 'search_filter'=>'contains');
    438458    $products_xml = oauth(
    439       get_option('clientid'), get_option('secretkey'), get_option('code'), get_option('authorizationurl'),
     459      get_option('ss_clientid'), get_option('ss_secretkey'), get_option('ss_code'), get_option('ss_authorizationurl'),
    440460      DOWNLOAD,
    441461      array_merge(array('clientApp'=>'1', 'dbname'=>'products', 'version'=>'11.2', 'fields'=>'|Product GUID|Name|SKU|Graphic|', 'limit'=>$limit), $search_array)
     
    473493
    474494function print_product ($count, $name, $data, $media_url) {
     495 
    475496  $id = $data[0];
    476497  $sku = rawurlencode($data[1]);
     
    488509  }
    489510 
    490   echo "<div class=\"wp_product\" id=\"wp_product_$count\">";
     511  $outdated = "";
     512  if (!$media_url)
     513    $outdated = " outdated";
     514 
     515  echo "<div class=\"wp_product$outdated\" id=\"wp_product_$count\">";
    491516  if ($media_url)
    492517    if (strstr($image, "://"))
     
    494519    else
    495520      echo "<img class=\"product_image\" src=\"".$media_url.$image."\">";
    496   else
    497     echo "<div class=\"outdated_shopsite\">Update ShopSite to see product images</div>";
    498521  if (strlen($sku) > 0)
    499522    echo "<div class='product_sku'>".strip_tags($sku)."</div>";
     
    517540    ), $atts ) );
    518541 
    519   if (get_option('identifier') == 'SKU')
     542  if (get_option('ss_identifier') == 'SKU')
    520543    $identifier = $sku;
    521544  else
     
    568591  $product_map = json_encode($product_list);
    569592  ///debug_print("product_map:".print_r($product_map, true));
    570   $identifier = get_option('identifier');
     593  $identifier = get_option('ss_identifier');
    571594  $id_list = implode(",",array_unique(array_keys($product_list)));
    572595 
     
    576599  echo
    577600    "<script> var ss_path='".plugin_dir_url(__FILE__)."';
    578     var identifier = \"$identifier\";
    579     var product_map = $product_map;
    580     var id_list = \"$id_list\";
    581     var shopsite_url=\"".get_option('shopsite_url')."\";</script>";
     601    var ss_identifier = \"$identifier\";
     602    var ss_product_map = $product_map;
     603    var ss_id_list = \"$id_list\";
     604    var ss_shopsite_url=\"".get_option('ss_shopsite_url')."\";</script>";
    582605  //echo "<script> var product_mapping = ".json_encode($product_list).";</script>";
    583606}
     
    587610  $id_list = stripslashes($id_list);
    588611  //debug_print("GPD |$id_list|");
    589   $clientid = get_option('clientid');
    590   $secretkey = get_option('secretkey');
     612  $clientid = get_option('ss_clientid');
     613  $secretkey = get_option('ss_secretkey');
    591614  $ids = explode(",", $id_list);
    592615  $decoded_id_list = array();
     
    598621  $signature = rawurlencode(base64_encode($hmachash));
    599622 
    600   $identifier = get_option('identifier');
     623  $identifier = get_option('ss_identifier');
    601624 
    602625  //$shopsite_url = $_REQUEST['shopsite_url'];   
    603   $shopsite_url = get_option('shopsite_url');
     626  $shopsite_url = get_option('ss_shopsite_url');
    604627  //$id_list = "\"".str_replace(",","\",\"",$id_list)."\"";
    605628  $url = $shopsite_url."&operation=get_products&".$identifier."_list=".$id_list."&signature=".$signature;
     
    620643
    621644  $test_download_xml = oauth(
    622     get_option('clientid'), get_option('secretkey'), get_option('code'), get_option('authorizationurl'),
     645    get_option('ss_clientid'), get_option('ss_secretkey'), get_option('ss_code'), get_option('ss_authorizationurl'),
    623646    DOWNLOAD,
    624647    array('clientApp'=>'1', 'dbname'=>'products', 'version'=>'11.2', 'fields'=>'|Product GUID|Name|SKU|', 'search_term'=>"B0gu5", 'search_on'=>'name', 'search_filter'=>'contains', 'limit'=>1)
     
    639662    return array("success"=>false, "error"=>"Check your callback URL");*/
    640663 
    641   if (curl_open(get_option('shopsite_url')) == false)
     664  if (curl_open(get_option('ss_shopsite_url')) == false)
    642665    return array("success"=>false, "error"=>"Check your callback URL");
    643666 
Note: See TracChangeset for help on using the changeset viewer.