@@ -8,7 +8,7 @@ |
||
| 8 | 8 | * @version 1.0.19 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | return array( |
| 14 | 14 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | 'block-keywords'=> "['invoicing','history']", |
| 23 | 23 | 'class_name' => __CLASS__, |
| 24 | 24 | 'base_id' => 'wpinv_messages', |
| 25 | - 'name' => __('GetPaid > Invoice Messages','invoicing'), |
|
| 25 | + 'name' => __('GetPaid > Invoice Messages', 'invoicing'), |
|
| 26 | 26 | 'widget_ops' => array( |
| 27 | 27 | 'classname' => 'wpinv-messages-class wpi-g', |
| 28 | - 'description' => esc_html__('Displays invoice error and warning messages on checkout page.','invoicing'), |
|
| 28 | + 'description' => esc_html__('Displays invoice error and warning messages on checkout page.', 'invoicing'), |
|
| 29 | 29 | ), |
| 30 | 30 | 'arguments' => array( |
| 31 | 31 | 'title' => array( |
| 32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 32 | + 'title' => __('Widget title', 'invoicing'), |
|
| 33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 34 | 34 | 'type' => 'text', |
| 35 | 35 | 'desc_tip' => true, |
| 36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - parent::__construct( $options ); |
|
| 44 | + parent::__construct($options); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return mixed|string|bool |
| 55 | 55 | */ |
| 56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 57 | 57 | |
| 58 | 58 | ob_start(); |
| 59 | 59 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -23,40 +23,40 @@ discard block |
||
| 23 | 23 | 'block-keywords'=> "['invoicing','buy', 'buy item']", |
| 24 | 24 | 'class_name' => __CLASS__, |
| 25 | 25 | 'base_id' => 'wpinv_buy', |
| 26 | - 'name' => __('Get Paid > Buy Item Button (Deprecated)','invoicing'), |
|
| 26 | + 'name' => __('Get Paid > Buy Item Button (Deprecated)', 'invoicing'), |
|
| 27 | 27 | 'widget_ops' => array( |
| 28 | 28 | 'classname' => 'wpinv-buy-item-class wpi-g', |
| 29 | - 'description' => esc_html__('This widget is deprecated. Use the GetPaid widget instead.','invoicing'), |
|
| 29 | + 'description' => esc_html__('This widget is deprecated. Use the GetPaid widget instead.', 'invoicing'), |
|
| 30 | 30 | ), |
| 31 | 31 | 'arguments' => array( |
| 32 | 32 | 'title' => array( |
| 33 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 34 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 33 | + 'title' => __('Widget title', 'invoicing'), |
|
| 34 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 35 | 35 | 'type' => 'text', |
| 36 | 36 | 'desc_tip' => true, |
| 37 | 37 | 'default' => '', |
| 38 | 38 | 'advanced' => false |
| 39 | 39 | ), |
| 40 | 40 | 'items' => array( |
| 41 | - 'title' => __( 'Items to buy', 'invoicing' ), |
|
| 42 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
| 41 | + 'title' => __('Items to buy', 'invoicing'), |
|
| 42 | + 'desc' => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing'), |
|
| 43 | 43 | 'type' => 'text', |
| 44 | 44 | 'desc_tip' => true, |
| 45 | 45 | 'default' => '', |
| 46 | - 'placeholder' => __('Items to buy','invoicing'), |
|
| 46 | + 'placeholder' => __('Items to buy', 'invoicing'), |
|
| 47 | 47 | 'advanced' => false |
| 48 | 48 | ), |
| 49 | 49 | 'label' => array( |
| 50 | - 'title' => __( 'Button Label', 'invoicing' ), |
|
| 51 | - 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
| 50 | + 'title' => __('Button Label', 'invoicing'), |
|
| 51 | + 'desc' => __('Enter button label. Default "Buy Now".', 'invoicing'), |
|
| 52 | 52 | 'type' => 'text', |
| 53 | 53 | 'desc_tip' => true, |
| 54 | - 'default' => __( 'Buy Now', 'invoicing' ), |
|
| 54 | + 'default' => __('Buy Now', 'invoicing'), |
|
| 55 | 55 | 'advanced' => false |
| 56 | 56 | ), |
| 57 | 57 | 'post_id' => array( |
| 58 | - 'title' => __( 'Post ID', 'invoicing' ), |
|
| 59 | - 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
| 58 | + 'title' => __('Post ID', 'invoicing'), |
|
| 59 | + 'desc' => __('Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing'), |
|
| 60 | 60 | 'type' => 'number', |
| 61 | 61 | 'desc_tip' => true, |
| 62 | 62 | 'default' => '', |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | 69 | |
| 70 | - parent::__construct( $options ); |
|
| 70 | + parent::__construct($options); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -79,31 +79,31 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 82 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 83 | 83 | |
| 84 | 84 | $defaults = array( |
| 85 | 85 | 'items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
| 86 | - 'label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
| 86 | + 'label' => __('Buy Now', 'invoicing'), // the button title |
|
| 87 | 87 | 'post_id' => '', // any related post_id |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Parse incoming $args into an array and merge it with $defaults |
| 92 | 92 | */ |
| 93 | - $args = wp_parse_args( $args, $defaults ); |
|
| 93 | + $args = wp_parse_args($args, $defaults); |
|
| 94 | 94 | |
| 95 | 95 | $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
| 96 | 96 | |
| 97 | - if ( empty( $args['items'] ) ) { |
|
| 98 | - $html .= __( 'No items selected', 'invoicing' ); |
|
| 97 | + if (empty($args['items'])) { |
|
| 98 | + $html .= __('No items selected', 'invoicing'); |
|
| 99 | 99 | } else { |
| 100 | - $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0; |
|
| 101 | - $label = isset( $args['label'] ) ? sanitize_text_field( $args['label'] ) : __( 'Buy Now', 'invoicing' ); |
|
| 102 | - $items = esc_attr( $args['items'] ); |
|
| 100 | + $post_id = isset($args['post_id']) && is_numeric($args['post_id']) ? sanitize_text_field($args['post_id']) : 0; |
|
| 101 | + $label = isset($args['label']) ? sanitize_text_field($args['label']) : __('Buy Now', 'invoicing'); |
|
| 102 | + $items = esc_attr($args['items']); |
|
| 103 | 103 | $html .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>"; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
| 106 | + $html .= wp_nonce_field('wpinv_buy_items', 'wpinv_buy_nonce', true, false); |
|
| 107 | 107 | $html .= '</div>'; |
| 108 | 108 | |
| 109 | 109 | return $html; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -23,15 +23,15 @@ discard block |
||
| 23 | 23 | 'block-keywords'=> "['invoicing','checkout']", |
| 24 | 24 | 'class_name' => __CLASS__, |
| 25 | 25 | 'base_id' => 'wpinv_checkout', |
| 26 | - 'name' => __('GetPaid > Checkout','invoicing'), |
|
| 26 | + 'name' => __('GetPaid > Checkout', 'invoicing'), |
|
| 27 | 27 | 'widget_ops' => array( |
| 28 | 28 | 'classname' => 'getpaid-checkout bsui', |
| 29 | - 'description' => esc_html__('Displays a checkout form.','invoicing'), |
|
| 29 | + 'description' => esc_html__('Displays a checkout form.', 'invoicing'), |
|
| 30 | 30 | ), |
| 31 | 31 | 'arguments' => array( |
| 32 | 32 | 'title' => array( |
| 33 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 34 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 33 | + 'title' => __('Widget title', 'invoicing'), |
|
| 34 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 35 | 35 | 'type' => 'text', |
| 36 | 36 | 'desc_tip' => true, |
| 37 | 37 | 'default' => '', |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - parent::__construct( $options ); |
|
| 45 | + parent::__construct($options); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return mixed|string|bool |
| 56 | 56 | */ |
| 57 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 57 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 58 | 58 | return wpinv_checkout_form(); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Session handler class. |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function __construct() { |
| 54 | 54 | |
| 55 | - $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH ); |
|
| 56 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
| 57 | - add_action( 'wp_logout', array( $this, 'destroy_session' ) ); |
|
| 58 | - add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 ); |
|
| 59 | - add_action( 'shutdown', array( $this, 'save_data' ), 20 ); |
|
| 55 | + $this->_cookie = apply_filters('wpinv_cookie', 'wpinv_session_' . COOKIEHASH); |
|
| 56 | + add_action('init', array($this, 'init'), -1); |
|
| 57 | + add_action('wp_logout', array($this, 'destroy_session')); |
|
| 58 | + add_action('wp', array($this, 'set_customer_session_cookie'), 10); |
|
| 59 | + add_action('shutdown', array($this, 'save_data'), 20); |
|
| 60 | 60 | |
| 61 | 61 | } |
| 62 | 62 | |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | public function init() { |
| 69 | 69 | $this->init_session_cookie(); |
| 70 | 70 | |
| 71 | - if ( ! is_user_logged_in() ) { |
|
| 72 | - add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) ); |
|
| 71 | + if (!is_user_logged_in()) { |
|
| 72 | + add_filter('nonce_user_logged_out', array($this, 'nonce_user_logged_out')); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | public function init_session_cookie() { |
| 82 | 82 | $cookie = $this->get_session_cookie(); |
| 83 | 83 | |
| 84 | - if ( $cookie ) { |
|
| 84 | + if ($cookie) { |
|
| 85 | 85 | $this->_customer_id = $cookie[0]; |
| 86 | 86 | $this->_session_expiration = $cookie[1]; |
| 87 | 87 | $this->_session_expiring = $cookie[2]; |
@@ -89,17 +89,17 @@ discard block |
||
| 89 | 89 | $this->_data = $this->get_session_data(); |
| 90 | 90 | |
| 91 | 91 | // If the user logs in, update session. |
| 92 | - if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) { |
|
| 92 | + if (is_user_logged_in() && get_current_user_id() != $this->_customer_id) { |
|
| 93 | 93 | $this->_customer_id = get_current_user_id(); |
| 94 | 94 | $this->_dirty = true; |
| 95 | 95 | $this->save_data(); |
| 96 | - $this->set_customer_session_cookie( true ); |
|
| 96 | + $this->set_customer_session_cookie(true); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Update session if its close to expiring. |
| 100 | - if ( time() > $this->_session_expiring ) { |
|
| 100 | + if (time() > $this->_session_expiring) { |
|
| 101 | 101 | $this->set_session_expiration(); |
| 102 | - $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); |
|
| 102 | + $this->update_session_timestamp($this->_customer_id, $this->_session_expiration); |
|
| 103 | 103 | } |
| 104 | 104 | } else { |
| 105 | 105 | $this->set_session_expiration(); |
@@ -117,25 +117,25 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @param bool $set Should the session cookie be set. |
| 119 | 119 | */ |
| 120 | - public function set_customer_session_cookie( $set ) { |
|
| 121 | - if ( $set ) { |
|
| 120 | + public function set_customer_session_cookie($set) { |
|
| 121 | + if ($set) { |
|
| 122 | 122 | $to_hash = $this->_customer_id . '|' . $this->_session_expiration; |
| 123 | - $cookie_hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
| 123 | + $cookie_hash = hash_hmac('md5', $to_hash, wp_hash($to_hash)); |
|
| 124 | 124 | $cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash; |
| 125 | 125 | $this->_has_cookie = true; |
| 126 | 126 | |
| 127 | - if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) { |
|
| 128 | - $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true ); |
|
| 127 | + if (!isset($_COOKIE[$this->_cookie]) || $_COOKIE[$this->_cookie] !== $cookie_value) { |
|
| 128 | + $this->setcookie($this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true); |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){ |
|
| 134 | - if ( ! headers_sent() ) { |
|
| 135 | - setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) ); |
|
| 136 | - } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
| 137 | - headers_sent( $file, $line ); |
|
| 138 | - trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine |
|
| 133 | + public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false) { |
|
| 134 | + if (!headers_sent()) { |
|
| 135 | + setcookie($name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters('wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure)); |
|
| 136 | + } elseif (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 137 | + headers_sent($file, $line); |
|
| 138 | + trigger_error("{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE); // @codingStandardsIgnoreLine |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | * @return bool |
| 147 | 147 | */ |
| 148 | 148 | protected function use_secure_cookie() { |
| 149 | - $is_https = false !== strstr( get_option( 'home' ), 'https:' ); |
|
| 150 | - return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() ); |
|
| 149 | + $is_https = false !== strstr(get_option('home'), 'https:'); |
|
| 150 | + return apply_filters('wpinv_session_use_secure_cookie', $is_https && is_ssl()); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -156,15 +156,15 @@ discard block |
||
| 156 | 156 | * @return bool |
| 157 | 157 | */ |
| 158 | 158 | public function has_session() { |
| 159 | - return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
| 159 | + return isset($_COOKIE[$this->_cookie]) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * Set session expiration. |
| 164 | 164 | */ |
| 165 | 165 | public function set_session_expiration() { |
| 166 | - $this->_session_expiring = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours. |
|
| 167 | - $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours. |
|
| 166 | + $this->_session_expiring = time() + intval(apply_filters('wpinv_session_expiring', 60 * 60 * 47)); // 47 Hours. |
|
| 167 | + $this->_session_expiration = time() + intval(apply_filters('wpinv_session_expiration', 60 * 60 * 48)); // 48 Hours. |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function generate_customer_id() { |
| 176 | 176 | require_once ABSPATH . 'wp-includes/class-phpass.php'; |
| 177 | - $hasher = new PasswordHash( 8, false ); |
|
| 178 | - return md5( $hasher->get_random_bytes( 32 ) ); |
|
| 177 | + $hasher = new PasswordHash(8, false); |
|
| 178 | + return md5($hasher->get_random_bytes(32)); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -186,27 +186,27 @@ discard block |
||
| 186 | 186 | * @return bool|array |
| 187 | 187 | */ |
| 188 | 188 | public function get_session_cookie() { |
| 189 | - $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine. |
|
| 189 | + $cookie_value = isset($_COOKIE[$this->_cookie]) ? wp_unslash($_COOKIE[$this->_cookie]) : false; // @codingStandardsIgnoreLine. |
|
| 190 | 190 | |
| 191 | - if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { |
|
| 191 | + if (empty($cookie_value) || !is_string($cookie_value)) { |
|
| 192 | 192 | return false; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); |
|
| 195 | + list($customer_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value); |
|
| 196 | 196 | |
| 197 | - if ( empty( $customer_id ) ) { |
|
| 197 | + if (empty($customer_id)) { |
|
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // Validate hash. |
| 202 | 202 | $to_hash = $customer_id . '|' . $session_expiration; |
| 203 | - $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
| 203 | + $hash = hash_hmac('md5', $to_hash, wp_hash($to_hash)); |
|
| 204 | 204 | |
| 205 | - if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { |
|
| 205 | + if (empty($cookie_hash) || !hash_equals($hash, $cookie_hash)) { |
|
| 206 | 206 | return false; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ); |
|
| 209 | + return array($customer_id, $session_expiration, $session_expiring, $cookie_hash); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | * @return array |
| 216 | 216 | */ |
| 217 | 217 | public function get_session_data() { |
| 218 | - return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array(); |
|
| 218 | + return $this->has_session() ? (array) $this->get_session($this->_customer_id) : array(); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - public function generate_key($customer_id){ |
|
| 222 | - if(!$customer_id){ |
|
| 221 | + public function generate_key($customer_id) { |
|
| 222 | + if (!$customer_id) { |
|
| 223 | 223 | return; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - return 'wpi_trans_'.$customer_id; |
|
| 226 | + return 'wpi_trans_' . $customer_id; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function save_data() { |
| 233 | 233 | // Dirty if something changed - prevents saving nothing new. |
| 234 | - if ( $this->_dirty && $this->has_session() ) { |
|
| 234 | + if ($this->_dirty && $this->has_session()) { |
|
| 235 | 235 | |
| 236 | - set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration); |
|
| 236 | + set_transient($this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration); |
|
| 237 | 237 | |
| 238 | 238 | $this->_dirty = false; |
| 239 | 239 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * Destroy all session data. |
| 244 | 244 | */ |
| 245 | 245 | public function destroy_session() { |
| 246 | - $this->delete_session( $this->_customer_id ); |
|
| 246 | + $this->delete_session($this->_customer_id); |
|
| 247 | 247 | $this->forget_session(); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * Forget all session data without destroying it. |
| 252 | 252 | */ |
| 253 | 253 | public function forget_session() { |
| 254 | - $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true ); |
|
| 254 | + $this->setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true); |
|
| 255 | 255 | |
| 256 | 256 | wpinv_empty_cart(); |
| 257 | 257 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param int $uid User ID. |
| 267 | 267 | * @return string |
| 268 | 268 | */ |
| 269 | - public function nonce_user_logged_out( $uid ) { |
|
| 269 | + public function nonce_user_logged_out($uid) { |
|
| 270 | 270 | return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid; |
| 271 | 271 | } |
| 272 | 272 | |
@@ -277,20 +277,20 @@ discard block |
||
| 277 | 277 | * @param mixed $default Default session value. |
| 278 | 278 | * @return string|array |
| 279 | 279 | */ |
| 280 | - public function get_session( $customer_id, $default = false ) { |
|
| 280 | + public function get_session($customer_id, $default = false) { |
|
| 281 | 281 | |
| 282 | - if ( defined( 'WP_SETUP_CONFIG' ) ) { |
|
| 282 | + if (defined('WP_SETUP_CONFIG')) { |
|
| 283 | 283 | return array(); |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | $key = $this->generate_key($customer_id); |
| 287 | 287 | $value = get_transient($key); |
| 288 | 288 | |
| 289 | - if ( !$value ) { |
|
| 289 | + if (!$value) { |
|
| 290 | 290 | $value = $default; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - return maybe_unserialize( $value ); |
|
| 293 | + return maybe_unserialize($value); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @param int $customer_id Customer ID. |
| 300 | 300 | */ |
| 301 | - public function delete_session( $customer_id ) { |
|
| 301 | + public function delete_session($customer_id) { |
|
| 302 | 302 | |
| 303 | 303 | $key = $this->generate_key($customer_id); |
| 304 | 304 | |
@@ -311,9 +311,9 @@ discard block |
||
| 311 | 311 | * @param string $customer_id Customer ID. |
| 312 | 312 | * @param int $timestamp Timestamp to expire the cookie. |
| 313 | 313 | */ |
| 314 | - public function update_session_timestamp( $customer_id, $timestamp ) { |
|
| 314 | + public function update_session_timestamp($customer_id, $timestamp) { |
|
| 315 | 315 | |
| 316 | - set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp); |
|
| 316 | + set_transient($this->generate_key($customer_id), maybe_serialize($this->_data), $timestamp); |
|
| 317 | 317 | |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | 'block-output' => array( // the block visual output elements as an array |
| 24 | 24 | array( |
| 25 | 25 | 'element' => 'p', |
| 26 | - 'title' => __( 'Placeholder', 'hello-world' ), |
|
| 26 | + 'title' => __('Placeholder', 'hello-world'), |
|
| 27 | 27 | 'class' => '[%className%]', |
| 28 | 28 | 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
| 29 | 29 | ) |
@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | // The calling class name |
| 34 | 34 | 'base_id' => 'hello_world', |
| 35 | 35 | // this is used as the widget id and the shortcode id. |
| 36 | - 'name' => __( 'Hello World', 'hello-world' ), |
|
| 36 | + 'name' => __('Hello World', 'hello-world'), |
|
| 37 | 37 | // the name of the widget/block |
| 38 | 38 | 'widget_ops' => array( |
| 39 | 39 | 'classname' => 'hello-world-class', |
| 40 | 40 | // widget class |
| 41 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
| 41 | + 'description' => esc_html__('This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world'), |
|
| 42 | 42 | // widget description |
| 43 | 43 | ), |
| 44 | 44 | 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
| 45 | 45 | 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
| 46 | 46 | 'after_text' => array( // this is the input name='' |
| 47 | - 'title' => __( 'Text after hello:', 'hello-world' ), |
|
| 47 | + 'title' => __('Text after hello:', 'hello-world'), |
|
| 48 | 48 | // input title |
| 49 | - 'desc' => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ), |
|
| 49 | + 'desc' => __('This is the text that will appear after `Hello:`.', 'hello-world'), |
|
| 50 | 50 | // input description |
| 51 | 51 | 'type' => 'text', |
| 52 | 52 | // the type of input, test, select, checkbox etc. |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | ) |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - parent::__construct( $options ); |
|
| 65 | + parent::__construct($options); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
@@ -75,18 +75,18 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return string |
| 77 | 77 | */ |
| 78 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 78 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * @var string $after_text |
| 82 | 82 | * @var string $another_input This is added by filter below. |
| 83 | 83 | */ |
| 84 | - extract( $args, EXTR_SKIP ); |
|
| 84 | + extract($args, EXTR_SKIP); |
|
| 85 | 85 | |
| 86 | 86 | /* |
| 87 | 87 | * This value is added by filter so might not exist if filter is removed so we check. |
| 88 | 88 | */ |
| 89 | - if ( ! isset( $another_input ) ) { |
|
| 89 | + if (!isset($another_input)) { |
|
| 90 | 90 | $another_input = ''; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // register it. |
| 100 | -add_action( 'widgets_init', function () { |
|
| 101 | - register_widget( 'SD_Hello_World' ); |
|
| 100 | +add_action('widgets_init', function() { |
|
| 101 | + register_widget('SD_Hello_World'); |
|
| 102 | 102 | } ); |
| 103 | 103 | |
| 104 | 104 | |
@@ -109,15 +109,15 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return mixed |
| 111 | 111 | */ |
| 112 | -function _my_extra_arguments( $options ) { |
|
| 112 | +function _my_extra_arguments($options) { |
|
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | * Add a new input option. |
| 116 | 116 | */ |
| 117 | 117 | $options['arguments']['another_input'] = array( |
| 118 | 118 | 'name' => 'another_input', // this is the input name='' |
| 119 | - 'title' => __( 'Another input:', 'hello-world' ), // input title |
|
| 120 | - 'desc' => __( 'This is an input added via filter.', 'hello-world' ), // input description |
|
| 119 | + 'title' => __('Another input:', 'hello-world'), // input title |
|
| 120 | + 'desc' => __('This is an input added via filter.', 'hello-world'), // input description |
|
| 121 | 121 | 'type' => 'text', // the type of input, test, select, checkbox etc. |
| 122 | 122 | 'placeholder' => 'Placeholder text', // the input placeholder text. |
| 123 | 123 | 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | /* |
| 129 | 129 | * Output the new option in the block output also. |
| 130 | 130 | */ |
| 131 | - $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
| 131 | + $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]"; ; |
|
| 132 | 132 | |
| 133 | 133 | return $options; |
| 134 | 134 | } |
@@ -14,21 +14,21 @@ |
||
| 14 | 14 | * Tested up to: 5.3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 17 | +if (!defined('ABSPATH')) { |
|
| 18 | 18 | exit; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -if ( ! class_exists( 'WP_Super_Duper' ) ) { |
|
| 21 | +if (!class_exists('WP_Super_Duper')) { |
|
| 22 | 22 | // include the class if needed |
| 23 | - include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
| 23 | + include_once(dirname(__FILE__) . "/wp-super-duper.php"); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /* |
| 27 | 27 | * Hello world example. |
| 28 | 28 | */ |
| 29 | -include_once( dirname( __FILE__ ) . "/hello-world.php" ); |
|
| 29 | +include_once(dirname(__FILE__) . "/hello-world.php"); |
|
| 30 | 30 | |
| 31 | 31 | /* |
| 32 | 32 | * Map example. |
| 33 | 33 | */ |
| 34 | -include_once( dirname( __FILE__ ) . "/map.php" ); |
|
| 34 | +include_once(dirname(__FILE__) . "/map.php"); |
|
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function getLocations() |
| 36 | 36 | { |
| 37 | 37 | if ($this->matchesCakeVersion('>=', '3.0.0')) { |
| 38 | - $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; |
|
| 38 | + $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; |
|
| 39 | 39 | } |
| 40 | 40 | return $this->locations; |
| 41 | 41 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $repositoryManager = $this->composer->getRepositoryManager(); |
| 61 | - if (! $repositoryManager) { |
|
| 61 | + if (!$repositoryManager) { |
|
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return string The rendered component. |
| 20 | 20 | */ |
| 21 | - public static function get($args = array()){ |
|
| 21 | + public static function get($args = array()) { |
|
| 22 | 22 | $defaults = array( |
| 23 | 23 | 'type' => 'info', |
| 24 | 24 | 'class' => '', |
@@ -33,50 +33,50 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * Parse incoming $args into an array and merge it with $defaults |
| 35 | 35 | */ |
| 36 | - $args = wp_parse_args( $args, $defaults ); |
|
| 36 | + $args = wp_parse_args($args, $defaults); |
|
| 37 | 37 | $output = ''; |
| 38 | - if ( ! empty( $args['content'] ) ) { |
|
| 39 | - $type = sanitize_html_class( $args['type'] ); |
|
| 40 | - if($type=='error'){$type='danger';} |
|
| 41 | - $icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : ''; |
|
| 38 | + if (!empty($args['content'])) { |
|
| 39 | + $type = sanitize_html_class($args['type']); |
|
| 40 | + if ($type == 'error') {$type = 'danger'; } |
|
| 41 | + $icon = !empty($args['icon']) ? "<i class='" . esc_attr($args['icon']) . "'></i>" : ''; |
|
| 42 | 42 | |
| 43 | 43 | // set default icon |
| 44 | - if(!$icon && $args['icon']!==false && $type){ |
|
| 45 | - if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';} |
|
| 46 | - elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';} |
|
| 47 | - elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';} |
|
| 48 | - elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';} |
|
| 44 | + if (!$icon && $args['icon'] !== false && $type) { |
|
| 45 | + if ($type == 'danger') {$icon = '<i class="fas fa-exclamation-circle"></i>'; } |
|
| 46 | + elseif ($type == 'warning') {$icon = '<i class="fas fa-exclamation-triangle"></i>'; } |
|
| 47 | + elseif ($type == 'success') {$icon = '<i class="fas fa-check-circle"></i>'; } |
|
| 48 | + elseif ($type == 'info') {$icon = '<i class="fas fa-info-circle"></i>'; } |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $data = ''; |
| 52 | 52 | $class = !empty($args['class']) ? esc_attr($args['class']) : ''; |
| 53 | - if($args['dismissible']){$class .= " alert-dismissible fade show";} |
|
| 53 | + if ($args['dismissible']) {$class .= " alert-dismissible fade show"; } |
|
| 54 | 54 | |
| 55 | 55 | // open |
| 56 | - $output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>'; |
|
| 56 | + $output .= '<div class="alert alert-' . $type . ' ' . $class . '" role="alert" ' . $data . '>'; |
|
| 57 | 57 | |
| 58 | 58 | // heading |
| 59 | - if ( ! empty( $args['heading'] ) ) { |
|
| 59 | + if (!empty($args['heading'])) { |
|
| 60 | 60 | $output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>'; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // icon |
| 64 | - if ( ! empty( $icon) ) { |
|
| 65 | - $output .= $icon." "; |
|
| 64 | + if (!empty($icon)) { |
|
| 65 | + $output .= $icon . " "; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // content |
| 69 | 69 | $output .= $args['content']; |
| 70 | 70 | |
| 71 | 71 | // dismissible |
| 72 | - if($args['dismissible']){ |
|
| 72 | + if ($args['dismissible']) { |
|
| 73 | 73 | $output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">'; |
| 74 | 74 | $output .= '<span aria-hidden="true">×</span>'; |
| 75 | 75 | $output .= '</button>'; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // footer |
| 79 | - if ( ! empty( $args['footer'] ) ) { |
|
| 79 | + if (!empty($args['footer'])) { |
|
| 80 | 80 | $output .= '<hr>'; |
| 81 | 81 | $output .= '<p class="mb-0">' . $args['footer'] . '</p>'; |
| 82 | 82 | } |