zipaddr-jp.php
| 1 | <?php |
| 2 | if( !defined('ABSPATH') ) exit; |
| 3 | /* |
| 4 | Plugin Name: zipaddr-jp |
| 5 | Plugin URI: https://zipaddr2.com/wordpress/ |
| 6 | Description: The input convert an address from a zip code automatically. |
| 7 | Version: 1.45 |
| 8 | Author: Tatsuro, Terunuma |
| 9 | Author URI: https://pierre-soft.com/ |
| 10 | License: GPLv2 or later |
| 11 | */ |
| 12 | define('ZIPADDR_JP_PLUGIN_DIR', plugin_dir_path(__FILE__)); // /myplugin/ |
| 13 | define('ZIPADDR_JP_PLUGIN_URL',plugins_url( '', __FILE__)); |
| 14 | define('ZIPADDR_JP_VERS', '1.45'); |
| 15 | define('ZIPADDR_JP_KEYS', 'zipaddr-config'); |
| 16 | define('ZIPADDR_JP_SYS', 'sys_'); |
| 17 | define('ZIPADDR_JP_COM', 'https://zipaddr.com/'); |
| 18 | define('ZIPADDR_JP_2COM', 'https://zipaddr2.com/'); |
| 19 | define('ZIPADDR_JP_GIT', 'https://zipaddr.github.io/'); |
| 20 | define('ZIPADDR_JP_DEFINE','zipaddr_define'); |
| 21 | define('ZIPADDR_JP_MEI', plugin_basename(dirname(__FILE__))); |
| 22 | define('ZIPADDR_JP_FILE1', str_replace("/".ZIPADDR_JP_MEI."/","",ZIPADDR_JP_PLUGIN_DIR)."/zipaddr_define.txt"); //�� |
| 23 | define('ZIPADDR_JP_FILE2', ZIPADDR_JP_PLUGIN_DIR."include/zipaddrjp_define.php"); //�V |
| 24 | |
| 25 | $zipaddr_jp_plugin=""; |
| 26 | $zipaddr_jp_keywd= "usces_"; |
| 27 | if( !empty($_SERVER["REQUEST_URI"]) ){ |
| 28 | $zipaddr_jp_wk= trim( sanitize_text_field(wp_unslash($_SERVER["REQUEST_URI"])) ); |
| 29 | $zipaddr_jp_wk= htmlspecialchars($zipaddr_jp_wk, ENT_QUOTES); |
| 30 | if( strpos($zipaddr_jp_wk,'?page='.$zipaddr_jp_keywd) !== false ) $zipaddr_jp_plugin= $zipaddr_jp_keywd; |
| 31 | } |
| 32 | require_once ZIPADDR_JP_PLUGIN_DIR.'include/zipaddrjp_config.php'; |
| 33 | |
| 34 | if( is_admin() && $zipaddr_jp_plugin == $zipaddr_jp_keywd ){ // welcart |
| 35 | define( 'ZIPADDR_JP_IDENT', '3'); |
| 36 | require_once ZIPADDR_JP_PLUGIN_DIR.'zipaddr.php'; |
| 37 | add_filter('usces_filter_apply_admin_addressform', 'zipaddr_jp_usces', 99999, 3);// welcart |
| 38 | } |
| 39 | else |
| 40 | if( is_admin() ){ // admin |
| 41 | define( 'ZIPADDR_JP_IDENT', '2'); |
| 42 | require_once ZIPADDR_JP_PLUGIN_DIR.'admin.php'; |
| 43 | add_action('admin_menu', 'zipaddr_admin_menu'); |
| 44 | if( function_exists('register_uninstall_hook') ) {register_uninstall_hook( __FILE__, 'zipaddr_uninstall' );} // uninstall�ďo�� |
| 45 | } |
| 46 | else { // user |
| 47 | define( 'ZIPADDR_JP_IDENT', '1'); |
| 48 | require_once ZIPADDR_JP_PLUGIN_DIR.'zipaddr.php'; |
| 49 | add_filter('usces_filter_apply_addressform', 'zipaddr_jp_usces', 99999, 3);// welcart |
| 50 | add_filter('usces_filter_cart_delivery_script','zipaddr_jp_welcart', 99999, 3);// welcart |
| 51 | add_filter('the_content', 'zipaddr_jp_change', 99999); // html change |
| 52 | } |
| 53 | |
| 54 | function zipaddr_jp_usces($formtag,$type,$data) {return zipaddr_jp_change($formtag,"1");} |
| 55 | function zipaddr_jp_welcart($script) {return $script; |
| 56 | $zipaddr_jp_keywd1="if(delivery_days[selected]"; |
| 57 | $addon=" |
| 58 | if(typeof Zip.welorder==='function'){ |
| 59 | var wk1= $('#delivery_country').val(); |
| 60 | var wk2= $('#delivery_pref').val(); |
| 61 | if( wk1!='' && wk2!='' ) {delivery_country=wk1; delivery_pref=wk2;} |
| 62 | } |
| 63 | "; |
| 64 | $zipaddr_jp_wk0= strpos($script,$zipaddr_jp_keywd1); |
| 65 | if( $zipaddr_jp_wk0!==false ) {$script= str_replace($zipaddr_jp_keywd1, $addon.$zipaddr_jp_keywd1, $script);} |
| 66 | return $script; |
| 67 | } |
| 68 | function zipaddr_uninstall() {delete_option(ZIPADDR_JP_DEFINE);} // uninstall���� |
| 69 | ?> |
| 70 |