Changeset 2246462
- Timestamp:
- 02/18/2020 10:49:24 PM (6 years ago)
- Location:
- pushover-for-woocommerce
- Files:
-
- 19 added
- 5 edited
-
tags/1.0.16 (added)
-
tags/1.0.16/assets (added)
-
tags/1.0.16/assets/banner-772x250.png (added)
-
tags/1.0.16/assets/icon-128x128.jpg (added)
-
tags/1.0.16/assets/icon-256x256.jpg (added)
-
tags/1.0.16/assets/screenshot-1.jpg (added)
-
tags/1.0.16/assets/screenshot-2.png (added)
-
tags/1.0.16/changelog.txt (added)
-
tags/1.0.16/classes (added)
-
tags/1.0.16/classes/class-pushover-api.php (added)
-
tags/1.0.16/classes/class-wc-pushover.php (added)
-
tags/1.0.16/languages (added)
-
tags/1.0.16/languages/wc_pushover-sl_SI.mo (added)
-
tags/1.0.16/languages/wc_pushover-sl_SI.po (added)
-
tags/1.0.16/languages/wc_pushover.pot (added)
-
tags/1.0.16/readme.txt (added)
-
tags/1.0.16/screenshot-1.jpg (added)
-
tags/1.0.16/screenshot-2.png (added)
-
tags/1.0.16/woocommerce-pushover.php (added)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/classes/class-pushover-api.php (modified) (3 diffs)
-
trunk/classes/class-wc-pushover.php (modified) (31 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/woocommerce-pushover.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pushover-for-woocommerce/trunk/changelog.txt
r2021583 r2246462 1 1 *** WooCommerce Pushover Integration *** 2 3 2020.20.18 1.0.16 4 * Tested with WooCommerce 3.9 5 * Removed support for WooCommerce 2.x 6 * Added direct link to edit order page - Thanks @galapogos01 7 * Fixing formatting and PHPCS Doc 8 * Moved debug log to WC_Logger 2 9 3 10 2019.01.29 1.0.15 -
pushover-for-woocommerce/trunk/classes/class-pushover-api.php
r2021583 r2246462 4 4 * 5 5 */ 6 /* 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License, version 2, as 9 published by the Free Software Foundation. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 6 /** 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License, version 2, as 9 * published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 19 */ 21 20 if ( ! defined( 'ABSPATH' ) ) { … … 25 24 class Pushover_Api { 26 25 27 private $endpoint = 'https://api.pushover.net/1/messages.json';28 private $site_api = '';29 private $user_api = '';30 private $device = '';31 private $priority = '';32 private $sound = '';33 private $title = '';34 private $message = '';35 private $url = '';36 37 /**38 * Constructor39 *40 * @access public41 */26 private $endpoint = 'https://api.pushover.net/1/messages.json'; 27 private $site_api = ''; 28 private $user_api = ''; 29 private $device = ''; 30 private $priority = ''; 31 private $sound = ''; 32 private $title = ''; 33 private $message = ''; 34 private $url = ''; 35 36 /** 37 * Constructor 38 * 39 * @access public 40 */ 42 41 public function __construct() { 43 44 } 45 46 /*47 * Sets the Site API for Pushover48 *49 * @param string $site_api50 *51 */42 43 } 44 45 /** 46 * Sets the Site API for Pushover 47 * 48 * @param string $site_api 49 * 50 */ 52 51 public function setSiteApi( $site_api ) { 53 52 $this->site_api = $site_api; 54 53 } 55 54 56 /*57 * Getter for Site API58 *59 * @return string $site_api60 */55 /** 56 * Getter for Site API 57 * 58 * @return string $site_api 59 */ 61 60 public function getSiteApi() { 62 61 return $this->site_api; 63 62 } 64 63 65 /* 66 * setUserApi() 67 * 68 */ 64 /** 65 * setUserApi() 66 */ 69 67 public function setUserApi( $user_api ) { 70 68 $this->user_api = $user_api; 71 69 } 72 70 73 /*74 * getUserApi()75 *76 * @return string @site_api77 */71 /** 72 * getUserApi() 73 * 74 * @return string @site_api 75 */ 78 76 public function getUserApi() { 79 77 return $this->user_api; 80 78 } 81 79 82 /*83 * Set Device ID to send to Pushover (optional)84 *85 */80 /** 81 * Set Device ID to send to Pushover (optional) 82 * 83 */ 86 84 public function setDevice( $device ) { 87 85 $this->device = $device; 88 86 } 89 87 90 /*91 * Get Device ID to send to Pushover92 *93 * @return string device94 */88 /** 89 * Get Device ID to send to Pushover 90 * 91 * @return string device 92 */ 95 93 public function getDevice() { 96 94 return $this->device; 97 95 } 98 96 99 /*100 * Set Priority to send to Pushover (optional)101 *102 */97 /** 98 * Set Priority to send to Pushover (optional) 99 * 100 */ 103 101 public function setPriority( $priority ) { 104 102 $this->priority = $priority; 105 103 } 106 104 107 /*108 *Get Priority to send to Pushover (optional)109 *110 * @return string $priority111 */105 /** 106 * Get Priority to send to Pushover (optional) 107 * 108 * @return string $priority 109 */ 112 110 public function getPriority() { 113 111 return $this->priority; 114 112 } 115 /* 116 * Set Sound to send to Pushover (optional) 117 * 118 */ 113 114 /** 115 * Set Sound to send to Pushover (optional) 116 * 117 */ 119 118 public function setSound( $sound ) { 120 119 $this->sound = $sound; 121 120 } 122 121 123 /*124 *Get Sound to send to Pushover (optional)125 *126 * @return string $priority127 */122 /** 123 * Get Sound to send to Pushover (optional) 124 * 125 * @return string $priority 126 */ 128 127 public function getSound() { 129 128 return $this->sound; 130 129 } 131 130 132 /* 133 * setTitle() 134 * 135 */ 131 /** 132 * setTitle() 133 */ 136 134 public function setTitle( $title ) { 137 135 $this->title = $title; 138 136 } 139 137 140 /* 141 * getTitle() 142 * 143 */ 138 /** 139 * getTitle() 140 */ 144 141 public function getTitle() { 145 142 return $this->title; 146 143 } 147 144 148 /* 149 * setMessage() 150 * 151 */ 145 /** 146 * setMessage() 147 */ 152 148 public function setMessage( $message ) { 153 149 $this->message = $message; 154 150 } 155 151 156 /* 157 * getMessage() 158 * 159 */ 152 /** 153 * getMessage() 154 */ 160 155 public function getMessage() { 161 156 return $this->message; 162 157 } 163 158 164 /* 165 * setUrl() 166 * 167 */ 159 /** 160 * setUrl() 161 */ 168 162 public function setUrl( $url ) { 169 163 $this->url = $url; 170 164 } 171 165 172 /* 166 /** 173 167 * getUrl() 174 *175 168 */ 176 169 public function getUrl() { … … 178 171 } 179 172 180 /* 181 * send() 182 * 183 * Use WP_remote_post to send message to Pushover API 184 * 185 * @throws exception - on any error in sending, or missing settings 186 * @return none 187 */ 188 function send() { 189 190 if ( $this->site_api == '' ) 191 throw new Exception('Missing Site API'); 192 if ( $this->user_api == '' ) 193 throw new Exception('Missing User API'); 194 if ( $this->title == '' ) 195 throw new Exception('Missing Title'); 196 if ( $this->message == '' ) 197 throw new Exception('Missing Message'); 198 if ( $this->url == '' ) 199 throw new Exception('Missing URL'); 173 /** 174 * send() 175 * 176 * Use WP_remote_post to send message to Pushover API 177 * 178 * @return array|WP_Error 179 * @throws Exception 180 */ 181 public function send() { 182 183 if ( '' === $this->site_api ) { 184 throw new Exception( 'Missing Site API' ); 185 } 186 if ( '' === $this->user_api ) { 187 throw new Exception( 'Missing User API' ); 188 } 189 if ( '' === $this->title ) { 190 throw new Exception( 'Missing Title' ); 191 } 192 if ( '' === $this->message ) { 193 throw new Exception( 'Missing Message' ); 194 } 195 if ( '' === $this->url ) { 196 throw new Exception( 'Missing URL' ); 197 } 200 198 201 199 $request = array( 202 'token' => $this->site_api, 203 'user' => $this->user_api, 204 'title' => $this->title, 205 'message' => $this->message, 206 'url' => $this->url, 207 'sound' => $this->sound 208 ); 209 210 $response = wp_remote_post( 211 $this->endpoint, 212 array( 213 'timeout' => 70, 214 'sslverify' => 0, 215 'body' => $request 216 ) 200 'token' => $this->site_api, 201 'user' => $this->user_api, 202 'title' => $this->title, 203 'message' => $this->message, 204 'url' => $this->url, 205 'sound' => $this->sound, 217 206 ); 218 219 return $response; 220 221 } 222 207 208 $response = wp_remote_post( 209 $this->endpoint, 210 array( 211 'timeout' => 70, 212 'sslverify' => 0, 213 'body' => $request, 214 ) 215 ); 216 217 return $response; 218 } 223 219 224 220 } -
pushover-for-woocommerce/trunk/classes/class-wc-pushover.php
r2021583 r2246462 3 3 * WC_Pushover class. 4 4 */ 5 /* 6 This program is free software; you can redistribute it and/or modify7 it under the terms of the GNU General Public License, version 2, as8 published by the Free Software Foundation.9 10 This program is distributed in the hope that it will be useful,11 but WITHOUT ANY WARRANTY; without even the implied warranty of12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 GNU General Public License for more details.14 15 You should have received a copy of the GNU General Public License16 along with this program; if not, write to the Free Software17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA18 */5 /** 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License, version 2, as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 19 if ( ! defined( 'ABSPATH' ) ) { 20 20 exit; // Exit if accessed directly … … 24 24 25 25 /** 26 * True if WooCommerce 3 is installed 27 * 28 * @var boolean 29 */ 30 protected $is_wc_3; 26 * desc 27 * 28 * @var string 29 */ 30 public $site_api = ''; 31 32 /** 33 * desc 34 * 35 * @var string 36 */ 37 public $user_api = ''; 38 39 /** 40 * desc 41 * 42 * @var string 43 */ 44 public $device = ''; 45 46 /** 47 * desc 48 * 49 * @var string 50 */ 51 public $priority = ''; 52 53 /** 54 * desc 55 * 56 * @var bool 57 */ 58 public $debug = false; 59 60 /** 61 * desc 62 * 63 * @var string 64 */ 65 public $sound = ''; 66 67 /** 68 * desc 69 * 70 * @var bool 71 */ 72 public $notify_new_order = false; 73 74 /** 75 * desc 76 * 77 * @var bool 78 */ 79 public $notify_free_order = false; 80 81 /** 82 * desc 83 * 84 * @var bool 85 */ 86 public $notify_backorder = false; 87 88 /** 89 * desc 90 * 91 * @var bool 92 */ 93 public $notify_no_stock = false; 94 95 /** 96 * desc 97 * 98 * @var bool 99 */ 100 public $notify_low_stock = false; 31 101 32 102 /** … … 36 106 */ 37 107 public function __construct() { 38 39 $this->is_wc_3 = version_compare( WC()->version, '3.0.0', '>=');40 108 41 109 $this->id = 'pushover'; … … 50 118 51 119 // Define user set variables 52 $this->enabled = isset( $this->settings['enabled'] ) && $this->settings['enabled'] == 'yes'? true : false;53 $this->site_api = isset( $this->settings['site_api'] ) ? $this->settings['site_api'] : '';54 $this->user_api = isset( $this->settings['user_api'] ) ? $this->settings['user_api'] : '';55 $this->device = isset( $this->settings['device'] ) ? $this->settings['device'] : '';56 $this->priority = isset( $this->settings['priority'] ) ? $this->settings['priority'] : '';57 $this->debug = isset( $this->settings['debug'] ) && $this->settings['debug'] == 'yes'? true : false;58 $this->sound = isset( $this->settings['sound'] ) ? $this->settings['sound'] : '';59 120 $this->enabled = isset( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'] ? true : false; 121 $this->site_api = isset( $this->settings['site_api'] ) ? $this->settings['site_api'] : ''; 122 $this->user_api = isset( $this->settings['user_api'] ) ? $this->settings['user_api'] : ''; 123 $this->device = isset( $this->settings['device'] ) ? $this->settings['device'] : ''; 124 $this->priority = isset( $this->settings['priority'] ) ? $this->settings['priority'] : ''; 125 $this->debug = isset( $this->settings['debug'] ) && 'yes' === $this->settings['debug'] ? true : false; 126 $this->sound = isset( $this->settings['sound'] ) ? $this->settings['sound'] : ''; 127 60 128 // Notices 61 $this->notify_new_order = isset( $this->settings['notify_new_order'] ) && $this->settings['notify_new_order'] == 'yes'? true : false;62 $this->notify_free_order = isset( $this->settings['notify_free_order'] ) && $this->settings['notify_free_order'] == 'yes'? true : false;63 $this->notify_backorder = isset( $this->settings['notify_backorder'] ) && $this->settings['notify_backorder'] == 'yes'? true : false;64 $this->notify_no_stock = isset( $this->settings['notify_no_stock'] ) && $this->settings['notify_no_stock'] == 'yes'? true : false;65 $this->notify_low_stock = isset( $this->settings['notify_low_stock'] ) && $this->settings['notify_low_stock'] == 'yes'? true : false;129 $this->notify_new_order = isset( $this->settings['notify_new_order'] ) && 'yes' === $this->settings['notify_new_order'] ? true : false; 130 $this->notify_free_order = isset( $this->settings['notify_free_order'] ) && 'yes' === $this->settings['notify_free_order'] ? true : false; 131 $this->notify_backorder = isset( $this->settings['notify_backorder'] ) && 'yes' === $this->settings['notify_backorder'] ? true : false; 132 $this->notify_no_stock = isset( $this->settings['notify_no_stock'] ) && 'yes' === $this->settings['notify_no_stock'] ? true : false; 133 $this->notify_low_stock = isset( $this->settings['notify_low_stock'] ) && 'yes' === $this->settings['notify_low_stock'] ? true : false; 66 134 67 135 // Actions 68 add_action( 'woocommerce_update_options_integration_pushover', array( &$this, 'process_admin_options' ) );136 add_action( 'woocommerce_update_options_integration_pushover', array( &$this, 'process_admin_options' ) ); 69 137 add_action( 'init', array( $this, 'wc_pushover_init' ), 10 ); 70 138 71 if ( $this->notify_new_order ) 139 if ( $this->notify_new_order ) { 72 140 add_action( 'woocommerce_thankyou', array( $this, 'notify_new_order' ) ); 73 if ( $this->notify_backorder ) 141 } 142 if ( $this->notify_backorder ) { 74 143 add_action( 'woocommerce_product_on_backorder', array( $this, 'notify_backorder' ) ); 75 if ( $this->notify_no_stock ) 144 } 145 if ( $this->notify_no_stock ) { 76 146 add_action( 'woocommerce_no_stock', array( $this, 'notify_no_stock' ) ); 77 if ( $this->notify_low_stock ) 147 } 148 if ( $this->notify_low_stock ) { 78 149 add_action( 'woocommerce_low_stock', array( $this, 'notify_low_stock' ) ); 150 } 79 151 80 152 } … … 86 158 * @return void 87 159 */ 88 function init_form_fields() {160 public function init_form_fields() { 89 161 90 162 $this->form_fields = array( 91 'enabled' => array(92 'title' => __( 'Enable/Disable', 'wc_pushover' ),93 'label' => __( 'Enable sending of notifications', 'wc_pushover' ),94 'type' => 'checkbox',95 'default' => 'no',96 ), 97 'site_api' => array(163 'enabled' => array( 164 'title' => __( 'Enable/Disable', 'wc_pushover' ), 165 'label' => __( 'Enable sending of notifications', 'wc_pushover' ), 166 'type' => 'checkbox', 167 'default' => 'no', 168 ), 169 'site_api' => array( 98 170 'title' => __( 'API Token', 'wc_pushover' ), 99 171 'description' => sprintf( … … 105 177 'default' => '', 106 178 ), 107 'user_api' => array(179 'user_api' => array( 108 180 'title' => __( 'User Key', 'wc_pushover' ), 109 181 'description' => sprintf( … … 115 187 'default' => '', 116 188 ), 117 'priority' => array(189 'priority' => array( 118 190 'title' => __( 'Priority', 'wc_pushover' ), 119 191 'description' => sprintf( … … 122 194 __( 'Priorities explained.', 'wc_pushover' ) 123 195 ), 124 'type' => 'select',196 'type' => 'select', 125 197 'options' => array( 126 '-2' => __( '-2 Lowest Priority', 'wc_pushover'),127 '-1' => __( '-1 Low Priority', 'wc_pushover'),128 '0' => __( '0 Normal', 'wc_pushover'),129 '1' => __( '1 High', 'wc_pushover'),130 '2' => __( '2 Emergency Priority', 'wc_pushover'),131 ),198 '-2' => __( '-2 Lowest Priority', 'wc_pushover' ), 199 '-1' => __( '-1 Low Priority', 'wc_pushover' ), 200 '0' => __( '0 Normal', 'wc_pushover' ), 201 '1' => __( '1 High', 'wc_pushover' ), 202 '2' => __( '2 Emergency Priority', 'wc_pushover' ), 203 ), 132 204 'default' => '0', 133 205 ), 134 'sound' => array(206 'sound' => array( 135 207 'title' => __( 'Notification Sound', 'wc_pushover' ), 136 208 'description' => sprintf( … … 142 214 'default' => '', 143 215 ), 144 'device' => array(216 'device' => array( 145 217 'title' => __( 'Device', 'wc_pushover' ), 146 218 'description' => __( 'Optional: Name of device to send notifications', 'wc_pushover' ), … … 148 220 'default' => '', 149 221 ), 150 'debug' => array(222 'debug' => array( 151 223 'title' => __( 'Debug', 'wc_pushover' ), 152 'description' => __( 'Enable debug logging', 'wc_pushover'),224 'description' => sprintf( __( 'Enable debug logging. View log <a href="%s">here</a>.', 'wc_pushover' ), admin_url('admin.php?page=wc-status&tab=logs') ), 153 225 'type' => 'checkbox', 154 226 'default' => 'no', 155 227 ), 156 'notifications' => array(157 'title' => __( 'Notifications', 'wc_pushover' ),158 'type' => 'title',159 ), 160 'notify_new_order' => array(161 'title' => __( 'New Order', 'wc_pushover' ),162 'label' => __( 'Send notification when a new order is received.', 'wc_pushover' ),163 'type' => 'checkbox',164 'default' => 'no',165 ), 166 'notify_free_order' => array(167 'title' => __( 'Free Order', 'wc_pushover' ),168 'label' => __( 'Send notification when an order totals $0.', 'wc_pushover' ),169 'type' => 'checkbox',170 'default' => 'no',171 ), 172 'notify_backorder' => array(173 'title' => __( 'Back Order', 'wc_pushover' ),174 'label' => __( 'Send notification when a product is back ordered.', 'wc_pushover' ),175 'type' => 'checkbox',176 'default' => 'no',177 ), 178 'notify_no_stock' => array(179 'title' => __( 'No Stock', 'wc_pushover' ),180 'label' => __( 'Send notification when a product has no stock.', 'wc_pushover' ),181 'type' => 'checkbox',182 'default' => 'no',183 ), 184 'notify_low_stock' => array(185 'title' => __( 'Low Stock', 'wc_pushover' ),186 'label' => __( 'Send notification when a product hits the low stock.', 'wc_pushover' ),187 'type' => 'checkbox',188 'default' => 'no',189 ), 190 'messages' => array(191 'title' => __( 'Messages', 'wc_pushover' ),192 'type' => 'title',193 ), 194 'title_new_order' => array(228 'notifications' => array( 229 'title' => __( 'Notifications', 'wc_pushover' ), 230 'type' => 'title', 231 ), 232 'notify_new_order' => array( 233 'title' => __( 'New Order', 'wc_pushover' ), 234 'label' => __( 'Send notification when a new order is received.', 'wc_pushover' ), 235 'type' => 'checkbox', 236 'default' => 'no', 237 ), 238 'notify_free_order' => array( 239 'title' => __( 'Free Order', 'wc_pushover' ), 240 'label' => __( 'Send notification when an order totals $0.', 'wc_pushover' ), 241 'type' => 'checkbox', 242 'default' => 'no', 243 ), 244 'notify_backorder' => array( 245 'title' => __( 'Back Order', 'wc_pushover' ), 246 'label' => __( 'Send notification when a product is back ordered.', 'wc_pushover' ), 247 'type' => 'checkbox', 248 'default' => 'no', 249 ), 250 'notify_no_stock' => array( 251 'title' => __( 'No Stock', 'wc_pushover' ), 252 'label' => __( 'Send notification when a product has no stock.', 'wc_pushover' ), 253 'type' => 'checkbox', 254 'default' => 'no', 255 ), 256 'notify_low_stock' => array( 257 'title' => __( 'Low Stock', 'wc_pushover' ), 258 'label' => __( 'Send notification when a product hits the low stock.', 'wc_pushover' ), 259 'type' => 'checkbox', 260 'default' => 'no', 261 ), 262 'messages' => array( 263 'title' => __( 'Messages', 'wc_pushover' ), 264 'type' => 'title', 265 ), 266 'title_new_order' => array( 195 267 'title' => __( 'New Order', 'wc_pushover' ), 196 268 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Title', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {First Name}, {Last Name}, {Phone}, {Order Id}, {Products}, {Total}, {Currency}, {Currency Symbol}, {Payment Method}, {Order Status}', 197 'type' => 'text',198 'default' => '',199 'placeholder' => sprintf(200 '%s {Order Id}',201 __( 'New Order', 'wc_pushover' )202 ),203 'css' => 'width: 100%',204 ),205 'message_new_order' => array(206 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Message', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {First Name}, {Last Name}, {Phone}, {Order Id}, {Products}, {Total}, {Currency}, {Currency Symbol}, {Payment Method}, {Order Status}',207 'type' => 'text',208 'default' => '',209 'placeholder' => sprintf(210 '{First Name} {Last Name} %s {Products} %s {Currency Symbol}{Total}',211 __( 'ordered', 'wc_pushover' ),212 __( 'for', 'wc_pushover' )213 ),214 'css' => 'width: 100%',215 ),216 'title_free_order' => array(217 'title' => __( 'Free Order', 'wc_pushover' ),218 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Title', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {First Name}, {Last Name}, {Phone}, {Order Id}, {Products}, {Total}, {Currency}, {Currency Symbol}, {Payment Method}, {Order Status}',219 269 'type' => 'text', 220 270 'default' => '', … … 225 275 'css' => 'width: 100%', 226 276 ), 227 'message_ free_order'=> array(277 'message_new_order' => array( 228 278 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Message', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {First Name}, {Last Name}, {Phone}, {Order Id}, {Products}, {Total}, {Currency}, {Currency Symbol}, {Payment Method}, {Order Status}', 229 279 'type' => 'text', … … 236 286 'css' => 'width: 100%', 237 287 ), 238 'title_backorder' => array( 288 'title_free_order' => array( 289 'title' => __( 'Free Order', 'wc_pushover' ), 290 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Title', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {First Name}, {Last Name}, {Phone}, {Order Id}, {Products}, {Total}, {Currency}, {Currency Symbol}, {Payment Method}, {Order Status}', 291 'type' => 'text', 292 'default' => '', 293 'placeholder' => sprintf( 294 '%s {Order Id}', 295 __( 'New Order', 'wc_pushover' ) 296 ), 297 'css' => 'width: 100%', 298 ), 299 'message_free_order' => array( 300 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Message', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {First Name}, {Last Name}, {Phone}, {Order Id}, {Products}, {Total}, {Currency}, {Currency Symbol}, {Payment Method}, {Order Status}', 301 'type' => 'text', 302 'default' => '', 303 'placeholder' => sprintf( 304 '{First Name} {Last Name} %s {Products} %s {Currency Symbol}{Total}', 305 __( 'ordered', 'wc_pushover' ), 306 __( 'for', 'wc_pushover' ) 307 ), 308 'css' => 'width: 100%', 309 ), 310 'title_backorder' => array( 239 311 'title' => __( 'Back Order', 'wc_pushover' ), 240 312 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Title', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {First Name}, {Last Name}, {Phone}, {Order Id}, {Products}, {Total}, {Currency}, {Currency Symbol}, {Payment Method}, {Order Status}, {Product Id}, {Product Name}, {Product Url}', … … 244 316 'css' => 'width: 100%', 245 317 ), 246 'message_backorder' => array(318 'message_backorder' => array( 247 319 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Message', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {First Name}, {Last Name}, {Phone}, {Order Id}, {Products}, {Total}, {Currency}, {Currency Symbol}, {Payment Method}, {Order Status}, {Product Id}, {Product Name}, {Product Url}', 248 320 'type' => 'text', … … 255 327 'css' => 'width: 100%', 256 328 ), 257 'title_no_stock' => array(329 'title_no_stock' => array( 258 330 'title' => __( 'No Stock', 'wc_pushover' ), 259 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Title', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {Product Id}, {Product Name}, {Product Url}',331 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Title', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {Product Id}, {Product Name}, {Product Url}', 260 332 'type' => 'text', 261 333 'default' => '', … … 263 335 'css' => 'width: 100%', 264 336 ), 265 'message_no_stock' => array(337 'message_no_stock' => array( 266 338 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Message', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {Product Id}, {Product Name}, {Product Url}', 267 339 'type' => 'text', … … 274 346 'css' => 'width: 100%', 275 347 ), 276 'title_low_stock' => array(348 'title_low_stock' => array( 277 349 'title' => __( 'Low Stock', 'wc_pushover' ), 278 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Title', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {Product Id}, {Product Name}, {Product Url}',350 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Title', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {Product Id}, {Product Name}, {Product Url}', 279 351 'type' => 'text', 280 352 'default' => '', … … 282 354 'css' => 'width: 100%', 283 355 ), 284 'message_low_stock' => array(356 'message_low_stock' => array( 285 357 'description' => sprintf( '%s<br>%s:', __( 'Optional: Custom Message', 'wc_pushover' ), __( 'Fields', 'wc_pushover' ) ) . ' {Product Id}, {Product Name}, {Product Url}', 286 358 'type' => 'text', … … 293 365 'css' => 'width: 100%', 294 366 ), 295 'test_button' => array(296 'type' => 'test_button',367 'test_button' => array( 368 'type' => 'test_button', 297 369 ), 298 370 … … 307 379 * @return void 308 380 */ 309 function wc_pushover_init() {310 311 if ( isset( $_GET['wc_test']) && ($_GET['wc_test']==1)){312 $title = __( 'Test Notification', 'wc_pushover' );313 $message = sprintf( __( 'This is a test notification from %s', 'wc_pushover' ), get_bloginfo( 'name'));381 public function wc_pushover_init() { 382 383 if ( isset( $_GET['wc_test'] ) && ( 1 === $_GET['wc_test'] ) ) { 384 $title = __( 'Test Notification', 'wc_pushover' ); 385 $message = sprintf( __( 'This is a test notification from %s', 'wc_pushover' ), get_bloginfo( 'name' ) ); 314 386 $url = get_admin_url(); 315 387 316 $this->send_notification(array( 317 'title' => $title, 318 'message' => $message, 319 'url' => $url 320 )); 388 $this->send_notification( 389 array( 390 'title' => $title, 391 'message' => $message, 392 'url' => $url, 393 ) 394 ); 321 395 322 396 wp_safe_redirect( get_admin_url() . 'admin.php?page=wc-settings&tab=integration§ion=pushover' ); … … 331 405 * @return void 332 406 */ 333 function notify_new_order( $order_id ) {407 public function notify_new_order( $order_id ) { 334 408 335 409 $order = new WC_Order( $order_id ); 336 $sent = get_post_meta( $order_id, '_pushover_new_order', true );410 $sent = get_post_meta( $order_id, '_pushover_new_order', true ); 337 411 338 412 if ( ! $sent ) { 339 413 340 $order_total = $this->is_wc_3 ? $order->get_total() : $order->order_total;414 $order_total = $order->get_total(); 341 415 // Send notifications if order total is greater than $0 342 416 // Or if free order notification is enabled 343 417 if ( 0 < absint( $order_total ) || $this->notify_free_order ) { 344 418 345 $type = 0== absint( $order_total ) ? 'free_order' : 'new_order';346 $title = ! empty($this->settings['title_' . $type]) ? $this->replace_fields_custom_message($this->settings['title_' . $type], $order) : sprintf( __( 'New Order %d', 'wc_pushover' ), $order_id );347 348 $message = ! empty($this->settings['message_' . $type]) ? $this->replace_fields_custom_message($this->settings['message_' . $type], $order) : sprintf(419 $type = 0 === absint( $order_total ) ? 'free_order' : 'new_order'; 420 $title = ! empty( $this->settings[ 'title_' . $type ] ) ? $this->replace_fields_custom_message( $this->settings[ 'title_' . $type ], $order ) : sprintf( __( 'New Order %d', 'wc_pushover' ), $order_id ); 421 422 $message = ! empty( $this->settings[ 'message_' . $type ] ) ? $this->replace_fields_custom_message( $this->settings[ 'message_' . $type ], $order ) : sprintf( 349 423 __( '%1$s ordered %2$s for %3$s ', 'wc_pushover' ), 350 $ this->is_wc_3 ? $order->get_billing_first_name() . " " . $order->get_billing_last_name() : $order->billing_first_name . " " . $order->billing_last_name,351 $this->get_ordered_products_string( $order),424 $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(), 425 $this->get_ordered_products_string( $order ), 352 426 $this->pushover_get_currency_symbol() . $order_total 353 427 ); 354 428 355 $url = get_admin_url() ;429 $url = get_admin_url().'post.php?post='.$order_id.'&action=edit'; 356 430 357 431 $args = array( 358 'title' => $title,432 'title' => $title, 359 433 'message' => $message, 360 'url' => $url 434 'url' => $url, 361 435 ); 362 436 363 if ( 'free_order' === $type ) {364 $this->send_notification( apply_filters( 'wc_pushover_notify_free_order', $args));437 if ( 'free_order' === $type ) { 438 $this->send_notification( apply_filters( 'wc_pushover_notify_free_order', $args ) ); 365 439 } else { 366 $this->send_notification( apply_filters( 'wc_pushover_notify_new_order', $args));440 $this->send_notification( apply_filters( 'wc_pushover_notify_new_order', $args ) ); 367 441 } 368 442 … … 377 451 * 378 452 * @access public 379 * @param $args453 * @param array $args 380 454 * @return void 381 455 */ 382 function notify_backorder( $args ) {456 public function notify_backorder( $args ) { 383 457 384 458 $product = $args['product']; 385 459 $order_id = $args['order_id']; 386 460 387 $title = !empty($this->settings['title_backorder']) ? $this->replace_fields_custom_message($this->settings['title_backorder'], new WC_Order($args['order_id']), $product) : sprintf( __( 'Product Backorder', 'wc_pushover' ), $order_id ); 388 $message = !empty($this->settings['message_backorder']) ? $this->replace_fields_custom_message($this->settings['message_backorder'], new WC_Order($args['order_id']), $product) : sprintf( __( 'Product (#%d %s) is on backorder.', 'wc_pushover' ), $product->get_id(), $product->get_title() ); 389 390 $url = get_admin_url(); 391 392 $this->send_notification( apply_filters('wc_pushover_notify_backorder', array( 393 'title' => $title, 394 'message' => $message, 395 'url' => $url 396 ))); 461 $title = ! empty( $this->settings['title_backorder'] ) ? $this->replace_fields_custom_message( $this->settings['title_backorder'], new WC_Order( $args['order_id'] ), $product ) : sprintf( __( 'Product Backorder', 'wc_pushover' ), $order_id ); 462 $message = ! empty( $this->settings['message_backorder'] ) ? $this->replace_fields_custom_message( $this->settings['message_backorder'], new WC_Order( $args['order_id'] ), $product ) : sprintf( __( 'Product (#%1$d %2$s) is on backorder.', 'wc_pushover' ), $product->get_id(), $product->get_title() ); 463 464 $url = get_admin_url(); 465 466 $this->send_notification( 467 apply_filters( 468 'wc_pushover_notify_backorder', array( 469 'title' => $title, 470 'message' => $message, 471 'url' => $url, 472 ) 473 ) 474 ); 397 475 398 476 } … … 407 485 * @return void 408 486 */ 409 function notify_no_stock( WC_Product $product ) {410 411 $title = !empty($this->settings['title_no_stock']) ? $this->replace_fields_custom_message($this->settings['title_no_stock'], null, $product) : __( 'Product Out of Stock', 'wc_pushover' );412 $message = ! empty($this->settings['message_no_stock']) ? $this->replace_fields_custom_message($this->settings['message_no_stock'], null, $product) : sprintf( __( 'Product (#%d %s) is now out of stock.', 'wc_pushover' ), $product->get_id(), $product->get_title() );487 public function notify_no_stock( WC_Product $product ) { 488 489 $title = ! empty( $this->settings['title_no_stock'] ) ? $this->replace_fields_custom_message( $this->settings['title_no_stock'], null, $product ) : __( 'Product Out of Stock', 'wc_pushover' ); 490 $message = ! empty( $this->settings['message_no_stock'] ) ? $this->replace_fields_custom_message( $this->settings['message_no_stock'], null, $product ) : sprintf( __( 'Product (#%1$d %2$s) is now out of stock.', 'wc_pushover' ), $product->get_id(), $product->get_title() ); 413 491 $url = get_admin_url(); 414 492 415 $this->send_notification( apply_filters('wc_pushover_notify_no_stock', array( 416 'title' => $title, 417 'message' => $message, 418 'url' => $url 419 ))); 493 $this->send_notification( 494 apply_filters( 495 'wc_pushover_notify_no_stock', array( 496 'title' => $title, 497 'message' => $message, 498 'url' => $url, 499 ) 500 ) 501 ); 420 502 421 503 } … … 430 512 * @return void 431 513 */ 432 function notify_low_stock( WC_Product $product ) {514 public function notify_low_stock( WC_Product $product ) { 433 515 434 516 // get order details 435 $title = !empty($this->settings['title_low_stock']) ? $this->replace_fields_custom_message($this->settings['title_low_stock'], null, $product) : __( 'Product Low Stock', 'wc_pushover' );436 $message = ! empty($this->settings['message_low_stock']) ? $this->replace_fields_custom_message($this->settings['message_low_stock'], null, $product) : sprintf( __( 'Product (#%d %s) now has low stock.', 'wc_pushover' ), $product->get_id(), $product->get_title() );517 $title = ! empty( $this->settings['title_low_stock'] ) ? $this->replace_fields_custom_message( $this->settings['title_low_stock'], null, $product ) : __( 'Product Low Stock', 'wc_pushover' ); 518 $message = ! empty( $this->settings['message_low_stock'] ) ? $this->replace_fields_custom_message( $this->settings['message_low_stock'], null, $product ) : sprintf( __( 'Product (#%1$d %2$s) now has low stock.', 'wc_pushover' ), $product->get_id(), $product->get_title() ); 437 519 $url = get_admin_url(); 438 520 439 $this->send_notification( apply_filters('wc_pushover_notify_low_stock', array( 440 'title' => $title, 441 'message' => $message, 442 'url' => $url 443 ))); 521 $this->send_notification( 522 apply_filters( 523 'wc_pushover_notify_low_stock', array( 524 'title' => $title, 525 'message' => $message, 526 'url' => $url, 527 ) 528 ) 529 ); 444 530 445 531 } … … 456 542 protected function replace_fields_custom_message( $custom_string, $order = null, $product = null ) { 457 543 458 if( ! empty( $order ) ) {459 $custom_string = str_replace(460 array(461 '{First Name}',462 '{Last Name}',463 '{Phone}',464 '{Order Id}',465 '{Products}',466 '{Total}',467 '{Currency}',468 '{Currency Symbol}',469 '{Payment Method}',470 '{Order Status}',471 ),472 array(473 $this->is_wc_3 ? $order->get_billing_first_name() : $order->billing_first_name,474 $this->is_wc_3 ? $order->get_billing_last_name() : $order->billing_last_name,475 $this->is_wc_3 ? $order->get_billing_phone() : $order->billing_phone,476 $this->is_wc_3 ? $order->get_id() : $order->id,477 $this->get_ordered_products_string($order),478 $order->get_total(),479 get_woocommerce_currency(),480 $this->pushover_get_currency_symbol(),481 $this->is_wc_3 ? $order->get_payment_method_title() : $order->payment_method_title,482 $order->get_status(),483 ),484 $custom_string485 );486 }487 488 if ( ! empty( $product ) ) {544 if ( ! empty( $order ) ) { 545 $custom_string = str_replace( 546 array( 547 '{First Name}', 548 '{Last Name}', 549 '{Phone}', 550 '{Order Id}', 551 '{Products}', 552 '{Total}', 553 '{Currency}', 554 '{Currency Symbol}', 555 '{Payment Method}', 556 '{Order Status}', 557 ), 558 array( 559 $order->get_billing_first_name(), 560 $order->get_billing_last_name(), 561 $order->get_billing_phone(), 562 $order->get_id(), 563 $this->get_ordered_products_string( $order ), 564 $order->get_total(), 565 get_woocommerce_currency(), 566 $this->pushover_get_currency_symbol(), 567 $order->get_payment_method_title(), 568 $order->get_status(), 569 ), 570 $custom_string 571 ); 572 } 573 574 if ( ! empty( $product ) ) { 489 575 $custom_string = str_replace( 490 576 array( … … 496 582 $product->get_id(), 497 583 $product->get_title(), 498 get_permalink( $product->get_id()),584 get_permalink( $product->get_id() ), 499 585 ), 500 586 $custom_string … … 513 599 * @return string of products 514 600 */ 515 protected function get_ordered_products_string($order) { 516 if ( $this->is_wc_3 ){ 517 $items = $order->get_items(); 518 $names = array(); 519 foreach( $items as $item ){ 520 $names[] = $item->get_name(); 521 } 522 $products = implode( ', ', $names ); 523 } else { 524 $products = implode( ', ', wp_list_pluck( $order->get_items(), 'name' ) ); 525 } 601 protected function get_ordered_products_string( $order ) { 602 $items = $order->get_items(); 603 $names = array(); 604 foreach ( $items as $item ) { 605 $names[] = $item->get_name(); 606 } 607 $products = implode( ', ', $names ); 526 608 527 609 return $products; … … 541 623 * @return void 542 624 */ 543 function send_notification( $args ) { 544 545 if ( ! class_exists( 'Pushover_Api' ) ) 546 include_once( 'class-pushover-api.php' ); 625 public function send_notification( $args ) { 626 627 if ( ! class_exists( 'Pushover_Api' ) ) { 628 include_once 'class-pushover-api.php'; 629 } 547 630 548 631 $pushover = new Pushover_Api(); 549 632 550 633 // check settings, if not return 551 if ( ( '' == $this->site_api ) || ( ''== $this->user_api ) ) {552 $this->add_log( __( 'Site API or User API setting is missing. Notification not sent.', 'wc_pushover') );634 if ( ( '' === $this->site_api ) || ( '' === $this->user_api ) ) { 635 $this->add_log( __( 'Site API or User API setting is missing. Notification not sent.', 'wc_pushover' ) ); 553 636 return; 554 637 } … … 557 640 $pushover->setSiteApi( $this->site_api ); 558 641 $pushover->setUserApi( $this->user_api ); 559 if ( '' != $this->device ) {642 if ( '' !== $this->device ) { 560 643 $pushover->setDevice( $this->device ); 561 644 } 562 645 $pushover->setPriority( $this->priority ); 563 646 $pushover->setSound( $this->sound ); 564 647 565 648 // Setup message 566 $pushover->setTitle ( $args['title'] );649 $pushover->setTitle( $args['title'] ); 567 650 $pushover->setMessage( $args['message'] ); 568 651 $pushover->setUrl( $args['url'] ); 569 652 $response = ''; 570 653 571 $this->add_log( __( 'Sending: ', 'wc_pushover' ) . 572 "\nTitle: ". $args['title'] . 573 "\nMessage: ". $args['message'] . 654 $this->add_log( 655 __( 'Sending: ', 'wc_pushover' ) . 656 "\nTitle: " . $args['title'] . 657 "\nMessage: " . $args['message'] . 574 658 "\nURL: " . $args['url'] . 575 "\nPriority: " . $this->priority . 576 "\nSound: " . $this->sound ); 659 "\nPriority: " . $this->priority . 660 "\nSound: " . $this->sound 661 ); 577 662 578 663 try { 579 664 $response = $pushover->send(); 580 $this->add_log( __( 'Response: ', 'wc_pushover' ) . "\n" . print_r( $response, true ) );665 $this->add_log( __( 'Response: ', 'wc_pushover' ) . "\n" . print_r( $response, true ) ); 581 666 582 667 } catch ( Exception $e ) { 583 668 $this->add_log( sprintf( __( 'Error: Caught exception from send method: %s', 'wc_pushover' ), $e->getMessage() ) ); 584 669 } 585 586 $this->add_log( __( 'Pushover response', 'wc_pushover') . "\n" . print_r($response,true) );670 671 $this->add_log( __( 'Pushover response', 'wc_pushover' ) . "\n" . print_r( $response, true ) ); 587 672 588 673 } … … 593 678 * @access public 594 679 */ 595 function generate_test_button_html() {680 public function generate_test_button_html() { 596 681 ob_start(); 597 682 ?> … … 613 698 * @return void 614 699 */ 615 function add_log( $message ) { 616 617 if ( ! $this->debug ) return; 618 619 $time = date_i18n( 'm-d-Y @ H:i:s -' ); 620 $handle = fopen( WC_PUSHOVER_DIR . 'debug_pushover.log', 'a' ); 621 if ( $handle ) { 622 fwrite( $handle, $time . ' ' . $message . "\n" ); 623 fclose( $handle ); 624 } 700 private function add_log( $message ) { 701 702 if ( ! $this->debug ) { 703 return; 704 } 705 706 $logger = new WC_Logger(); 707 $logger->add('pushover-woocommerce', $message ); 625 708 626 709 } … … 633 716 * @since 1.0.2 634 717 */ 635 function pushover_get_currency_symbol() {718 public function pushover_get_currency_symbol() { 636 719 $currency = get_woocommerce_currency(); 637 720 638 721 switch ( $currency ) { 639 case 'BRL' :722 case 'BRL': 640 723 $currency_symbol = 'R$'; 641 724 break; 642 case 'AUD' :643 case 'CAD' :644 case 'MXN' :645 case 'NZD' :646 case 'HKD' :647 case 'SGD' :648 case 'USD' :725 case 'AUD': 726 case 'CAD': 727 case 'MXN': 728 case 'NZD': 729 case 'HKD': 730 case 'SGD': 731 case 'USD': 649 732 $currency_symbol = '$'; 650 733 break; 651 case 'EUR' :734 case 'EUR': 652 735 $currency_symbol = '€'; 653 736 break; 654 case 'CNY' :655 case 'RMB' :656 case 'JPY' :737 case 'CNY': 738 case 'RMB': 739 case 'JPY': 657 740 $currency_symbol = '¥'; 658 741 break; 659 case 'RUB' :742 case 'RUB': 660 743 $currency_symbol = 'руб.'; 661 744 break; 662 case 'KRW' : $currency_symbol = '₩'; break; 663 case 'TRY' : $currency_symbol = 'TL'; break; 664 case 'NOK' : $currency_symbol = 'kr'; break; 665 case 'ZAR' : $currency_symbol = 'R'; break; 666 case 'CZK' : $currency_symbol = 'Kč'; break; 667 case 'MYR' : $currency_symbol = 'RM'; break; 668 case 'DKK' : $currency_symbol = 'kr'; break; 669 case 'HUF' : $currency_symbol = 'Ft'; break; 670 case 'IDR' : $currency_symbol = 'Rp'; break; 671 case 'INR' : $currency_symbol = '₹'; break; 672 case 'ILS' : $currency_symbol = '₪'; break; 673 case 'PHP' : $currency_symbol = '₱'; break; 674 case 'PLN' : $currency_symbol = 'zł'; break; 675 case 'SEK' : $currency_symbol = 'kr'; break; 676 case 'CHF' : $currency_symbol = 'CHF'; break; 677 case 'TWD' : $currency_symbol = 'NT$'; break; 678 case 'THB' : $currency_symbol = '฿'; break; 679 case 'GBP' : $currency_symbol = '£'; break; 680 case 'RON' : $currency_symbol = 'lei'; break; 681 default : $currency_symbol = ''; break; 745 case 'KRW': 746 $currency_symbol = '₩'; 747 break; 748 case 'TRY': 749 $currency_symbol = 'TL'; 750 break; 751 case 'NOK': 752 $currency_symbol = 'kr'; 753 break; 754 case 'ZAR': 755 $currency_symbol = 'R'; 756 break; 757 case 'CZK': 758 $currency_symbol = 'Kč'; 759 break; 760 case 'MYR': 761 $currency_symbol = 'RM'; 762 break; 763 case 'DKK': 764 $currency_symbol = 'kr'; 765 break; 766 case 'HUF': 767 $currency_symbol = 'Ft'; 768 break; 769 case 'IDR': 770 $currency_symbol = 'Rp'; 771 break; 772 case 'INR': 773 $currency_symbol = '₹'; 774 break; 775 case 'ILS': 776 $currency_symbol = '₪'; 777 break; 778 case 'PHP': 779 $currency_symbol = '₱'; 780 break; 781 case 'PLN': 782 $currency_symbol = 'zł'; 783 break; 784 case 'SEK': 785 $currency_symbol = 'kr'; 786 break; 787 case 'CHF': 788 $currency_symbol = 'CHF'; 789 break; 790 case 'TWD': 791 $currency_symbol = 'NT$'; 792 break; 793 case 'THB': 794 $currency_symbol = '฿'; 795 break; 796 case 'GBP': 797 $currency_symbol = '£'; 798 break; 799 case 'RON': 800 $currency_symbol = 'lei'; 801 break; 802 default: 803 $currency_symbol = ''; 804 break; 682 805 } 683 806 -
pushover-for-woocommerce/trunk/readme.txt
r2021584 r2246462 4 4 Tags: woocommerce, pushover, ecommerce, notification, integration, ios, android, store manager 5 5 Requires at least: 3.5 6 Tested up to: 5. 0.37 Stable tag: 1.0.1 58 WC tested up to: 3.5.46 Tested up to: 5.3.2 7 Stable tag: 1.0.16 8 WC tested up to: 4.0 9 9 License: GPLv3 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 91 91 == Changelog == 92 92 93 2020.20.18 1.0.16 94 * Tested with WooCommerce 3.9 95 * Removed support for WooCommerce 2.x 96 * Added direct link to edit order page - Thanks @galapogos01 97 * Fixing formatting and PHPCS Doc 98 * Moved debug log to WC_Logger 99 93 100 2019.01.29 1.0.15 94 101 * Added Phone field for messages -
pushover-for-woocommerce/trunk/woocommerce-pushover.php
r2021583 r2246462 3 3 * Plugin Name: WooCommerce Pushover Integration 4 4 * Plugin URI: https://shopplugins.com/ 5 * Description: Integrates <a href="http ://www.woothemes.com/woocommerce" target="_blank" >WooCommerce</a> with the <a href="https://pushover.net/" target="_blank">Pushover</a> notifications app for Android and iOS.6 * Version: 1.0.1 55 * Description: Integrates <a href="https://woocommerce.com" target="_blank" >WooCommerce</a> with the <a href="https://pushover.net/" target="_blank">Pushover</a> notifications app for Android and iOS. 6 * Version: 1.0.16 7 7 * Author: Shop Plugins 8 8 * Author URI: https://shopplugins.com/ 9 * WC requires at least: 2.6.1410 * WC tested up to: 3.5.49 * WC requires at least: 3.0 10 * WC tested up to: 4.0 11 11 */ 12 12 /** … … 27 27 * Required functions 28 28 */ 29 if ( class_exists( 'WC_Pushover' ) ) return; 29 if ( class_exists( 'WC_Pushover' ) ) { 30 return; 31 } 30 32 31 define( 'WC_PUSHOVER_DIR', plugin_dir_path( __FILE__) );33 define( 'WC_PUSHOVER_DIR', plugin_dir_path( __FILE__ ) ); 32 34 33 35 /** … … 50 52 $active_plugins = (array) get_option( 'active_plugins', array() ); 51 53 52 if ( is_multisite() ) 54 if ( is_multisite() ) { 53 55 $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); 56 } 54 57 55 if ( ! ( in_array( 'woocommerce/woocommerce.php', $active_plugins) || array_key_exists('woocommerce/woocommerce.php', $active_plugins) ) ) {56 deactivate_plugins( basename( __FILE__ ) );57 wp_die( "This plugin requires WooCommerce to be installed and active.");58 if ( ! ( in_array( 'woocommerce/woocommerce.php', $active_plugins, true ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins ) ) ) { 59 deactivate_plugins( basename( __FILE__ ) ); 60 wp_die( 'This plugin requires WooCommerce to be installed and active.' ); 58 61 } 59 62 60 63 // verify that SimpleXML library is available 61 64 if ( ! function_exists( 'simplexml_load_string' ) ) { 62 deactivate_plugins( basename( __FILE__ ) );63 wp_die( "Sorry, but you can't run this plugin, it requires the SimpleXML library installed on your server/hosting to function." );65 deactivate_plugins( basename( __FILE__ ) ); 66 wp_die( "Sorry, but you can't run this plugin, it requires the SimpleXML library installed on your server/hosting to function." ); 64 67 } 65 68 66 69 } 67 70 register_activation_hook( __FILE__, 'wc_pushover_activation_check' ); … … 74 77 */ 75 78 function wc_pushover_init() { 76 include_once ( 'classes/class-wc-pushover.php' );79 include_once 'classes/class-wc-pushover.php'; 77 80 } 78 81 add_action( 'woocommerce_integrations_init', 'wc_pushover_init' ); … … 82 85 return $integrations; 83 86 } 84 add_filter( 'woocommerce_integrations', 'add_pushover_integration' );87 add_filter( 'woocommerce_integrations', 'add_pushover_integration' ); 85 88 86 89 /** … … 89 92 function wc_pushover_plugin_links( $links ) { 90 93 $plugin_links = array( 91 '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=integration ' ) . '">' . __( 'Settings', 'wc_pushover' ) . '</a>',94 '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=integration§ion=pushover' ) . '">' . __( 'Settings', 'wc_pushover' ) . '</a>', 92 95 '<a href="https://shopplugins.com/support">' . __( 'Support', 'wc_pushover' ) . '</a>', 93 96 '<a href="https://wordpress.org/plugins/pushover-for-woocommerce/installation/">' . __( 'Docs', 'wc_pushover' ) . '</a>',
Note: See TracChangeset
for help on using the changeset viewer.