近幾年來,JavaScript 可謂風生水起,從後端到前端,從 mobile 到 desktop,各種 module 滿天飛,信手拈來就是一個 web app。不過,「沒碰過 IE,別說你會做前端」,本人從超新手的角度出發,整理最近修正 IE 相容性遇到的坑與解法,給自己日後留個參考。
(撰於 2017-07-15,基於 IE 11/Edge 15)
| { | |
| "apiVersion": 2, | |
| "name": "my-affiliate-plugin/my-affiliate-block", | |
| "version": "0.1.0", | |
| "title": "Affiliate Block", | |
| "category": "design", | |
| "icon": "money", | |
| "keywords": [ "kinsta", "affiliate", "money" ], | |
| "description": "An example block for Kinsta readers", | |
| "supports": { |
| <?php | |
| //修正 wp-content/plugins/js_composer/include/classes/core/class-vc-post-admin.php 中 saveAjaxFe 方法的權限補強,補強在方法第一行 | |
| $user = wp_get_current_user(); | |
| // 僅限制「編輯」、「管理員」與「商店管理員」等級開放編輯,若有其他角色,自行補充 | |
| $allowed_roles = array('editor', 'administrator', 'shop_manager'); | |
| if (empty(array_intersect($allowed_roles, $user->roles))) { | |
| wp_send_json_error(); | |
| exit; | |
| } |
| <?php | |
| /* | |
| * arg: | |
| * $msg: 要紀錄的內容,可用 string/array | |
| * $source_name: 此 log 的別名,方便於後台辨識 | |
| */ | |
| function my_wc_log($msg, $source_name) { | |
| if (function_exists('wc_get_logger')) { | |
| $log = wc_get_logger(); |
| <?php | |
| /* | |
| Plugin Name: 三竹簡訊 Webhook | |
| Plugin URI: https://gist.github.com/nczz/750c3d8d18b9e0ca07ca06a248c11570 | |
| Description: 接收 Webhook 請求發送簡訊 | |
| Author: Chun | |
| Version: 1.0 | |
| Author URI: https://www.mxp.tw/ | |
| */ |
| <?php | |
| //設定系統環境,確保輸出執行環境無礙 | |
| set_time_limit(0); | |
| ini_set('memory_limit', '256M'); | |
| //判斷執行權限 | |
| //建立資料庫連線,開始取得資料 | |
| //撰寫資料庫欄位與可讀性資料的轉換方法 |
| <?php | |
| /** | |
| * Plugin name: WP Trac #42573: Fix for theme template file caching. | |
| * Description: Flush the theme file cache each time the admin screens are loaded which uses the file list. | |
| * Plugin URI: https://core.trac.wordpress.org/ticket/42573 | |
| * Author: Weston Ruter, XWP. | |
| * Author URI: https://weston.ruter.net | |
| */ | |
| function wp_42573_fix_template_caching( WP_Screen $current_screen ) { |
| var preventMultipleInstances = function(window) { | |
| var socket = (process.platform === 'win32') ? '\\\\.\\pipe\\myapp-sock' : path.join(os.tmpdir(), 'myapp.sock'); | |
| net.connect({path: socket}, function () { | |
| var errorMessage = 'Another instance of ' + pjson.productName + ' is already running. Only one instance of the app can be open at a time.' | |
| dialog.showMessageBox(window, {'type': 'error', message: errorMessage, buttons: ['OK']}, function() { | |
| window.destroy() | |
| }) | |
| }).on('error', function (err) { | |
| if (process.platform !== 'win32') { | |
| // try to unlink older socket if it exists, if it doesn't, |
| git init # 初始化本地git仓库(创建新仓库) | |
| git config --global user.name "xxx" # 配置用户名 | |
| git config --global user.email "[email protected]" # 配置邮件 | |
| git config --global color.ui true # git status等命令自动着色 | |
| git config --global color.status auto | |
| git config --global color.diff auto | |
| git config --global color.branch auto | |
| git config --global color.interactive auto | |
| git config --global --unset http.proxy # remove proxy configuration on git | |
| git clone git+ssh://[email protected]/VT.git # clone远程仓库 |
| <?php | |
| // put this in your functions.php | |
| add_filter('pre_user_query', function(&$query) { | |
| if($query->query_vars["orderby"] == 'rand') { | |
| $query->query_orderby = 'ORDER by RAND()'; | |
| } | |
| }); | |
| // Query will look like this: | |
| $args = array('orderby' => 'rand', 'number' => 5); |