Changeset 3054878
- Timestamp:
- 03/19/2024 10:49:25 PM (2 years ago)
- Location:
- shopsite-plugin/trunk
- Files:
-
- 3 edited
-
populate_products.js (modified) (1 diff)
-
search_products.js (modified) (3 diffs)
-
shopsite.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shopsite-plugin/trunk/populate_products.js
r3053843 r3054878 37 37 }*/ 38 38 } 39 window.addEventListener('load',populate_products);39 jQuery(populate_products); -
shopsite-plugin/trunk/search_products.js
r3053843 r3054878 1 1 $ = jQuery; 2 function do_stuff() {2 jQuery(function ($) { 3 3 function search_products(string, rems) { 4 4 $('#search_results').html('<div id=please_wait>Loading products... please wait</div>'); … … 103 103 $('#search_button').trigger('click'); 104 104 } 105 } 105 }); 106 106 107 107 function insert_shortcodes() { … … 120 120 tinyMCEPopup.close(); 121 121 } 122 window.addEventListener('load',do_stuff); -
shopsite-plugin/trunk/shopsite.php
r3053843 r3054878 2 2 /** 3 3 * @package ShopSite 4 * @version 1.5. 84 * @version 1.5.9 5 5 */ 6 6 /* … … 9 9 * Description: ShopSite plugin to put products into your WordPress blog 10 10 * Author: ShopSite 11 * Version: 1.5. 811 * Version: 1.5.9 12 12 * Author URI: http://shopsite.com/ 13 13 */ 14 15 /* 16 function debug_print($text) { 17 file_put_contents("log.txt", $text."\n", FILE_APPEND); 18 } 19 */ 20 21 $product_list = array(); 22 $wp_id = 0; 14 23 15 24 if (isset($_REQUEST['ss_action'])) { … … 27 36 if ($_REQUEST['ss_action'] == 'insert') 28 37 show_search_form(); 29 if ($_REQUEST['ss_action'] == 'search_products')38 else if ($_REQUEST['ss_action'] == 'search_products') 30 39 get_product_list(); 31 if ($_REQUEST['ss_action'] == 'get_data')40 else if ($_REQUEST['ss_action'] == 'get_data') 32 41 get_product_data(($_REQUEST['id_list'])); 33 42 exit(0); 34 43 } 35 36 $product_list;37 $wp_id;38 44 39 45 register_uninstall_hook(__FILE__, 'on_uninstall'); … … 52 58 53 59 function load_plugin() { 54 $version = "1.5. 7";60 $version = "1.5.9"; 55 61 if ( is_admin() ) { 56 62 $running_version = get_option('ss_version'); … … 91 97 92 98 function link_tutorial() { 93 echo "<script> $ = jQuery;</script>"; 94 echo "<script type='text/javascript' src=".plugin_dir_url(__FILE__)."jquery.tutorial.js></script>"; 95 echo "<script type='text/javascript' src=".plugin_dir_url(__FILE__)."tutorial_driver.js></script>"; 96 echo "<link rel='stylesheet' href=".plugin_dir_url(__FILE__)."shopsite.css type='text/css' />"; 99 ?><script>var $ = jQuery;</script><script src="<?php echo plugin_dir_url(__FILE__); ?>jquery.tutorial.js"></script><script src="<?php echo plugin_dir_url(__FILE__); ?>tutorial_driver.js"></script><link rel="stylesheet" href="<?php echo plugin_dir_url(__FILE__); ?>shopsite.css" type="text/css" /> 100 <?php 97 101 } 98 102 99 103 function link_ss_path() { 100 echo "<script>var ss_path='".plugin_dir_url(__FILE__)."';</script>"; 104 ?><script>var ss_path='<?php echo plugin_dir_url(__FILE__); ?>';</script> 105 <?php 101 106 } 102 107 … … 194 199 $SKU_selected = $GUID_selected = ""; 195 200 if ($identifier == 'SKU') 196 $SKU_selected = " checked";201 $SKU_selected = " checked"; 197 202 else 198 $GUID_selected = " checked";203 $GUID_selected = " checked"; 199 204 200 205 $ss_12_extra = ""; 201 206 $ss_11_extra = ""; 202 207 if ($config_type == 'ss_11') { 203 $ss_12_extra = " style= 'display:none;'";204 $ss_11_extra = " style= 'display:table-row-group;'";208 $ss_12_extra = " style=\"display:none;\""; 209 $ss_11_extra = " style=\"display:table-row-group;\""; 205 210 } 206 211 207 212 //ss_action=plugins.php?page=shopsite_menu 208 echo 209 "<script> 210 211 \$('#ss_11').live('click', function() {\$('#config_type').val('ss_11'); \$('#ss_12_settings').css({'display':'none'}); \$('#ss_11_settings').css({'display':'table-row-group'}); }); 212 \$('#ss_12').live('click', function() {\$('#config_type').val('ss_12'); \$('#ss_11_settings').css({'display':'none'}); \$('#ss_12_settings').css({'display':'table-row-group'}); }); 213 </script>"; 214 215 echo 216 "<h1>ShopSite configuration</h1> 217 Don't have a ShopSite store? <a id=get_shopsite target=_blank href='https://saas.shopsite.com/express/'>Get a free 10-product Express store</a>. 218 <form method=post> 219 <input type=hidden id=config_type name=config_type value=$config_type> 213 ?> 214 <script>$('#ss_11').live('click', function() {$('#config_type').val('ss_11'); $('#ss_12_settings').css({'display':'none'}); $('#ss_11_settings').css({'display':'table-row-group'}); });$('#ss_12').live('click', function() {$('#config_type').val('ss_12'); $('#ss_11_settings').css({'display':'none'}); $('#ss_12_settings').css({'display':'table-row-group'});});</script> 215 216 <h1>ShopSite configuration</h1> 217 Don't have a ShopSite store? <a id="get_shopsite" target="_blank" href="https://saas.shopsite.com/express/">Get a free 10-product Express store</a>. 218 <form method="post" action=""> 219 <input type="hidden" id="config_type" name="config_type" value="<?=$config_type?>"> 220 220 <table> 221 <thead><tr><th colspan=2>Application settings</th></tr></thead>"; 222 223 echo 224 "<tbody id='ss_12_settings' $ss_12_extra><tr><td>Configuration data (paste from ShopSite) 225 <br><a id=ss_11>Click here if you have 5 fields to copy and paste in your ShopSite backoffice WordPress config</a></td> 226 <td><textarea name=config_dump id=config_dump style='height:100px;width:675px;'>$config_dump</textarea></td></tr></tbody>"; 227 228 229 echo 230 "<tbody id='ss_11_settings' $ss_11_extra> 231 <tr><td colspan=2><a id=ss_12>Click here if you only have 1 field to paste in your ShopSite backoffice WordPress config</a></td></tr> 232 <tr><td>Client ID:</td><td><input type=text name=clientid id=clientid value='$clientid' size=100></td></tr> 233 <tr><td>Secret Key for Signing:</td><td><input type=text name=secretkey id=secretkey value='$secretkey' size=100></td></tr> 234 <tr><td>Authorization Code:</td><td><input type=text name=code id=code value='$code' size=100></td></tr> 235 <tr><td>Authorization URL:</td><td><input type=text name=authorizationurl id=authorizationurl value='$authorizationurl' size=100></td></tr> 236 <tr><td>ShopSite callback URL:</td><td><input type=text name=shopsite_url value='$shopsite_url' size=100></td></tr>"; 237 238 echo 239 "</tbody>"; 240 241 echo "<tbody><tr><th colspan=2>Other settings</th></tr> 221 <thead><tr><th colspan="2">Application settings</th></tr></thead> 222 223 <tbody id="ss_12_settings"<?= $ss_12_extra ?>><tr><td>Configuration data (paste from ShopSite) 224 <br><a id="ss_11">Click here if you have 5 fields to copy and paste in your ShopSite backoffice WordPress config</a></td> 225 <td><textarea name="config_dump" id="config_dump" style="height:100px;width:675px;"><?= $config_dump ?></textarea></td></tr></tbody> 226 227 228 <tbody id="ss_11_settings"<?= $ss_11_extra ?>> 229 <tr><td colspan="2"><a id="ss_12">Click here if you only have 1 field to paste in your ShopSite backoffice WordPress config</a></td></tr> 230 <tr><td>Client ID:</td><td><input type="text" name="clientid" id="clientid" value="<?= $clientid ?>" size="100"></td></tr> 231 <tr><td>Secret Key for Signing:</td><td><input type="text" name="secretkey" id="secretkey" value="<?= $secretkey ?>" size="100"></td></tr> 232 <tr><td>Authorization Code:</td><td><input type="text" name="code" id="code" value="<?= $code ?>" size="100"></td></tr> 233 <tr><td>Authorization URL:</td><td><input type="text" name="authorizationurl" id="authorizationurl" value="<?= $authorizationurl ?>" size="100"></td></tr> 234 <tr><td>ShopSite callback URL:</td><td><input type="text" name="shopsite_url" value="<?php esc_attr($shopsite_url); ?>" size="100"></td></tr> 235 236 </tbody> 237 238 <tbody><tr><th colspan="2">Other settings</th></tr> 242 239 <tr><td>Unique product identifier:</td> 243 240 <td> 244 <input type= radio name=identifier value='GUID' $GUID_selected/>Global unique ID<br/>245 <input type= radio name=identifier value='SKU' $SKU_selected/>SKU</td></tr>241 <input type="radio" name="identifier" value="GUID"<?= $GUID_selected ?>>Global unique ID<br/> 242 <input type="radio" name="identifier" value="SKU"<?= $SKU_selected ?>>SKU</td></tr> 246 243 </tbody></table> 247 <br/><input type=submit name=test id=test_connection value='Test connection'>"; 248 244 <br/><input type="submit" class="button" name="test" id="test_connection" value="<?php esc_attr_e('Test connection'); ?>"> 245 <?php 249 246 if ($testing) { 250 echo "<div id= test_result>";247 echo "<div id=\"test_result\">"; 251 248 if ($test_result['success'] == true) 252 249 echo "<p id=\"test_good\">Connection test successful</p>"; … … 255 252 } 256 253 echo "</div>"; 257 258 } 259 260 echo "<input type=hidden name=state id=state value=$state>"; 261 echo "<br/><input type=submit id=save_settings value='Save settings'></form>"; 254 } 255 else 256 { 257 echo "<div></div>"; 258 } 259 ?> 260 <input type="hidden" name="state" id="state" value="<?= $state ?>"> 261 <br/><input type="submit" class="button button-primary" id="save_settings" value="<?php esc_attr_e('Save settings' ); ?>"></form> 262 <?php 262 263 } 263 264 … … 287 288 288 289 function show_search_form() { 289 290 //debug_print("show_search_form"); 290 291 $tinymce_url = includes_url()."js/tinymce/tiny_mce_popup.js"; 291 292 $jquery_url = includes_url()."js/jquery/jquery.js"; … … 303 304 } 304 305 305 echo " 306 ?> 306 307 <html> 307 308 <head> 308 <script type='text/javascript' src='".$jquery_url."'></script>\n"; 309 <script type="text/javascript" src="<?= $jquery_url ?>"></script> 310 <?php 309 311 link_tutorial(); 310 echo"<script type='text/javascript' src='".$tinymce_url."'></script>\n 311 <script type='text/javascript' src='".plugin_dir_url(__FILE__)."search_products.js?".time()."'></script> 312 <script type='text/javascript'> var ss_remembered_search_string = '".$search_string."';</script> 312 ?> 313 <script src="<?= $tinymce_url ?>"></script> 314 <script src="<?php echo plugin_dir_url(__FILE__).'search_products.js?'.time(); ?>"></script> 315 <script> var ss_remembered_search_string = '<?= $search_string ?>';</script> 313 316 </head> 314 <body>"; 315 echo "<div id=top_bar>"; 316 echo "<div id=message>You can use CTRL and SHIFT keys to select multiple products.</div>"; 317 echo "<div id=tabs>"; 318 echo "<div class='tab selected_tab' id=list_all>List all products</div><div class=tab id=search>Search</div>"; 319 echo "</div>"; 320 echo "</div>"; 321 echo "<div id=search_results></div>"; 317 <body> 318 <div id="top_bar"> 319 <div id="message">You can use CTRL and SHIFT keys to select multiple products.</div> 320 <div id="tabs"> 321 <div class="tab selected_tab" id="list_all">List all products</div><div class="tab" id="search">Search</div> 322 </div> 323 </div> 324 <div id="search_results"></div> 325 <?php 322 326 323 327 $extra_space = ""; … … 326 330 if (!$media_url) 327 331 { 328 $extra_space = " style= 'height:80px;'";329 $message = "<div id= extra_message>Upgrade your store to ShopSite v12 sp1 or greater to see product images above.</div>";332 $extra_space = " style=\"height:80px;\""; 333 $message = "<div id=\"extra_message\">Upgrade your store to ShopSite v12 sp1 or greater to see product images above.</div>"; 330 334 } 331 335 … … 396 400 397 401 if (!$products_xml['success']) { 398 echo "<div id=error_head>Unfortunately, something went wrong.</div>"; 399 echo "<div id=error_message>Detailed error message: <br>".$products_xml['error']."</div>"; 402 ?><div id="error_head">Unfortunately, something went wrong.</div> 403 <div id="error_message">Detailed error message: <br><?= $products_xml['error'] ?></div><?php 400 404 exit(1); 401 405 } … … 431 435 432 436 if (count($products_ar) == 0) { 433 echo "<div id=no_products>No matching products.</div>";437 echo '<div id="no_products">No matching products.</div>'; 434 438 return; 435 439 } … … 439 443 $products_ar = array_slice($products_ar,0,$limit); 440 444 441 echo "<div id=\"products\">";445 echo '<div id="products">'; 442 446 if (count($products_ar) == $limit) { 443 447 echo "<div id=\"over_limit_warning\">Displaying first $limit products only. Please use \"Search\" button to narrow down your results.</div>"; … … 448 452 $count++; 449 453 } 450 echo "</div>";454 echo '</div>'; 451 455 452 456 } … … 492 496 function product_handler( $atts, $content=null, $code="" ) { 493 497 global $product_list, $wp_id; 494 ///debug_print("product_handler entered"); 495 //return "<iframe src='$content' width='100%' height='300px' ><p>IFRAME FAIL!</p></iframe>"; 498 //debug_print("product_handler entered"); 499 500 //debug_print( var_export($atts, true)); 496 501 497 502 extract( shortcode_atts( array( … … 509 514 return ""; 510 515 511 512 516 /*$shopsite_url = get_option('shopsite_url'); 513 517 $handle = fopen($shopsite_url."&operation=get_product&id=$id",'r'); … … 516 520 $wp_id++; 517 521 518 519 522 if (!isset($product_list[$identifier])) { 520 // /debug_print("sticking stuff into product_list for $identifier");523 //debug_print("sticking stuff into product_list for $identifier"); 521 524 $product_list[$identifier] = array(); 522 525 } 523 // /debug_print("sticking stuff into product_list 2");526 //debug_print("sticking stuff into product_list 2"); 524 527 array_push($product_list[$identifier], $wp_id); 525 526 527 //$product_list["wp".$wp_id] = $id; 528 return "<div class=ss_product id=product_".$wp_id."></div>"; 529 530 //return $contents; 528 //debug_print("product_list:".print_r($product_list, true)); 529 //debug_print("product_list: ".implode(",",array_unique(array_keys($product_list)))); 530 //debug_print("product_map: ". json_encode($product_list)); 531 532 return "<div class=\"ss_product\" id=\"product_$wp_id\" data-id=\"".esc_attr($identifier)."\"></div>"; 531 533 } 532 534 … … 538 540 539 541 function init_product_list() { 540 global $product_list; 541 542 echo "<script type='text/javascript' src=".plugin_dir_url(__FILE__)."populate_products.js></script>"; 543 $product_list = array(); 544 $wp_id = 0; 542 echo "<script type=\"text/javascript\" src=\"".plugin_dir_url(__FILE__)."populate_products.js\"></script>"; 545 543 } 546 544 547 545 function dispatch_product_list() { 548 546 global $product_list; 549 ///debug_print("Xi2"); 550 ///debug_print("product_list:".print_r($product_list, true)); 547 //debug_print("product_list:".print_r($product_list, true)); 551 548 $product_map = json_encode($product_list); 552 // /debug_print("product_map:".print_r($product_map, true));549 //debug_print("product_map:".print_r($product_map, true)); 553 550 $identifier = get_option('ss_identifier'); 554 551 $id_list = implode(",",array_unique(array_keys($product_list))); … … 556 553 //debug_print("dispatched:|$id_list|"); 557 554 558 559 echo 560 "<script> var ss_path='".plugin_dir_url(__FILE__)."'; 561 var ss_identifier = \"$identifier\"; 562 var ss_product_map = $product_map; 563 var ss_id_list = '$id_list'; 564 var ss_shopsite_url='".get_option('ss_shopsite_url')."';</script>"; 565 //echo "<script> var product_mapping = ".json_encode($product_list).";</script>"; 555 ?> 556 <script> var ss_path='<?php echo plugin_dir_url(__FILE__); ?>', ss_identifier = '<?= $identifier ?>', ss_product_map = <?= $product_map ?>, ss_id_list = '<?= $id_list ?>', ss_shopsite_url='<?php echo get_option('ss_shopsite_url'); ?>';</script> 557 <?php 566 558 } 567 559 … … 588 580 $resp = get_url($url); 589 581 $product_data = $resp[0]; 590 if ($product_data) 591 print($product_data); 592 else 593 print($product_data[1]); 582 //debug_print("Product Data = ", var_export($product_data, true)); 583 print($product_data); 594 584 } 595 585 … … 610 600 } 611 601 612 function debug_print($text) {613 //file_put_contents("log.txt", $text."\n", FILE_APPEND);614 }615 616 602 function get_url($url) { 617 603 $response = wp_remote_get($url);
Note: See TracChangeset
for help on using the changeset viewer.