Changeset 1097525
- Timestamp:
- 02/23/2015 08:14:25 PM (11 years ago)
- Location:
- shopsite-plugin/trunk
- Files:
-
- 5 edited
-
populate_products.js (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
search_products.js (modified) (1 diff)
-
shopsite.css (modified) (2 diffs)
-
shopsite.php (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shopsite-plugin/trunk/populate_products.js
r1085770 r1097525 12 12 async: true, 13 13 type: 'POST', 14 data: {ss_action:'get_data', shopsite_url:s hopsite_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}, 15 15 url: ss_path + "shopsite.php", 16 16 success: function(data) { … … 23 23 var id = rfc3986EncodeURIComponent(pair[0]); 24 24 //alert(id); 25 for (j in product_map[id]) {25 for (j in ss_product_map[id]) { 26 26 if (jQuery.isNumeric(j)) 27 $('#product_' + product_map[id][j]).html(pair[1]);27 $('#product_' + ss_product_map[id][j]).html(pair[1]); 28 28 } 29 29 } -
shopsite-plugin/trunk/readme.txt
r1085770 r1097525 3 3 Tags: e-commerce, shopping, shopsite 4 4 Requires at least: 3.2.0 5 Tested up to: 4.1 5 Tested up to: 4.1.1 6 6 Stable tag: trunk 7 7 … … 26 26 27 27 == 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 28 31 = 1.5.0 = 29 32 * Changed UI for selecting a product. -
shopsite-plugin/trunk/search_products.js
r1079131 r1097525 121 121 122 122 var last_search_string = ""; 123 if ( remembered_search_string == "*")123 if (ss_remembered_search_string == "*") 124 124 search_products('*', 'true'); 125 125 else { 126 last_search_string = remembered_search_string;126 last_search_string = ss_remembered_search_string; 127 127 $('#search').trigger('click'); 128 128 $('#search_button').trigger('click'); -
shopsite-plugin/trunk/shopsite.css
r1079131 r1097525 141 141 } 142 142 143 div.outdated { 144 height: 80px; 145 padding-top: 20px; 146 } 147 143 148 div.wp_product img { 144 149 max-width:130px; … … 195 200 } 196 201 202 div#extra_message { 203 margin-top: 5px; 204 margin-bottom: -10px; 205 margin-left: auto; 206 margin-right: auto; 207 text-align: center; 208 } 209 197 210 div#insert_button { 198 211 background-color: #2ea2cc; 199 212 border: 1px solid #0074a2; 200 213 color: white; 201 width: 150px;214 width: 300px; 202 215 border-radius: 3px; 203 216 font-size: 13px; -
shopsite-plugin/trunk/shopsite.php
r1079131 r1097525 2 2 /** 3 3 * @package ShopSite 4 * @version 1.5. 04 * @version 1.5.1 5 5 */ 6 6 /* … … 9 9 Description: ShopSite plugin to put products into your WordPress blog 10 10 Author: ShopSite 11 Version: 1.5. 011 Version: 1.5.1 12 12 Author URI: http://shopsite.com/ 13 13 */ 14 15 16 14 17 if (isset($_REQUEST['ss_action'])) { 15 18 //taken from http://plugins.svn.wordpress.org/limelight-networks/trunk/limelight_popup.php … … 39 42 $wp_id; 40 43 44 45 register_uninstall_hook(__FILE__, 'on_uninstall'); 46 41 47 register_activation_hook( __FILE__, 'on_activate' ); 42 43 48 function on_activate() { 44 add_option('Activated_Plugin','Plugin-Slug'); 49 add_option('ss_just_activated','yes'); 50 } 51 52 function 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 } 45 57 } 46 58 47 59 function 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"; 50 65 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'); 52 86 if ($shopsite_url == false || strlen($shopsite_url) < 10) { 53 87 add_action( 'admin_head', 'start_tutorial'); 54 88 } 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 60 92 } 61 93 } … … 107 139 $testing = false; 108 140 $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 }*/ 123 146 124 147 … … 128 151 //echo "<script>alert('$config_type');</script>"; 129 152 130 update_option(' config_type', $config_type);153 update_option('ss_config_type', $config_type); 131 154 $state = 'settings_saved'; 132 155 133 156 if ($config_type == 'ss_12') { 134 update_option(' config_dump', trim($_REQUEST['config_dump']));157 update_option('ss_config_dump', trim($_REQUEST['config_dump'])); 135 158 136 159 … … 138 161 $decoded = explode('^',$decoded); 139 162 140 update_option(' clientid', trim($decoded[0]));141 update_option('s ecretkey', trim($decoded[1]));142 update_option(' code', trim($decoded[2]));143 update_option(' authorizationurl', trim($decoded[3]));144 update_option('s hopsite_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])); 145 168 } else { 146 169 147 $clientid = trim($_REQUEST['clientid']); update_option(' clientid', $clientid);148 $secretkey = trim($_REQUEST['secretkey']); update_option('s ecretkey', $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('s hopsite_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); 152 175 $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); 154 177 } 155 178 } … … 161 184 if (isset($_REQUEST['authorizationurl'])) update_option('authorizationurl', trim($_REQUEST['authorizationurl']));*/ 162 185 163 if (isset($_REQUEST['identifier'])) update_option(' identifier', trim($_REQUEST['identifier']));186 if (isset($_REQUEST['identifier'])) update_option('ss_identifier', trim($_REQUEST['identifier'])); 164 187 if (isset($_REQUEST['test'])) { 165 188 $testing = true; … … 168 191 } 169 192 170 $config_type = get_option(' config_type');193 $config_type = get_option('ss_config_type'); 171 194 if (strlen($config_type) == 0) 172 195 $config_type = 'ss_12'; 173 $config_dump = get_option(' config_dump');174 $shopsite_url = get_option('s hopsite_url');175 $clientid = get_option(' clientid');176 $secretkey = get_option('s ecretkey');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'); 182 205 183 206 $SKU_selected = $GUID_selected = ""; … … 288 311 // Load the TinyMCE plugin : editor_plugin.js (wp2.5) 289 312 function 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 */303 313 echo 304 314 "<script> … … 326 336 $selected_name = ""; 327 337 $selected_sku = ""; 328 if (get_option(' remember_search') == 'true') {338 if (get_option('ss_remember_search') == 'true') { 329 339 $remember_search = "checked"; 330 340 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'); 333 343 334 344 } … … 341 351 echo"<script type='text/javascript' src='".$tinymce_url."'></script>\n 342 352 <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> 344 354 345 355 346 356 </head> 347 357 <body>"; 358 359 348 360 349 361 echo "<div id=top_bar>"; … … 354 366 echo "</div>"; 355 367 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>"; 357 378 358 379 echo " … … 373 394 374 395 ///debug_print("Updating remember_search to $remember_search"); 375 update_option(' remember_search', $remember_search);396 update_option('ss_remember_search', $remember_search); 376 397 377 398 if ($remember_search == 'true') { 378 update_option(' remembered_search_string', $search_string);379 } 380 381 382 $shopsite_url = get_option('s hopsite_url');399 update_option('ss_remembered_search_string', $search_string); 400 } 401 402 403 $shopsite_url = get_option('ss_shopsite_url'); 383 404 384 405 385 406 $media_url = false;//get_option('media_url'); 386 407 if (!$media_url) { 387 $shopsite_url = get_option('s hopsite_url');408 $shopsite_url = get_option('ss_shopsite_url'); 388 409 $url = $shopsite_url."&operation=get_setting&setting=output_url"; 389 410 $outputurl = curl_open($url); 390 411 if (strlen($outputurl) > 10) { 391 412 $media_url = $outputurl."/media/"; 392 add_option('media_url'); 393 update_option('media_url', $media_url); 413 update_option('ss_media_url', $media_url); 394 414 } 395 415 } … … 412 432 413 433 $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'), 415 435 DOWNLOAD, 416 436 array_merge(array('clientApp'=>'1', 'dbname'=>'products', 'version'=>'11.2', 'fields'=>'|Product GUID|Name|SKU|Graphic|', 'limit'=>$limit), $search_array) … … 437 457 $search_array = array('search_on'=>"sku", 'search_term'=>$search_string, 'search_filter'=>'contains'); 438 458 $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'), 440 460 DOWNLOAD, 441 461 array_merge(array('clientApp'=>'1', 'dbname'=>'products', 'version'=>'11.2', 'fields'=>'|Product GUID|Name|SKU|Graphic|', 'limit'=>$limit), $search_array) … … 473 493 474 494 function print_product ($count, $name, $data, $media_url) { 495 475 496 $id = $data[0]; 476 497 $sku = rawurlencode($data[1]); … … 488 509 } 489 510 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\">"; 491 516 if ($media_url) 492 517 if (strstr($image, "://")) … … 494 519 else 495 520 echo "<img class=\"product_image\" src=\"".$media_url.$image."\">"; 496 else497 echo "<div class=\"outdated_shopsite\">Update ShopSite to see product images</div>";498 521 if (strlen($sku) > 0) 499 522 echo "<div class='product_sku'>".strip_tags($sku)."</div>"; … … 517 540 ), $atts ) ); 518 541 519 if (get_option(' identifier') == 'SKU')542 if (get_option('ss_identifier') == 'SKU') 520 543 $identifier = $sku; 521 544 else … … 568 591 $product_map = json_encode($product_list); 569 592 ///debug_print("product_map:".print_r($product_map, true)); 570 $identifier = get_option(' identifier');593 $identifier = get_option('ss_identifier'); 571 594 $id_list = implode(",",array_unique(array_keys($product_list))); 572 595 … … 576 599 echo 577 600 "<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 s hopsite_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>"; 582 605 //echo "<script> var product_mapping = ".json_encode($product_list).";</script>"; 583 606 } … … 587 610 $id_list = stripslashes($id_list); 588 611 //debug_print("GPD |$id_list|"); 589 $clientid = get_option(' clientid');590 $secretkey = get_option('s ecretkey');612 $clientid = get_option('ss_clientid'); 613 $secretkey = get_option('ss_secretkey'); 591 614 $ids = explode(",", $id_list); 592 615 $decoded_id_list = array(); … … 598 621 $signature = rawurlencode(base64_encode($hmachash)); 599 622 600 $identifier = get_option(' identifier');623 $identifier = get_option('ss_identifier'); 601 624 602 625 //$shopsite_url = $_REQUEST['shopsite_url']; 603 $shopsite_url = get_option('s hopsite_url');626 $shopsite_url = get_option('ss_shopsite_url'); 604 627 //$id_list = "\"".str_replace(",","\",\"",$id_list)."\""; 605 628 $url = $shopsite_url."&operation=get_products&".$identifier."_list=".$id_list."&signature=".$signature; … … 620 643 621 644 $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'), 623 646 DOWNLOAD, 624 647 array('clientApp'=>'1', 'dbname'=>'products', 'version'=>'11.2', 'fields'=>'|Product GUID|Name|SKU|', 'search_term'=>"B0gu5", 'search_on'=>'name', 'search_filter'=>'contains', 'limit'=>1) … … 639 662 return array("success"=>false, "error"=>"Check your callback URL");*/ 640 663 641 if (curl_open(get_option('s hopsite_url')) == false)664 if (curl_open(get_option('ss_shopsite_url')) == false) 642 665 return array("success"=>false, "error"=>"Check your callback URL"); 643 666
Note: See TracChangeset
for help on using the changeset viewer.