@@ -126,8 +126,12 @@ discard block |
||
| 126 | 126 | public function constants(){ |
| 127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
| 128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
| 129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
| 130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
| 129 | + if (!defined('AUI_PRIMARY_COLOR')) { |
|
| 130 | + define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
| 131 | + } |
|
| 132 | + if (!defined('AUI_SECONDARY_COLOR')) { |
|
| 133 | + define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
| 134 | + } |
|
| 131 | 135 | } |
| 132 | 136 | |
| 133 | 137 | /** |
@@ -233,7 +237,7 @@ discard block |
||
| 233 | 237 | |
| 234 | 238 | if( is_admin() && !$this->is_aui_screen()){ |
| 235 | 239 | // don't add wp-admin scripts if not requested to |
| 236 | - }else{ |
|
| 240 | + } else{ |
|
| 237 | 241 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
| 238 | 242 | |
| 239 | 243 | $rtl = is_rtl() ? '-rtl' : ''; |
@@ -1051,7 +1055,7 @@ discard block |
||
| 1051 | 1055 | |
| 1052 | 1056 | if( is_admin() && !$this->is_aui_screen()){ |
| 1053 | 1057 | // don't add wp-admin scripts if not requested to |
| 1054 | - }else { |
|
| 1058 | + } else { |
|
| 1055 | 1059 | |
| 1056 | 1060 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
| 1057 | 1061 | |
@@ -2093,7 +2097,9 @@ discard block |
||
| 2093 | 2097 | * @return mixed |
| 2094 | 2098 | */ |
| 2095 | 2099 | public static function minify_js($input) { |
| 2096 | - if(trim($input) === "") return $input; |
|
| 2100 | + if(trim($input) === "") { |
|
| 2101 | + return $input; |
|
| 2102 | + } |
|
| 2097 | 2103 | return preg_replace( |
| 2098 | 2104 | array( |
| 2099 | 2105 | // Remove comment(s) |
@@ -2125,7 +2131,9 @@ discard block |
||
| 2125 | 2131 | * @return mixed |
| 2126 | 2132 | */ |
| 2127 | 2133 | public static function minify_css($input) { |
| 2128 | - if(trim($input) === "") return $input; |
|
| 2134 | + if(trim($input) === "") { |
|
| 2135 | + return $input; |
|
| 2136 | + } |
|
| 2129 | 2137 | return preg_replace( |
| 2130 | 2138 | array( |
| 2131 | 2139 | // Remove comment(s) |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -21,236 +21,236 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * A Class to be able to change settings for Font Awesome. |
|
| 26 | - * |
|
| 27 | - * Class AyeCode_UI_Settings |
|
| 28 | - * @ver 1.0.0 |
|
| 29 | - * @todo decide how to implement textdomain |
|
| 30 | - */ |
|
| 31 | - class AyeCode_UI_Settings { |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Class version version. |
|
| 35 | - * |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - public $version = '0.1.51'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Class textdomain. |
|
| 42 | - * |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - public $textdomain = 'aui'; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Latest version of Bootstrap at time of publish published. |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - public $latest = "4.5.3"; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Current version of select2 being used. |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - public $select2_version = "4.0.11"; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * The title. |
|
| 63 | - * |
|
| 64 | - * @var string |
|
| 65 | - */ |
|
| 66 | - public $name = 'AyeCode UI'; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * The relative url to the assets. |
|
| 70 | - * |
|
| 71 | - * @var string |
|
| 72 | - */ |
|
| 73 | - public $url = ''; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Holds the settings values. |
|
| 77 | - * |
|
| 78 | - * @var array |
|
| 79 | - */ |
|
| 80 | - private $settings; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * AyeCode_UI_Settings instance. |
|
| 84 | - * |
|
| 85 | - * @access private |
|
| 86 | - * @since 1.0.0 |
|
| 87 | - * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | - */ |
|
| 89 | - private static $instance = null; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Main AyeCode_UI_Settings Instance. |
|
| 93 | - * |
|
| 94 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 95 | - * |
|
| 96 | - * @since 1.0.0 |
|
| 97 | - * @static |
|
| 98 | - * @return AyeCode_UI_Settings - Main instance. |
|
| 99 | - */ |
|
| 100 | - public static function instance() { |
|
| 101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 102 | - |
|
| 103 | - self::$instance = new AyeCode_UI_Settings; |
|
| 104 | - |
|
| 105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 106 | - |
|
| 107 | - if ( is_admin() ) { |
|
| 108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 110 | - |
|
| 111 | - // Maybe show example page |
|
| 112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 116 | - |
|
| 117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - return self::$instance; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Setup some constants. |
|
| 125 | - */ |
|
| 126 | - public function constants(){ |
|
| 127 | - define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
| 128 | - define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
| 129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
| 130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Initiate the settings and add the required action hooks. |
|
| 135 | - */ |
|
| 136 | - public function init() { |
|
| 137 | - $this->constants(); |
|
| 138 | - $this->settings = $this->get_settings(); |
|
| 139 | - $this->url = $this->get_url(); |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Maybe load CSS |
|
| 143 | - * |
|
| 144 | - * We load super early in case there is a theme version that might change the colors |
|
| 145 | - */ |
|
| 146 | - if ( $this->settings['css'] ) { |
|
| 147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 148 | - } |
|
| 149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - // maybe load JS |
|
| 154 | - if ( $this->settings['js'] ) { |
|
| 155 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 157 | - } |
|
| 158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - // Maybe set the HTML font size |
|
| 163 | - if ( $this->settings['html_font_size'] ) { |
|
| 164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Check if we should load the admin scripts or not. |
|
| 172 | - * |
|
| 173 | - * @return bool |
|
| 174 | - */ |
|
| 175 | - public function load_admin_scripts(){ |
|
| 176 | - $result = true; |
|
| 177 | - |
|
| 178 | - // check if specifically disabled |
|
| 179 | - if(!empty($this->settings['disable_admin'])){ |
|
| 180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 181 | - foreach($url_parts as $part){ |
|
| 182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 183 | - return false; // return early, no point checking further |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - return $result; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Add a html font size to the footer. |
|
| 193 | - */ |
|
| 194 | - public function html_font_size(){ |
|
| 195 | - $this->settings = $this->get_settings(); |
|
| 196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 197 | - } |
|
| 24 | + /** |
|
| 25 | + * A Class to be able to change settings for Font Awesome. |
|
| 26 | + * |
|
| 27 | + * Class AyeCode_UI_Settings |
|
| 28 | + * @ver 1.0.0 |
|
| 29 | + * @todo decide how to implement textdomain |
|
| 30 | + */ |
|
| 31 | + class AyeCode_UI_Settings { |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Class version version. |
|
| 35 | + * |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + public $version = '0.1.51'; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Class textdomain. |
|
| 42 | + * |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + public $textdomain = 'aui'; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Latest version of Bootstrap at time of publish published. |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + public $latest = "4.5.3"; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Current version of select2 being used. |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + public $select2_version = "4.0.11"; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * The title. |
|
| 63 | + * |
|
| 64 | + * @var string |
|
| 65 | + */ |
|
| 66 | + public $name = 'AyeCode UI'; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * The relative url to the assets. |
|
| 70 | + * |
|
| 71 | + * @var string |
|
| 72 | + */ |
|
| 73 | + public $url = ''; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Holds the settings values. |
|
| 77 | + * |
|
| 78 | + * @var array |
|
| 79 | + */ |
|
| 80 | + private $settings; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * AyeCode_UI_Settings instance. |
|
| 84 | + * |
|
| 85 | + * @access private |
|
| 86 | + * @since 1.0.0 |
|
| 87 | + * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | + */ |
|
| 89 | + private static $instance = null; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Main AyeCode_UI_Settings Instance. |
|
| 93 | + * |
|
| 94 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 95 | + * |
|
| 96 | + * @since 1.0.0 |
|
| 97 | + * @static |
|
| 98 | + * @return AyeCode_UI_Settings - Main instance. |
|
| 99 | + */ |
|
| 100 | + public static function instance() { |
|
| 101 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 102 | + |
|
| 103 | + self::$instance = new AyeCode_UI_Settings; |
|
| 104 | + |
|
| 105 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 106 | + |
|
| 107 | + if ( is_admin() ) { |
|
| 108 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 109 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 110 | + |
|
| 111 | + // Maybe show example page |
|
| 112 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 113 | + } |
|
| 198 | 114 | |
| 199 | - /** |
|
| 200 | - * Check if the current admin screen should load scripts. |
|
| 201 | - * |
|
| 202 | - * @return bool |
|
| 203 | - */ |
|
| 204 | - public function is_aui_screen(){ |
|
| 205 | - $load = false; |
|
| 206 | - // check if we should load or not |
|
| 207 | - if ( is_admin() ) { |
|
| 208 | - // Only enable on set pages |
|
| 209 | - $aui_screens = array( |
|
| 210 | - 'page', |
|
| 211 | - 'post', |
|
| 212 | - 'settings_page_ayecode-ui-settings', |
|
| 213 | - 'appearance_page_gutenberg-widgets' |
|
| 214 | - ); |
|
| 215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 216 | - |
|
| 217 | - $screen = get_current_screen(); |
|
| 115 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 116 | + |
|
| 117 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + return self::$instance; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Setup some constants. |
|
| 125 | + */ |
|
| 126 | + public function constants(){ |
|
| 127 | + define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
| 128 | + define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
| 129 | + if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
| 130 | + if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Initiate the settings and add the required action hooks. |
|
| 135 | + */ |
|
| 136 | + public function init() { |
|
| 137 | + $this->constants(); |
|
| 138 | + $this->settings = $this->get_settings(); |
|
| 139 | + $this->url = $this->get_url(); |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Maybe load CSS |
|
| 143 | + * |
|
| 144 | + * We load super early in case there is a theme version that might change the colors |
|
| 145 | + */ |
|
| 146 | + if ( $this->settings['css'] ) { |
|
| 147 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 148 | + } |
|
| 149 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 150 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + // maybe load JS |
|
| 154 | + if ( $this->settings['js'] ) { |
|
| 155 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 156 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 157 | + } |
|
| 158 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 159 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + // Maybe set the HTML font size |
|
| 163 | + if ( $this->settings['html_font_size'] ) { |
|
| 164 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Check if we should load the admin scripts or not. |
|
| 172 | + * |
|
| 173 | + * @return bool |
|
| 174 | + */ |
|
| 175 | + public function load_admin_scripts(){ |
|
| 176 | + $result = true; |
|
| 177 | + |
|
| 178 | + // check if specifically disabled |
|
| 179 | + if(!empty($this->settings['disable_admin'])){ |
|
| 180 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 181 | + foreach($url_parts as $part){ |
|
| 182 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 183 | + return false; // return early, no point checking further |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + return $result; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Add a html font size to the footer. |
|
| 193 | + */ |
|
| 194 | + public function html_font_size(){ |
|
| 195 | + $this->settings = $this->get_settings(); |
|
| 196 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Check if the current admin screen should load scripts. |
|
| 201 | + * |
|
| 202 | + * @return bool |
|
| 203 | + */ |
|
| 204 | + public function is_aui_screen(){ |
|
| 205 | + $load = false; |
|
| 206 | + // check if we should load or not |
|
| 207 | + if ( is_admin() ) { |
|
| 208 | + // Only enable on set pages |
|
| 209 | + $aui_screens = array( |
|
| 210 | + 'page', |
|
| 211 | + 'post', |
|
| 212 | + 'settings_page_ayecode-ui-settings', |
|
| 213 | + 'appearance_page_gutenberg-widgets' |
|
| 214 | + ); |
|
| 215 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 216 | + |
|
| 217 | + $screen = get_current_screen(); |
|
| 218 | 218 | |
| 219 | 219 | // echo '###'.$screen->id; |
| 220 | 220 | |
| 221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 222 | - $load = true; |
|
| 223 | - } |
|
| 224 | - } |
|
| 221 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 222 | + $load = true; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - return $load; |
|
| 227 | - } |
|
| 226 | + return $load; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Adds the styles. |
|
| 231 | - */ |
|
| 232 | - public function enqueue_style() { |
|
| 229 | + /** |
|
| 230 | + * Adds the styles. |
|
| 231 | + */ |
|
| 232 | + public function enqueue_style() { |
|
| 233 | 233 | |
| 234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 235 | - // don't add wp-admin scripts if not requested to |
|
| 236 | - }else{ |
|
| 237 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 234 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 235 | + // don't add wp-admin scripts if not requested to |
|
| 236 | + }else{ |
|
| 237 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 238 | 238 | |
| 239 | - $rtl = is_rtl() ? '-rtl' : ''; |
|
| 239 | + $rtl = is_rtl() ? '-rtl' : ''; |
|
| 240 | 240 | |
| 241 | - if($this->settings[$css_setting]){ |
|
| 242 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 243 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 244 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
| 245 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 241 | + if($this->settings[$css_setting]){ |
|
| 242 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 243 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 244 | + wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
| 245 | + wp_enqueue_style( 'ayecode-ui' ); |
|
| 246 | 246 | |
| 247 | - // flatpickr |
|
| 248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
| 247 | + // flatpickr |
|
| 248 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
| 249 | 249 | |
| 250 | 250 | |
| 251 | - // fix some wp-admin issues |
|
| 252 | - if(is_admin()){ |
|
| 253 | - $custom_css = " |
|
| 251 | + // fix some wp-admin issues |
|
| 252 | + if(is_admin()){ |
|
| 253 | + $custom_css = " |
|
| 254 | 254 | body{ |
| 255 | 255 | background-color: #f1f1f1; |
| 256 | 256 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -292,35 +292,35 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | "; |
| 294 | 294 | |
| 295 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 296 | - $custom_css .= " |
|
| 295 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 296 | + $custom_css .= " |
|
| 297 | 297 | .edit-post-sidebar input[type=color].components-text-control__input{ |
| 298 | 298 | padding: 0; |
| 299 | 299 | } |
| 300 | 300 | "; |
| 301 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 302 | - } |
|
| 301 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - // custom changes |
|
| 305 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 304 | + // custom changes |
|
| 305 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 306 | 306 | |
| 307 | - } |
|
| 308 | - } |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | 310 | |
| 311 | - } |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * Get inline script used if bootstrap enqueued |
|
| 315 | + * |
|
| 316 | + * If this remains small then its best to use this than to add another JS file. |
|
| 317 | + */ |
|
| 318 | + public function inline_script() { |
|
| 319 | + // Flatpickr calendar locale |
|
| 320 | + $flatpickr_locale = self::flatpickr_locale(); |
|
| 312 | 321 | |
| 313 | - /** |
|
| 314 | - * Get inline script used if bootstrap enqueued |
|
| 315 | - * |
|
| 316 | - * If this remains small then its best to use this than to add another JS file. |
|
| 317 | - */ |
|
| 318 | - public function inline_script() { |
|
| 319 | - // Flatpickr calendar locale |
|
| 320 | - $flatpickr_locale = self::flatpickr_locale(); |
|
| 321 | - |
|
| 322 | - ob_start(); |
|
| 323 | - ?> |
|
| 322 | + ob_start(); |
|
| 323 | + ?> |
|
| 324 | 324 | <script> |
| 325 | 325 | /** |
| 326 | 326 | * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ). |
@@ -1009,29 +1009,29 @@ discard block |
||
| 1009 | 1009 | }); |
| 1010 | 1010 | </script> |
| 1011 | 1011 | <?php |
| 1012 | - $output = ob_get_clean(); |
|
| 1012 | + $output = ob_get_clean(); |
|
| 1013 | 1013 | |
| 1014 | 1014 | |
| 1015 | 1015 | |
| 1016 | - /* |
|
| 1016 | + /* |
|
| 1017 | 1017 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1018 | 1018 | */ |
| 1019 | - return str_replace( array( |
|
| 1020 | - '<script>', |
|
| 1021 | - '</script>' |
|
| 1022 | - ), '', self::minify_js($output) ); |
|
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - |
|
| 1026 | - /** |
|
| 1027 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1028 | - * |
|
| 1029 | - * @TODO we may need this when other conflicts arrise. |
|
| 1030 | - * @return mixed |
|
| 1031 | - */ |
|
| 1032 | - public static function bs3_compat_js() { |
|
| 1033 | - ob_start(); |
|
| 1034 | - ?> |
|
| 1019 | + return str_replace( array( |
|
| 1020 | + '<script>', |
|
| 1021 | + '</script>' |
|
| 1022 | + ), '', self::minify_js($output) ); |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + |
|
| 1026 | + /** |
|
| 1027 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1028 | + * |
|
| 1029 | + * @TODO we may need this when other conflicts arrise. |
|
| 1030 | + * @return mixed |
|
| 1031 | + */ |
|
| 1032 | + public static function bs3_compat_js() { |
|
| 1033 | + ob_start(); |
|
| 1034 | + ?> |
|
| 1035 | 1035 | <script> |
| 1036 | 1036 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
| 1037 | 1037 | /* With Avada builder */ |
@@ -1039,20 +1039,20 @@ discard block |
||
| 1039 | 1039 | <?php } ?> |
| 1040 | 1040 | </script> |
| 1041 | 1041 | <?php |
| 1042 | - return str_replace( array( |
|
| 1043 | - '<script>', |
|
| 1044 | - '</script>' |
|
| 1045 | - ), '', ob_get_clean()); |
|
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - /** |
|
| 1049 | - * Get inline script used if bootstrap file browser enqueued. |
|
| 1050 | - * |
|
| 1051 | - * If this remains small then its best to use this than to add another JS file. |
|
| 1052 | - */ |
|
| 1053 | - public function inline_script_file_browser(){ |
|
| 1054 | - ob_start(); |
|
| 1055 | - ?> |
|
| 1042 | + return str_replace( array( |
|
| 1043 | + '<script>', |
|
| 1044 | + '</script>' |
|
| 1045 | + ), '', ob_get_clean()); |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + /** |
|
| 1049 | + * Get inline script used if bootstrap file browser enqueued. |
|
| 1050 | + * |
|
| 1051 | + * If this remains small then its best to use this than to add another JS file. |
|
| 1052 | + */ |
|
| 1053 | + public function inline_script_file_browser(){ |
|
| 1054 | + ob_start(); |
|
| 1055 | + ?> |
|
| 1056 | 1056 | <script> |
| 1057 | 1057 | // run on doc ready |
| 1058 | 1058 | jQuery(document).ready(function () { |
@@ -1060,192 +1060,192 @@ discard block |
||
| 1060 | 1060 | }); |
| 1061 | 1061 | </script> |
| 1062 | 1062 | <?php |
| 1063 | - $output = ob_get_clean(); |
|
| 1063 | + $output = ob_get_clean(); |
|
| 1064 | 1064 | |
| 1065 | - /* |
|
| 1065 | + /* |
|
| 1066 | 1066 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1067 | 1067 | */ |
| 1068 | - return str_replace( array( |
|
| 1069 | - '<script>', |
|
| 1070 | - '</script>' |
|
| 1071 | - ), '', $output ); |
|
| 1072 | - } |
|
| 1073 | - |
|
| 1074 | - /** |
|
| 1075 | - * Adds the Font Awesome JS. |
|
| 1076 | - */ |
|
| 1077 | - public function enqueue_scripts() { |
|
| 1078 | - |
|
| 1079 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 1080 | - // don't add wp-admin scripts if not requested to |
|
| 1081 | - }else { |
|
| 1082 | - |
|
| 1083 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 1084 | - |
|
| 1085 | - // select2 |
|
| 1086 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1087 | - |
|
| 1088 | - // flatpickr |
|
| 1089 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
| 1090 | - |
|
| 1091 | - // Bootstrap file browser |
|
| 1092 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1093 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1094 | - |
|
| 1095 | - $load_inline = false; |
|
| 1096 | - |
|
| 1097 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1098 | - // Bootstrap bundle |
|
| 1099 | - $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 1100 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1101 | - 'select2', |
|
| 1102 | - 'jquery' |
|
| 1103 | - ), $this->latest, $this->is_bs3_compat() ); |
|
| 1104 | - // if in admin then add to footer for compatibility. |
|
| 1105 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1106 | - $script = $this->inline_script(); |
|
| 1107 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1108 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1109 | - $url = $this->url . 'assets/js/popper.min.js'; |
|
| 1110 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
| 1111 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1112 | - $load_inline = true; |
|
| 1113 | - } else { |
|
| 1114 | - $load_inline = true; |
|
| 1115 | - } |
|
| 1116 | - |
|
| 1117 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 1118 | - if ( $load_inline ) { |
|
| 1119 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1120 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1121 | - $script = $this->inline_script(); |
|
| 1122 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1123 | - } |
|
| 1124 | - } |
|
| 1125 | - |
|
| 1126 | - } |
|
| 1127 | - |
|
| 1128 | - /** |
|
| 1129 | - * Enqueue flatpickr if called. |
|
| 1130 | - */ |
|
| 1131 | - public function enqueue_flatpickr(){ |
|
| 1132 | - wp_enqueue_style( 'flatpickr' ); |
|
| 1133 | - wp_enqueue_script( 'flatpickr' ); |
|
| 1134 | - } |
|
| 1135 | - |
|
| 1136 | - /** |
|
| 1137 | - * Get the url path to the current folder. |
|
| 1138 | - * |
|
| 1139 | - * @return string |
|
| 1140 | - */ |
|
| 1141 | - public function get_url() { |
|
| 1142 | - |
|
| 1143 | - $url = ''; |
|
| 1144 | - // check if we are inside a plugin |
|
| 1145 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1146 | - |
|
| 1147 | - // add check in-case user has changed wp-content dir name. |
|
| 1148 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 1149 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1150 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1151 | - |
|
| 1152 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1153 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1154 | - } |
|
| 1155 | - |
|
| 1156 | - return $url; |
|
| 1157 | - } |
|
| 1158 | - |
|
| 1159 | - /** |
|
| 1160 | - * Register the database settings with WordPress. |
|
| 1161 | - */ |
|
| 1162 | - public function register_settings() { |
|
| 1163 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1164 | - } |
|
| 1165 | - |
|
| 1166 | - /** |
|
| 1167 | - * Add the WordPress settings menu item. |
|
| 1168 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 1169 | - */ |
|
| 1170 | - public function menu_item() { |
|
| 1171 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 1172 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1173 | - $this, |
|
| 1174 | - 'settings_page' |
|
| 1175 | - ) ); |
|
| 1176 | - } |
|
| 1177 | - |
|
| 1178 | - /** |
|
| 1179 | - * Get a list of themes and their default JS settings. |
|
| 1180 | - * |
|
| 1181 | - * @return array |
|
| 1182 | - */ |
|
| 1183 | - public function theme_js_settings(){ |
|
| 1184 | - return array( |
|
| 1185 | - 'ayetheme' => 'popper', |
|
| 1186 | - 'listimia' => 'required', |
|
| 1187 | - 'listimia_backend' => 'core-popper', |
|
| 1188 | - //'avada' => 'required', // removed as we now add compatibility |
|
| 1189 | - ); |
|
| 1190 | - } |
|
| 1191 | - |
|
| 1192 | - /** |
|
| 1193 | - * Get the current Font Awesome output settings. |
|
| 1194 | - * |
|
| 1195 | - * @return array The array of settings. |
|
| 1196 | - */ |
|
| 1197 | - public function get_settings() { |
|
| 1198 | - |
|
| 1199 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1200 | - $js_default = 'core-popper'; |
|
| 1201 | - $js_default_backend = $js_default; |
|
| 1202 | - |
|
| 1203 | - // maybe set defaults (if no settings set) |
|
| 1204 | - if(empty($db_settings)){ |
|
| 1205 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1206 | - $theme_js_settings = self::theme_js_settings(); |
|
| 1207 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 1208 | - $js_default = $theme_js_settings[$active_theme]; |
|
| 1209 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1210 | - } |
|
| 1211 | - } |
|
| 1212 | - |
|
| 1213 | - $defaults = array( |
|
| 1214 | - 'css' => 'compatibility', // core, compatibility |
|
| 1215 | - 'js' => $js_default, // js to load, core-popper, popper |
|
| 1216 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 1217 | - 'css_backend' => 'compatibility', // core, compatibility |
|
| 1218 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 1219 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 1220 | - ); |
|
| 1221 | - |
|
| 1222 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1223 | - |
|
| 1224 | - /** |
|
| 1225 | - * Filter the Bootstrap settings. |
|
| 1226 | - * |
|
| 1227 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 1228 | - */ |
|
| 1229 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1230 | - } |
|
| 1231 | - |
|
| 1068 | + return str_replace( array( |
|
| 1069 | + '<script>', |
|
| 1070 | + '</script>' |
|
| 1071 | + ), '', $output ); |
|
| 1072 | + } |
|
| 1073 | + |
|
| 1074 | + /** |
|
| 1075 | + * Adds the Font Awesome JS. |
|
| 1076 | + */ |
|
| 1077 | + public function enqueue_scripts() { |
|
| 1078 | + |
|
| 1079 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 1080 | + // don't add wp-admin scripts if not requested to |
|
| 1081 | + }else { |
|
| 1082 | + |
|
| 1083 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 1084 | + |
|
| 1085 | + // select2 |
|
| 1086 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1087 | + |
|
| 1088 | + // flatpickr |
|
| 1089 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
| 1090 | + |
|
| 1091 | + // Bootstrap file browser |
|
| 1092 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1093 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1094 | + |
|
| 1095 | + $load_inline = false; |
|
| 1096 | + |
|
| 1097 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1098 | + // Bootstrap bundle |
|
| 1099 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 1100 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1101 | + 'select2', |
|
| 1102 | + 'jquery' |
|
| 1103 | + ), $this->latest, $this->is_bs3_compat() ); |
|
| 1104 | + // if in admin then add to footer for compatibility. |
|
| 1105 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1106 | + $script = $this->inline_script(); |
|
| 1107 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1108 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1109 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
| 1110 | + wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
| 1111 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1112 | + $load_inline = true; |
|
| 1113 | + } else { |
|
| 1114 | + $load_inline = true; |
|
| 1115 | + } |
|
| 1232 | 1116 | |
| 1233 | - /** |
|
| 1234 | - * The settings page html output. |
|
| 1235 | - */ |
|
| 1236 | - public function settings_page() { |
|
| 1237 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1238 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1239 | - } |
|
| 1240 | - ?> |
|
| 1117 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 1118 | + if ( $load_inline ) { |
|
| 1119 | + wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1120 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1121 | + $script = $this->inline_script(); |
|
| 1122 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1123 | + } |
|
| 1124 | + } |
|
| 1125 | + |
|
| 1126 | + } |
|
| 1127 | + |
|
| 1128 | + /** |
|
| 1129 | + * Enqueue flatpickr if called. |
|
| 1130 | + */ |
|
| 1131 | + public function enqueue_flatpickr(){ |
|
| 1132 | + wp_enqueue_style( 'flatpickr' ); |
|
| 1133 | + wp_enqueue_script( 'flatpickr' ); |
|
| 1134 | + } |
|
| 1135 | + |
|
| 1136 | + /** |
|
| 1137 | + * Get the url path to the current folder. |
|
| 1138 | + * |
|
| 1139 | + * @return string |
|
| 1140 | + */ |
|
| 1141 | + public function get_url() { |
|
| 1142 | + |
|
| 1143 | + $url = ''; |
|
| 1144 | + // check if we are inside a plugin |
|
| 1145 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1146 | + |
|
| 1147 | + // add check in-case user has changed wp-content dir name. |
|
| 1148 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 1149 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1150 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1151 | + |
|
| 1152 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1153 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1154 | + } |
|
| 1155 | + |
|
| 1156 | + return $url; |
|
| 1157 | + } |
|
| 1158 | + |
|
| 1159 | + /** |
|
| 1160 | + * Register the database settings with WordPress. |
|
| 1161 | + */ |
|
| 1162 | + public function register_settings() { |
|
| 1163 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1164 | + } |
|
| 1165 | + |
|
| 1166 | + /** |
|
| 1167 | + * Add the WordPress settings menu item. |
|
| 1168 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 1169 | + */ |
|
| 1170 | + public function menu_item() { |
|
| 1171 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 1172 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1173 | + $this, |
|
| 1174 | + 'settings_page' |
|
| 1175 | + ) ); |
|
| 1176 | + } |
|
| 1177 | + |
|
| 1178 | + /** |
|
| 1179 | + * Get a list of themes and their default JS settings. |
|
| 1180 | + * |
|
| 1181 | + * @return array |
|
| 1182 | + */ |
|
| 1183 | + public function theme_js_settings(){ |
|
| 1184 | + return array( |
|
| 1185 | + 'ayetheme' => 'popper', |
|
| 1186 | + 'listimia' => 'required', |
|
| 1187 | + 'listimia_backend' => 'core-popper', |
|
| 1188 | + //'avada' => 'required', // removed as we now add compatibility |
|
| 1189 | + ); |
|
| 1190 | + } |
|
| 1191 | + |
|
| 1192 | + /** |
|
| 1193 | + * Get the current Font Awesome output settings. |
|
| 1194 | + * |
|
| 1195 | + * @return array The array of settings. |
|
| 1196 | + */ |
|
| 1197 | + public function get_settings() { |
|
| 1198 | + |
|
| 1199 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1200 | + $js_default = 'core-popper'; |
|
| 1201 | + $js_default_backend = $js_default; |
|
| 1202 | + |
|
| 1203 | + // maybe set defaults (if no settings set) |
|
| 1204 | + if(empty($db_settings)){ |
|
| 1205 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1206 | + $theme_js_settings = self::theme_js_settings(); |
|
| 1207 | + if(isset($theme_js_settings[$active_theme])){ |
|
| 1208 | + $js_default = $theme_js_settings[$active_theme]; |
|
| 1209 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1210 | + } |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + $defaults = array( |
|
| 1214 | + 'css' => 'compatibility', // core, compatibility |
|
| 1215 | + 'js' => $js_default, // js to load, core-popper, popper |
|
| 1216 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 1217 | + 'css_backend' => 'compatibility', // core, compatibility |
|
| 1218 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 1219 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 1220 | + ); |
|
| 1221 | + |
|
| 1222 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1223 | + |
|
| 1224 | + /** |
|
| 1225 | + * Filter the Bootstrap settings. |
|
| 1226 | + * |
|
| 1227 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 1228 | + */ |
|
| 1229 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1230 | + } |
|
| 1231 | + |
|
| 1232 | + |
|
| 1233 | + /** |
|
| 1234 | + * The settings page html output. |
|
| 1235 | + */ |
|
| 1236 | + public function settings_page() { |
|
| 1237 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1238 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1239 | + } |
|
| 1240 | + ?> |
|
| 1241 | 1241 | <div class="wrap"> |
| 1242 | 1242 | <h1><?php echo $this->name; ?></h1> |
| 1243 | 1243 | <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
| 1244 | 1244 | <form method="post" action="options.php"> |
| 1245 | 1245 | <?php |
| 1246 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 1247 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1248 | - ?> |
|
| 1246 | + settings_fields( 'ayecode-ui-settings' ); |
|
| 1247 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1248 | + ?> |
|
| 1249 | 1249 | |
| 1250 | 1250 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
| 1251 | 1251 | <table class="form-table wpbs-table-settings"> |
@@ -1325,60 +1325,60 @@ discard block |
||
| 1325 | 1325 | </table> |
| 1326 | 1326 | |
| 1327 | 1327 | <?php |
| 1328 | - submit_button(); |
|
| 1329 | - ?> |
|
| 1328 | + submit_button(); |
|
| 1329 | + ?> |
|
| 1330 | 1330 | </form> |
| 1331 | 1331 | |
| 1332 | 1332 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
| 1333 | 1333 | </div> |
| 1334 | 1334 | |
| 1335 | 1335 | <?php |
| 1336 | - } |
|
| 1337 | - |
|
| 1338 | - public function customizer_settings($wp_customize){ |
|
| 1339 | - $wp_customize->add_section('aui_settings', array( |
|
| 1340 | - 'title' => __('AyeCode UI','aui'), |
|
| 1341 | - 'priority' => 120, |
|
| 1342 | - )); |
|
| 1343 | - |
|
| 1344 | - // ============================= |
|
| 1345 | - // = Color Picker = |
|
| 1346 | - // ============================= |
|
| 1347 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1348 | - 'default' => AUI_PRIMARY_COLOR, |
|
| 1349 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1350 | - 'capability' => 'edit_theme_options', |
|
| 1351 | - 'type' => 'option', |
|
| 1352 | - 'transport' => 'refresh', |
|
| 1353 | - )); |
|
| 1354 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1355 | - 'label' => __('Primary Color','aui'), |
|
| 1356 | - 'section' => 'aui_settings', |
|
| 1357 | - 'settings' => 'aui_options[color_primary]', |
|
| 1358 | - ))); |
|
| 1359 | - |
|
| 1360 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1361 | - 'default' => '#6c757d', |
|
| 1362 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1363 | - 'capability' => 'edit_theme_options', |
|
| 1364 | - 'type' => 'option', |
|
| 1365 | - 'transport' => 'refresh', |
|
| 1366 | - )); |
|
| 1367 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1368 | - 'label' => __('Secondary Color','aui'), |
|
| 1369 | - 'section' => 'aui_settings', |
|
| 1370 | - 'settings' => 'aui_options[color_secondary]', |
|
| 1371 | - ))); |
|
| 1372 | - } |
|
| 1373 | - |
|
| 1374 | - /** |
|
| 1375 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1376 | - * |
|
| 1377 | - * @return mixed |
|
| 1378 | - */ |
|
| 1379 | - public static function bs3_compat_css() { |
|
| 1380 | - ob_start(); |
|
| 1381 | - ?> |
|
| 1336 | + } |
|
| 1337 | + |
|
| 1338 | + public function customizer_settings($wp_customize){ |
|
| 1339 | + $wp_customize->add_section('aui_settings', array( |
|
| 1340 | + 'title' => __('AyeCode UI','aui'), |
|
| 1341 | + 'priority' => 120, |
|
| 1342 | + )); |
|
| 1343 | + |
|
| 1344 | + // ============================= |
|
| 1345 | + // = Color Picker = |
|
| 1346 | + // ============================= |
|
| 1347 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1348 | + 'default' => AUI_PRIMARY_COLOR, |
|
| 1349 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1350 | + 'capability' => 'edit_theme_options', |
|
| 1351 | + 'type' => 'option', |
|
| 1352 | + 'transport' => 'refresh', |
|
| 1353 | + )); |
|
| 1354 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1355 | + 'label' => __('Primary Color','aui'), |
|
| 1356 | + 'section' => 'aui_settings', |
|
| 1357 | + 'settings' => 'aui_options[color_primary]', |
|
| 1358 | + ))); |
|
| 1359 | + |
|
| 1360 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1361 | + 'default' => '#6c757d', |
|
| 1362 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1363 | + 'capability' => 'edit_theme_options', |
|
| 1364 | + 'type' => 'option', |
|
| 1365 | + 'transport' => 'refresh', |
|
| 1366 | + )); |
|
| 1367 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1368 | + 'label' => __('Secondary Color','aui'), |
|
| 1369 | + 'section' => 'aui_settings', |
|
| 1370 | + 'settings' => 'aui_options[color_secondary]', |
|
| 1371 | + ))); |
|
| 1372 | + } |
|
| 1373 | + |
|
| 1374 | + /** |
|
| 1375 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1376 | + * |
|
| 1377 | + * @return mixed |
|
| 1378 | + */ |
|
| 1379 | + public static function bs3_compat_css() { |
|
| 1380 | + ob_start(); |
|
| 1381 | + ?> |
|
| 1382 | 1382 | <style> |
| 1383 | 1383 | /* Bootstrap 3 compatibility */ |
| 1384 | 1384 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1404,579 +1404,579 @@ discard block |
||
| 1404 | 1404 | <?php } ?> |
| 1405 | 1405 | </style> |
| 1406 | 1406 | <?php |
| 1407 | - return str_replace( array( |
|
| 1408 | - '<style>', |
|
| 1409 | - '</style>' |
|
| 1410 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1411 | - } |
|
| 1407 | + return str_replace( array( |
|
| 1408 | + '<style>', |
|
| 1409 | + '</style>' |
|
| 1410 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1411 | + } |
|
| 1412 | 1412 | |
| 1413 | 1413 | |
| 1414 | - public static function custom_css($compatibility = true) { |
|
| 1415 | - $settings = get_option('aui_options'); |
|
| 1414 | + public static function custom_css($compatibility = true) { |
|
| 1415 | + $settings = get_option('aui_options'); |
|
| 1416 | 1416 | |
| 1417 | - ob_start(); |
|
| 1417 | + ob_start(); |
|
| 1418 | 1418 | |
| 1419 | - $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
| 1420 | - $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
| 1421 | - //AUI_PRIMARY_COLOR_ORIGINAL |
|
| 1422 | - ?> |
|
| 1419 | + $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
| 1420 | + $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
| 1421 | + //AUI_PRIMARY_COLOR_ORIGINAL |
|
| 1422 | + ?> |
|
| 1423 | 1423 | <style> |
| 1424 | 1424 | <?php |
| 1425 | 1425 | |
| 1426 | - // BS v3 compat |
|
| 1427 | - if( self::is_bs3_compat() ){ |
|
| 1428 | - echo self::bs3_compat_css(); |
|
| 1429 | - } |
|
| 1426 | + // BS v3 compat |
|
| 1427 | + if( self::is_bs3_compat() ){ |
|
| 1428 | + echo self::bs3_compat_css(); |
|
| 1429 | + } |
|
| 1430 | 1430 | |
| 1431 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
| 1432 | - echo self::css_primary($primary_color,$compatibility); |
|
| 1433 | - } |
|
| 1431 | + if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
| 1432 | + echo self::css_primary($primary_color,$compatibility); |
|
| 1433 | + } |
|
| 1434 | 1434 | |
| 1435 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
| 1436 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 1437 | - } |
|
| 1435 | + if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
| 1436 | + echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 1437 | + } |
|
| 1438 | 1438 | |
| 1439 | - // Set admin bar z-index lower when modal is open. |
|
| 1440 | - echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
| 1439 | + // Set admin bar z-index lower when modal is open. |
|
| 1440 | + echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
| 1441 | 1441 | ?> |
| 1442 | 1442 | </style> |
| 1443 | 1443 | <?php |
| 1444 | 1444 | |
| 1445 | 1445 | |
| 1446 | - /* |
|
| 1446 | + /* |
|
| 1447 | 1447 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1448 | 1448 | */ |
| 1449 | - return str_replace( array( |
|
| 1450 | - '<style>', |
|
| 1451 | - '</style>' |
|
| 1452 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1453 | - } |
|
| 1454 | - |
|
| 1455 | - /** |
|
| 1456 | - * Check if we should add booststrap 3 compatibility changes. |
|
| 1457 | - * |
|
| 1458 | - * @return bool |
|
| 1459 | - */ |
|
| 1460 | - public static function is_bs3_compat(){ |
|
| 1461 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1462 | - } |
|
| 1463 | - |
|
| 1464 | - public static function css_primary($color_code,$compatibility){; |
|
| 1465 | - $color_code = sanitize_hex_color($color_code); |
|
| 1466 | - if(!$color_code){return '';} |
|
| 1467 | - /** |
|
| 1468 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1469 | - */ |
|
| 1470 | - $selectors = array( |
|
| 1471 | - 'a' => array('c'), |
|
| 1472 | - '.btn-primary' => array('b','o'), |
|
| 1473 | - '.btn-primary.disabled' => array('b','o'), |
|
| 1474 | - '.btn-primary:disabled' => array('b','o'), |
|
| 1475 | - '.btn-outline-primary' => array('c','o'), |
|
| 1476 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 1477 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1478 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1479 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1480 | - '.btn-link' => array('c'), |
|
| 1481 | - '.dropdown-item.active' => array('b'), |
|
| 1482 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1483 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1449 | + return str_replace( array( |
|
| 1450 | + '<style>', |
|
| 1451 | + '</style>' |
|
| 1452 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1453 | + } |
|
| 1454 | + |
|
| 1455 | + /** |
|
| 1456 | + * Check if we should add booststrap 3 compatibility changes. |
|
| 1457 | + * |
|
| 1458 | + * @return bool |
|
| 1459 | + */ |
|
| 1460 | + public static function is_bs3_compat(){ |
|
| 1461 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1462 | + } |
|
| 1463 | + |
|
| 1464 | + public static function css_primary($color_code,$compatibility){; |
|
| 1465 | + $color_code = sanitize_hex_color($color_code); |
|
| 1466 | + if(!$color_code){return '';} |
|
| 1467 | + /** |
|
| 1468 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1469 | + */ |
|
| 1470 | + $selectors = array( |
|
| 1471 | + 'a' => array('c'), |
|
| 1472 | + '.btn-primary' => array('b','o'), |
|
| 1473 | + '.btn-primary.disabled' => array('b','o'), |
|
| 1474 | + '.btn-primary:disabled' => array('b','o'), |
|
| 1475 | + '.btn-outline-primary' => array('c','o'), |
|
| 1476 | + '.btn-outline-primary:hover' => array('b','o'), |
|
| 1477 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1478 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1479 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1480 | + '.btn-link' => array('c'), |
|
| 1481 | + '.dropdown-item.active' => array('b'), |
|
| 1482 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1483 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1484 | 1484 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1485 | 1485 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1486 | 1486 | // '.custom-range::-ms-thumb' => array('b'), |
| 1487 | - '.nav-pills .nav-link.active' => array('b'), |
|
| 1488 | - '.nav-pills .show>.nav-link' => array('b'), |
|
| 1489 | - '.page-link' => array('c'), |
|
| 1490 | - '.page-item.active .page-link' => array('b','o'), |
|
| 1491 | - '.badge-primary' => array('b'), |
|
| 1492 | - '.alert-primary' => array('b','o'), |
|
| 1493 | - '.progress-bar' => array('b'), |
|
| 1494 | - '.list-group-item.active' => array('b','o'), |
|
| 1495 | - '.bg-primary' => array('b','f'), |
|
| 1496 | - '.btn-link.btn-primary' => array('c'), |
|
| 1497 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1498 | - ); |
|
| 1499 | - |
|
| 1500 | - $important_selectors = array( |
|
| 1501 | - '.bg-primary' => array('b','f'), |
|
| 1502 | - '.border-primary' => array('o'), |
|
| 1503 | - '.text-primary' => array('c'), |
|
| 1504 | - ); |
|
| 1505 | - |
|
| 1506 | - $color = array(); |
|
| 1507 | - $color_i = array(); |
|
| 1508 | - $background = array(); |
|
| 1509 | - $background_i = array(); |
|
| 1510 | - $border = array(); |
|
| 1511 | - $border_i = array(); |
|
| 1512 | - $fill = array(); |
|
| 1513 | - $fill_i = array(); |
|
| 1514 | - |
|
| 1515 | - $output = ''; |
|
| 1516 | - |
|
| 1517 | - // build rules into each type |
|
| 1518 | - foreach($selectors as $selector => $types){ |
|
| 1519 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1520 | - $types = array_combine($types,$types); |
|
| 1521 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1522 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1523 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1524 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1525 | - } |
|
| 1526 | - |
|
| 1527 | - // build rules into each type |
|
| 1528 | - foreach($important_selectors as $selector => $types){ |
|
| 1529 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1530 | - $types = array_combine($types,$types); |
|
| 1531 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1532 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1533 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1534 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1535 | - } |
|
| 1536 | - |
|
| 1537 | - // add any color rules |
|
| 1538 | - if(!empty($color)){ |
|
| 1539 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1540 | - } |
|
| 1541 | - if(!empty($color_i)){ |
|
| 1542 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1543 | - } |
|
| 1544 | - |
|
| 1545 | - // add any background color rules |
|
| 1546 | - if(!empty($background)){ |
|
| 1547 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1548 | - } |
|
| 1549 | - if(!empty($background_i)){ |
|
| 1550 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1551 | - } |
|
| 1552 | - |
|
| 1553 | - // add any border color rules |
|
| 1554 | - if(!empty($border)){ |
|
| 1555 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1556 | - } |
|
| 1557 | - if(!empty($border_i)){ |
|
| 1558 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1559 | - } |
|
| 1560 | - |
|
| 1561 | - // add any fill color rules |
|
| 1562 | - if(!empty($fill)){ |
|
| 1563 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1564 | - } |
|
| 1565 | - if(!empty($fill_i)){ |
|
| 1566 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1567 | - } |
|
| 1568 | - |
|
| 1569 | - |
|
| 1570 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 1571 | - |
|
| 1572 | - // darken |
|
| 1573 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1574 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1575 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1576 | - |
|
| 1577 | - // lighten |
|
| 1578 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1579 | - |
|
| 1580 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1581 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1582 | - |
|
| 1583 | - |
|
| 1584 | - // button states |
|
| 1585 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1586 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1587 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1588 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1589 | - |
|
| 1590 | - |
|
| 1591 | - // dropdown's |
|
| 1592 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1593 | - |
|
| 1594 | - |
|
| 1595 | - // input states |
|
| 1596 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1597 | - |
|
| 1598 | - // page link |
|
| 1599 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1600 | - |
|
| 1601 | - return $output; |
|
| 1602 | - } |
|
| 1603 | - |
|
| 1604 | - public static function css_secondary($color_code,$compatibility){; |
|
| 1605 | - $color_code = sanitize_hex_color($color_code); |
|
| 1606 | - if(!$color_code){return '';} |
|
| 1607 | - /** |
|
| 1608 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1609 | - */ |
|
| 1610 | - $selectors = array( |
|
| 1611 | - '.btn-secondary' => array('b','o'), |
|
| 1612 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 1613 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 1614 | - '.btn-outline-secondary' => array('c','o'), |
|
| 1615 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1616 | - '.btn-outline-secondary.disabled' => array('c'), |
|
| 1617 | - '.btn-outline-secondary:disabled' => array('c'), |
|
| 1618 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1619 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1620 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1621 | - '.badge-secondary' => array('b'), |
|
| 1622 | - '.alert-secondary' => array('b','o'), |
|
| 1623 | - '.btn-link.btn-secondary' => array('c'), |
|
| 1624 | - ); |
|
| 1625 | - |
|
| 1626 | - $important_selectors = array( |
|
| 1627 | - '.bg-secondary' => array('b','f'), |
|
| 1628 | - '.border-secondary' => array('o'), |
|
| 1629 | - '.text-secondary' => array('c'), |
|
| 1630 | - ); |
|
| 1631 | - |
|
| 1632 | - $color = array(); |
|
| 1633 | - $color_i = array(); |
|
| 1634 | - $background = array(); |
|
| 1635 | - $background_i = array(); |
|
| 1636 | - $border = array(); |
|
| 1637 | - $border_i = array(); |
|
| 1638 | - $fill = array(); |
|
| 1639 | - $fill_i = array(); |
|
| 1640 | - |
|
| 1641 | - $output = ''; |
|
| 1642 | - |
|
| 1643 | - // build rules into each type |
|
| 1644 | - foreach($selectors as $selector => $types){ |
|
| 1645 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1646 | - $types = array_combine($types,$types); |
|
| 1647 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1648 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1649 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1650 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1651 | - } |
|
| 1652 | - |
|
| 1653 | - // build rules into each type |
|
| 1654 | - foreach($important_selectors as $selector => $types){ |
|
| 1655 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1656 | - $types = array_combine($types,$types); |
|
| 1657 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1658 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1659 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1660 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1661 | - } |
|
| 1662 | - |
|
| 1663 | - // add any color rules |
|
| 1664 | - if(!empty($color)){ |
|
| 1665 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1666 | - } |
|
| 1667 | - if(!empty($color_i)){ |
|
| 1668 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1669 | - } |
|
| 1670 | - |
|
| 1671 | - // add any background color rules |
|
| 1672 | - if(!empty($background)){ |
|
| 1673 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1674 | - } |
|
| 1675 | - if(!empty($background_i)){ |
|
| 1676 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1677 | - } |
|
| 1678 | - |
|
| 1679 | - // add any border color rules |
|
| 1680 | - if(!empty($border)){ |
|
| 1681 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1682 | - } |
|
| 1683 | - if(!empty($border_i)){ |
|
| 1684 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1685 | - } |
|
| 1686 | - |
|
| 1687 | - // add any fill color rules |
|
| 1688 | - if(!empty($fill)){ |
|
| 1689 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1690 | - } |
|
| 1691 | - if(!empty($fill_i)){ |
|
| 1692 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1693 | - } |
|
| 1694 | - |
|
| 1695 | - |
|
| 1696 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 1697 | - |
|
| 1698 | - // darken |
|
| 1699 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1700 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1701 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1702 | - |
|
| 1703 | - // lighten |
|
| 1704 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1705 | - |
|
| 1706 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1707 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1708 | - |
|
| 1709 | - |
|
| 1710 | - // button states |
|
| 1711 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1712 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1713 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1714 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1715 | - |
|
| 1716 | - |
|
| 1717 | - return $output; |
|
| 1718 | - } |
|
| 1719 | - |
|
| 1720 | - /** |
|
| 1721 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 1722 | - * |
|
| 1723 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 1724 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 1725 | - * |
|
| 1726 | - * @return string |
|
| 1727 | - */ |
|
| 1728 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 1729 | - $hexCode = ltrim($hexCode, '#'); |
|
| 1730 | - |
|
| 1731 | - if (strlen($hexCode) == 3) { |
|
| 1732 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 1733 | - } |
|
| 1734 | - |
|
| 1735 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 1736 | - |
|
| 1737 | - foreach ($hexCode as & $color) { |
|
| 1738 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 1739 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 1740 | - |
|
| 1741 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 1742 | - } |
|
| 1743 | - |
|
| 1744 | - return '#' . implode($hexCode); |
|
| 1745 | - } |
|
| 1746 | - |
|
| 1747 | - /** |
|
| 1748 | - * Check if we should display examples. |
|
| 1749 | - */ |
|
| 1750 | - public function maybe_show_examples(){ |
|
| 1751 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 1752 | - echo "<head>"; |
|
| 1753 | - wp_head(); |
|
| 1754 | - echo "</head>"; |
|
| 1755 | - echo "<body>"; |
|
| 1756 | - echo $this->get_examples(); |
|
| 1757 | - echo "</body>"; |
|
| 1758 | - exit; |
|
| 1759 | - } |
|
| 1760 | - } |
|
| 1761 | - |
|
| 1762 | - /** |
|
| 1763 | - * Get developer examples. |
|
| 1764 | - * |
|
| 1765 | - * @return string |
|
| 1766 | - */ |
|
| 1767 | - public function get_examples(){ |
|
| 1768 | - $output = ''; |
|
| 1769 | - |
|
| 1770 | - |
|
| 1771 | - // open form |
|
| 1772 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 1773 | - |
|
| 1774 | - // input example |
|
| 1775 | - $output .= aui()->input(array( |
|
| 1776 | - 'type' => 'text', |
|
| 1777 | - 'id' => 'text-example', |
|
| 1778 | - 'name' => 'text-example', |
|
| 1779 | - 'placeholder' => 'text placeholder', |
|
| 1780 | - 'title' => 'Text input example', |
|
| 1781 | - 'value' => '', |
|
| 1782 | - 'required' => false, |
|
| 1783 | - 'help_text' => 'help text', |
|
| 1784 | - 'label' => 'Text input example label' |
|
| 1785 | - )); |
|
| 1786 | - |
|
| 1787 | - // input example |
|
| 1788 | - $output .= aui()->input(array( |
|
| 1789 | - 'type' => 'url', |
|
| 1790 | - 'id' => 'text-example2', |
|
| 1791 | - 'name' => 'text-example', |
|
| 1792 | - 'placeholder' => 'url placeholder', |
|
| 1793 | - 'title' => 'Text input example', |
|
| 1794 | - 'value' => '', |
|
| 1795 | - 'required' => false, |
|
| 1796 | - 'help_text' => 'help text', |
|
| 1797 | - 'label' => 'Text input example label' |
|
| 1798 | - )); |
|
| 1799 | - |
|
| 1800 | - // checkbox example |
|
| 1801 | - $output .= aui()->input(array( |
|
| 1802 | - 'type' => 'checkbox', |
|
| 1803 | - 'id' => 'checkbox-example', |
|
| 1804 | - 'name' => 'checkbox-example', |
|
| 1805 | - 'placeholder' => 'checkbox-example', |
|
| 1806 | - 'title' => 'Checkbox example', |
|
| 1807 | - 'value' => '1', |
|
| 1808 | - 'checked' => true, |
|
| 1809 | - 'required' => false, |
|
| 1810 | - 'help_text' => 'help text', |
|
| 1811 | - 'label' => 'Checkbox checked' |
|
| 1812 | - )); |
|
| 1813 | - |
|
| 1814 | - // checkbox example |
|
| 1815 | - $output .= aui()->input(array( |
|
| 1816 | - 'type' => 'checkbox', |
|
| 1817 | - 'id' => 'checkbox-example2', |
|
| 1818 | - 'name' => 'checkbox-example2', |
|
| 1819 | - 'placeholder' => 'checkbox-example', |
|
| 1820 | - 'title' => 'Checkbox example', |
|
| 1821 | - 'value' => '1', |
|
| 1822 | - 'checked' => false, |
|
| 1823 | - 'required' => false, |
|
| 1824 | - 'help_text' => 'help text', |
|
| 1825 | - 'label' => 'Checkbox un-checked' |
|
| 1826 | - )); |
|
| 1827 | - |
|
| 1828 | - // switch example |
|
| 1829 | - $output .= aui()->input(array( |
|
| 1830 | - 'type' => 'checkbox', |
|
| 1831 | - 'id' => 'switch-example', |
|
| 1832 | - 'name' => 'switch-example', |
|
| 1833 | - 'placeholder' => 'checkbox-example', |
|
| 1834 | - 'title' => 'Switch example', |
|
| 1835 | - 'value' => '1', |
|
| 1836 | - 'checked' => true, |
|
| 1837 | - 'switch' => true, |
|
| 1838 | - 'required' => false, |
|
| 1839 | - 'help_text' => 'help text', |
|
| 1840 | - 'label' => 'Switch on' |
|
| 1841 | - )); |
|
| 1842 | - |
|
| 1843 | - // switch example |
|
| 1844 | - $output .= aui()->input(array( |
|
| 1845 | - 'type' => 'checkbox', |
|
| 1846 | - 'id' => 'switch-example2', |
|
| 1847 | - 'name' => 'switch-example2', |
|
| 1848 | - 'placeholder' => 'checkbox-example', |
|
| 1849 | - 'title' => 'Switch example', |
|
| 1850 | - 'value' => '1', |
|
| 1851 | - 'checked' => false, |
|
| 1852 | - 'switch' => true, |
|
| 1853 | - 'required' => false, |
|
| 1854 | - 'help_text' => 'help text', |
|
| 1855 | - 'label' => 'Switch off' |
|
| 1856 | - )); |
|
| 1857 | - |
|
| 1858 | - // close form |
|
| 1859 | - $output .= "</form>"; |
|
| 1860 | - |
|
| 1861 | - return $output; |
|
| 1862 | - } |
|
| 1863 | - |
|
| 1864 | - /** |
|
| 1865 | - * Calendar params. |
|
| 1866 | - * |
|
| 1867 | - * @since 0.1.44 |
|
| 1868 | - * |
|
| 1869 | - * @return array Calendar params. |
|
| 1870 | - */ |
|
| 1871 | - public static function calendar_params() { |
|
| 1872 | - $params = array( |
|
| 1873 | - 'month_long_1' => __( 'January', 'aui' ), |
|
| 1874 | - 'month_long_2' => __( 'February', 'aui' ), |
|
| 1875 | - 'month_long_3' => __( 'March', 'aui' ), |
|
| 1876 | - 'month_long_4' => __( 'April', 'aui' ), |
|
| 1877 | - 'month_long_5' => __( 'May', 'aui' ), |
|
| 1878 | - 'month_long_6' => __( 'June', 'aui' ), |
|
| 1879 | - 'month_long_7' => __( 'July', 'aui' ), |
|
| 1880 | - 'month_long_8' => __( 'August', 'aui' ), |
|
| 1881 | - 'month_long_9' => __( 'September', 'aui' ), |
|
| 1882 | - 'month_long_10' => __( 'October', 'aui' ), |
|
| 1883 | - 'month_long_11' => __( 'November', 'aui' ), |
|
| 1884 | - 'month_long_12' => __( 'December', 'aui' ), |
|
| 1885 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 1886 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 1887 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 1888 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 1889 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 1890 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 1891 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 1892 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 1893 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 1894 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 1895 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 1896 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 1897 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 1898 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 1899 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 1900 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 1901 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 1902 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 1903 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 1904 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 1905 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 1906 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 1907 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
| 1908 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 1909 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 1910 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 1911 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 1912 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 1913 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 1914 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 1915 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 1916 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 1917 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 1918 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 1919 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 1920 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 1921 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 1922 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 1923 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 1924 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 1925 | - 'am_lower' => __( 'am', 'aui' ), |
|
| 1926 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
| 1927 | - 'am_upper' => __( 'AM', 'aui' ), |
|
| 1928 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
| 1929 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 1930 | - 'time_24hr' => false, |
|
| 1931 | - 'year' => __( 'Year', 'aui' ), |
|
| 1932 | - 'hour' => __( 'Hour', 'aui' ), |
|
| 1933 | - 'minute' => __( 'Minute', 'aui' ), |
|
| 1934 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 1935 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 1936 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 1937 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 1938 | - ); |
|
| 1939 | - |
|
| 1940 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 1941 | - } |
|
| 1942 | - |
|
| 1943 | - /** |
|
| 1944 | - * Flatpickr calendar localize. |
|
| 1945 | - * |
|
| 1946 | - * @since 0.1.44 |
|
| 1947 | - * |
|
| 1948 | - * @return string Calendar locale. |
|
| 1949 | - */ |
|
| 1950 | - public static function flatpickr_locale() { |
|
| 1951 | - $params = self::calendar_params(); |
|
| 1952 | - |
|
| 1953 | - if ( is_string( $params ) ) { |
|
| 1954 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 1955 | - } else { |
|
| 1956 | - foreach ( (array) $params as $key => $value ) { |
|
| 1957 | - if ( ! is_scalar( $value ) ) { |
|
| 1958 | - continue; |
|
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 1962 | - } |
|
| 1963 | - } |
|
| 1487 | + '.nav-pills .nav-link.active' => array('b'), |
|
| 1488 | + '.nav-pills .show>.nav-link' => array('b'), |
|
| 1489 | + '.page-link' => array('c'), |
|
| 1490 | + '.page-item.active .page-link' => array('b','o'), |
|
| 1491 | + '.badge-primary' => array('b'), |
|
| 1492 | + '.alert-primary' => array('b','o'), |
|
| 1493 | + '.progress-bar' => array('b'), |
|
| 1494 | + '.list-group-item.active' => array('b','o'), |
|
| 1495 | + '.bg-primary' => array('b','f'), |
|
| 1496 | + '.btn-link.btn-primary' => array('c'), |
|
| 1497 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1498 | + ); |
|
| 1499 | + |
|
| 1500 | + $important_selectors = array( |
|
| 1501 | + '.bg-primary' => array('b','f'), |
|
| 1502 | + '.border-primary' => array('o'), |
|
| 1503 | + '.text-primary' => array('c'), |
|
| 1504 | + ); |
|
| 1505 | + |
|
| 1506 | + $color = array(); |
|
| 1507 | + $color_i = array(); |
|
| 1508 | + $background = array(); |
|
| 1509 | + $background_i = array(); |
|
| 1510 | + $border = array(); |
|
| 1511 | + $border_i = array(); |
|
| 1512 | + $fill = array(); |
|
| 1513 | + $fill_i = array(); |
|
| 1514 | + |
|
| 1515 | + $output = ''; |
|
| 1516 | + |
|
| 1517 | + // build rules into each type |
|
| 1518 | + foreach($selectors as $selector => $types){ |
|
| 1519 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1520 | + $types = array_combine($types,$types); |
|
| 1521 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1522 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1523 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1524 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1525 | + } |
|
| 1526 | + |
|
| 1527 | + // build rules into each type |
|
| 1528 | + foreach($important_selectors as $selector => $types){ |
|
| 1529 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1530 | + $types = array_combine($types,$types); |
|
| 1531 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1532 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1533 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1534 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + // add any color rules |
|
| 1538 | + if(!empty($color)){ |
|
| 1539 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1540 | + } |
|
| 1541 | + if(!empty($color_i)){ |
|
| 1542 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1543 | + } |
|
| 1544 | + |
|
| 1545 | + // add any background color rules |
|
| 1546 | + if(!empty($background)){ |
|
| 1547 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1548 | + } |
|
| 1549 | + if(!empty($background_i)){ |
|
| 1550 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1551 | + } |
|
| 1552 | + |
|
| 1553 | + // add any border color rules |
|
| 1554 | + if(!empty($border)){ |
|
| 1555 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1556 | + } |
|
| 1557 | + if(!empty($border_i)){ |
|
| 1558 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1559 | + } |
|
| 1560 | + |
|
| 1561 | + // add any fill color rules |
|
| 1562 | + if(!empty($fill)){ |
|
| 1563 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1564 | + } |
|
| 1565 | + if(!empty($fill_i)){ |
|
| 1566 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1567 | + } |
|
| 1568 | + |
|
| 1569 | + |
|
| 1570 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 1571 | + |
|
| 1572 | + // darken |
|
| 1573 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1574 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1575 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1576 | + |
|
| 1577 | + // lighten |
|
| 1578 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1579 | + |
|
| 1580 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1581 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1582 | + |
|
| 1583 | + |
|
| 1584 | + // button states |
|
| 1585 | + $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1586 | + $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1587 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1588 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1589 | + |
|
| 1590 | + |
|
| 1591 | + // dropdown's |
|
| 1592 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1593 | + |
|
| 1594 | + |
|
| 1595 | + // input states |
|
| 1596 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1597 | + |
|
| 1598 | + // page link |
|
| 1599 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1600 | + |
|
| 1601 | + return $output; |
|
| 1602 | + } |
|
| 1603 | + |
|
| 1604 | + public static function css_secondary($color_code,$compatibility){; |
|
| 1605 | + $color_code = sanitize_hex_color($color_code); |
|
| 1606 | + if(!$color_code){return '';} |
|
| 1607 | + /** |
|
| 1608 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1609 | + */ |
|
| 1610 | + $selectors = array( |
|
| 1611 | + '.btn-secondary' => array('b','o'), |
|
| 1612 | + '.btn-secondary.disabled' => array('b','o'), |
|
| 1613 | + '.btn-secondary:disabled' => array('b','o'), |
|
| 1614 | + '.btn-outline-secondary' => array('c','o'), |
|
| 1615 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1616 | + '.btn-outline-secondary.disabled' => array('c'), |
|
| 1617 | + '.btn-outline-secondary:disabled' => array('c'), |
|
| 1618 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1619 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1620 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1621 | + '.badge-secondary' => array('b'), |
|
| 1622 | + '.alert-secondary' => array('b','o'), |
|
| 1623 | + '.btn-link.btn-secondary' => array('c'), |
|
| 1624 | + ); |
|
| 1625 | + |
|
| 1626 | + $important_selectors = array( |
|
| 1627 | + '.bg-secondary' => array('b','f'), |
|
| 1628 | + '.border-secondary' => array('o'), |
|
| 1629 | + '.text-secondary' => array('c'), |
|
| 1630 | + ); |
|
| 1631 | + |
|
| 1632 | + $color = array(); |
|
| 1633 | + $color_i = array(); |
|
| 1634 | + $background = array(); |
|
| 1635 | + $background_i = array(); |
|
| 1636 | + $border = array(); |
|
| 1637 | + $border_i = array(); |
|
| 1638 | + $fill = array(); |
|
| 1639 | + $fill_i = array(); |
|
| 1640 | + |
|
| 1641 | + $output = ''; |
|
| 1642 | + |
|
| 1643 | + // build rules into each type |
|
| 1644 | + foreach($selectors as $selector => $types){ |
|
| 1645 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1646 | + $types = array_combine($types,$types); |
|
| 1647 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1648 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1649 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1650 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1651 | + } |
|
| 1652 | + |
|
| 1653 | + // build rules into each type |
|
| 1654 | + foreach($important_selectors as $selector => $types){ |
|
| 1655 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1656 | + $types = array_combine($types,$types); |
|
| 1657 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1658 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1659 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1660 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1661 | + } |
|
| 1662 | + |
|
| 1663 | + // add any color rules |
|
| 1664 | + if(!empty($color)){ |
|
| 1665 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1666 | + } |
|
| 1667 | + if(!empty($color_i)){ |
|
| 1668 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1669 | + } |
|
| 1670 | + |
|
| 1671 | + // add any background color rules |
|
| 1672 | + if(!empty($background)){ |
|
| 1673 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1674 | + } |
|
| 1675 | + if(!empty($background_i)){ |
|
| 1676 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1677 | + } |
|
| 1678 | + |
|
| 1679 | + // add any border color rules |
|
| 1680 | + if(!empty($border)){ |
|
| 1681 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1682 | + } |
|
| 1683 | + if(!empty($border_i)){ |
|
| 1684 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1685 | + } |
|
| 1686 | + |
|
| 1687 | + // add any fill color rules |
|
| 1688 | + if(!empty($fill)){ |
|
| 1689 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1690 | + } |
|
| 1691 | + if(!empty($fill_i)){ |
|
| 1692 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1693 | + } |
|
| 1694 | + |
|
| 1695 | + |
|
| 1696 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 1697 | + |
|
| 1698 | + // darken |
|
| 1699 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1700 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1701 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1702 | + |
|
| 1703 | + // lighten |
|
| 1704 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1705 | + |
|
| 1706 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1707 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1708 | + |
|
| 1709 | + |
|
| 1710 | + // button states |
|
| 1711 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1712 | + $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1713 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1714 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1715 | + |
|
| 1716 | + |
|
| 1717 | + return $output; |
|
| 1718 | + } |
|
| 1719 | + |
|
| 1720 | + /** |
|
| 1721 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 1722 | + * |
|
| 1723 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 1724 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 1725 | + * |
|
| 1726 | + * @return string |
|
| 1727 | + */ |
|
| 1728 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 1729 | + $hexCode = ltrim($hexCode, '#'); |
|
| 1730 | + |
|
| 1731 | + if (strlen($hexCode) == 3) { |
|
| 1732 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 1733 | + } |
|
| 1734 | + |
|
| 1735 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 1736 | + |
|
| 1737 | + foreach ($hexCode as & $color) { |
|
| 1738 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 1739 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 1740 | + |
|
| 1741 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 1742 | + } |
|
| 1743 | + |
|
| 1744 | + return '#' . implode($hexCode); |
|
| 1745 | + } |
|
| 1746 | + |
|
| 1747 | + /** |
|
| 1748 | + * Check if we should display examples. |
|
| 1749 | + */ |
|
| 1750 | + public function maybe_show_examples(){ |
|
| 1751 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 1752 | + echo "<head>"; |
|
| 1753 | + wp_head(); |
|
| 1754 | + echo "</head>"; |
|
| 1755 | + echo "<body>"; |
|
| 1756 | + echo $this->get_examples(); |
|
| 1757 | + echo "</body>"; |
|
| 1758 | + exit; |
|
| 1759 | + } |
|
| 1760 | + } |
|
| 1761 | + |
|
| 1762 | + /** |
|
| 1763 | + * Get developer examples. |
|
| 1764 | + * |
|
| 1765 | + * @return string |
|
| 1766 | + */ |
|
| 1767 | + public function get_examples(){ |
|
| 1768 | + $output = ''; |
|
| 1769 | + |
|
| 1770 | + |
|
| 1771 | + // open form |
|
| 1772 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 1773 | + |
|
| 1774 | + // input example |
|
| 1775 | + $output .= aui()->input(array( |
|
| 1776 | + 'type' => 'text', |
|
| 1777 | + 'id' => 'text-example', |
|
| 1778 | + 'name' => 'text-example', |
|
| 1779 | + 'placeholder' => 'text placeholder', |
|
| 1780 | + 'title' => 'Text input example', |
|
| 1781 | + 'value' => '', |
|
| 1782 | + 'required' => false, |
|
| 1783 | + 'help_text' => 'help text', |
|
| 1784 | + 'label' => 'Text input example label' |
|
| 1785 | + )); |
|
| 1786 | + |
|
| 1787 | + // input example |
|
| 1788 | + $output .= aui()->input(array( |
|
| 1789 | + 'type' => 'url', |
|
| 1790 | + 'id' => 'text-example2', |
|
| 1791 | + 'name' => 'text-example', |
|
| 1792 | + 'placeholder' => 'url placeholder', |
|
| 1793 | + 'title' => 'Text input example', |
|
| 1794 | + 'value' => '', |
|
| 1795 | + 'required' => false, |
|
| 1796 | + 'help_text' => 'help text', |
|
| 1797 | + 'label' => 'Text input example label' |
|
| 1798 | + )); |
|
| 1799 | + |
|
| 1800 | + // checkbox example |
|
| 1801 | + $output .= aui()->input(array( |
|
| 1802 | + 'type' => 'checkbox', |
|
| 1803 | + 'id' => 'checkbox-example', |
|
| 1804 | + 'name' => 'checkbox-example', |
|
| 1805 | + 'placeholder' => 'checkbox-example', |
|
| 1806 | + 'title' => 'Checkbox example', |
|
| 1807 | + 'value' => '1', |
|
| 1808 | + 'checked' => true, |
|
| 1809 | + 'required' => false, |
|
| 1810 | + 'help_text' => 'help text', |
|
| 1811 | + 'label' => 'Checkbox checked' |
|
| 1812 | + )); |
|
| 1813 | + |
|
| 1814 | + // checkbox example |
|
| 1815 | + $output .= aui()->input(array( |
|
| 1816 | + 'type' => 'checkbox', |
|
| 1817 | + 'id' => 'checkbox-example2', |
|
| 1818 | + 'name' => 'checkbox-example2', |
|
| 1819 | + 'placeholder' => 'checkbox-example', |
|
| 1820 | + 'title' => 'Checkbox example', |
|
| 1821 | + 'value' => '1', |
|
| 1822 | + 'checked' => false, |
|
| 1823 | + 'required' => false, |
|
| 1824 | + 'help_text' => 'help text', |
|
| 1825 | + 'label' => 'Checkbox un-checked' |
|
| 1826 | + )); |
|
| 1827 | + |
|
| 1828 | + // switch example |
|
| 1829 | + $output .= aui()->input(array( |
|
| 1830 | + 'type' => 'checkbox', |
|
| 1831 | + 'id' => 'switch-example', |
|
| 1832 | + 'name' => 'switch-example', |
|
| 1833 | + 'placeholder' => 'checkbox-example', |
|
| 1834 | + 'title' => 'Switch example', |
|
| 1835 | + 'value' => '1', |
|
| 1836 | + 'checked' => true, |
|
| 1837 | + 'switch' => true, |
|
| 1838 | + 'required' => false, |
|
| 1839 | + 'help_text' => 'help text', |
|
| 1840 | + 'label' => 'Switch on' |
|
| 1841 | + )); |
|
| 1842 | + |
|
| 1843 | + // switch example |
|
| 1844 | + $output .= aui()->input(array( |
|
| 1845 | + 'type' => 'checkbox', |
|
| 1846 | + 'id' => 'switch-example2', |
|
| 1847 | + 'name' => 'switch-example2', |
|
| 1848 | + 'placeholder' => 'checkbox-example', |
|
| 1849 | + 'title' => 'Switch example', |
|
| 1850 | + 'value' => '1', |
|
| 1851 | + 'checked' => false, |
|
| 1852 | + 'switch' => true, |
|
| 1853 | + 'required' => false, |
|
| 1854 | + 'help_text' => 'help text', |
|
| 1855 | + 'label' => 'Switch off' |
|
| 1856 | + )); |
|
| 1857 | + |
|
| 1858 | + // close form |
|
| 1859 | + $output .= "</form>"; |
|
| 1860 | + |
|
| 1861 | + return $output; |
|
| 1862 | + } |
|
| 1863 | + |
|
| 1864 | + /** |
|
| 1865 | + * Calendar params. |
|
| 1866 | + * |
|
| 1867 | + * @since 0.1.44 |
|
| 1868 | + * |
|
| 1869 | + * @return array Calendar params. |
|
| 1870 | + */ |
|
| 1871 | + public static function calendar_params() { |
|
| 1872 | + $params = array( |
|
| 1873 | + 'month_long_1' => __( 'January', 'aui' ), |
|
| 1874 | + 'month_long_2' => __( 'February', 'aui' ), |
|
| 1875 | + 'month_long_3' => __( 'March', 'aui' ), |
|
| 1876 | + 'month_long_4' => __( 'April', 'aui' ), |
|
| 1877 | + 'month_long_5' => __( 'May', 'aui' ), |
|
| 1878 | + 'month_long_6' => __( 'June', 'aui' ), |
|
| 1879 | + 'month_long_7' => __( 'July', 'aui' ), |
|
| 1880 | + 'month_long_8' => __( 'August', 'aui' ), |
|
| 1881 | + 'month_long_9' => __( 'September', 'aui' ), |
|
| 1882 | + 'month_long_10' => __( 'October', 'aui' ), |
|
| 1883 | + 'month_long_11' => __( 'November', 'aui' ), |
|
| 1884 | + 'month_long_12' => __( 'December', 'aui' ), |
|
| 1885 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 1886 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 1887 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 1888 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 1889 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 1890 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 1891 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 1892 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 1893 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 1894 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 1895 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 1896 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 1897 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 1898 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 1899 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 1900 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 1901 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 1902 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 1903 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 1904 | + 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 1905 | + 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 1906 | + 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 1907 | + 'day_s2_4' => __( 'We', 'aui' ), |
|
| 1908 | + 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 1909 | + 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 1910 | + 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 1911 | + 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 1912 | + 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 1913 | + 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 1914 | + 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 1915 | + 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 1916 | + 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 1917 | + 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 1918 | + 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 1919 | + 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 1920 | + 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 1921 | + 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 1922 | + 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 1923 | + 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 1924 | + 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 1925 | + 'am_lower' => __( 'am', 'aui' ), |
|
| 1926 | + 'pm_lower' => __( 'pm', 'aui' ), |
|
| 1927 | + 'am_upper' => __( 'AM', 'aui' ), |
|
| 1928 | + 'pm_upper' => __( 'PM', 'aui' ), |
|
| 1929 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 1930 | + 'time_24hr' => false, |
|
| 1931 | + 'year' => __( 'Year', 'aui' ), |
|
| 1932 | + 'hour' => __( 'Hour', 'aui' ), |
|
| 1933 | + 'minute' => __( 'Minute', 'aui' ), |
|
| 1934 | + 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 1935 | + 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 1936 | + 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 1937 | + 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 1938 | + ); |
|
| 1939 | + |
|
| 1940 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 1941 | + } |
|
| 1942 | + |
|
| 1943 | + /** |
|
| 1944 | + * Flatpickr calendar localize. |
|
| 1945 | + * |
|
| 1946 | + * @since 0.1.44 |
|
| 1947 | + * |
|
| 1948 | + * @return string Calendar locale. |
|
| 1949 | + */ |
|
| 1950 | + public static function flatpickr_locale() { |
|
| 1951 | + $params = self::calendar_params(); |
|
| 1952 | + |
|
| 1953 | + if ( is_string( $params ) ) { |
|
| 1954 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 1955 | + } else { |
|
| 1956 | + foreach ( (array) $params as $key => $value ) { |
|
| 1957 | + if ( ! is_scalar( $value ) ) { |
|
| 1958 | + continue; |
|
| 1959 | + } |
|
| 1960 | + |
|
| 1961 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 1962 | + } |
|
| 1963 | + } |
|
| 1964 | 1964 | |
| 1965 | - $day_s3 = array(); |
|
| 1966 | - $day_s5 = array(); |
|
| 1965 | + $day_s3 = array(); |
|
| 1966 | + $day_s5 = array(); |
|
| 1967 | 1967 | |
| 1968 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 1969 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 1970 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 1971 | - } |
|
| 1968 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 1969 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 1970 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 1971 | + } |
|
| 1972 | 1972 | |
| 1973 | - $month_s = array(); |
|
| 1974 | - $month_long = array(); |
|
| 1973 | + $month_s = array(); |
|
| 1974 | + $month_long = array(); |
|
| 1975 | 1975 | |
| 1976 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 1977 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 1978 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 1979 | - } |
|
| 1976 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 1977 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 1978 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 1979 | + } |
|
| 1980 | 1980 | |
| 1981 | 1981 | ob_start(); |
| 1982 | 1982 | if ( 0 ) { ?><script><?php } ?> |
@@ -2018,184 +2018,184 @@ discard block |
||
| 2018 | 2018 | } |
| 2019 | 2019 | <?php if ( 0 ) { ?></script><?php } ?> |
| 2020 | 2020 | <?php |
| 2021 | - $locale = ob_get_clean(); |
|
| 2022 | - |
|
| 2023 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2024 | - } |
|
| 2025 | - |
|
| 2026 | - /** |
|
| 2027 | - * Select2 JS params. |
|
| 2028 | - * |
|
| 2029 | - * @since 0.1.44 |
|
| 2030 | - * |
|
| 2031 | - * @return array Select2 JS params. |
|
| 2032 | - */ |
|
| 2033 | - public static function select2_params() { |
|
| 2034 | - $params = array( |
|
| 2035 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2036 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2037 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2038 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2039 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2040 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2041 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2042 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2043 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2044 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2045 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2046 | - ); |
|
| 2047 | - |
|
| 2048 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2049 | - } |
|
| 2050 | - |
|
| 2051 | - /** |
|
| 2052 | - * Select2 JS localize. |
|
| 2053 | - * |
|
| 2054 | - * @since 0.1.44 |
|
| 2055 | - * |
|
| 2056 | - * @return string Select2 JS locale. |
|
| 2057 | - */ |
|
| 2058 | - public static function select2_locale() { |
|
| 2059 | - $params = self::select2_params(); |
|
| 2060 | - |
|
| 2061 | - foreach ( (array) $params as $key => $value ) { |
|
| 2062 | - if ( ! is_scalar( $value ) ) { |
|
| 2063 | - continue; |
|
| 2064 | - } |
|
| 2065 | - |
|
| 2066 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2067 | - } |
|
| 2068 | - |
|
| 2069 | - $locale = json_encode( $params ); |
|
| 2070 | - |
|
| 2071 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2072 | - } |
|
| 2073 | - |
|
| 2074 | - /** |
|
| 2075 | - * Time ago JS localize. |
|
| 2076 | - * |
|
| 2077 | - * @since 0.1.47 |
|
| 2078 | - * |
|
| 2079 | - * @return string Time ago JS locale. |
|
| 2080 | - */ |
|
| 2081 | - public static function timeago_locale() { |
|
| 2082 | - $params = array( |
|
| 2083 | - 'prefix_ago' => '', |
|
| 2084 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2085 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2086 | - 'suffix_after' => '', |
|
| 2087 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2088 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2089 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2090 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2091 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2092 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2093 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2094 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2095 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2096 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2097 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2098 | - ); |
|
| 2099 | - |
|
| 2100 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2101 | - |
|
| 2102 | - foreach ( (array) $params as $key => $value ) { |
|
| 2103 | - if ( ! is_scalar( $value ) ) { |
|
| 2104 | - continue; |
|
| 2105 | - } |
|
| 2106 | - |
|
| 2107 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2108 | - } |
|
| 2109 | - |
|
| 2110 | - $locale = json_encode( $params ); |
|
| 2111 | - |
|
| 2112 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2113 | - } |
|
| 2114 | - |
|
| 2115 | - /** |
|
| 2116 | - * JavaScript Minifier |
|
| 2117 | - * |
|
| 2118 | - * @param $input |
|
| 2119 | - * |
|
| 2120 | - * @return mixed |
|
| 2121 | - */ |
|
| 2122 | - public static function minify_js($input) { |
|
| 2123 | - if(trim($input) === "") return $input; |
|
| 2124 | - return preg_replace( |
|
| 2125 | - array( |
|
| 2126 | - // Remove comment(s) |
|
| 2127 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2128 | - // Remove white-space(s) outside the string and regex |
|
| 2129 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2130 | - // Remove the last semicolon |
|
| 2131 | - '#;+\}#', |
|
| 2132 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2133 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2134 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2135 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2136 | - ), |
|
| 2137 | - array( |
|
| 2138 | - '$1', |
|
| 2139 | - '$1$2', |
|
| 2140 | - '}', |
|
| 2141 | - '$1$3', |
|
| 2142 | - '$1.$3' |
|
| 2143 | - ), |
|
| 2144 | - $input); |
|
| 2145 | - } |
|
| 2021 | + $locale = ob_get_clean(); |
|
| 2022 | + |
|
| 2023 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2024 | + } |
|
| 2025 | + |
|
| 2026 | + /** |
|
| 2027 | + * Select2 JS params. |
|
| 2028 | + * |
|
| 2029 | + * @since 0.1.44 |
|
| 2030 | + * |
|
| 2031 | + * @return array Select2 JS params. |
|
| 2032 | + */ |
|
| 2033 | + public static function select2_params() { |
|
| 2034 | + $params = array( |
|
| 2035 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2036 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2037 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2038 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2039 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2040 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2041 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2042 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2043 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2044 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2045 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2046 | + ); |
|
| 2047 | + |
|
| 2048 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2049 | + } |
|
| 2050 | + |
|
| 2051 | + /** |
|
| 2052 | + * Select2 JS localize. |
|
| 2053 | + * |
|
| 2054 | + * @since 0.1.44 |
|
| 2055 | + * |
|
| 2056 | + * @return string Select2 JS locale. |
|
| 2057 | + */ |
|
| 2058 | + public static function select2_locale() { |
|
| 2059 | + $params = self::select2_params(); |
|
| 2060 | + |
|
| 2061 | + foreach ( (array) $params as $key => $value ) { |
|
| 2062 | + if ( ! is_scalar( $value ) ) { |
|
| 2063 | + continue; |
|
| 2064 | + } |
|
| 2146 | 2065 | |
| 2147 | - /** |
|
| 2148 | - * Minify CSS |
|
| 2149 | - * |
|
| 2150 | - * @param $input |
|
| 2151 | - * |
|
| 2152 | - * @return mixed |
|
| 2153 | - */ |
|
| 2154 | - public static function minify_css($input) { |
|
| 2155 | - if(trim($input) === "") return $input; |
|
| 2156 | - return preg_replace( |
|
| 2157 | - array( |
|
| 2158 | - // Remove comment(s) |
|
| 2159 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2160 | - // Remove unused white-space(s) |
|
| 2161 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2162 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2163 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2164 | - // Replace `:0 0 0 0` with `:0` |
|
| 2165 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2166 | - // Replace `background-position:0` with `background-position:0 0` |
|
| 2167 | - '#(background-position):0(?=[;\}])#si', |
|
| 2168 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2169 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2170 | - // Minify string value |
|
| 2171 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2172 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2173 | - // Minify HEX color code |
|
| 2174 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2175 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2176 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2177 | - // Remove empty selector(s) |
|
| 2178 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2179 | - ), |
|
| 2180 | - array( |
|
| 2181 | - '$1', |
|
| 2182 | - '$1$2$3$4$5$6$7', |
|
| 2183 | - '$1', |
|
| 2184 | - ':0', |
|
| 2185 | - '$1:0 0', |
|
| 2186 | - '.$1', |
|
| 2187 | - '$1$3', |
|
| 2188 | - '$1$2$4$5', |
|
| 2189 | - '$1$2$3', |
|
| 2190 | - '$1:0', |
|
| 2191 | - '$1$2' |
|
| 2192 | - ), |
|
| 2193 | - $input); |
|
| 2194 | - } |
|
| 2195 | - } |
|
| 2066 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2067 | + } |
|
| 2068 | + |
|
| 2069 | + $locale = json_encode( $params ); |
|
| 2070 | + |
|
| 2071 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2072 | + } |
|
| 2073 | + |
|
| 2074 | + /** |
|
| 2075 | + * Time ago JS localize. |
|
| 2076 | + * |
|
| 2077 | + * @since 0.1.47 |
|
| 2078 | + * |
|
| 2079 | + * @return string Time ago JS locale. |
|
| 2080 | + */ |
|
| 2081 | + public static function timeago_locale() { |
|
| 2082 | + $params = array( |
|
| 2083 | + 'prefix_ago' => '', |
|
| 2084 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2085 | + 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2086 | + 'suffix_after' => '', |
|
| 2087 | + 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2088 | + 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2089 | + 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2090 | + 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2091 | + 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2092 | + 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2093 | + 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2094 | + 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2095 | + 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2096 | + 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2097 | + 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2098 | + ); |
|
| 2099 | + |
|
| 2100 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2101 | + |
|
| 2102 | + foreach ( (array) $params as $key => $value ) { |
|
| 2103 | + if ( ! is_scalar( $value ) ) { |
|
| 2104 | + continue; |
|
| 2105 | + } |
|
| 2196 | 2106 | |
| 2197 | - /** |
|
| 2198 | - * Run the class if found. |
|
| 2199 | - */ |
|
| 2200 | - AyeCode_UI_Settings::instance(); |
|
| 2107 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2108 | + } |
|
| 2109 | + |
|
| 2110 | + $locale = json_encode( $params ); |
|
| 2111 | + |
|
| 2112 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2113 | + } |
|
| 2114 | + |
|
| 2115 | + /** |
|
| 2116 | + * JavaScript Minifier |
|
| 2117 | + * |
|
| 2118 | + * @param $input |
|
| 2119 | + * |
|
| 2120 | + * @return mixed |
|
| 2121 | + */ |
|
| 2122 | + public static function minify_js($input) { |
|
| 2123 | + if(trim($input) === "") return $input; |
|
| 2124 | + return preg_replace( |
|
| 2125 | + array( |
|
| 2126 | + // Remove comment(s) |
|
| 2127 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2128 | + // Remove white-space(s) outside the string and regex |
|
| 2129 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2130 | + // Remove the last semicolon |
|
| 2131 | + '#;+\}#', |
|
| 2132 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2133 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2134 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2135 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2136 | + ), |
|
| 2137 | + array( |
|
| 2138 | + '$1', |
|
| 2139 | + '$1$2', |
|
| 2140 | + '}', |
|
| 2141 | + '$1$3', |
|
| 2142 | + '$1.$3' |
|
| 2143 | + ), |
|
| 2144 | + $input); |
|
| 2145 | + } |
|
| 2146 | + |
|
| 2147 | + /** |
|
| 2148 | + * Minify CSS |
|
| 2149 | + * |
|
| 2150 | + * @param $input |
|
| 2151 | + * |
|
| 2152 | + * @return mixed |
|
| 2153 | + */ |
|
| 2154 | + public static function minify_css($input) { |
|
| 2155 | + if(trim($input) === "") return $input; |
|
| 2156 | + return preg_replace( |
|
| 2157 | + array( |
|
| 2158 | + // Remove comment(s) |
|
| 2159 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2160 | + // Remove unused white-space(s) |
|
| 2161 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2162 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2163 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2164 | + // Replace `:0 0 0 0` with `:0` |
|
| 2165 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2166 | + // Replace `background-position:0` with `background-position:0 0` |
|
| 2167 | + '#(background-position):0(?=[;\}])#si', |
|
| 2168 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2169 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2170 | + // Minify string value |
|
| 2171 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2172 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2173 | + // Minify HEX color code |
|
| 2174 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2175 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2176 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2177 | + // Remove empty selector(s) |
|
| 2178 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2179 | + ), |
|
| 2180 | + array( |
|
| 2181 | + '$1', |
|
| 2182 | + '$1$2$3$4$5$6$7', |
|
| 2183 | + '$1', |
|
| 2184 | + ':0', |
|
| 2185 | + '$1:0 0', |
|
| 2186 | + '.$1', |
|
| 2187 | + '$1$3', |
|
| 2188 | + '$1$2$4$5', |
|
| 2189 | + '$1$2$3', |
|
| 2190 | + '$1:0', |
|
| 2191 | + '$1$2' |
|
| 2192 | + ), |
|
| 2193 | + $input); |
|
| 2194 | + } |
|
| 2195 | + } |
|
| 2196 | + |
|
| 2197 | + /** |
|
| 2198 | + * Run the class if found. |
|
| 2199 | + */ |
|
| 2200 | + AyeCode_UI_Settings::instance(); |
|
| 2201 | 2201 | } |
| 2202 | 2202 | \ No newline at end of file |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if (!defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Only add if the class does not already exist. |
| 21 | 21 | */ |
| 22 | -if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
|
| 22 | +if (!class_exists('AyeCode_UI_Settings')) { |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -98,23 +98,23 @@ discard block |
||
| 98 | 98 | * @return AyeCode_UI_Settings - Main instance. |
| 99 | 99 | */ |
| 100 | 100 | public static function instance() { |
| 101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 101 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
| 102 | 102 | |
| 103 | 103 | self::$instance = new AyeCode_UI_Settings; |
| 104 | 104 | |
| 105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 105 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
| 106 | 106 | |
| 107 | - if ( is_admin() ) { |
|
| 108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 107 | + if (is_admin()) { |
|
| 108 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
| 109 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
| 110 | 110 | |
| 111 | 111 | // Maybe show example page |
| 112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 112 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 115 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
| 116 | 116 | |
| 117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 117 | + do_action('ayecode_ui_settings_loaded'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return self::$instance; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | /** |
| 124 | 124 | * Setup some constants. |
| 125 | 125 | */ |
| 126 | - public function constants(){ |
|
| 126 | + public function constants() { |
|
| 127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
| 128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
| 129 | 129 | if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
@@ -143,25 +143,25 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * We load super early in case there is a theme version that might change the colors |
| 145 | 145 | */ |
| 146 | - if ( $this->settings['css'] ) { |
|
| 147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 146 | + if ($this->settings['css']) { |
|
| 147 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
| 148 | 148 | } |
| 149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 149 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
| 150 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // maybe load JS |
| 154 | - if ( $this->settings['js'] ) { |
|
| 154 | + if ($this->settings['js']) { |
|
| 155 | 155 | $priority = $this->is_bs3_compat() ? 100 : 1; |
| 156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 156 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority); |
|
| 157 | 157 | } |
| 158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 158 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
| 159 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // Maybe set the HTML font size |
| 163 | - if ( $this->settings['html_font_size'] ) { |
|
| 164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 163 | + if ($this->settings['html_font_size']) { |
|
| 164 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
@@ -172,14 +172,14 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return bool |
| 174 | 174 | */ |
| 175 | - public function load_admin_scripts(){ |
|
| 175 | + public function load_admin_scripts() { |
|
| 176 | 176 | $result = true; |
| 177 | 177 | |
| 178 | 178 | // check if specifically disabled |
| 179 | - if(!empty($this->settings['disable_admin'])){ |
|
| 180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 181 | - foreach($url_parts as $part){ |
|
| 182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 179 | + if (!empty($this->settings['disable_admin'])) { |
|
| 180 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
| 181 | + foreach ($url_parts as $part) { |
|
| 182 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
| 183 | 183 | return false; // return early, no point checking further |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | /** |
| 192 | 192 | * Add a html font size to the footer. |
| 193 | 193 | */ |
| 194 | - public function html_font_size(){ |
|
| 194 | + public function html_font_size() { |
|
| 195 | 195 | $this->settings = $this->get_settings(); |
| 196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 196 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @return bool |
| 203 | 203 | */ |
| 204 | - public function is_aui_screen(){ |
|
| 204 | + public function is_aui_screen() { |
|
| 205 | 205 | $load = false; |
| 206 | 206 | // check if we should load or not |
| 207 | - if ( is_admin() ) { |
|
| 207 | + if (is_admin()) { |
|
| 208 | 208 | // Only enable on set pages |
| 209 | 209 | $aui_screens = array( |
| 210 | 210 | 'page', |
@@ -212,13 +212,13 @@ discard block |
||
| 212 | 212 | 'settings_page_ayecode-ui-settings', |
| 213 | 213 | 'appearance_page_gutenberg-widgets' |
| 214 | 214 | ); |
| 215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 215 | + $screen_ids = apply_filters('aui_screen_ids', $aui_screens); |
|
| 216 | 216 | |
| 217 | 217 | $screen = get_current_screen(); |
| 218 | 218 | |
| 219 | 219 | // echo '###'.$screen->id; |
| 220 | 220 | |
| 221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 221 | + if ($screen && in_array($screen->id, $screen_ids)) { |
|
| 222 | 222 | $load = true; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -231,25 +231,25 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function enqueue_style() { |
| 233 | 233 | |
| 234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 234 | + if (is_admin() && !$this->is_aui_screen()) { |
|
| 235 | 235 | // don't add wp-admin scripts if not requested to |
| 236 | - }else{ |
|
| 236 | + } else { |
|
| 237 | 237 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
| 238 | 238 | |
| 239 | 239 | $rtl = is_rtl() ? '-rtl' : ''; |
| 240 | 240 | |
| 241 | - if($this->settings[$css_setting]){ |
|
| 242 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 243 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 244 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
| 245 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 241 | + if ($this->settings[$css_setting]) { |
|
| 242 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
| 243 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css'; |
|
| 244 | + wp_register_style('ayecode-ui', $url, array(), $this->latest); |
|
| 245 | + wp_enqueue_style('ayecode-ui'); |
|
| 246 | 246 | |
| 247 | 247 | // flatpickr |
| 248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
| 248 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest); |
|
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | // fix some wp-admin issues |
| 252 | - if(is_admin()){ |
|
| 252 | + if (is_admin()) { |
|
| 253 | 253 | $custom_css = " |
| 254 | 254 | body{ |
| 255 | 255 | background-color: #f1f1f1; |
@@ -298,11 +298,11 @@ discard block |
||
| 298 | 298 | padding: 0; |
| 299 | 299 | } |
| 300 | 300 | "; |
| 301 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 301 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // custom changes |
| 305 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 305 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
| 306 | 306 | |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | function aui_init_flatpickr(){ |
| 563 | 563 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
| 564 | 564 | $aui_doing_init_flatpickr = true; |
| 565 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
| 565 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
| 566 | 566 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
| 567 | 567 | } |
| 568 | 568 | $aui_doing_init_flatpickr = false; |
@@ -1016,10 +1016,10 @@ discard block |
||
| 1016 | 1016 | /* |
| 1017 | 1017 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1018 | 1018 | */ |
| 1019 | - return str_replace( array( |
|
| 1019 | + return str_replace(array( |
|
| 1020 | 1020 | '<script>', |
| 1021 | 1021 | '</script>' |
| 1022 | - ), '', self::minify_js($output) ); |
|
| 1022 | + ), '', self::minify_js($output)); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | |
@@ -1033,13 +1033,13 @@ discard block |
||
| 1033 | 1033 | ob_start(); |
| 1034 | 1034 | ?> |
| 1035 | 1035 | <script> |
| 1036 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
| 1036 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
| 1037 | 1037 | /* With Avada builder */ |
| 1038 | 1038 | |
| 1039 | 1039 | <?php } ?> |
| 1040 | 1040 | </script> |
| 1041 | 1041 | <?php |
| 1042 | - return str_replace( array( |
|
| 1042 | + return str_replace(array( |
|
| 1043 | 1043 | '<script>', |
| 1044 | 1044 | '</script>' |
| 1045 | 1045 | ), '', ob_get_clean()); |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | * |
| 1051 | 1051 | * If this remains small then its best to use this than to add another JS file. |
| 1052 | 1052 | */ |
| 1053 | - public function inline_script_file_browser(){ |
|
| 1053 | + public function inline_script_file_browser() { |
|
| 1054 | 1054 | ob_start(); |
| 1055 | 1055 | ?> |
| 1056 | 1056 | <script> |
@@ -1065,10 +1065,10 @@ discard block |
||
| 1065 | 1065 | /* |
| 1066 | 1066 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1067 | 1067 | */ |
| 1068 | - return str_replace( array( |
|
| 1068 | + return str_replace(array( |
|
| 1069 | 1069 | '<script>', |
| 1070 | 1070 | '</script>' |
| 1071 | - ), '', $output ); |
|
| 1071 | + ), '', $output); |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | /** |
@@ -1076,50 +1076,50 @@ discard block |
||
| 1076 | 1076 | */ |
| 1077 | 1077 | public function enqueue_scripts() { |
| 1078 | 1078 | |
| 1079 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 1079 | + if (is_admin() && !$this->is_aui_screen()) { |
|
| 1080 | 1080 | // don't add wp-admin scripts if not requested to |
| 1081 | - }else { |
|
| 1081 | + } else { |
|
| 1082 | 1082 | |
| 1083 | 1083 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
| 1084 | 1084 | |
| 1085 | 1085 | // select2 |
| 1086 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1086 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
| 1087 | 1087 | |
| 1088 | 1088 | // flatpickr |
| 1089 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
| 1089 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest); |
|
| 1090 | 1090 | |
| 1091 | 1091 | // Bootstrap file browser |
| 1092 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1093 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1092 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
| 1093 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
| 1094 | 1094 | |
| 1095 | 1095 | $load_inline = false; |
| 1096 | 1096 | |
| 1097 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1097 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
| 1098 | 1098 | // Bootstrap bundle |
| 1099 | 1099 | $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
| 1100 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1100 | + wp_register_script('bootstrap-js-bundle', $url, array( |
|
| 1101 | 1101 | 'select2', |
| 1102 | 1102 | 'jquery' |
| 1103 | - ), $this->latest, $this->is_bs3_compat() ); |
|
| 1103 | + ), $this->latest, $this->is_bs3_compat()); |
|
| 1104 | 1104 | // if in admin then add to footer for compatibility. |
| 1105 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1105 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
| 1106 | 1106 | $script = $this->inline_script(); |
| 1107 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1108 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1107 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
| 1108 | + } elseif ($this->settings[$js_setting] == 'popper') { |
|
| 1109 | 1109 | $url = $this->url . 'assets/js/popper.min.js'; |
| 1110 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
| 1111 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1110 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->latest); |
|
| 1111 | + wp_enqueue_script('bootstrap-js-popper'); |
|
| 1112 | 1112 | $load_inline = true; |
| 1113 | 1113 | } else { |
| 1114 | 1114 | $load_inline = true; |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
| 1118 | - if ( $load_inline ) { |
|
| 1119 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1120 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1118 | + if ($load_inline) { |
|
| 1119 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
| 1120 | + wp_enqueue_script('bootstrap-dummy'); |
|
| 1121 | 1121 | $script = $this->inline_script(); |
| 1122 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1122 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
| 1123 | 1123 | } |
| 1124 | 1124 | } |
| 1125 | 1125 | |
@@ -1128,9 +1128,9 @@ discard block |
||
| 1128 | 1128 | /** |
| 1129 | 1129 | * Enqueue flatpickr if called. |
| 1130 | 1130 | */ |
| 1131 | - public function enqueue_flatpickr(){ |
|
| 1132 | - wp_enqueue_style( 'flatpickr' ); |
|
| 1133 | - wp_enqueue_script( 'flatpickr' ); |
|
| 1131 | + public function enqueue_flatpickr() { |
|
| 1132 | + wp_enqueue_style('flatpickr'); |
|
| 1133 | + wp_enqueue_script('flatpickr'); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | /** |
@@ -1142,15 +1142,15 @@ discard block |
||
| 1142 | 1142 | |
| 1143 | 1143 | $url = ''; |
| 1144 | 1144 | // check if we are inside a plugin |
| 1145 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1145 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
| 1146 | 1146 | |
| 1147 | 1147 | // add check in-case user has changed wp-content dir name. |
| 1148 | 1148 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
| 1149 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1150 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1149 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
| 1150 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
| 1151 | 1151 | |
| 1152 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1153 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1152 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
| 1153 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | return $url; |
@@ -1160,7 +1160,7 @@ discard block |
||
| 1160 | 1160 | * Register the database settings with WordPress. |
| 1161 | 1161 | */ |
| 1162 | 1162 | public function register_settings() { |
| 1163 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1163 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | /** |
@@ -1169,10 +1169,10 @@ discard block |
||
| 1169 | 1169 | */ |
| 1170 | 1170 | public function menu_item() { |
| 1171 | 1171 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
| 1172 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1172 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1173 | 1173 | $this, |
| 1174 | 1174 | 'settings_page' |
| 1175 | - ) ); |
|
| 1175 | + )); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | /** |
@@ -1180,7 +1180,7 @@ discard block |
||
| 1180 | 1180 | * |
| 1181 | 1181 | * @return array |
| 1182 | 1182 | */ |
| 1183 | - public function theme_js_settings(){ |
|
| 1183 | + public function theme_js_settings() { |
|
| 1184 | 1184 | return array( |
| 1185 | 1185 | 'ayetheme' => 'popper', |
| 1186 | 1186 | 'listimia' => 'required', |
@@ -1196,17 +1196,17 @@ discard block |
||
| 1196 | 1196 | */ |
| 1197 | 1197 | public function get_settings() { |
| 1198 | 1198 | |
| 1199 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1199 | + $db_settings = get_option('ayecode-ui-settings'); |
|
| 1200 | 1200 | $js_default = 'core-popper'; |
| 1201 | 1201 | $js_default_backend = $js_default; |
| 1202 | 1202 | |
| 1203 | 1203 | // maybe set defaults (if no settings set) |
| 1204 | - if(empty($db_settings)){ |
|
| 1205 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1204 | + if (empty($db_settings)) { |
|
| 1205 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
| 1206 | 1206 | $theme_js_settings = self::theme_js_settings(); |
| 1207 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 1207 | + if (isset($theme_js_settings[$active_theme])) { |
|
| 1208 | 1208 | $js_default = $theme_js_settings[$active_theme]; |
| 1209 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1209 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
| 1210 | 1210 | } |
| 1211 | 1211 | } |
| 1212 | 1212 | |
@@ -1219,14 +1219,14 @@ discard block |
||
| 1219 | 1219 | 'disable_admin' => '', // URL snippets to disable loading on admin |
| 1220 | 1220 | ); |
| 1221 | 1221 | |
| 1222 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1222 | + $settings = wp_parse_args($db_settings, $defaults); |
|
| 1223 | 1223 | |
| 1224 | 1224 | /** |
| 1225 | 1225 | * Filter the Bootstrap settings. |
| 1226 | 1226 | * |
| 1227 | 1227 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
| 1228 | 1228 | */ |
| 1229 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1229 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | 1232 | |
@@ -1234,90 +1234,90 @@ discard block |
||
| 1234 | 1234 | * The settings page html output. |
| 1235 | 1235 | */ |
| 1236 | 1236 | public function settings_page() { |
| 1237 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1238 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1237 | + if (!current_user_can('manage_options')) { |
|
| 1238 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
| 1239 | 1239 | } |
| 1240 | 1240 | ?> |
| 1241 | 1241 | <div class="wrap"> |
| 1242 | 1242 | <h1><?php echo $this->name; ?></h1> |
| 1243 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
|
| 1243 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", 'aui'); ?></p> |
|
| 1244 | 1244 | <form method="post" action="options.php"> |
| 1245 | 1245 | <?php |
| 1246 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 1247 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1246 | + settings_fields('ayecode-ui-settings'); |
|
| 1247 | + do_settings_sections('ayecode-ui-settings'); |
|
| 1248 | 1248 | ?> |
| 1249 | 1249 | |
| 1250 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
| 1250 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
| 1251 | 1251 | <table class="form-table wpbs-table-settings"> |
| 1252 | 1252 | <tr valign="top"> |
| 1253 | 1253 | <th scope="row"><label |
| 1254 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 1254 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 1255 | 1255 | <td> |
| 1256 | 1256 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
| 1257 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
| 1258 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
| 1259 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 1257 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
| 1258 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
| 1259 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 1260 | 1260 | </select> |
| 1261 | 1261 | </td> |
| 1262 | 1262 | </tr> |
| 1263 | 1263 | |
| 1264 | 1264 | <tr valign="top"> |
| 1265 | 1265 | <th scope="row"><label |
| 1266 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 1266 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 1267 | 1267 | <td> |
| 1268 | 1268 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
| 1269 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 1270 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 1271 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 1272 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 1269 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 1270 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 1271 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 1272 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 1273 | 1273 | </select> |
| 1274 | 1274 | </td> |
| 1275 | 1275 | </tr> |
| 1276 | 1276 | |
| 1277 | 1277 | <tr valign="top"> |
| 1278 | 1278 | <th scope="row"><label |
| 1279 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
| 1279 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
| 1280 | 1280 | <td> |
| 1281 | - <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
|
| 1282 | - <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p> |
|
| 1281 | + <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" /> |
|
| 1282 | + <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'aui'); ?></p> |
|
| 1283 | 1283 | </td> |
| 1284 | 1284 | </tr> |
| 1285 | 1285 | |
| 1286 | 1286 | </table> |
| 1287 | 1287 | |
| 1288 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
| 1288 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
| 1289 | 1289 | <table class="form-table wpbs-table-settings"> |
| 1290 | 1290 | <tr valign="top"> |
| 1291 | 1291 | <th scope="row"><label |
| 1292 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 1292 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 1293 | 1293 | <td> |
| 1294 | 1294 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
| 1295 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
| 1296 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
|
| 1297 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 1295 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
| 1296 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option> |
|
| 1297 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 1298 | 1298 | </select> |
| 1299 | 1299 | </td> |
| 1300 | 1300 | </tr> |
| 1301 | 1301 | |
| 1302 | 1302 | <tr valign="top"> |
| 1303 | 1303 | <th scope="row"><label |
| 1304 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 1304 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 1305 | 1305 | <td> |
| 1306 | 1306 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
| 1307 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 1308 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 1309 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 1310 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 1307 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 1308 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 1309 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 1310 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 1311 | 1311 | </select> |
| 1312 | 1312 | </td> |
| 1313 | 1313 | </tr> |
| 1314 | 1314 | |
| 1315 | 1315 | <tr valign="top"> |
| 1316 | 1316 | <th scope="row"><label |
| 1317 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
| 1317 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
| 1318 | 1318 | <td> |
| 1319 | - <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
|
| 1320 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
| 1319 | + <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p> |
|
| 1320 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
| 1321 | 1321 | |
| 1322 | 1322 | </td> |
| 1323 | 1323 | </tr> |
@@ -1335,9 +1335,9 @@ discard block |
||
| 1335 | 1335 | <?php |
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | - public function customizer_settings($wp_customize){ |
|
| 1338 | + public function customizer_settings($wp_customize) { |
|
| 1339 | 1339 | $wp_customize->add_section('aui_settings', array( |
| 1340 | - 'title' => __('AyeCode UI','aui'), |
|
| 1340 | + 'title' => __('AyeCode UI', 'aui'), |
|
| 1341 | 1341 | 'priority' => 120, |
| 1342 | 1342 | )); |
| 1343 | 1343 | |
@@ -1351,8 +1351,8 @@ discard block |
||
| 1351 | 1351 | 'type' => 'option', |
| 1352 | 1352 | 'transport' => 'refresh', |
| 1353 | 1353 | )); |
| 1354 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1355 | - 'label' => __('Primary Color','aui'), |
|
| 1354 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1355 | + 'label' => __('Primary Color', 'aui'), |
|
| 1356 | 1356 | 'section' => 'aui_settings', |
| 1357 | 1357 | 'settings' => 'aui_options[color_primary]', |
| 1358 | 1358 | ))); |
@@ -1364,8 +1364,8 @@ discard block |
||
| 1364 | 1364 | 'type' => 'option', |
| 1365 | 1365 | 'transport' => 'refresh', |
| 1366 | 1366 | )); |
| 1367 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1368 | - 'label' => __('Secondary Color','aui'), |
|
| 1367 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1368 | + 'label' => __('Secondary Color', 'aui'), |
|
| 1369 | 1369 | 'section' => 'aui_settings', |
| 1370 | 1370 | 'settings' => 'aui_options[color_secondary]', |
| 1371 | 1371 | ))); |
@@ -1391,12 +1391,12 @@ discard block |
||
| 1391 | 1391 | .collapse.show:not(.in){display: inherit;} |
| 1392 | 1392 | .fade.show{opacity: 1;} |
| 1393 | 1393 | |
| 1394 | - <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?> |
|
| 1394 | + <?php if (defined('SVQ_THEME_VERSION')) { ?> |
|
| 1395 | 1395 | /* KLEO theme specific */ |
| 1396 | 1396 | .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;} |
| 1397 | 1397 | <?php } ?> |
| 1398 | 1398 | |
| 1399 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
| 1399 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
| 1400 | 1400 | /* With Avada builder */ |
| 1401 | 1401 | body.modal-open .modal.in {opacity:1;z-index: 99999} |
| 1402 | 1402 | body.modal-open .modal.bsui.in .modal-content {box-shadow: none;} |
@@ -1404,10 +1404,10 @@ discard block |
||
| 1404 | 1404 | <?php } ?> |
| 1405 | 1405 | </style> |
| 1406 | 1406 | <?php |
| 1407 | - return str_replace( array( |
|
| 1407 | + return str_replace(array( |
|
| 1408 | 1408 | '<style>', |
| 1409 | 1409 | '</style>' |
| 1410 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1410 | + ), '', self::minify_css(ob_get_clean())); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | |
@@ -1424,16 +1424,16 @@ discard block |
||
| 1424 | 1424 | <?php |
| 1425 | 1425 | |
| 1426 | 1426 | // BS v3 compat |
| 1427 | - if( self::is_bs3_compat() ){ |
|
| 1427 | + if (self::is_bs3_compat()) { |
|
| 1428 | 1428 | echo self::bs3_compat_css(); |
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
| 1432 | - echo self::css_primary($primary_color,$compatibility); |
|
| 1431 | + if (!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL) { |
|
| 1432 | + echo self::css_primary($primary_color, $compatibility); |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
| 1436 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 1435 | + if (!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL) { |
|
| 1436 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | // Set admin bar z-index lower when modal is open. |
@@ -1446,10 +1446,10 @@ discard block |
||
| 1446 | 1446 | /* |
| 1447 | 1447 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1448 | 1448 | */ |
| 1449 | - return str_replace( array( |
|
| 1449 | + return str_replace(array( |
|
| 1450 | 1450 | '<style>', |
| 1451 | 1451 | '</style>' |
| 1452 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1452 | + ), '', self::minify_css(ob_get_clean())); |
|
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | 1455 | /** |
@@ -1457,48 +1457,48 @@ discard block |
||
| 1457 | 1457 | * |
| 1458 | 1458 | * @return bool |
| 1459 | 1459 | */ |
| 1460 | - public static function is_bs3_compat(){ |
|
| 1460 | + public static function is_bs3_compat() { |
|
| 1461 | 1461 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | - public static function css_primary($color_code,$compatibility){; |
|
| 1464 | + public static function css_primary($color_code, $compatibility) {; |
|
| 1465 | 1465 | $color_code = sanitize_hex_color($color_code); |
| 1466 | - if(!$color_code){return '';} |
|
| 1466 | + if (!$color_code) {return ''; } |
|
| 1467 | 1467 | /** |
| 1468 | 1468 | * c = color, b = background color, o = border-color, f = fill |
| 1469 | 1469 | */ |
| 1470 | 1470 | $selectors = array( |
| 1471 | 1471 | 'a' => array('c'), |
| 1472 | - '.btn-primary' => array('b','o'), |
|
| 1473 | - '.btn-primary.disabled' => array('b','o'), |
|
| 1474 | - '.btn-primary:disabled' => array('b','o'), |
|
| 1475 | - '.btn-outline-primary' => array('c','o'), |
|
| 1476 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 1477 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1478 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1479 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1472 | + '.btn-primary' => array('b', 'o'), |
|
| 1473 | + '.btn-primary.disabled' => array('b', 'o'), |
|
| 1474 | + '.btn-primary:disabled' => array('b', 'o'), |
|
| 1475 | + '.btn-outline-primary' => array('c', 'o'), |
|
| 1476 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
| 1477 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 1478 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 1479 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
| 1480 | 1480 | '.btn-link' => array('c'), |
| 1481 | 1481 | '.dropdown-item.active' => array('b'), |
| 1482 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1483 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1482 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
| 1483 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
| 1484 | 1484 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1485 | 1485 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1486 | 1486 | // '.custom-range::-ms-thumb' => array('b'), |
| 1487 | 1487 | '.nav-pills .nav-link.active' => array('b'), |
| 1488 | 1488 | '.nav-pills .show>.nav-link' => array('b'), |
| 1489 | 1489 | '.page-link' => array('c'), |
| 1490 | - '.page-item.active .page-link' => array('b','o'), |
|
| 1490 | + '.page-item.active .page-link' => array('b', 'o'), |
|
| 1491 | 1491 | '.badge-primary' => array('b'), |
| 1492 | - '.alert-primary' => array('b','o'), |
|
| 1492 | + '.alert-primary' => array('b', 'o'), |
|
| 1493 | 1493 | '.progress-bar' => array('b'), |
| 1494 | - '.list-group-item.active' => array('b','o'), |
|
| 1495 | - '.bg-primary' => array('b','f'), |
|
| 1494 | + '.list-group-item.active' => array('b', 'o'), |
|
| 1495 | + '.bg-primary' => array('b', 'f'), |
|
| 1496 | 1496 | '.btn-link.btn-primary' => array('c'), |
| 1497 | 1497 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
| 1498 | 1498 | ); |
| 1499 | 1499 | |
| 1500 | 1500 | $important_selectors = array( |
| 1501 | - '.bg-primary' => array('b','f'), |
|
| 1501 | + '.bg-primary' => array('b', 'f'), |
|
| 1502 | 1502 | '.border-primary' => array('o'), |
| 1503 | 1503 | '.text-primary' => array('c'), |
| 1504 | 1504 | ); |
@@ -1515,116 +1515,116 @@ discard block |
||
| 1515 | 1515 | $output = ''; |
| 1516 | 1516 | |
| 1517 | 1517 | // build rules into each type |
| 1518 | - foreach($selectors as $selector => $types){ |
|
| 1519 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1520 | - $types = array_combine($types,$types); |
|
| 1521 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1522 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1523 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1524 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1518 | + foreach ($selectors as $selector => $types) { |
|
| 1519 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1520 | + $types = array_combine($types, $types); |
|
| 1521 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 1522 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 1523 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 1524 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | // build rules into each type |
| 1528 | - foreach($important_selectors as $selector => $types){ |
|
| 1529 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1530 | - $types = array_combine($types,$types); |
|
| 1531 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1532 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1533 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1534 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1528 | + foreach ($important_selectors as $selector => $types) { |
|
| 1529 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1530 | + $types = array_combine($types, $types); |
|
| 1531 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 1532 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 1533 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 1534 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 1535 | 1535 | } |
| 1536 | 1536 | |
| 1537 | 1537 | // add any color rules |
| 1538 | - if(!empty($color)){ |
|
| 1539 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1538 | + if (!empty($color)) { |
|
| 1539 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 1540 | 1540 | } |
| 1541 | - if(!empty($color_i)){ |
|
| 1542 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1541 | + if (!empty($color_i)) { |
|
| 1542 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | 1545 | // add any background color rules |
| 1546 | - if(!empty($background)){ |
|
| 1547 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1546 | + if (!empty($background)) { |
|
| 1547 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 1548 | 1548 | } |
| 1549 | - if(!empty($background_i)){ |
|
| 1550 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1549 | + if (!empty($background_i)) { |
|
| 1550 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 1551 | 1551 | } |
| 1552 | 1552 | |
| 1553 | 1553 | // add any border color rules |
| 1554 | - if(!empty($border)){ |
|
| 1555 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1554 | + if (!empty($border)) { |
|
| 1555 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 1556 | 1556 | } |
| 1557 | - if(!empty($border_i)){ |
|
| 1558 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1557 | + if (!empty($border_i)) { |
|
| 1558 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | // add any fill color rules |
| 1562 | - if(!empty($fill)){ |
|
| 1563 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1562 | + if (!empty($fill)) { |
|
| 1563 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 1564 | 1564 | } |
| 1565 | - if(!empty($fill_i)){ |
|
| 1566 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1565 | + if (!empty($fill_i)) { |
|
| 1566 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | 1569 | |
| 1570 | 1570 | $prefix = $compatibility ? ".bsui " : ""; |
| 1571 | 1571 | |
| 1572 | 1572 | // darken |
| 1573 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1574 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1575 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1573 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 1574 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 1575 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 1576 | 1576 | |
| 1577 | 1577 | // lighten |
| 1578 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1578 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 1579 | 1579 | |
| 1580 | 1580 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 1581 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1581 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 1582 | 1582 | |
| 1583 | 1583 | |
| 1584 | 1584 | // button states |
| 1585 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1586 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1587 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1588 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1585 | + $output .= $prefix . " .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 1586 | + $output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1587 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
| 1588 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1589 | 1589 | |
| 1590 | 1590 | |
| 1591 | 1591 | // dropdown's |
| 1592 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1592 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1593 | 1593 | |
| 1594 | 1594 | |
| 1595 | 1595 | // input states |
| 1596 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1596 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1597 | 1597 | |
| 1598 | 1598 | // page link |
| 1599 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1599 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1600 | 1600 | |
| 1601 | 1601 | return $output; |
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | - public static function css_secondary($color_code,$compatibility){; |
|
| 1604 | + public static function css_secondary($color_code, $compatibility) {; |
|
| 1605 | 1605 | $color_code = sanitize_hex_color($color_code); |
| 1606 | - if(!$color_code){return '';} |
|
| 1606 | + if (!$color_code) {return ''; } |
|
| 1607 | 1607 | /** |
| 1608 | 1608 | * c = color, b = background color, o = border-color, f = fill |
| 1609 | 1609 | */ |
| 1610 | 1610 | $selectors = array( |
| 1611 | - '.btn-secondary' => array('b','o'), |
|
| 1612 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 1613 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 1614 | - '.btn-outline-secondary' => array('c','o'), |
|
| 1615 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1611 | + '.btn-secondary' => array('b', 'o'), |
|
| 1612 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
| 1613 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
| 1614 | + '.btn-outline-secondary' => array('c', 'o'), |
|
| 1615 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
| 1616 | 1616 | '.btn-outline-secondary.disabled' => array('c'), |
| 1617 | 1617 | '.btn-outline-secondary:disabled' => array('c'), |
| 1618 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1619 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1620 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1618 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 1619 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 1620 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
| 1621 | 1621 | '.badge-secondary' => array('b'), |
| 1622 | - '.alert-secondary' => array('b','o'), |
|
| 1622 | + '.alert-secondary' => array('b', 'o'), |
|
| 1623 | 1623 | '.btn-link.btn-secondary' => array('c'), |
| 1624 | 1624 | ); |
| 1625 | 1625 | |
| 1626 | 1626 | $important_selectors = array( |
| 1627 | - '.bg-secondary' => array('b','f'), |
|
| 1627 | + '.bg-secondary' => array('b', 'f'), |
|
| 1628 | 1628 | '.border-secondary' => array('o'), |
| 1629 | 1629 | '.text-secondary' => array('c'), |
| 1630 | 1630 | ); |
@@ -1641,77 +1641,77 @@ discard block |
||
| 1641 | 1641 | $output = ''; |
| 1642 | 1642 | |
| 1643 | 1643 | // build rules into each type |
| 1644 | - foreach($selectors as $selector => $types){ |
|
| 1645 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1646 | - $types = array_combine($types,$types); |
|
| 1647 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1648 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1649 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1650 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1644 | + foreach ($selectors as $selector => $types) { |
|
| 1645 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1646 | + $types = array_combine($types, $types); |
|
| 1647 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 1648 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 1649 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 1650 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | 1653 | // build rules into each type |
| 1654 | - foreach($important_selectors as $selector => $types){ |
|
| 1655 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1656 | - $types = array_combine($types,$types); |
|
| 1657 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1658 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1659 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1660 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1654 | + foreach ($important_selectors as $selector => $types) { |
|
| 1655 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1656 | + $types = array_combine($types, $types); |
|
| 1657 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 1658 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 1659 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 1660 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | // add any color rules |
| 1664 | - if(!empty($color)){ |
|
| 1665 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1664 | + if (!empty($color)) { |
|
| 1665 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 1666 | 1666 | } |
| 1667 | - if(!empty($color_i)){ |
|
| 1668 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1667 | + if (!empty($color_i)) { |
|
| 1668 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | // add any background color rules |
| 1672 | - if(!empty($background)){ |
|
| 1673 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1672 | + if (!empty($background)) { |
|
| 1673 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 1674 | 1674 | } |
| 1675 | - if(!empty($background_i)){ |
|
| 1676 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1675 | + if (!empty($background_i)) { |
|
| 1676 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | 1679 | // add any border color rules |
| 1680 | - if(!empty($border)){ |
|
| 1681 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1680 | + if (!empty($border)) { |
|
| 1681 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 1682 | 1682 | } |
| 1683 | - if(!empty($border_i)){ |
|
| 1684 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1683 | + if (!empty($border_i)) { |
|
| 1684 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 1685 | 1685 | } |
| 1686 | 1686 | |
| 1687 | 1687 | // add any fill color rules |
| 1688 | - if(!empty($fill)){ |
|
| 1689 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1688 | + if (!empty($fill)) { |
|
| 1689 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 1690 | 1690 | } |
| 1691 | - if(!empty($fill_i)){ |
|
| 1692 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1691 | + if (!empty($fill_i)) { |
|
| 1692 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | 1695 | |
| 1696 | 1696 | $prefix = $compatibility ? ".bsui " : ""; |
| 1697 | 1697 | |
| 1698 | 1698 | // darken |
| 1699 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1700 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1701 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1699 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 1700 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 1701 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 1702 | 1702 | |
| 1703 | 1703 | // lighten |
| 1704 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1704 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 1705 | 1705 | |
| 1706 | 1706 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 1707 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1707 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 1708 | 1708 | |
| 1709 | 1709 | |
| 1710 | 1710 | // button states |
| 1711 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1712 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1713 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 1714 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1711 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 1712 | + $output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1713 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
| 1714 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1715 | 1715 | |
| 1716 | 1716 | |
| 1717 | 1717 | return $output; |
@@ -1747,8 +1747,8 @@ discard block |
||
| 1747 | 1747 | /** |
| 1748 | 1748 | * Check if we should display examples. |
| 1749 | 1749 | */ |
| 1750 | - public function maybe_show_examples(){ |
|
| 1751 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 1750 | + public function maybe_show_examples() { |
|
| 1751 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
| 1752 | 1752 | echo "<head>"; |
| 1753 | 1753 | wp_head(); |
| 1754 | 1754 | echo "</head>"; |
@@ -1764,7 +1764,7 @@ discard block |
||
| 1764 | 1764 | * |
| 1765 | 1765 | * @return string |
| 1766 | 1766 | */ |
| 1767 | - public function get_examples(){ |
|
| 1767 | + public function get_examples() { |
|
| 1768 | 1768 | $output = ''; |
| 1769 | 1769 | |
| 1770 | 1770 | |
@@ -1870,74 +1870,74 @@ discard block |
||
| 1870 | 1870 | */ |
| 1871 | 1871 | public static function calendar_params() { |
| 1872 | 1872 | $params = array( |
| 1873 | - 'month_long_1' => __( 'January', 'aui' ), |
|
| 1874 | - 'month_long_2' => __( 'February', 'aui' ), |
|
| 1875 | - 'month_long_3' => __( 'March', 'aui' ), |
|
| 1876 | - 'month_long_4' => __( 'April', 'aui' ), |
|
| 1877 | - 'month_long_5' => __( 'May', 'aui' ), |
|
| 1878 | - 'month_long_6' => __( 'June', 'aui' ), |
|
| 1879 | - 'month_long_7' => __( 'July', 'aui' ), |
|
| 1880 | - 'month_long_8' => __( 'August', 'aui' ), |
|
| 1881 | - 'month_long_9' => __( 'September', 'aui' ), |
|
| 1882 | - 'month_long_10' => __( 'October', 'aui' ), |
|
| 1883 | - 'month_long_11' => __( 'November', 'aui' ), |
|
| 1884 | - 'month_long_12' => __( 'December', 'aui' ), |
|
| 1885 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 1886 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 1887 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 1888 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 1889 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 1890 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 1891 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 1892 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 1893 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 1894 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 1895 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 1896 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 1897 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 1898 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 1899 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 1900 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 1901 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 1902 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 1903 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 1904 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 1905 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 1906 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 1907 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
| 1908 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 1909 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 1910 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 1911 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 1912 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 1913 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 1914 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 1915 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 1916 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 1917 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 1918 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 1919 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 1920 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 1921 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 1922 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 1923 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 1924 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 1925 | - 'am_lower' => __( 'am', 'aui' ), |
|
| 1926 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
| 1927 | - 'am_upper' => __( 'AM', 'aui' ), |
|
| 1928 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
| 1929 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 1873 | + 'month_long_1' => __('January', 'aui'), |
|
| 1874 | + 'month_long_2' => __('February', 'aui'), |
|
| 1875 | + 'month_long_3' => __('March', 'aui'), |
|
| 1876 | + 'month_long_4' => __('April', 'aui'), |
|
| 1877 | + 'month_long_5' => __('May', 'aui'), |
|
| 1878 | + 'month_long_6' => __('June', 'aui'), |
|
| 1879 | + 'month_long_7' => __('July', 'aui'), |
|
| 1880 | + 'month_long_8' => __('August', 'aui'), |
|
| 1881 | + 'month_long_9' => __('September', 'aui'), |
|
| 1882 | + 'month_long_10' => __('October', 'aui'), |
|
| 1883 | + 'month_long_11' => __('November', 'aui'), |
|
| 1884 | + 'month_long_12' => __('December', 'aui'), |
|
| 1885 | + 'month_s_1' => _x('Jan', 'January abbreviation', 'aui'), |
|
| 1886 | + 'month_s_2' => _x('Feb', 'February abbreviation', 'aui'), |
|
| 1887 | + 'month_s_3' => _x('Mar', 'March abbreviation', 'aui'), |
|
| 1888 | + 'month_s_4' => _x('Apr', 'April abbreviation', 'aui'), |
|
| 1889 | + 'month_s_5' => _x('May', 'May abbreviation', 'aui'), |
|
| 1890 | + 'month_s_6' => _x('Jun', 'June abbreviation', 'aui'), |
|
| 1891 | + 'month_s_7' => _x('Jul', 'July abbreviation', 'aui'), |
|
| 1892 | + 'month_s_8' => _x('Aug', 'August abbreviation', 'aui'), |
|
| 1893 | + 'month_s_9' => _x('Sep', 'September abbreviation', 'aui'), |
|
| 1894 | + 'month_s_10' => _x('Oct', 'October abbreviation', 'aui'), |
|
| 1895 | + 'month_s_11' => _x('Nov', 'November abbreviation', 'aui'), |
|
| 1896 | + 'month_s_12' => _x('Dec', 'December abbreviation', 'aui'), |
|
| 1897 | + 'day_s1_1' => _x('S', 'Sunday initial', 'aui'), |
|
| 1898 | + 'day_s1_2' => _x('M', 'Monday initial', 'aui'), |
|
| 1899 | + 'day_s1_3' => _x('T', 'Tuesday initial', 'aui'), |
|
| 1900 | + 'day_s1_4' => _x('W', 'Wednesday initial', 'aui'), |
|
| 1901 | + 'day_s1_5' => _x('T', 'Friday initial', 'aui'), |
|
| 1902 | + 'day_s1_6' => _x('F', 'Thursday initial', 'aui'), |
|
| 1903 | + 'day_s1_7' => _x('S', 'Saturday initial', 'aui'), |
|
| 1904 | + 'day_s2_1' => __('Su', 'aui'), |
|
| 1905 | + 'day_s2_2' => __('Mo', 'aui'), |
|
| 1906 | + 'day_s2_3' => __('Tu', 'aui'), |
|
| 1907 | + 'day_s2_4' => __('We', 'aui'), |
|
| 1908 | + 'day_s2_5' => __('Th', 'aui'), |
|
| 1909 | + 'day_s2_6' => __('Fr', 'aui'), |
|
| 1910 | + 'day_s2_7' => __('Sa', 'aui'), |
|
| 1911 | + 'day_s3_1' => __('Sun', 'aui'), |
|
| 1912 | + 'day_s3_2' => __('Mon', 'aui'), |
|
| 1913 | + 'day_s3_3' => __('Tue', 'aui'), |
|
| 1914 | + 'day_s3_4' => __('Wed', 'aui'), |
|
| 1915 | + 'day_s3_5' => __('Thu', 'aui'), |
|
| 1916 | + 'day_s3_6' => __('Fri', 'aui'), |
|
| 1917 | + 'day_s3_7' => __('Sat', 'aui'), |
|
| 1918 | + 'day_s5_1' => __('Sunday', 'aui'), |
|
| 1919 | + 'day_s5_2' => __('Monday', 'aui'), |
|
| 1920 | + 'day_s5_3' => __('Tuesday', 'aui'), |
|
| 1921 | + 'day_s5_4' => __('Wednesday', 'aui'), |
|
| 1922 | + 'day_s5_5' => __('Thursday', 'aui'), |
|
| 1923 | + 'day_s5_6' => __('Friday', 'aui'), |
|
| 1924 | + 'day_s5_7' => __('Saturday', 'aui'), |
|
| 1925 | + 'am_lower' => __('am', 'aui'), |
|
| 1926 | + 'pm_lower' => __('pm', 'aui'), |
|
| 1927 | + 'am_upper' => __('AM', 'aui'), |
|
| 1928 | + 'pm_upper' => __('PM', 'aui'), |
|
| 1929 | + 'firstDayOfWeek' => (int) get_option('start_of_week'), |
|
| 1930 | 1930 | 'time_24hr' => false, |
| 1931 | - 'year' => __( 'Year', 'aui' ), |
|
| 1932 | - 'hour' => __( 'Hour', 'aui' ), |
|
| 1933 | - 'minute' => __( 'Minute', 'aui' ), |
|
| 1934 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 1935 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 1936 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 1937 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 1931 | + 'year' => __('Year', 'aui'), |
|
| 1932 | + 'hour' => __('Hour', 'aui'), |
|
| 1933 | + 'minute' => __('Minute', 'aui'), |
|
| 1934 | + 'weekAbbreviation' => __('Wk', 'aui'), |
|
| 1935 | + 'rangeSeparator' => __(' to ', 'aui'), |
|
| 1936 | + 'scrollTitle' => __('Scroll to increment', 'aui'), |
|
| 1937 | + 'toggleTitle' => __('Click to toggle', 'aui') |
|
| 1938 | 1938 | ); |
| 1939 | 1939 | |
| 1940 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 1940 | + return apply_filters('ayecode_ui_calendar_params', $params); |
|
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | 1943 | /** |
@@ -1950,47 +1950,47 @@ discard block |
||
| 1950 | 1950 | public static function flatpickr_locale() { |
| 1951 | 1951 | $params = self::calendar_params(); |
| 1952 | 1952 | |
| 1953 | - if ( is_string( $params ) ) { |
|
| 1954 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 1953 | + if (is_string($params)) { |
|
| 1954 | + $params = html_entity_decode($params, ENT_QUOTES, 'UTF-8'); |
|
| 1955 | 1955 | } else { |
| 1956 | - foreach ( (array) $params as $key => $value ) { |
|
| 1957 | - if ( ! is_scalar( $value ) ) { |
|
| 1956 | + foreach ((array) $params as $key => $value) { |
|
| 1957 | + if (!is_scalar($value)) { |
|
| 1958 | 1958 | continue; |
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 1961 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 1962 | 1962 | } |
| 1963 | 1963 | } |
| 1964 | 1964 | |
| 1965 | 1965 | $day_s3 = array(); |
| 1966 | 1966 | $day_s5 = array(); |
| 1967 | 1967 | |
| 1968 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 1969 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 1970 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 1968 | + for ($i = 1; $i <= 7; $i++) { |
|
| 1969 | + $day_s3[] = addslashes($params['day_s3_' . $i]); |
|
| 1970 | + $day_s5[] = addslashes($params['day_s3_' . $i]); |
|
| 1971 | 1971 | } |
| 1972 | 1972 | |
| 1973 | 1973 | $month_s = array(); |
| 1974 | 1974 | $month_long = array(); |
| 1975 | 1975 | |
| 1976 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 1977 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 1978 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 1976 | + for ($i = 1; $i <= 12; $i++) { |
|
| 1977 | + $month_s[] = addslashes($params['month_s_' . $i]); |
|
| 1978 | + $month_long[] = addslashes($params['month_long_' . $i]); |
|
| 1979 | 1979 | } |
| 1980 | 1980 | |
| 1981 | 1981 | ob_start(); |
| 1982 | -if ( 0 ) { ?><script><?php } ?> |
|
| 1982 | +if (0) { ?><script><?php } ?> |
|
| 1983 | 1983 | { |
| 1984 | 1984 | weekdays: { |
| 1985 | - shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'], |
|
| 1986 | - longhand: ['<?php echo implode( "','", $day_s5 ); ?>'], |
|
| 1985 | + shorthand: ['<?php echo implode("','", $day_s3); ?>'], |
|
| 1986 | + longhand: ['<?php echo implode("','", $day_s5); ?>'], |
|
| 1987 | 1987 | }, |
| 1988 | 1988 | months: { |
| 1989 | - shorthand: ['<?php echo implode( "','", $month_s ); ?>'], |
|
| 1990 | - longhand: ['<?php echo implode( "','", $month_long ); ?>'], |
|
| 1989 | + shorthand: ['<?php echo implode("','", $month_s); ?>'], |
|
| 1990 | + longhand: ['<?php echo implode("','", $month_long); ?>'], |
|
| 1991 | 1991 | }, |
| 1992 | 1992 | daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31], |
| 1993 | - firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>, |
|
| 1993 | + firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>, |
|
| 1994 | 1994 | ordinal: function (nth) { |
| 1995 | 1995 | var s = nth % 100; |
| 1996 | 1996 | if (s > 3 && s < 21) |
@@ -2006,21 +2006,21 @@ discard block |
||
| 2006 | 2006 | return "th"; |
| 2007 | 2007 | } |
| 2008 | 2008 | }, |
| 2009 | - rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>', |
|
| 2010 | - weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>', |
|
| 2011 | - scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>', |
|
| 2012 | - toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>', |
|
| 2013 | - amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'], |
|
| 2014 | - yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>', |
|
| 2015 | - hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>', |
|
| 2016 | - minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>', |
|
| 2017 | - time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?> |
|
| 2009 | + rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>', |
|
| 2010 | + weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>', |
|
| 2011 | + scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>', |
|
| 2012 | + toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>', |
|
| 2013 | + amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'], |
|
| 2014 | + yearAriaLabel: '<?php echo addslashes($params['year']); ?>', |
|
| 2015 | + hourAriaLabel: '<?php echo addslashes($params['hour']); ?>', |
|
| 2016 | + minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>', |
|
| 2017 | + time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?> |
|
| 2018 | 2018 | } |
| 2019 | -<?php if ( 0 ) { ?></script><?php } ?> |
|
| 2019 | +<?php if (0) { ?></script><?php } ?> |
|
| 2020 | 2020 | <?php |
| 2021 | 2021 | $locale = ob_get_clean(); |
| 2022 | 2022 | |
| 2023 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2023 | + return apply_filters('ayecode_ui_flatpickr_locale', trim($locale)); |
|
| 2024 | 2024 | } |
| 2025 | 2025 | |
| 2026 | 2026 | /** |
@@ -2032,20 +2032,20 @@ discard block |
||
| 2032 | 2032 | */ |
| 2033 | 2033 | public static function select2_params() { |
| 2034 | 2034 | $params = array( |
| 2035 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2036 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2037 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2038 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2039 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2040 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2041 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2042 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2043 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2044 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2045 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2035 | + 'i18n_select_state_text' => esc_attr__('Select an option…', 'aui'), |
|
| 2036 | + 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'aui'), |
|
| 2037 | + 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'aui'), |
|
| 2038 | + 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'aui'), |
|
| 2039 | + 'i18n_input_too_short_n' => _x('Please enter %item% or more characters', 'enhanced select', 'aui'), |
|
| 2040 | + 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'aui'), |
|
| 2041 | + 'i18n_input_too_long_n' => _x('Please delete %item% characters', 'enhanced select', 'aui'), |
|
| 2042 | + 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'aui'), |
|
| 2043 | + 'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'aui'), |
|
| 2044 | + 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'aui'), |
|
| 2045 | + 'i18n_searching' => _x('Searching…', 'enhanced select', 'aui') |
|
| 2046 | 2046 | ); |
| 2047 | 2047 | |
| 2048 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2048 | + return apply_filters('ayecode_ui_select2_params', $params); |
|
| 2049 | 2049 | } |
| 2050 | 2050 | |
| 2051 | 2051 | /** |
@@ -2058,17 +2058,17 @@ discard block |
||
| 2058 | 2058 | public static function select2_locale() { |
| 2059 | 2059 | $params = self::select2_params(); |
| 2060 | 2060 | |
| 2061 | - foreach ( (array) $params as $key => $value ) { |
|
| 2062 | - if ( ! is_scalar( $value ) ) { |
|
| 2061 | + foreach ((array) $params as $key => $value) { |
|
| 2062 | + if (!is_scalar($value)) { |
|
| 2063 | 2063 | continue; |
| 2064 | 2064 | } |
| 2065 | 2065 | |
| 2066 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2066 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 2067 | 2067 | } |
| 2068 | 2068 | |
| 2069 | - $locale = json_encode( $params ); |
|
| 2069 | + $locale = json_encode($params); |
|
| 2070 | 2070 | |
| 2071 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2071 | + return apply_filters('ayecode_ui_select2_locale', trim($locale)); |
|
| 2072 | 2072 | } |
| 2073 | 2073 | |
| 2074 | 2074 | /** |
@@ -2081,35 +2081,35 @@ discard block |
||
| 2081 | 2081 | public static function timeago_locale() { |
| 2082 | 2082 | $params = array( |
| 2083 | 2083 | 'prefix_ago' => '', |
| 2084 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2085 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2084 | + 'suffix_ago' => ' ' . _x('ago', 'time ago', 'aui'), |
|
| 2085 | + 'prefix_after' => _x('after', 'time ago', 'aui') . ' ', |
|
| 2086 | 2086 | 'suffix_after' => '', |
| 2087 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2088 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2089 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2090 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2091 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2092 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2093 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2094 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2095 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2096 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2097 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2087 | + 'seconds' => _x('less than a minute', 'time ago', 'aui'), |
|
| 2088 | + 'minute' => _x('about a minute', 'time ago', 'aui'), |
|
| 2089 | + 'minutes' => _x('%d minutes', 'time ago', 'aui'), |
|
| 2090 | + 'hour' => _x('about an hour', 'time ago', 'aui'), |
|
| 2091 | + 'hours' => _x('about %d hours', 'time ago', 'aui'), |
|
| 2092 | + 'day' => _x('a day', 'time ago', 'aui'), |
|
| 2093 | + 'days' => _x('%d days', 'time ago', 'aui'), |
|
| 2094 | + 'month' => _x('about a month', 'time ago', 'aui'), |
|
| 2095 | + 'months' => _x('%d months', 'time ago', 'aui'), |
|
| 2096 | + 'year' => _x('about a year', 'time ago', 'aui'), |
|
| 2097 | + 'years' => _x('%d years', 'time ago', 'aui'), |
|
| 2098 | 2098 | ); |
| 2099 | 2099 | |
| 2100 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2100 | + $params = apply_filters('ayecode_ui_timeago_params', $params); |
|
| 2101 | 2101 | |
| 2102 | - foreach ( (array) $params as $key => $value ) { |
|
| 2103 | - if ( ! is_scalar( $value ) ) { |
|
| 2102 | + foreach ((array) $params as $key => $value) { |
|
| 2103 | + if (!is_scalar($value)) { |
|
| 2104 | 2104 | continue; |
| 2105 | 2105 | } |
| 2106 | 2106 | |
| 2107 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2107 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 2108 | 2108 | } |
| 2109 | 2109 | |
| 2110 | - $locale = json_encode( $params ); |
|
| 2110 | + $locale = json_encode($params); |
|
| 2111 | 2111 | |
| 2112 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2112 | + return apply_filters('ayecode_ui_timeago_locale', trim($locale)); |
|
| 2113 | 2113 | } |
| 2114 | 2114 | |
| 2115 | 2115 | /** |
@@ -2120,7 +2120,7 @@ discard block |
||
| 2120 | 2120 | * @return mixed |
| 2121 | 2121 | */ |
| 2122 | 2122 | public static function minify_js($input) { |
| 2123 | - if(trim($input) === "") return $input; |
|
| 2123 | + if (trim($input) === "") return $input; |
|
| 2124 | 2124 | return preg_replace( |
| 2125 | 2125 | array( |
| 2126 | 2126 | // Remove comment(s) |
@@ -2152,7 +2152,7 @@ discard block |
||
| 2152 | 2152 | * @return mixed |
| 2153 | 2153 | */ |
| 2154 | 2154 | public static function minify_css($input) { |
| 2155 | - if(trim($input) === "") return $input; |
|
| 2155 | + if (trim($input) === "") return $input; |
|
| 2156 | 2156 | return preg_replace( |
| 2157 | 2157 | array( |
| 2158 | 2158 | // Remove comment(s) |
@@ -13,17 +13,17 @@ discard block |
||
| 13 | 13 | class GetPaid_Notification_Email_Sender { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Whether or not we should inline CSS into the email. |
|
| 17 | - */ |
|
| 18 | - public $inline_css = true; |
|
| 16 | + * Whether or not we should inline CSS into the email. |
|
| 17 | + */ |
|
| 18 | + public $inline_css = true; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * The wp_mail() data. |
|
| 22 | - */ |
|
| 21 | + * The wp_mail() data. |
|
| 22 | + */ |
|
| 23 | 23 | public $wp_mail_data = null; |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * Sends a new email. |
|
| 26 | + * Sends a new email. |
|
| 27 | 27 | * |
| 28 | 28 | * @param string|array $to The recipients email or an array of recipient emails. |
| 29 | 29 | * @param string $subject The email's subject. |
@@ -31,49 +31,49 @@ discard block |
||
| 31 | 31 | * @param array $attachments The email attachments. |
| 32 | 32 | * |
| 33 | 33 | * @return bool |
| 34 | - */ |
|
| 35 | - public function send( $to, $subject, $email, $attachments = array() ) { |
|
| 34 | + */ |
|
| 35 | + public function send( $to, $subject, $email, $attachments = array() ) { |
|
| 36 | 36 | |
| 37 | - /* |
|
| 37 | + /* |
|
| 38 | 38 | * Allow to filter data on per-email basis. |
| 39 | 39 | */ |
| 40 | - $data = apply_filters( |
|
| 41 | - 'getpaid_email_data', |
|
| 42 | - array( |
|
| 43 | - 'to' => array_filter( array_unique( wpinv_parse_list( $to ) ) ), |
|
| 44 | - 'subject' => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ), |
|
| 45 | - 'email' => apply_filters( 'wpinv_mail_content', $email ), |
|
| 46 | - 'headers' => $this->get_headers(), |
|
| 47 | - 'attachments' => $attachments, |
|
| 48 | - ), |
|
| 49 | - $this |
|
| 50 | - ); |
|
| 40 | + $data = apply_filters( |
|
| 41 | + 'getpaid_email_data', |
|
| 42 | + array( |
|
| 43 | + 'to' => array_filter( array_unique( wpinv_parse_list( $to ) ) ), |
|
| 44 | + 'subject' => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ), |
|
| 45 | + 'email' => apply_filters( 'wpinv_mail_content', $email ), |
|
| 46 | + 'headers' => $this->get_headers(), |
|
| 47 | + 'attachments' => $attachments, |
|
| 48 | + ), |
|
| 49 | + $this |
|
| 50 | + ); |
|
| 51 | 51 | |
| 52 | 52 | // Remove slashes. |
| 53 | 53 | $data = (array) wp_unslash( $data ); |
| 54 | 54 | |
| 55 | 55 | // Cache it. |
| 56 | - $this->wp_mail_data = $data; |
|
| 56 | + $this->wp_mail_data = $data; |
|
| 57 | 57 | |
| 58 | - // Attach our own hooks. |
|
| 59 | - $this->before_sending(); |
|
| 58 | + // Attach our own hooks. |
|
| 59 | + $this->before_sending(); |
|
| 60 | 60 | |
| 61 | 61 | $result = false; |
| 62 | 62 | |
| 63 | 63 | foreach ( $this->wp_mail_data['to'] as $to ) { |
| 64 | - $result = $this->_send( $to, $data ); |
|
| 64 | + $result = $this->_send( $to, $data ); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - // Remove our hooks. |
|
| 68 | - $this->after_sending(); |
|
| 67 | + // Remove our hooks. |
|
| 68 | + $this->after_sending(); |
|
| 69 | 69 | |
| 70 | - $this->wp_mail_data = null; |
|
| 70 | + $this->wp_mail_data = null; |
|
| 71 | 71 | |
| 72 | - return $result; |
|
| 73 | - } |
|
| 72 | + return $result; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Does the actual sending. |
|
| 75 | + /** |
|
| 76 | + * Does the actual sending. |
|
| 77 | 77 | * |
| 78 | 78 | * @param string $to The recipient's email. |
| 79 | 79 | * @param array $data The email's data. |
@@ -81,81 +81,81 @@ discard block |
||
| 81 | 81 | * @param array $attachments The email attachments. |
| 82 | 82 | * |
| 83 | 83 | * @return bool |
| 84 | - */ |
|
| 85 | - protected function _send( $to, $data ) { |
|
| 86 | - |
|
| 87 | - // Prepare the sending function. |
|
| 88 | - $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
| 89 | - |
|
| 90 | - // Send the actual email. |
|
| 91 | - $result = call_user_func( |
|
| 92 | - $sending_function, |
|
| 93 | - $to, |
|
| 94 | - html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
| 95 | - $data['email'], |
|
| 96 | - $data['headers'], |
|
| 97 | - $data['attachments'] |
|
| 98 | - ); |
|
| 99 | - |
|
| 100 | - if ( ! $result ) { |
|
| 101 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] ); |
|
| 102 | - wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ ); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - return $result; |
|
| 106 | - } |
|
| 84 | + */ |
|
| 85 | + protected function _send( $to, $data ) { |
|
| 86 | + |
|
| 87 | + // Prepare the sending function. |
|
| 88 | + $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
| 89 | + |
|
| 90 | + // Send the actual email. |
|
| 91 | + $result = call_user_func( |
|
| 92 | + $sending_function, |
|
| 93 | + $to, |
|
| 94 | + html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
| 95 | + $data['email'], |
|
| 96 | + $data['headers'], |
|
| 97 | + $data['attachments'] |
|
| 98 | + ); |
|
| 99 | + |
|
| 100 | + if ( ! $result ) { |
|
| 101 | + $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] ); |
|
| 102 | + wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ ); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + return $result; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | - * Retrieves email headers. |
|
| 110 | - */ |
|
| 111 | - public function get_headers() { |
|
| 109 | + * Retrieves email headers. |
|
| 110 | + */ |
|
| 111 | + public function get_headers() { |
|
| 112 | 112 | |
| 113 | - $name = $this->get_from_name(); |
|
| 114 | - $reply_to = $this->get_reply_to(); |
|
| 115 | - $headers = array( "Reply-To:$name <$reply_to>" ); |
|
| 113 | + $name = $this->get_from_name(); |
|
| 114 | + $reply_to = $this->get_reply_to(); |
|
| 115 | + $headers = array( "Reply-To:$name <$reply_to>" ); |
|
| 116 | 116 | |
| 117 | - return apply_filters( 'getpaid_email_headers', $headers, $this ); |
|
| 117 | + return apply_filters( 'getpaid_email_headers', $headers, $this ); |
|
| 118 | 118 | |
| 119 | - } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | - * Fires before an email is sent |
|
| 123 | - * |
|
| 124 | - * @since 1.0.0 |
|
| 125 | - */ |
|
| 126 | - public function before_sending() { |
|
| 122 | + * Fires before an email is sent |
|
| 123 | + * |
|
| 124 | + * @since 1.0.0 |
|
| 125 | + */ |
|
| 126 | + public function before_sending() { |
|
| 127 | 127 | |
| 128 | 128 | do_action( 'getpaid_before_send_email', $this ); |
| 129 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
| 130 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
| 131 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
| 132 | - add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
| 129 | + add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
| 130 | + add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
| 131 | + add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
| 132 | + add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
| 133 | 133 | |
| 134 | - } |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | - * Returns the from name. |
|
| 138 | - */ |
|
| 139 | - public function get_from_name() { |
|
| 137 | + * Returns the from name. |
|
| 138 | + */ |
|
| 139 | + public function get_from_name() { |
|
| 140 | 140 | |
| 141 | 141 | $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) ); |
| 142 | 142 | |
| 143 | - if ( empty( $from_name ) ) { |
|
| 144 | - $from_name = get_bloginfo( 'name' ); |
|
| 143 | + if ( empty( $from_name ) ) { |
|
| 144 | + $from_name = get_bloginfo( 'name' ); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - return wp_specialchars_decode( $from_name, ENT_QUOTES ); |
|
| 147 | + return wp_specialchars_decode( $from_name, ENT_QUOTES ); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * Returns the from email. |
|
| 152 | - */ |
|
| 153 | - public function get_from_address() { |
|
| 151 | + * Returns the from email. |
|
| 152 | + */ |
|
| 153 | + public function get_from_address() { |
|
| 154 | 154 | |
| 155 | 155 | $from_address = wpinv_get_option( 'email_from', $this->default_from_address() ); |
| 156 | 156 | |
| 157 | - if ( ! is_email( $from_address ) ) { |
|
| 158 | - $from_address = $this->default_from_address(); |
|
| 157 | + if ( ! is_email( $from_address ) ) { |
|
| 158 | + $from_address = $this->default_from_address(); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | return $from_address; |
@@ -163,75 +163,75 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | - * The default emails from address. |
|
| 167 | - * |
|
| 168 | - * Defaults to wordpress@$sitename |
|
| 169 | - * Some hosts will block outgoing mail from this address if it doesn't exist, |
|
| 170 | - * but there's no easy alternative. Defaulting to admin_email might appear to be |
|
| 171 | - * another option, but some hosts may refuse to relay mail from an unknown domain. |
|
| 172 | - * |
|
| 173 | - */ |
|
| 174 | - public function default_from_address() { |
|
| 175 | - |
|
| 176 | - // Get the site domain and get rid of www. |
|
| 177 | - $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
|
| 178 | - if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
|
| 179 | - $sitename = substr( $sitename, 4 ); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - $from_email = 'wordpress@' . $sitename; |
|
| 183 | - |
|
| 184 | - return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
| 166 | + * The default emails from address. |
|
| 167 | + * |
|
| 168 | + * Defaults to wordpress@$sitename |
|
| 169 | + * Some hosts will block outgoing mail from this address if it doesn't exist, |
|
| 170 | + * but there's no easy alternative. Defaulting to admin_email might appear to be |
|
| 171 | + * another option, but some hosts may refuse to relay mail from an unknown domain. |
|
| 172 | + * |
|
| 173 | + */ |
|
| 174 | + public function default_from_address() { |
|
| 175 | + |
|
| 176 | + // Get the site domain and get rid of www. |
|
| 177 | + $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
|
| 178 | + if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
|
| 179 | + $sitename = substr( $sitename, 4 ); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + $from_email = 'wordpress@' . $sitename; |
|
| 183 | + |
|
| 184 | + return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
| 185 | 185 | |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | - * Get the email reply-to. |
|
| 190 | - * |
|
| 191 | - * |
|
| 192 | - * @return string The email reply-to address. |
|
| 193 | - */ |
|
| 194 | - public function get_reply_to() { |
|
| 189 | + * Get the email reply-to. |
|
| 190 | + * |
|
| 191 | + * |
|
| 192 | + * @return string The email reply-to address. |
|
| 193 | + */ |
|
| 194 | + public function get_reply_to() { |
|
| 195 | 195 | |
| 196 | - $reply_to = wpinv_get_admin_email(); |
|
| 196 | + $reply_to = wpinv_get_admin_email(); |
|
| 197 | 197 | |
| 198 | - if ( ! is_email( $reply_to ) ) { |
|
| 199 | - $reply_to = get_option( 'admin_email' ); |
|
| 200 | - } |
|
| 198 | + if ( ! is_email( $reply_to ) ) { |
|
| 199 | + $reply_to = get_option( 'admin_email' ); |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - return $reply_to; |
|
| 202 | + return $reply_to; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | - * Get the email content type. |
|
| 207 | - * |
|
| 208 | - */ |
|
| 209 | - public function get_content_type() { |
|
| 210 | - return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
| 206 | + * Get the email content type. |
|
| 207 | + * |
|
| 208 | + */ |
|
| 209 | + public function get_content_type() { |
|
| 210 | + return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | - * Ensures that our email messages are not messed up by template plugins. |
|
| 215 | - * |
|
| 216 | - * @return array wp_mail_data. |
|
| 217 | - */ |
|
| 218 | - public function ensure_email_content( $args ) { |
|
| 219 | - $args['message'] = $this->wp_mail_data['email']; |
|
| 220 | - return $args; |
|
| 214 | + * Ensures that our email messages are not messed up by template plugins. |
|
| 215 | + * |
|
| 216 | + * @return array wp_mail_data. |
|
| 217 | + */ |
|
| 218 | + public function ensure_email_content( $args ) { |
|
| 219 | + $args['message'] = $this->wp_mail_data['email']; |
|
| 220 | + return $args; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
| 224 | - * A little house keeping after an email is sent. |
|
| 225 | - * |
|
| 226 | - */ |
|
| 227 | - public function after_sending() { |
|
| 224 | + * A little house keeping after an email is sent. |
|
| 225 | + * |
|
| 226 | + */ |
|
| 227 | + public function after_sending() { |
|
| 228 | 228 | |
| 229 | 229 | do_action( 'getpaid_after_send_email', $this->wp_mail_data ); |
| 230 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
| 231 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
| 232 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
| 233 | - remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
| 230 | + remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
| 231 | + remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
| 232 | + remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
| 233 | + remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
| 234 | 234 | |
| 235 | - } |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | 237 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * This function is responsible for sending emails. |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public function send( $to, $subject, $email, $attachments = array() ) { |
|
| 35 | + public function send($to, $subject, $email, $attachments = array()) { |
|
| 36 | 36 | |
| 37 | 37 | /* |
| 38 | 38 | * Allow to filter data on per-email basis. |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | $data = apply_filters( |
| 41 | 41 | 'getpaid_email_data', |
| 42 | 42 | array( |
| 43 | - 'to' => array_filter( array_unique( wpinv_parse_list( $to ) ) ), |
|
| 44 | - 'subject' => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ), |
|
| 45 | - 'email' => apply_filters( 'wpinv_mail_content', $email ), |
|
| 43 | + 'to' => array_filter(array_unique(wpinv_parse_list($to))), |
|
| 44 | + 'subject' => htmlspecialchars_decode(strip_tags($subject), ENT_QUOTES), |
|
| 45 | + 'email' => apply_filters('wpinv_mail_content', $email), |
|
| 46 | 46 | 'headers' => $this->get_headers(), |
| 47 | 47 | 'attachments' => $attachments, |
| 48 | 48 | ), |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | 52 | // Remove slashes. |
| 53 | - $data = (array) wp_unslash( $data ); |
|
| 53 | + $data = (array) wp_unslash($data); |
|
| 54 | 54 | |
| 55 | 55 | // Cache it. |
| 56 | 56 | $this->wp_mail_data = $data; |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $result = false; |
| 62 | 62 | |
| 63 | - foreach ( $this->wp_mail_data['to'] as $to ) { |
|
| 64 | - $result = $this->_send( $to, $data ); |
|
| 63 | + foreach ($this->wp_mail_data['to'] as $to) { |
|
| 64 | + $result = $this->_send($to, $data); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Remove our hooks. |
@@ -82,24 +82,24 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | - protected function _send( $to, $data ) { |
|
| 85 | + protected function _send($to, $data) { |
|
| 86 | 86 | |
| 87 | 87 | // Prepare the sending function. |
| 88 | - $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
| 88 | + $sending_function = apply_filters('getpaid_email_email_sending_function', 'wp_mail'); |
|
| 89 | 89 | |
| 90 | 90 | // Send the actual email. |
| 91 | 91 | $result = call_user_func( |
| 92 | 92 | $sending_function, |
| 93 | 93 | $to, |
| 94 | - html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
| 94 | + html_entity_decode($data['subject'], ENT_QUOTES, get_bloginfo('charset')), |
|
| 95 | 95 | $data['email'], |
| 96 | 96 | $data['headers'], |
| 97 | 97 | $data['attachments'] |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - if ( ! $result ) { |
|
| 101 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] ); |
|
| 102 | - wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ ); |
|
| 100 | + if (!$result) { |
|
| 101 | + $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), $to, $data['subject']); |
|
| 102 | + wpinv_error_log($log_message, __('Email from Invoicing plugin failed to send', 'invoicing'), __FILE__, __LINE__); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | return $result; |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $name = $this->get_from_name(); |
| 114 | 114 | $reply_to = $this->get_reply_to(); |
| 115 | - $headers = array( "Reply-To:$name <$reply_to>" ); |
|
| 115 | + $headers = array("Reply-To:$name <$reply_to>"); |
|
| 116 | 116 | |
| 117 | - return apply_filters( 'getpaid_email_headers', $headers, $this ); |
|
| 117 | + return apply_filters('getpaid_email_headers', $headers, $this); |
|
| 118 | 118 | |
| 119 | 119 | } |
| 120 | 120 | |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function before_sending() { |
| 127 | 127 | |
| 128 | - do_action( 'getpaid_before_send_email', $this ); |
|
| 129 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
| 130 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
| 131 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
| 132 | - add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
| 128 | + do_action('getpaid_before_send_email', $this); |
|
| 129 | + add_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
| 130 | + add_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
| 131 | + add_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
| 132 | + add_filter('wp_mail', array($this, 'ensure_email_content'), 1000); |
|
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function get_from_name() { |
| 140 | 140 | |
| 141 | - $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) ); |
|
| 141 | + $from_name = wpinv_get_option('email_from_name', get_bloginfo('name')); |
|
| 142 | 142 | |
| 143 | - if ( empty( $from_name ) ) { |
|
| 144 | - $from_name = get_bloginfo( 'name' ); |
|
| 143 | + if (empty($from_name)) { |
|
| 144 | + $from_name = get_bloginfo('name'); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - return wp_specialchars_decode( $from_name, ENT_QUOTES ); |
|
| 147 | + return wp_specialchars_decode($from_name, ENT_QUOTES); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function get_from_address() { |
| 154 | 154 | |
| 155 | - $from_address = wpinv_get_option( 'email_from', $this->default_from_address() ); |
|
| 155 | + $from_address = wpinv_get_option('email_from', $this->default_from_address()); |
|
| 156 | 156 | |
| 157 | - if ( ! is_email( $from_address ) ) { |
|
| 158 | - $from_address = $this->default_from_address(); |
|
| 157 | + if (!is_email($from_address)) { |
|
| 158 | + $from_address = $this->default_from_address(); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | return $from_address; |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | public function default_from_address() { |
| 175 | 175 | |
| 176 | 176 | // Get the site domain and get rid of www. |
| 177 | - $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
|
| 178 | - if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
|
| 179 | - $sitename = substr( $sitename, 4 ); |
|
| 177 | + $sitename = strtolower($_SERVER['SERVER_NAME']); |
|
| 178 | + if (substr($sitename, 0, 4) == 'www.') { |
|
| 179 | + $sitename = substr($sitename, 4); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $from_email = 'wordpress@' . $sitename; |
| 183 | 183 | |
| 184 | - return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
| 184 | + return apply_filters('getpaid_default_from_address', $from_email); |
|
| 185 | 185 | |
| 186 | 186 | } |
| 187 | 187 | |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | $reply_to = wpinv_get_admin_email(); |
| 197 | 197 | |
| 198 | - if ( ! is_email( $reply_to ) ) { |
|
| 199 | - $reply_to = get_option( 'admin_email' ); |
|
| 198 | + if (!is_email($reply_to)) { |
|
| 199 | + $reply_to = get_option('admin_email'); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | return $reply_to; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | */ |
| 209 | 209 | public function get_content_type() { |
| 210 | - return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
| 210 | + return apply_filters('getpaid_email_content_type', 'text/html', $this); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return array wp_mail_data. |
| 217 | 217 | */ |
| 218 | - public function ensure_email_content( $args ) { |
|
| 218 | + public function ensure_email_content($args) { |
|
| 219 | 219 | $args['message'] = $this->wp_mail_data['email']; |
| 220 | 220 | return $args; |
| 221 | 221 | } |
@@ -226,11 +226,11 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function after_sending() { |
| 228 | 228 | |
| 229 | - do_action( 'getpaid_after_send_email', $this->wp_mail_data ); |
|
| 230 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
| 231 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
| 232 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
| 233 | - remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
| 229 | + do_action('getpaid_after_send_email', $this->wp_mail_data); |
|
| 230 | + remove_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
| 231 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
| 232 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
| 233 | + remove_filter('wp_mail', array($this, 'ensure_email_content'), 1000); |
|
| 234 | 234 | |
| 235 | 235 | } |
| 236 | 236 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function wpinv_subscriptions_page() { |
| 16 | 16 | |
| 17 | - ?> |
|
| 17 | + ?> |
|
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,27 +22,27 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | - // Verify user permissions. |
|
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 25 | + // Verify user permissions. |
|
| 26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 27 | 27 | |
| 28 | - echo aui()->alert( |
|
| 29 | - array( |
|
| 30 | - 'type' => 'danger', |
|
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | - ) |
|
| 33 | - ); |
|
| 28 | + echo aui()->alert( |
|
| 29 | + array( |
|
| 30 | + 'type' => 'danger', |
|
| 31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | + ) |
|
| 33 | + ); |
|
| 34 | 34 | |
| 35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 35 | + } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 36 | 36 | |
| 37 | - // Display a single subscription. |
|
| 38 | - wpinv_recurring_subscription_details(); |
|
| 39 | - } else { |
|
| 37 | + // Display a single subscription. |
|
| 38 | + wpinv_recurring_subscription_details(); |
|
| 39 | + } else { |
|
| 40 | 40 | |
| 41 | - // Display a list of available subscriptions. |
|
| 42 | - getpaid_print_subscriptions_list(); |
|
| 43 | - } |
|
| 41 | + // Display a list of available subscriptions. |
|
| 42 | + getpaid_print_subscriptions_list(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - ?> |
|
| 45 | + ?> |
|
| 46 | 46 | |
| 47 | 47 | </div> |
| 48 | 48 | </div> |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function getpaid_print_subscriptions_list() { |
| 61 | 61 | |
| 62 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 63 | - $subscribers_table->prepare_items(); |
|
| 62 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 63 | + $subscribers_table->prepare_items(); |
|
| 64 | 64 | |
| 65 | - ?> |
|
| 65 | + ?> |
|
| 66 | 66 | <form id="subscribers-filter" class="bsui" method="get"> |
| 67 | 67 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
| 68 | 68 | <?php $subscribers_table->views(); ?> |
@@ -80,41 +80,41 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | function wpinv_recurring_subscription_details() { |
| 82 | 82 | |
| 83 | - // Fetch the subscription. |
|
| 84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 85 | - if ( ! $sub->exists() ) { |
|
| 83 | + // Fetch the subscription. |
|
| 84 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 85 | + if ( ! $sub->exists() ) { |
|
| 86 | 86 | |
| 87 | - echo aui()->alert( |
|
| 88 | - array( |
|
| 89 | - 'type' => 'danger', |
|
| 90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 91 | - ) |
|
| 92 | - ); |
|
| 87 | + echo aui()->alert( |
|
| 88 | + array( |
|
| 89 | + 'type' => 'danger', |
|
| 90 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 91 | + ) |
|
| 92 | + ); |
|
| 93 | 93 | |
| 94 | - return; |
|
| 95 | - } |
|
| 94 | + return; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - // Use metaboxes to display the subscription details. |
|
| 98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 97 | + // Use metaboxes to display the subscription details. |
|
| 98 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 99 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 100 | 100 | |
| 101 | - $subscription_id = $sub->get_id(); |
|
| 102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 101 | + $subscription_id = $sub->get_id(); |
|
| 102 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 103 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 104 | 104 | |
| 105 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 107 | - } |
|
| 105 | + if ( 1 < count( $subscription_groups ) ) { |
|
| 106 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if ( ! empty( $subscription_group ) ) { |
|
| 110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 111 | - } |
|
| 109 | + if ( ! empty( $subscription_group ) ) { |
|
| 110 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 113 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 114 | 114 | |
| 115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 115 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 116 | 116 | |
| 117 | - ?> |
|
| 117 | + ?> |
|
| 118 | 118 | |
| 119 | 119 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
| 120 | 120 | |
@@ -154,45 +154,45 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | function getpaid_admin_subscription_details_metabox( $sub ) { |
| 156 | 156 | |
| 157 | - // Subscription items. |
|
| 158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 160 | - |
|
| 161 | - // Prepare subscription detail columns. |
|
| 162 | - $fields = apply_filters( |
|
| 163 | - 'getpaid_subscription_admin_page_fields', |
|
| 164 | - array( |
|
| 165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 174 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 175 | - ) |
|
| 176 | - ); |
|
| 177 | - |
|
| 178 | - if ( ! $sub->is_active() ) { |
|
| 179 | - |
|
| 180 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 181 | - unset( $fields['renews_on'] ); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if ( isset( $fields['gateway'] ) ) { |
|
| 185 | - unset( $fields['gateway'] ); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $profile_id = $sub->get_profile_id(); |
|
| 191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 192 | - unset( $fields['profile_id'] ); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - ?> |
|
| 157 | + // Subscription items. |
|
| 158 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 159 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 160 | + |
|
| 161 | + // Prepare subscription detail columns. |
|
| 162 | + $fields = apply_filters( |
|
| 163 | + 'getpaid_subscription_admin_page_fields', |
|
| 164 | + array( |
|
| 165 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 166 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
| 167 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 168 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 169 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 170 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 171 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 172 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 173 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 174 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 175 | + ) |
|
| 176 | + ); |
|
| 177 | + |
|
| 178 | + if ( ! $sub->is_active() ) { |
|
| 179 | + |
|
| 180 | + if ( isset( $fields['renews_on'] ) ) { |
|
| 181 | + unset( $fields['renews_on'] ); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if ( isset( $fields['gateway'] ) ) { |
|
| 185 | + unset( $fields['gateway'] ); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $profile_id = $sub->get_profile_id(); |
|
| 191 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 192 | + unset( $fields['profile_id'] ); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + ?> |
|
| 196 | 196 | |
| 197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
| 198 | 198 | <tbody> |
@@ -226,20 +226,20 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
| 228 | 228 | |
| 229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 229 | + $username = __( '(Missing User)', 'invoicing' ); |
|
| 230 | 230 | |
| 231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 232 | - if ( $user ) { |
|
| 231 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
| 232 | + if ( $user ) { |
|
| 233 | 233 | |
| 234 | - $username = sprintf( |
|
| 235 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 236 | - absint( $user->ID ), |
|
| 237 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 238 | - ); |
|
| 234 | + $username = sprintf( |
|
| 235 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 236 | + absint( $user->ID ), |
|
| 237 | + ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 238 | + ); |
|
| 239 | 239 | |
| 240 | - } |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - echo $username; |
|
| 242 | + echo $username; |
|
| 243 | 243 | } |
| 244 | 244 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
| 245 | 245 | |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | * @param WPInv_Subscription $subscription |
| 250 | 250 | */ |
| 251 | 251 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
| 252 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 253 | - echo "<span>$amount</span>"; |
|
| 252 | + $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 253 | + echo "<span>$amount</span>"; |
|
| 254 | 254 | } |
| 255 | 255 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
| 256 | 256 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @param WPInv_Subscription $subscription |
| 261 | 261 | */ |
| 262 | 262 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
| 263 | - echo '#' . absint( $subscription->get_id() ); |
|
| 263 | + echo '#' . absint( $subscription->get_id() ); |
|
| 264 | 264 | } |
| 265 | 265 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
| 266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @param WPInv_Subscription $subscription |
| 271 | 271 | */ |
| 272 | 272 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
| 273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 273 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 274 | 274 | } |
| 275 | 275 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
| 276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * @param WPInv_Subscription $subscription |
| 281 | 281 | */ |
| 282 | 282 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
| 283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 283 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 284 | 284 | } |
| 285 | 285 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
| 286 | 286 | |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | * @param WPInv_Subscription $subscription |
| 291 | 291 | */ |
| 292 | 292 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
| 293 | - $max_bills = $subscription->get_bill_times(); |
|
| 294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 293 | + $max_bills = $subscription->get_bill_times(); |
|
| 294 | + echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 295 | 295 | } |
| 296 | 296 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
| 297 | 297 | /** |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
| 304 | 304 | |
| 305 | - if ( empty( $subscription_group ) ) { |
|
| 306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
| 307 | - return; |
|
| 308 | - } |
|
| 305 | + if ( empty( $subscription_group ) ) { |
|
| 306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
| 307 | + return; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 311 | - echo implode( ' | ', $markup ); |
|
| 310 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 311 | + echo implode( ' | ', $markup ); |
|
| 312 | 312 | |
| 313 | 313 | } |
| 314 | 314 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -320,13 +320,13 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
| 322 | 322 | |
| 323 | - $gateway = $subscription->get_gateway(); |
|
| 323 | + $gateway = $subscription->get_gateway(); |
|
| 324 | 324 | |
| 325 | - if ( ! empty( $gateway ) ) { |
|
| 326 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 327 | - } else { |
|
| 328 | - echo "—"; |
|
| 329 | - } |
|
| 325 | + if ( ! empty( $gateway ) ) { |
|
| 326 | + echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 327 | + } else { |
|
| 328 | + echo "—"; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | 331 | } |
| 332 | 332 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | * @param WPInv_Subscription $subscription |
| 338 | 338 | */ |
| 339 | 339 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
| 340 | - echo $subscription->get_status_label_html(); |
|
| 340 | + echo $subscription->get_status_label_html(); |
|
| 341 | 341 | } |
| 342 | 342 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
| 343 | 343 | |
@@ -348,29 +348,29 @@ discard block |
||
| 348 | 348 | */ |
| 349 | 349 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
| 350 | 350 | |
| 351 | - $profile_id = $subscription->get_profile_id(); |
|
| 352 | - |
|
| 353 | - $input = aui()->input( |
|
| 354 | - array( |
|
| 355 | - 'type' => 'text', |
|
| 356 | - 'id' => 'wpinv_subscription_profile_id', |
|
| 357 | - 'name' => 'wpinv_subscription_profile_id', |
|
| 358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 359 | - 'label_type' => 'hidden', |
|
| 360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 361 | - 'value' => sanitize_text_field( $profile_id ), |
|
| 362 | - 'input_group_right' => '', |
|
| 363 | - 'no_wrap' => true, |
|
| 364 | - ) |
|
| 365 | - ); |
|
| 366 | - |
|
| 367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
| 368 | - |
|
| 369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 370 | - if ( ! empty( $url ) ) { |
|
| 371 | - $url = esc_url_raw( $url ); |
|
| 372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 373 | - } |
|
| 351 | + $profile_id = $subscription->get_profile_id(); |
|
| 352 | + |
|
| 353 | + $input = aui()->input( |
|
| 354 | + array( |
|
| 355 | + 'type' => 'text', |
|
| 356 | + 'id' => 'wpinv_subscription_profile_id', |
|
| 357 | + 'name' => 'wpinv_subscription_profile_id', |
|
| 358 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 359 | + 'label_type' => 'hidden', |
|
| 360 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 361 | + 'value' => sanitize_text_field( $profile_id ), |
|
| 362 | + 'input_group_right' => '', |
|
| 363 | + 'no_wrap' => true, |
|
| 364 | + ) |
|
| 365 | + ); |
|
| 366 | + |
|
| 367 | + echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
| 368 | + |
|
| 369 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 370 | + if ( ! empty( $url ) ) { |
|
| 371 | + $url = esc_url_raw( $url ); |
|
| 372 | + echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | 375 | } |
| 376 | 376 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -382,39 +382,39 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
| 384 | 384 | |
| 385 | - ?> |
|
| 385 | + ?> |
|
| 386 | 386 | <div class="mt-3"> |
| 387 | 387 | |
| 388 | 388 | <?php |
| 389 | - echo aui()->select( |
|
| 390 | - array( |
|
| 391 | - 'options' => getpaid_get_subscription_statuses(), |
|
| 392 | - 'name' => 'subscription_status', |
|
| 393 | - 'id' => 'subscription_status_update_select', |
|
| 394 | - 'required' => true, |
|
| 395 | - 'no_wrap' => false, |
|
| 396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 398 | - 'select2' => true, |
|
| 399 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 400 | - ) |
|
| 401 | - ); |
|
| 402 | - ?> |
|
| 389 | + echo aui()->select( |
|
| 390 | + array( |
|
| 391 | + 'options' => getpaid_get_subscription_statuses(), |
|
| 392 | + 'name' => 'subscription_status', |
|
| 393 | + 'id' => 'subscription_status_update_select', |
|
| 394 | + 'required' => true, |
|
| 395 | + 'no_wrap' => false, |
|
| 396 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 397 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 398 | + 'select2' => true, |
|
| 399 | + 'value' => $subscription->get_status( 'edit' ), |
|
| 400 | + ) |
|
| 401 | + ); |
|
| 402 | + ?> |
|
| 403 | 403 | |
| 404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 405 | 405 | |
| 406 | 406 | <?php |
| 407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 407 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 408 | 408 | |
| 409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 411 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 409 | + $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 410 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 411 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 412 | 412 | |
| 413 | - if ( $subscription->is_active() ) { |
|
| 414 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
| 415 | - } |
|
| 413 | + if ( $subscription->is_active() ) { |
|
| 414 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | - echo '</div></div>'; |
|
| 417 | + echo '</div></div>'; |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -425,33 +425,33 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
| 427 | 427 | |
| 428 | - $columns = apply_filters( |
|
| 429 | - 'getpaid_subscription_related_invoices_columns', |
|
| 430 | - array( |
|
| 431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 433 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 434 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 435 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 436 | - ), |
|
| 437 | - $subscription |
|
| 438 | - ); |
|
| 439 | - |
|
| 440 | - // Prepare the invoices. |
|
| 441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 442 | - $parent = $subscription->get_parent_invoice(); |
|
| 443 | - |
|
| 444 | - if ( $parent->exists() ) { |
|
| 445 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - $table_class = 'w-100 bg-white'; |
|
| 449 | - |
|
| 450 | - if ( ! is_admin() ) { |
|
| 451 | - $table_class = 'table table-bordered'; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - ?> |
|
| 428 | + $columns = apply_filters( |
|
| 429 | + 'getpaid_subscription_related_invoices_columns', |
|
| 430 | + array( |
|
| 431 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 432 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 433 | + 'date' => __( 'Date', 'invoicing' ), |
|
| 434 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 435 | + 'total' => __( 'Total', 'invoicing' ), |
|
| 436 | + ), |
|
| 437 | + $subscription |
|
| 438 | + ); |
|
| 439 | + |
|
| 440 | + // Prepare the invoices. |
|
| 441 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 442 | + $parent = $subscription->get_parent_invoice(); |
|
| 443 | + |
|
| 444 | + if ( $parent->exists() ) { |
|
| 445 | + $payments = array_merge( array( $parent ), $payments ); |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + $table_class = 'w-100 bg-white'; |
|
| 449 | + |
|
| 450 | + if ( ! is_admin() ) { |
|
| 451 | + $table_class = 'table table-bordered'; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + ?> |
|
| 455 | 455 | <div class="m-0" style="overflow: auto;"> |
| 456 | 456 | |
| 457 | 457 | <table class="<?php echo $table_class; ?>"> |
@@ -459,14 +459,14 @@ discard block |
||
| 459 | 459 | <thead> |
| 460 | 460 | <tr> |
| 461 | 461 | <?php |
| 462 | - foreach ( $columns as $key => $label ) { |
|
| 463 | - $key = esc_attr( $key ); |
|
| 464 | - $label = sanitize_text_field( $label ); |
|
| 465 | - $class = 'text-left'; |
|
| 466 | - |
|
| 467 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 468 | - } |
|
| 469 | - ?> |
|
| 462 | + foreach ( $columns as $key => $label ) { |
|
| 463 | + $key = esc_attr( $key ); |
|
| 464 | + $label = sanitize_text_field( $label ); |
|
| 465 | + $class = 'text-left'; |
|
| 466 | + |
|
| 467 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 468 | + } |
|
| 469 | + ?> |
|
| 470 | 470 | </tr> |
| 471 | 471 | </thead> |
| 472 | 472 | |
@@ -482,73 +482,73 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | <?php |
| 484 | 484 | |
| 485 | - foreach( $payments as $payment ) : |
|
| 485 | + foreach( $payments as $payment ) : |
|
| 486 | 486 | |
| 487 | - // Ensure that we have an invoice. |
|
| 488 | - $payment = new WPInv_Invoice( $payment ); |
|
| 487 | + // Ensure that we have an invoice. |
|
| 488 | + $payment = new WPInv_Invoice( $payment ); |
|
| 489 | 489 | |
| 490 | - // Abort if the invoice is invalid... |
|
| 491 | - if ( ! $payment->exists() ) { |
|
| 492 | - continue; |
|
| 493 | - } |
|
| 490 | + // Abort if the invoice is invalid... |
|
| 491 | + if ( ! $payment->exists() ) { |
|
| 492 | + continue; |
|
| 493 | + } |
|
| 494 | 494 | |
| 495 | - // ... or belongs to a different subscription. |
|
| 496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 497 | - continue; |
|
| 498 | - } |
|
| 495 | + // ... or belongs to a different subscription. |
|
| 496 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 497 | + continue; |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - echo '<tr>'; |
|
| 500 | + echo '<tr>'; |
|
| 501 | 501 | |
| 502 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 502 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 503 | 503 | |
| 504 | - $class = 'text-left'; |
|
| 504 | + $class = 'text-left'; |
|
| 505 | 505 | |
| 506 | - echo "<td class='p-2 $class'>"; |
|
| 506 | + echo "<td class='p-2 $class'>"; |
|
| 507 | 507 | |
| 508 | - switch( $key ) { |
|
| 508 | + switch( $key ) { |
|
| 509 | 509 | |
| 510 | - case 'total': |
|
| 511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
| 512 | - break; |
|
| 510 | + case 'total': |
|
| 511 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
| 512 | + break; |
|
| 513 | 513 | |
| 514 | - case 'relationship': |
|
| 515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 516 | - break; |
|
| 514 | + case 'relationship': |
|
| 515 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 516 | + break; |
|
| 517 | 517 | |
| 518 | - case 'date': |
|
| 519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 520 | - break; |
|
| 518 | + case 'date': |
|
| 519 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 520 | + break; |
|
| 521 | 521 | |
| 522 | - case 'status': |
|
| 522 | + case 'status': |
|
| 523 | 523 | |
| 524 | - $status = $payment->get_status_nicename(); |
|
| 525 | - if ( is_admin() ) { |
|
| 526 | - $status = $payment->get_status_label_html(); |
|
| 527 | - } |
|
| 524 | + $status = $payment->get_status_nicename(); |
|
| 525 | + if ( is_admin() ) { |
|
| 526 | + $status = $payment->get_status_label_html(); |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | - echo $status; |
|
| 530 | - break; |
|
| 529 | + echo $status; |
|
| 530 | + break; |
|
| 531 | 531 | |
| 532 | - case 'invoice': |
|
| 533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 532 | + case 'invoice': |
|
| 533 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 534 | 534 | |
| 535 | - if ( ! is_admin() ) { |
|
| 536 | - $link = esc_url( $payment->get_view_url() ); |
|
| 537 | - } |
|
| 535 | + if ( ! is_admin() ) { |
|
| 536 | + $link = esc_url( $payment->get_view_url() ); |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
| 540 | - echo "<a href='$link'>$invoice</a>"; |
|
| 541 | - break; |
|
| 542 | - } |
|
| 539 | + $invoice = sanitize_text_field( $payment->get_number() ); |
|
| 540 | + echo "<a href='$link'>$invoice</a>"; |
|
| 541 | + break; |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | - echo '</td>'; |
|
| 544 | + echo '</td>'; |
|
| 545 | 545 | |
| 546 | - } |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - echo '</tr>'; |
|
| 548 | + echo '</tr>'; |
|
| 549 | 549 | |
| 550 | - endforeach; |
|
| 551 | - ?> |
|
| 550 | + endforeach; |
|
| 551 | + ?> |
|
| 552 | 552 | |
| 553 | 553 | </tbody> |
| 554 | 554 | |
@@ -566,42 +566,42 @@ discard block |
||
| 566 | 566 | */ |
| 567 | 567 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
| 568 | 568 | |
| 569 | - // Fetch the subscription group. |
|
| 570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 569 | + // Fetch the subscription group. |
|
| 570 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 571 | 571 | |
| 572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 573 | - return; |
|
| 574 | - } |
|
| 572 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 573 | + return; |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | - // Prepare table columns. |
|
| 577 | - $columns = apply_filters( |
|
| 578 | - 'getpaid_subscription_item_details_columns', |
|
| 579 | - array( |
|
| 580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 581 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 584 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 585 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 586 | - ), |
|
| 587 | - $subscription |
|
| 588 | - ); |
|
| 576 | + // Prepare table columns. |
|
| 577 | + $columns = apply_filters( |
|
| 578 | + 'getpaid_subscription_item_details_columns', |
|
| 579 | + array( |
|
| 580 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
| 581 | + 'price' => __( 'Price', 'invoicing' ), |
|
| 582 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
| 583 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
| 584 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 585 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 586 | + ), |
|
| 587 | + $subscription |
|
| 588 | + ); |
|
| 589 | 589 | |
| 590 | - // Prepare the invoices. |
|
| 590 | + // Prepare the invoices. |
|
| 591 | 591 | |
| 592 | - $invoice = $subscription->get_parent_invoice(); |
|
| 592 | + $invoice = $subscription->get_parent_invoice(); |
|
| 593 | 593 | |
| 594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 595 | - unset( $columns['tax'] ); |
|
| 596 | - } |
|
| 594 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 595 | + unset( $columns['tax'] ); |
|
| 596 | + } |
|
| 597 | 597 | |
| 598 | - $table_class = 'w-100 bg-white'; |
|
| 598 | + $table_class = 'w-100 bg-white'; |
|
| 599 | 599 | |
| 600 | - if ( ! is_admin() ) { |
|
| 601 | - $table_class = 'table table-bordered'; |
|
| 602 | - } |
|
| 600 | + if ( ! is_admin() ) { |
|
| 601 | + $table_class = 'table table-bordered'; |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | - ?> |
|
| 604 | + ?> |
|
| 605 | 605 | <div class="m-0" style="overflow: auto;"> |
| 606 | 606 | |
| 607 | 607 | <table class="<?php echo $table_class; ?>"> |
@@ -610,14 +610,14 @@ discard block |
||
| 610 | 610 | <tr> |
| 611 | 611 | <?php |
| 612 | 612 | |
| 613 | - foreach ( $columns as $key => $label ) { |
|
| 614 | - $key = esc_attr( $key ); |
|
| 615 | - $label = sanitize_text_field( $label ); |
|
| 616 | - $class = 'text-left'; |
|
| 613 | + foreach ( $columns as $key => $label ) { |
|
| 614 | + $key = esc_attr( $key ); |
|
| 615 | + $label = sanitize_text_field( $label ); |
|
| 616 | + $class = 'text-left'; |
|
| 617 | 617 | |
| 618 | - echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 619 | - } |
|
| 620 | - ?> |
|
| 618 | + echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 619 | + } |
|
| 620 | + ?> |
|
| 621 | 621 | </tr> |
| 622 | 622 | </thead> |
| 623 | 623 | |
@@ -625,106 +625,106 @@ discard block |
||
| 625 | 625 | |
| 626 | 626 | <?php |
| 627 | 627 | |
| 628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
| 628 | + foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
| 629 | 629 | |
| 630 | - echo '<tr>'; |
|
| 630 | + echo '<tr>'; |
|
| 631 | 631 | |
| 632 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 632 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 633 | 633 | |
| 634 | - $class = 'text-left'; |
|
| 634 | + $class = 'text-left'; |
|
| 635 | 635 | |
| 636 | - echo "<td class='p-2 $class'>"; |
|
| 636 | + echo "<td class='p-2 $class'>"; |
|
| 637 | 637 | |
| 638 | - switch( $key ) { |
|
| 638 | + switch( $key ) { |
|
| 639 | 639 | |
| 640 | - case 'item_name': |
|
| 641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 640 | + case 'item_name': |
|
| 641 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 642 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 643 | 643 | |
| 644 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 645 | - echo sanitize_text_field( $item_name ); |
|
| 646 | - } else { |
|
| 647 | - printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 648 | - } |
|
| 644 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 645 | + echo sanitize_text_field( $item_name ); |
|
| 646 | + } else { |
|
| 647 | + printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | - break; |
|
| 650 | + break; |
|
| 651 | 651 | |
| 652 | - case 'price': |
|
| 653 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 654 | - break; |
|
| 652 | + case 'price': |
|
| 653 | + echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 654 | + break; |
|
| 655 | 655 | |
| 656 | - case 'tax': |
|
| 657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 658 | - break; |
|
| 656 | + case 'tax': |
|
| 657 | + echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 658 | + break; |
|
| 659 | 659 | |
| 660 | - case 'discount': |
|
| 661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 662 | - break; |
|
| 660 | + case 'discount': |
|
| 661 | + echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 662 | + break; |
|
| 663 | 663 | |
| 664 | - case 'initial': |
|
| 665 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 666 | - break; |
|
| 664 | + case 'initial': |
|
| 665 | + echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 666 | + break; |
|
| 667 | 667 | |
| 668 | - case 'recurring': |
|
| 669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
| 670 | - break; |
|
| 668 | + case 'recurring': |
|
| 669 | + echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
| 670 | + break; |
|
| 671 | 671 | |
| 672 | - } |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | - echo '</td>'; |
|
| 674 | + echo '</td>'; |
|
| 675 | 675 | |
| 676 | - } |
|
| 676 | + } |
|
| 677 | 677 | |
| 678 | - echo '</tr>'; |
|
| 678 | + echo '</tr>'; |
|
| 679 | 679 | |
| 680 | - endforeach; |
|
| 680 | + endforeach; |
|
| 681 | 681 | |
| 682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 682 | + foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 683 | 683 | |
| 684 | - echo '<tr>'; |
|
| 684 | + echo '<tr>'; |
|
| 685 | 685 | |
| 686 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 686 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 687 | 687 | |
| 688 | - $class = 'text-left'; |
|
| 688 | + $class = 'text-left'; |
|
| 689 | 689 | |
| 690 | - echo "<td class='p-2 $class'>"; |
|
| 690 | + echo "<td class='p-2 $class'>"; |
|
| 691 | 691 | |
| 692 | - switch( $key ) { |
|
| 692 | + switch( $key ) { |
|
| 693 | 693 | |
| 694 | - case 'item_name': |
|
| 695 | - echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
| 696 | - break; |
|
| 694 | + case 'item_name': |
|
| 695 | + echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
| 696 | + break; |
|
| 697 | 697 | |
| 698 | - case 'price': |
|
| 699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 700 | - break; |
|
| 698 | + case 'price': |
|
| 699 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 700 | + break; |
|
| 701 | 701 | |
| 702 | - case 'tax': |
|
| 703 | - echo "—"; |
|
| 704 | - break; |
|
| 702 | + case 'tax': |
|
| 703 | + echo "—"; |
|
| 704 | + break; |
|
| 705 | 705 | |
| 706 | - case 'discount': |
|
| 707 | - echo "—"; |
|
| 708 | - break; |
|
| 706 | + case 'discount': |
|
| 707 | + echo "—"; |
|
| 708 | + break; |
|
| 709 | 709 | |
| 710 | - case 'initial': |
|
| 711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 712 | - break; |
|
| 710 | + case 'initial': |
|
| 711 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 712 | + break; |
|
| 713 | 713 | |
| 714 | - case 'recurring': |
|
| 715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
| 716 | - break; |
|
| 714 | + case 'recurring': |
|
| 715 | + echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
| 716 | + break; |
|
| 717 | 717 | |
| 718 | - } |
|
| 718 | + } |
|
| 719 | 719 | |
| 720 | - echo '</td>'; |
|
| 720 | + echo '</td>'; |
|
| 721 | 721 | |
| 722 | - } |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | - echo '</tr>'; |
|
| 724 | + echo '</tr>'; |
|
| 725 | 725 | |
| 726 | - endforeach; |
|
| 727 | - ?> |
|
| 726 | + endforeach; |
|
| 727 | + ?> |
|
| 728 | 728 | |
| 729 | 729 | </tbody> |
| 730 | 730 | |
@@ -743,38 +743,38 @@ discard block |
||
| 743 | 743 | */ |
| 744 | 744 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
| 745 | 745 | |
| 746 | - // Fetch the subscription groups. |
|
| 747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 748 | - |
|
| 749 | - if ( empty( $subscription_groups ) ) { |
|
| 750 | - return; |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - // Prepare table columns. |
|
| 754 | - $columns = apply_filters( |
|
| 755 | - 'getpaid_subscription_related_subscriptions_columns', |
|
| 756 | - array( |
|
| 757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 761 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 762 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 763 | - ), |
|
| 764 | - $subscription |
|
| 765 | - ); |
|
| 766 | - |
|
| 767 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - $table_class = 'w-100 bg-white'; |
|
| 772 | - |
|
| 773 | - if ( ! is_admin() ) { |
|
| 774 | - $table_class = 'table table-bordered'; |
|
| 775 | - } |
|
| 776 | - |
|
| 777 | - ?> |
|
| 746 | + // Fetch the subscription groups. |
|
| 747 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 748 | + |
|
| 749 | + if ( empty( $subscription_groups ) ) { |
|
| 750 | + return; |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + // Prepare table columns. |
|
| 754 | + $columns = apply_filters( |
|
| 755 | + 'getpaid_subscription_related_subscriptions_columns', |
|
| 756 | + array( |
|
| 757 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 758 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 759 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 760 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 761 | + 'item' => __( 'Items', 'invoicing' ), |
|
| 762 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 763 | + ), |
|
| 764 | + $subscription |
|
| 765 | + ); |
|
| 766 | + |
|
| 767 | + if ( $subscription->get_status() == 'pending' ) { |
|
| 768 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + $table_class = 'w-100 bg-white'; |
|
| 772 | + |
|
| 773 | + if ( ! is_admin() ) { |
|
| 774 | + $table_class = 'table table-bordered'; |
|
| 775 | + } |
|
| 776 | + |
|
| 777 | + ?> |
|
| 778 | 778 | <div class="m-0" style="overflow: auto;"> |
| 779 | 779 | |
| 780 | 780 | <table class="<?php echo $table_class; ?>"> |
@@ -783,14 +783,14 @@ discard block |
||
| 783 | 783 | <tr> |
| 784 | 784 | <?php |
| 785 | 785 | |
| 786 | - foreach ( $columns as $key => $label ) { |
|
| 787 | - $key = esc_attr( $key ); |
|
| 788 | - $label = sanitize_text_field( $label ); |
|
| 789 | - $class = 'text-left'; |
|
| 786 | + foreach ( $columns as $key => $label ) { |
|
| 787 | + $key = esc_attr( $key ); |
|
| 788 | + $label = sanitize_text_field( $label ); |
|
| 789 | + $class = 'text-left'; |
|
| 790 | 790 | |
| 791 | - echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 792 | - } |
|
| 793 | - ?> |
|
| 791 | + echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 792 | + } |
|
| 793 | + ?> |
|
| 794 | 794 | </tr> |
| 795 | 795 | </thead> |
| 796 | 796 | |
@@ -798,74 +798,74 @@ discard block |
||
| 798 | 798 | |
| 799 | 799 | <?php |
| 800 | 800 | |
| 801 | - foreach( $subscription_groups as $subscription_group ) : |
|
| 801 | + foreach( $subscription_groups as $subscription_group ) : |
|
| 802 | 802 | |
| 803 | - // Do not list current subscription. |
|
| 804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 805 | - continue; |
|
| 806 | - } |
|
| 803 | + // Do not list current subscription. |
|
| 804 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 805 | + continue; |
|
| 806 | + } |
|
| 807 | 807 | |
| 808 | - // Ensure the subscription exists. |
|
| 809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 808 | + // Ensure the subscription exists. |
|
| 809 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 810 | 810 | |
| 811 | - if ( ! $_suscription->exists() ) { |
|
| 812 | - continue; |
|
| 813 | - } |
|
| 811 | + if ( ! $_suscription->exists() ) { |
|
| 812 | + continue; |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | - echo '<tr>'; |
|
| 815 | + echo '<tr>'; |
|
| 816 | 816 | |
| 817 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 817 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 818 | 818 | |
| 819 | - $class = 'text-left'; |
|
| 819 | + $class = 'text-left'; |
|
| 820 | 820 | |
| 821 | - echo "<td class='p-2 $class'>"; |
|
| 821 | + echo "<td class='p-2 $class'>"; |
|
| 822 | 822 | |
| 823 | - switch( $key ) { |
|
| 823 | + switch( $key ) { |
|
| 824 | 824 | |
| 825 | - case 'status': |
|
| 826 | - echo $_suscription->get_status_label_html(); |
|
| 827 | - break; |
|
| 825 | + case 'status': |
|
| 826 | + echo $_suscription->get_status_label_html(); |
|
| 827 | + break; |
|
| 828 | 828 | |
| 829 | - case 'item': |
|
| 830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 831 | - echo implode( ' | ', $markup ); |
|
| 832 | - break; |
|
| 829 | + case 'item': |
|
| 830 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 831 | + echo implode( ' | ', $markup ); |
|
| 832 | + break; |
|
| 833 | 833 | |
| 834 | - case 'renewals': |
|
| 835 | - $max_bills = $_suscription->get_bill_times(); |
|
| 836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 837 | - break; |
|
| 834 | + case 'renewals': |
|
| 835 | + $max_bills = $_suscription->get_bill_times(); |
|
| 836 | + echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 837 | + break; |
|
| 838 | 838 | |
| 839 | - case 'renewal_date': |
|
| 840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
| 841 | - break; |
|
| 839 | + case 'renewal_date': |
|
| 840 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
| 841 | + break; |
|
| 842 | 842 | |
| 843 | - case 'start_date': |
|
| 844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
| 845 | - break; |
|
| 843 | + case 'start_date': |
|
| 844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
| 845 | + break; |
|
| 846 | 846 | |
| 847 | - case 'subscription': |
|
| 848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 849 | - printf( |
|
| 850 | - '%1$s#%2$s%3$s', |
|
| 851 | - '<a href="' . esc_url( $url ) . '">', |
|
| 852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 853 | - '</a>' |
|
| 854 | - ); |
|
| 847 | + case 'subscription': |
|
| 848 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 849 | + printf( |
|
| 850 | + '%1$s#%2$s%3$s', |
|
| 851 | + '<a href="' . esc_url( $url ) . '">', |
|
| 852 | + '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 853 | + '</a>' |
|
| 854 | + ); |
|
| 855 | 855 | |
| 856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
| 857 | - break; |
|
| 856 | + echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
| 857 | + break; |
|
| 858 | 858 | |
| 859 | - } |
|
| 859 | + } |
|
| 860 | 860 | |
| 861 | - echo '</td>'; |
|
| 861 | + echo '</td>'; |
|
| 862 | 862 | |
| 863 | - } |
|
| 863 | + } |
|
| 864 | 864 | |
| 865 | - echo '</tr>'; |
|
| 865 | + echo '</tr>'; |
|
| 866 | 866 | |
| 867 | - endforeach; |
|
| 868 | - ?> |
|
| 867 | + endforeach; |
|
| 868 | + ?> |
|
| 869 | 869 | |
| 870 | 870 | </tbody> |
| 871 | 871 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * Contains functions that display the subscriptions admin page. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -defined( 'ABSPATH' ) || exit; |
|
| 6 | +defined('ABSPATH') || exit; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
| 20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
| 21 | 21 | <div class="bsui"> |
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | 25 | // Verify user permissions. |
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 27 | 27 | |
| 28 | 28 | echo aui()->alert( |
| 29 | 29 | array( |
| 30 | 30 | 'type' => 'danger', |
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
| 32 | 32 | ) |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
| 36 | 36 | |
| 37 | 37 | // Display a single subscription. |
| 38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | function wpinv_recurring_subscription_details() { |
| 82 | 82 | |
| 83 | 83 | // Fetch the subscription. |
| 84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 85 | - if ( ! $sub->exists() ) { |
|
| 84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
| 85 | + if (!$sub->exists()) { |
|
| 86 | 86 | |
| 87 | 87 | echo aui()->alert( |
| 88 | 88 | array( |
| 89 | 89 | 'type' => 'danger', |
| 90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
| 91 | 91 | ) |
| 92 | 92 | ); |
| 93 | 93 | |
@@ -95,45 +95,45 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Use metaboxes to display the subscription details. |
| 98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
| 99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
| 100 | 100 | |
| 101 | 101 | $subscription_id = $sub->get_id(); |
| 102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 102 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
| 103 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
| 104 | 104 | |
| 105 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 105 | + if (1 < count($subscription_groups)) { |
|
| 106 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if ( ! empty( $subscription_group ) ) { |
|
| 110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 109 | + if (!empty($subscription_group)) { |
|
| 110 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 113 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
| 114 | 114 | |
| 115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 115 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
| 116 | 116 | |
| 117 | 117 | ?> |
| 118 | 118 | |
| 119 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
| 119 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
| 120 | 120 | |
| 121 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
| 122 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
| 123 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
| 121 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
| 122 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
| 123 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
| 124 | 124 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
| 125 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
| 125 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
| 126 | 126 | |
| 127 | 127 | <div id="poststuff"> |
| 128 | 128 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
| 129 | 129 | |
| 130 | 130 | <div id="postbox-container-1" class="postbox-container"> |
| 131 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
| 131 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
| 132 | 132 | </div> |
| 133 | 133 | |
| 134 | 134 | <div id="postbox-container-2" class="postbox-container"> |
| 135 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
| 136 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
| 135 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
| 136 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
| 137 | 137 | </div> |
| 138 | 138 | |
| 139 | 139 | </div> |
@@ -152,44 +152,44 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @param WPInv_Subscription $sub |
| 154 | 154 | */ |
| 155 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
| 155 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
| 156 | 156 | |
| 157 | 157 | // Subscription items. |
| 158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 158 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
| 159 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
| 160 | 160 | |
| 161 | 161 | // Prepare subscription detail columns. |
| 162 | 162 | $fields = apply_filters( |
| 163 | 163 | 'getpaid_subscription_admin_page_fields', |
| 164 | 164 | array( |
| 165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 174 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 165 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 166 | + 'customer' => __('Customer', 'invoicing'), |
|
| 167 | + 'amount' => __('Amount', 'invoicing'), |
|
| 168 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 169 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
| 170 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 171 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
| 172 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
| 173 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
| 174 | + 'status' => __('Status', 'invoicing'), |
|
| 175 | 175 | ) |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | - if ( ! $sub->is_active() ) { |
|
| 178 | + if (!$sub->is_active()) { |
|
| 179 | 179 | |
| 180 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 181 | - unset( $fields['renews_on'] ); |
|
| 180 | + if (isset($fields['renews_on'])) { |
|
| 181 | + unset($fields['renews_on']); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( isset( $fields['gateway'] ) ) { |
|
| 185 | - unset( $fields['gateway'] ); |
|
| 184 | + if (isset($fields['gateway'])) { |
|
| 185 | + unset($fields['gateway']); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $profile_id = $sub->get_profile_id(); |
| 191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 192 | - unset( $fields['profile_id'] ); |
|
| 191 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
| 192 | + unset($fields['profile_id']); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | ?> |
@@ -197,16 +197,16 @@ discard block |
||
| 197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
| 198 | 198 | <tbody> |
| 199 | 199 | |
| 200 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
| 200 | + <?php foreach ($fields as $key => $label) : ?> |
|
| 201 | 201 | |
| 202 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 202 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
| 203 | 203 | |
| 204 | 204 | <th class="w-25" style="font-weight: 500;"> |
| 205 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 205 | + <?php echo sanitize_text_field($label); ?> |
|
| 206 | 206 | </th> |
| 207 | 207 | |
| 208 | 208 | <td class="w-75 text-muted"> |
| 209 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub, $subscription_group ); ?> |
|
| 209 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub, $subscription_group); ?> |
|
| 210 | 210 | </td> |
| 211 | 211 | |
| 212 | 212 | </tr> |
@@ -224,129 +224,129 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @param WPInv_Subscription $subscription |
| 226 | 226 | */ |
| 227 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
| 227 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
| 228 | 228 | |
| 229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 229 | + $username = __('(Missing User)', 'invoicing'); |
|
| 230 | 230 | |
| 231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 232 | - if ( $user ) { |
|
| 231 | + $user = get_userdata($subscription->get_customer_id()); |
|
| 232 | + if ($user) { |
|
| 233 | 233 | |
| 234 | 234 | $username = sprintf( |
| 235 | 235 | '<a href="user-edit.php?user_id=%s">%s</a>', |
| 236 | - absint( $user->ID ), |
|
| 237 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 236 | + absint($user->ID), |
|
| 237 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | echo $username; |
| 243 | 243 | } |
| 244 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
| 244 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
| 245 | 245 | |
| 246 | 246 | /** |
| 247 | 247 | * Displays the subscription amount. |
| 248 | 248 | * |
| 249 | 249 | * @param WPInv_Subscription $subscription |
| 250 | 250 | */ |
| 251 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
| 252 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 251 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
| 252 | + $amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription)); |
|
| 253 | 253 | echo "<span>$amount</span>"; |
| 254 | 254 | } |
| 255 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
| 255 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * Displays the subscription id. |
| 259 | 259 | * |
| 260 | 260 | * @param WPInv_Subscription $subscription |
| 261 | 261 | */ |
| 262 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
| 263 | - echo '#' . absint( $subscription->get_id() ); |
|
| 262 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
| 263 | + echo '#' . absint($subscription->get_id()); |
|
| 264 | 264 | } |
| 265 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
| 265 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | 268 | * Displays the subscription renewal date. |
| 269 | 269 | * |
| 270 | 270 | * @param WPInv_Subscription $subscription |
| 271 | 271 | */ |
| 272 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
| 273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 272 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
| 273 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
| 274 | 274 | } |
| 275 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
| 275 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * Displays the subscription renewal date. |
| 279 | 279 | * |
| 280 | 280 | * @param WPInv_Subscription $subscription |
| 281 | 281 | */ |
| 282 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
| 283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 282 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
| 283 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
| 284 | 284 | } |
| 285 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
| 285 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
| 286 | 286 | |
| 287 | 287 | /** |
| 288 | 288 | * Displays the subscription renewal count. |
| 289 | 289 | * |
| 290 | 290 | * @param WPInv_Subscription $subscription |
| 291 | 291 | */ |
| 292 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
| 292 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
| 293 | 293 | $max_bills = $subscription->get_bill_times(); |
| 294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 294 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
| 295 | 295 | } |
| 296 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
| 296 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
| 297 | 297 | /** |
| 298 | 298 | * Displays the subscription item. |
| 299 | 299 | * |
| 300 | 300 | * @param WPInv_Subscription $subscription |
| 301 | 301 | * @param false|array $subscription_group |
| 302 | 302 | */ |
| 303 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
| 303 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
| 304 | 304 | |
| 305 | - if ( empty( $subscription_group ) ) { |
|
| 306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
| 305 | + if (empty($subscription_group)) { |
|
| 306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
| 307 | 307 | return; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 311 | - echo implode( ' | ', $markup ); |
|
| 310 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 311 | + echo implode(' | ', $markup); |
|
| 312 | 312 | |
| 313 | 313 | } |
| 314 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
| 314 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
| 315 | 315 | |
| 316 | 316 | /** |
| 317 | 317 | * Displays the subscription gateway. |
| 318 | 318 | * |
| 319 | 319 | * @param WPInv_Subscription $subscription |
| 320 | 320 | */ |
| 321 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
| 321 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
| 322 | 322 | |
| 323 | 323 | $gateway = $subscription->get_gateway(); |
| 324 | 324 | |
| 325 | - if ( ! empty( $gateway ) ) { |
|
| 326 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 325 | + if (!empty($gateway)) { |
|
| 326 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
| 327 | 327 | } else { |
| 328 | 328 | echo "—"; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | } |
| 332 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
| 332 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | 335 | * Displays the subscription status. |
| 336 | 336 | * |
| 337 | 337 | * @param WPInv_Subscription $subscription |
| 338 | 338 | */ |
| 339 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
| 339 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
| 340 | 340 | echo $subscription->get_status_label_html(); |
| 341 | 341 | } |
| 342 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
| 342 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
| 343 | 343 | |
| 344 | 344 | /** |
| 345 | 345 | * Displays the subscription profile id. |
| 346 | 346 | * |
| 347 | 347 | * @param WPInv_Subscription $subscription |
| 348 | 348 | */ |
| 349 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
| 349 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
| 350 | 350 | |
| 351 | 351 | $profile_id = $subscription->get_profile_id(); |
| 352 | 352 | |
@@ -355,32 +355,32 @@ discard block |
||
| 355 | 355 | 'type' => 'text', |
| 356 | 356 | 'id' => 'wpinv_subscription_profile_id', |
| 357 | 357 | 'name' => 'wpinv_subscription_profile_id', |
| 358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 358 | + 'label' => __('Profile Id', 'invoicing'), |
|
| 359 | 359 | 'label_type' => 'hidden', |
| 360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 361 | - 'value' => sanitize_text_field( $profile_id ), |
|
| 360 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
| 361 | + 'value' => sanitize_text_field($profile_id), |
|
| 362 | 362 | 'input_group_right' => '', |
| 363 | 363 | 'no_wrap' => true, |
| 364 | 364 | ) |
| 365 | 365 | ); |
| 366 | 366 | |
| 367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
| 367 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
| 368 | 368 | |
| 369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 370 | - if ( ! empty( $url ) ) { |
|
| 371 | - $url = esc_url_raw( $url ); |
|
| 372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 369 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
| 370 | + if (!empty($url)) { |
|
| 371 | + $url = esc_url_raw($url); |
|
| 372 | + echo ' <a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | } |
| 376 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
| 376 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
| 377 | 377 | |
| 378 | 378 | /** |
| 379 | 379 | * Displays the subscriptions update metabox. |
| 380 | 380 | * |
| 381 | 381 | * @param WPInv_Subscription $subscription |
| 382 | 382 | */ |
| 383 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
| 383 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
| 384 | 384 | |
| 385 | 385 | ?> |
| 386 | 386 | <div class="mt-3"> |
@@ -393,10 +393,10 @@ discard block |
||
| 393 | 393 | 'id' => 'subscription_status_update_select', |
| 394 | 394 | 'required' => true, |
| 395 | 395 | 'no_wrap' => false, |
| 396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 396 | + 'label' => __('Subscription Status', 'invoicing'), |
|
| 397 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
| 398 | 398 | 'select2' => true, |
| 399 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 399 | + 'value' => $subscription->get_status('edit'), |
|
| 400 | 400 | ) |
| 401 | 401 | ); |
| 402 | 402 | ?> |
@@ -404,13 +404,13 @@ discard block |
||
| 404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 405 | 405 | |
| 406 | 406 | <?php |
| 407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 407 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
| 408 | 408 | |
| 409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 411 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 409 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
| 410 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
| 411 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
| 412 | 412 | |
| 413 | - if ( $subscription->is_active() ) { |
|
| 413 | + if ($subscription->is_active()) { |
|
| 414 | 414 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 415 | 415 | } |
| 416 | 416 | |
@@ -423,31 +423,31 @@ discard block |
||
| 423 | 423 | * @param WPInv_Subscription $subscription |
| 424 | 424 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
| 425 | 425 | */ |
| 426 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
| 426 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
| 427 | 427 | |
| 428 | 428 | $columns = apply_filters( |
| 429 | 429 | 'getpaid_subscription_related_invoices_columns', |
| 430 | 430 | array( |
| 431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 433 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 434 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 435 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 431 | + 'invoice' => __('Invoice', 'invoicing'), |
|
| 432 | + 'relationship' => __('Relationship', 'invoicing'), |
|
| 433 | + 'date' => __('Date', 'invoicing'), |
|
| 434 | + 'status' => __('Status', 'invoicing'), |
|
| 435 | + 'total' => __('Total', 'invoicing'), |
|
| 436 | 436 | ), |
| 437 | 437 | $subscription |
| 438 | 438 | ); |
| 439 | 439 | |
| 440 | 440 | // Prepare the invoices. |
| 441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 441 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
| 442 | 442 | $parent = $subscription->get_parent_invoice(); |
| 443 | 443 | |
| 444 | - if ( $parent->exists() ) { |
|
| 445 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 444 | + if ($parent->exists()) { |
|
| 445 | + $payments = array_merge(array($parent), $payments); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | $table_class = 'w-100 bg-white'; |
| 449 | 449 | |
| 450 | - if ( ! is_admin() ) { |
|
| 450 | + if (!is_admin()) { |
|
| 451 | 451 | $table_class = 'table table-bordered'; |
| 452 | 452 | } |
| 453 | 453 | |
@@ -459,9 +459,9 @@ discard block |
||
| 459 | 459 | <thead> |
| 460 | 460 | <tr> |
| 461 | 461 | <?php |
| 462 | - foreach ( $columns as $key => $label ) { |
|
| 463 | - $key = esc_attr( $key ); |
|
| 464 | - $label = sanitize_text_field( $label ); |
|
| 462 | + foreach ($columns as $key => $label) { |
|
| 463 | + $key = esc_attr($key); |
|
| 464 | + $label = sanitize_text_field($label); |
|
| 465 | 465 | $class = 'text-left'; |
| 466 | 466 | |
| 467 | 467 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -472,57 +472,57 @@ discard block |
||
| 472 | 472 | |
| 473 | 473 | <tbody> |
| 474 | 474 | |
| 475 | - <?php if ( empty( $payments ) ) : ?> |
|
| 475 | + <?php if (empty($payments)) : ?> |
|
| 476 | 476 | <tr> |
| 477 | 477 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
| 478 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
| 478 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
| 479 | 479 | </td> |
| 480 | 480 | </tr> |
| 481 | 481 | <?php endif; ?> |
| 482 | 482 | |
| 483 | 483 | <?php |
| 484 | 484 | |
| 485 | - foreach( $payments as $payment ) : |
|
| 485 | + foreach ($payments as $payment) : |
|
| 486 | 486 | |
| 487 | 487 | // Ensure that we have an invoice. |
| 488 | - $payment = new WPInv_Invoice( $payment ); |
|
| 488 | + $payment = new WPInv_Invoice($payment); |
|
| 489 | 489 | |
| 490 | 490 | // Abort if the invoice is invalid... |
| 491 | - if ( ! $payment->exists() ) { |
|
| 491 | + if (!$payment->exists()) { |
|
| 492 | 492 | continue; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | // ... or belongs to a different subscription. |
| 496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 496 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
| 497 | 497 | continue; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | echo '<tr>'; |
| 501 | 501 | |
| 502 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 502 | + foreach (array_keys($columns) as $key) { |
|
| 503 | 503 | |
| 504 | 504 | $class = 'text-left'; |
| 505 | 505 | |
| 506 | 506 | echo "<td class='p-2 $class'>"; |
| 507 | 507 | |
| 508 | - switch( $key ) { |
|
| 508 | + switch ($key) { |
|
| 509 | 509 | |
| 510 | 510 | case 'total': |
| 511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
| 511 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
| 512 | 512 | break; |
| 513 | 513 | |
| 514 | 514 | case 'relationship': |
| 515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 515 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
| 516 | 516 | break; |
| 517 | 517 | |
| 518 | 518 | case 'date': |
| 519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 519 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
| 520 | 520 | break; |
| 521 | 521 | |
| 522 | 522 | case 'status': |
| 523 | 523 | |
| 524 | 524 | $status = $payment->get_status_nicename(); |
| 525 | - if ( is_admin() ) { |
|
| 525 | + if (is_admin()) { |
|
| 526 | 526 | $status = $payment->get_status_label_html(); |
| 527 | 527 | } |
| 528 | 528 | |
@@ -530,13 +530,13 @@ discard block |
||
| 530 | 530 | break; |
| 531 | 531 | |
| 532 | 532 | case 'invoice': |
| 533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 533 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
| 534 | 534 | |
| 535 | - if ( ! is_admin() ) { |
|
| 536 | - $link = esc_url( $payment->get_view_url() ); |
|
| 535 | + if (!is_admin()) { |
|
| 536 | + $link = esc_url($payment->get_view_url()); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
| 539 | + $invoice = sanitize_text_field($payment->get_number()); |
|
| 540 | 540 | echo "<a href='$link'>$invoice</a>"; |
| 541 | 541 | break; |
| 542 | 542 | } |
@@ -564,12 +564,12 @@ discard block |
||
| 564 | 564 | * |
| 565 | 565 | * @param WPInv_Subscription $subscription |
| 566 | 566 | */ |
| 567 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
| 567 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
| 568 | 568 | |
| 569 | 569 | // Fetch the subscription group. |
| 570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 570 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
| 571 | 571 | |
| 572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 572 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
| 573 | 573 | return; |
| 574 | 574 | } |
| 575 | 575 | |
@@ -577,12 +577,12 @@ discard block |
||
| 577 | 577 | $columns = apply_filters( |
| 578 | 578 | 'getpaid_subscription_item_details_columns', |
| 579 | 579 | array( |
| 580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 581 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 580 | + 'item_name' => __('Item', 'invoicing'), |
|
| 581 | + 'price' => __('Price', 'invoicing'), |
|
| 582 | + 'tax' => __('Tax', 'invoicing'), |
|
| 583 | + 'discount' => __('Discount', 'invoicing'), |
|
| 584 | 584 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
| 585 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 585 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
| 586 | 586 | ), |
| 587 | 587 | $subscription |
| 588 | 588 | ); |
@@ -591,13 +591,13 @@ discard block |
||
| 591 | 591 | |
| 592 | 592 | $invoice = $subscription->get_parent_invoice(); |
| 593 | 593 | |
| 594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 595 | - unset( $columns['tax'] ); |
|
| 594 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
| 595 | + unset($columns['tax']); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | $table_class = 'w-100 bg-white'; |
| 599 | 599 | |
| 600 | - if ( ! is_admin() ) { |
|
| 600 | + if (!is_admin()) { |
|
| 601 | 601 | $table_class = 'table table-bordered'; |
| 602 | 602 | } |
| 603 | 603 | |
@@ -610,9 +610,9 @@ discard block |
||
| 610 | 610 | <tr> |
| 611 | 611 | <?php |
| 612 | 612 | |
| 613 | - foreach ( $columns as $key => $label ) { |
|
| 614 | - $key = esc_attr( $key ); |
|
| 615 | - $label = sanitize_text_field( $label ); |
|
| 613 | + foreach ($columns as $key => $label) { |
|
| 614 | + $key = esc_attr($key); |
|
| 615 | + $label = sanitize_text_field($label); |
|
| 616 | 616 | $class = 'text-left'; |
| 617 | 617 | |
| 618 | 618 | echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -625,48 +625,48 @@ discard block |
||
| 625 | 625 | |
| 626 | 626 | <?php |
| 627 | 627 | |
| 628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
| 628 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
| 629 | 629 | |
| 630 | 630 | echo '<tr>'; |
| 631 | 631 | |
| 632 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 632 | + foreach (array_keys($columns) as $key) { |
|
| 633 | 633 | |
| 634 | 634 | $class = 'text-left'; |
| 635 | 635 | |
| 636 | 636 | echo "<td class='p-2 $class'>"; |
| 637 | 637 | |
| 638 | - switch( $key ) { |
|
| 638 | + switch ($key) { |
|
| 639 | 639 | |
| 640 | 640 | case 'item_name': |
| 641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 641 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
| 642 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
| 643 | 643 | |
| 644 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 645 | - echo sanitize_text_field( $item_name ); |
|
| 644 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
| 645 | + echo sanitize_text_field($item_name); |
|
| 646 | 646 | } else { |
| 647 | - printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 647 | + printf('%1$s x %2$d', sanitize_text_field($item_name), (float) $subscription_group_item['quantity']); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | break; |
| 651 | 651 | |
| 652 | 652 | case 'price': |
| 653 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 653 | + echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
| 654 | 654 | break; |
| 655 | 655 | |
| 656 | 656 | case 'tax': |
| 657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 657 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
| 658 | 658 | break; |
| 659 | 659 | |
| 660 | 660 | case 'discount': |
| 661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 661 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
| 662 | 662 | break; |
| 663 | 663 | |
| 664 | 664 | case 'initial': |
| 665 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 665 | + echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
| 666 | 666 | break; |
| 667 | 667 | |
| 668 | 668 | case 'recurring': |
| 669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
| 669 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
| 670 | 670 | break; |
| 671 | 671 | |
| 672 | 672 | } |
@@ -679,24 +679,24 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | endforeach; |
| 681 | 681 | |
| 682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 682 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
| 683 | 683 | |
| 684 | 684 | echo '<tr>'; |
| 685 | 685 | |
| 686 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 686 | + foreach (array_keys($columns) as $key) { |
|
| 687 | 687 | |
| 688 | 688 | $class = 'text-left'; |
| 689 | 689 | |
| 690 | 690 | echo "<td class='p-2 $class'>"; |
| 691 | 691 | |
| 692 | - switch( $key ) { |
|
| 692 | + switch ($key) { |
|
| 693 | 693 | |
| 694 | 694 | case 'item_name': |
| 695 | - echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
| 695 | + echo sanitize_text_field($subscription_group_fee['name']); |
|
| 696 | 696 | break; |
| 697 | 697 | |
| 698 | 698 | case 'price': |
| 699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 699 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 700 | 700 | break; |
| 701 | 701 | |
| 702 | 702 | case 'tax': |
@@ -708,11 +708,11 @@ discard block |
||
| 708 | 708 | break; |
| 709 | 709 | |
| 710 | 710 | case 'initial': |
| 711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 711 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 712 | 712 | break; |
| 713 | 713 | |
| 714 | 714 | case 'recurring': |
| 715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
| 715 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
| 716 | 716 | break; |
| 717 | 717 | |
| 718 | 718 | } |
@@ -741,12 +741,12 @@ discard block |
||
| 741 | 741 | * @param WPInv_Subscription $subscription |
| 742 | 742 | * @param bool $skip_current |
| 743 | 743 | */ |
| 744 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
| 744 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
| 745 | 745 | |
| 746 | 746 | // Fetch the subscription groups. |
| 747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 747 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
| 748 | 748 | |
| 749 | - if ( empty( $subscription_groups ) ) { |
|
| 749 | + if (empty($subscription_groups)) { |
|
| 750 | 750 | return; |
| 751 | 751 | } |
| 752 | 752 | |
@@ -754,23 +754,23 @@ discard block |
||
| 754 | 754 | $columns = apply_filters( |
| 755 | 755 | 'getpaid_subscription_related_subscriptions_columns', |
| 756 | 756 | array( |
| 757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 761 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 762 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 757 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 758 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 759 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
| 760 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 761 | + 'item' => __('Items', 'invoicing'), |
|
| 762 | + 'status' => __('Status', 'invoicing'), |
|
| 763 | 763 | ), |
| 764 | 764 | $subscription |
| 765 | 765 | ); |
| 766 | 766 | |
| 767 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 767 | + if ($subscription->get_status() == 'pending') { |
|
| 768 | + unset($columns['start_date'], $columns['renewal_date']); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | $table_class = 'w-100 bg-white'; |
| 772 | 772 | |
| 773 | - if ( ! is_admin() ) { |
|
| 773 | + if (!is_admin()) { |
|
| 774 | 774 | $table_class = 'table table-bordered'; |
| 775 | 775 | } |
| 776 | 776 | |
@@ -783,9 +783,9 @@ discard block |
||
| 783 | 783 | <tr> |
| 784 | 784 | <?php |
| 785 | 785 | |
| 786 | - foreach ( $columns as $key => $label ) { |
|
| 787 | - $key = esc_attr( $key ); |
|
| 788 | - $label = sanitize_text_field( $label ); |
|
| 786 | + foreach ($columns as $key => $label) { |
|
| 787 | + $key = esc_attr($key); |
|
| 788 | + $label = sanitize_text_field($label); |
|
| 789 | 789 | $class = 'text-left'; |
| 790 | 790 | |
| 791 | 791 | echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -798,62 +798,62 @@ discard block |
||
| 798 | 798 | |
| 799 | 799 | <?php |
| 800 | 800 | |
| 801 | - foreach( $subscription_groups as $subscription_group ) : |
|
| 801 | + foreach ($subscription_groups as $subscription_group) : |
|
| 802 | 802 | |
| 803 | 803 | // Do not list current subscription. |
| 804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 804 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
| 805 | 805 | continue; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | // Ensure the subscription exists. |
| 809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 809 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
| 810 | 810 | |
| 811 | - if ( ! $_suscription->exists() ) { |
|
| 811 | + if (!$_suscription->exists()) { |
|
| 812 | 812 | continue; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | echo '<tr>'; |
| 816 | 816 | |
| 817 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 817 | + foreach (array_keys($columns) as $key) { |
|
| 818 | 818 | |
| 819 | 819 | $class = 'text-left'; |
| 820 | 820 | |
| 821 | 821 | echo "<td class='p-2 $class'>"; |
| 822 | 822 | |
| 823 | - switch( $key ) { |
|
| 823 | + switch ($key) { |
|
| 824 | 824 | |
| 825 | 825 | case 'status': |
| 826 | 826 | echo $_suscription->get_status_label_html(); |
| 827 | 827 | break; |
| 828 | 828 | |
| 829 | 829 | case 'item': |
| 830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 831 | - echo implode( ' | ', $markup ); |
|
| 830 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 831 | + echo implode(' | ', $markup); |
|
| 832 | 832 | break; |
| 833 | 833 | |
| 834 | 834 | case 'renewals': |
| 835 | 835 | $max_bills = $_suscription->get_bill_times(); |
| 836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 836 | + echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
| 837 | 837 | break; |
| 838 | 838 | |
| 839 | 839 | case 'renewal_date': |
| 840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
| 840 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "—"; |
|
| 841 | 841 | break; |
| 842 | 842 | |
| 843 | 843 | case 'start_date': |
| 844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
| 844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value($_suscription->get_date_created()); |
|
| 845 | 845 | break; |
| 846 | 846 | |
| 847 | 847 | case 'subscription': |
| 848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 848 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
| 849 | 849 | printf( |
| 850 | 850 | '%1$s#%2$s%3$s', |
| 851 | - '<a href="' . esc_url( $url ) . '">', |
|
| 852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 851 | + '<a href="' . esc_url($url) . '">', |
|
| 852 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
| 853 | 853 | '</a>' |
| 854 | 854 | ); |
| 855 | 855 | |
| 856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
| 856 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
| 857 | 857 | break; |
| 858 | 858 | |
| 859 | 859 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) { |
| 52 | 52 | $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id ); |
| 53 | - $matching_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 53 | + $matching_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 54 | 54 | return reset( $matching_group ); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | function getpaid_get_subscription( $subscription ) { |
| 65 | 65 | |
| 66 | - if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
| 67 | - $subscription = new WPInv_Subscription( $subscription ); |
|
| 68 | - } |
|
| 66 | + if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
| 67 | + $subscription = new WPInv_Subscription( $subscription ); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - return $subscription->exists() ? $subscription : false; |
|
| 70 | + return $subscription->exists() ? $subscription : false; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -81,28 +81,28 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
| 83 | 83 | |
| 84 | - // Do not retrieve all fields if we just want the count. |
|
| 85 | - if ( 'count' == $return ) { |
|
| 86 | - $args['fields'] = 'id'; |
|
| 87 | - $args['number'] = 1; |
|
| 88 | - } |
|
| 84 | + // Do not retrieve all fields if we just want the count. |
|
| 85 | + if ( 'count' == $return ) { |
|
| 86 | + $args['fields'] = 'id'; |
|
| 87 | + $args['number'] = 1; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - // Do not count all matches if we just want the results. |
|
| 91 | - if ( 'results' == $return ) { |
|
| 92 | - $args['count_total'] = false; |
|
| 93 | - } |
|
| 90 | + // Do not count all matches if we just want the results. |
|
| 91 | + if ( 'results' == $return ) { |
|
| 92 | + $args['count_total'] = false; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
| 95 | + $query = new GetPaid_Subscriptions_Query( $args ); |
|
| 96 | 96 | |
| 97 | - if ( 'results' == $return ) { |
|
| 98 | - return $query->get_results(); |
|
| 99 | - } |
|
| 97 | + if ( 'results' == $return ) { |
|
| 98 | + return $query->get_results(); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - if ( 'count' == $return ) { |
|
| 102 | - return $query->get_total(); |
|
| 103 | - } |
|
| 101 | + if ( 'count' == $return ) { |
|
| 102 | + return $query->get_total(); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $query; |
|
| 105 | + return $query; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -112,18 +112,18 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | function getpaid_get_subscription_statuses() { |
| 114 | 114 | |
| 115 | - return apply_filters( |
|
| 116 | - 'getpaid_get_subscription_statuses', |
|
| 117 | - array( |
|
| 118 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
| 119 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
| 120 | - 'active' => __( 'Active', 'invoicing' ), |
|
| 121 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
| 122 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
| 123 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
| 124 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
| 125 | - ) |
|
| 126 | - ); |
|
| 115 | + return apply_filters( |
|
| 116 | + 'getpaid_get_subscription_statuses', |
|
| 117 | + array( |
|
| 118 | + 'pending' => __( 'Pending', 'invoicing' ), |
|
| 119 | + 'trialling' => __( 'Trialing', 'invoicing' ), |
|
| 120 | + 'active' => __( 'Active', 'invoicing' ), |
|
| 121 | + 'failing' => __( 'Failing', 'invoicing' ), |
|
| 122 | + 'expired' => __( 'Expired', 'invoicing' ), |
|
| 123 | + 'completed' => __( 'Complete', 'invoicing' ), |
|
| 124 | + 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
| 125 | + ) |
|
| 126 | + ); |
|
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | 135 | function getpaid_get_subscription_status_label( $status ) { |
| 136 | - $statuses = getpaid_get_subscription_statuses(); |
|
| 137 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
| 136 | + $statuses = getpaid_get_subscription_statuses(); |
|
| 137 | + return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -144,18 +144,18 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | function getpaid_get_subscription_status_classes() { |
| 146 | 146 | |
| 147 | - return apply_filters( |
|
| 148 | - 'getpaid_get_subscription_status_classes', |
|
| 149 | - array( |
|
| 150 | - 'pending' => 'badge-dark', |
|
| 151 | - 'trialling' => 'badge-info', |
|
| 152 | - 'active' => 'badge-success', |
|
| 153 | - 'failing' => 'badge-warning', |
|
| 154 | - 'expired' => 'badge-danger', |
|
| 155 | - 'completed' => 'badge-primary', |
|
| 156 | - 'cancelled' => 'badge-secondary', |
|
| 157 | - ) |
|
| 158 | - ); |
|
| 147 | + return apply_filters( |
|
| 148 | + 'getpaid_get_subscription_status_classes', |
|
| 149 | + array( |
|
| 150 | + 'pending' => 'badge-dark', |
|
| 151 | + 'trialling' => 'badge-info', |
|
| 152 | + 'active' => 'badge-success', |
|
| 153 | + 'failing' => 'badge-warning', |
|
| 154 | + 'expired' => 'badge-danger', |
|
| 155 | + 'completed' => 'badge-primary', |
|
| 156 | + 'cancelled' => 'badge-secondary', |
|
| 157 | + ) |
|
| 158 | + ); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | function getpaid_get_subscription_status_counts( $args = array() ) { |
| 168 | 168 | |
| 169 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
| 170 | - $counts = array(); |
|
| 169 | + $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
| 170 | + $counts = array(); |
|
| 171 | 171 | |
| 172 | - foreach ( $statuses as $status ) { |
|
| 173 | - $_args = wp_parse_args( "status=$status", $args ); |
|
| 174 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
| 175 | - } |
|
| 172 | + foreach ( $statuses as $status ) { |
|
| 173 | + $_args = wp_parse_args( "status=$status", $args ); |
|
| 174 | + $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - return $counts; |
|
| 177 | + return $counts; |
|
| 178 | 178 | |
| 179 | 179 | } |
| 180 | 180 | |
@@ -185,32 +185,32 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | function getpaid_get_subscription_periods() { |
| 187 | 187 | |
| 188 | - return apply_filters( |
|
| 189 | - 'getpaid_get_subscription_periods', |
|
| 190 | - array( |
|
| 188 | + return apply_filters( |
|
| 189 | + 'getpaid_get_subscription_periods', |
|
| 190 | + array( |
|
| 191 | 191 | |
| 192 | - 'day' => array( |
|
| 193 | - 'singular' => __( '%s day', 'invoicing' ), |
|
| 194 | - 'plural' => __( '%d days', 'invoicing' ), |
|
| 195 | - ), |
|
| 192 | + 'day' => array( |
|
| 193 | + 'singular' => __( '%s day', 'invoicing' ), |
|
| 194 | + 'plural' => __( '%d days', 'invoicing' ), |
|
| 195 | + ), |
|
| 196 | 196 | |
| 197 | - 'week' => array( |
|
| 198 | - 'singular' => __( '%s week', 'invoicing' ), |
|
| 199 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
| 200 | - ), |
|
| 197 | + 'week' => array( |
|
| 198 | + 'singular' => __( '%s week', 'invoicing' ), |
|
| 199 | + 'plural' => __( '%d weeks', 'invoicing' ), |
|
| 200 | + ), |
|
| 201 | 201 | |
| 202 | - 'month' => array( |
|
| 203 | - 'singular' => __( '%s month', 'invoicing' ), |
|
| 204 | - 'plural' => __( '%d months', 'invoicing' ), |
|
| 205 | - ), |
|
| 202 | + 'month' => array( |
|
| 203 | + 'singular' => __( '%s month', 'invoicing' ), |
|
| 204 | + 'plural' => __( '%d months', 'invoicing' ), |
|
| 205 | + ), |
|
| 206 | 206 | |
| 207 | - 'year' => array( |
|
| 208 | - 'singular' => __( '%s year', 'invoicing' ), |
|
| 209 | - 'plural' => __( '%d years', 'invoicing' ), |
|
| 210 | - ), |
|
| 207 | + 'year' => array( |
|
| 208 | + 'singular' => __( '%s year', 'invoicing' ), |
|
| 209 | + 'plural' => __( '%d years', 'invoicing' ), |
|
| 210 | + ), |
|
| 211 | 211 | |
| 212 | - ) |
|
| 213 | - ); |
|
| 212 | + ) |
|
| 213 | + ); |
|
| 214 | 214 | |
| 215 | 215 | } |
| 216 | 216 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @return int |
| 222 | 222 | */ |
| 223 | 223 | function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
| 224 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
| 224 | + return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @return string |
| 232 | 232 | */ |
| 233 | 233 | function getpaid_get_subscription_trial_period_period( $trial_period ) { |
| 234 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
| 234 | + return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | * @return string |
| 243 | 243 | */ |
| 244 | 244 | function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
| 245 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
| 246 | - return strtolower( sanitize_text_field( $label ) ); |
|
| 245 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
| 246 | + return strtolower( sanitize_text_field( $label ) ); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -254,22 +254,22 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
| 256 | 256 | |
| 257 | - $periods = getpaid_get_subscription_periods(); |
|
| 258 | - $period = strtolower( $period ); |
|
| 257 | + $periods = getpaid_get_subscription_periods(); |
|
| 258 | + $period = strtolower( $period ); |
|
| 259 | 259 | |
| 260 | - if ( isset( $periods[ $period ] ) ) { |
|
| 261 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
| 262 | - } |
|
| 260 | + if ( isset( $periods[ $period ] ) ) { |
|
| 261 | + return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - // Backwards compatibility. |
|
| 265 | - foreach ( $periods as $key => $data ) { |
|
| 266 | - if ( strpos( $key, $period ) === 0 ) { |
|
| 267 | - return sprintf( $data['singular'], $singular_prefix ); |
|
| 268 | - } |
|
| 269 | - } |
|
| 264 | + // Backwards compatibility. |
|
| 265 | + foreach ( $periods as $key => $data ) { |
|
| 266 | + if ( strpos( $key, $period ) === 0 ) { |
|
| 267 | + return sprintf( $data['singular'], $singular_prefix ); |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - // Invalid string. |
|
| 272 | - return ''; |
|
| 271 | + // Invalid string. |
|
| 272 | + return ''; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -281,22 +281,22 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
| 283 | 283 | |
| 284 | - $periods = getpaid_get_subscription_periods(); |
|
| 285 | - $period = strtolower( $period ); |
|
| 284 | + $periods = getpaid_get_subscription_periods(); |
|
| 285 | + $period = strtolower( $period ); |
|
| 286 | 286 | |
| 287 | - if ( isset( $periods[ $period ] ) ) { |
|
| 288 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
| 289 | - } |
|
| 287 | + if ( isset( $periods[ $period ] ) ) { |
|
| 288 | + return sprintf( $periods[ $period ]['plural'], $interval ); |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - // Backwards compatibility. |
|
| 292 | - foreach ( $periods as $key => $data ) { |
|
| 293 | - if ( strpos( $key, $period ) === 0 ) { |
|
| 294 | - return sprintf( $data['plural'], $interval ); |
|
| 295 | - } |
|
| 296 | - } |
|
| 291 | + // Backwards compatibility. |
|
| 292 | + foreach ( $periods as $key => $data ) { |
|
| 293 | + if ( strpos( $key, $period ) === 0 ) { |
|
| 294 | + return sprintf( $data['plural'], $interval ); |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - // Invalid string. |
|
| 299 | - return ''; |
|
| 298 | + // Invalid string. |
|
| 299 | + return ''; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -307,101 +307,101 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | function getpaid_get_formatted_subscription_amount( $subscription ) { |
| 309 | 309 | |
| 310 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 311 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 312 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
| 313 | - $bill_times = $subscription->get_bill_times(); |
|
| 310 | + $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 311 | + $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 312 | + $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
| 313 | + $bill_times = $subscription->get_bill_times(); |
|
| 314 | 314 | |
| 315 | - if ( ! empty( $bill_times ) ) { |
|
| 316 | - $bill_times = $subscription->get_frequency() * $bill_times; |
|
| 317 | - $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times ); |
|
| 318 | - } |
|
| 315 | + if ( ! empty( $bill_times ) ) { |
|
| 316 | + $bill_times = $subscription->get_frequency() * $bill_times; |
|
| 317 | + $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times ); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - // Trial periods. |
|
| 321 | - if ( $subscription->has_trial_period() ) { |
|
| 320 | + // Trial periods. |
|
| 321 | + if ( $subscription->has_trial_period() ) { |
|
| 322 | 322 | |
| 323 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
| 324 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
| 323 | + $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
| 324 | + $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
| 325 | 325 | |
| 326 | - if ( empty( $bill_times ) ) { |
|
| 326 | + if ( empty( $bill_times ) ) { |
|
| 327 | 327 | |
| 328 | - return sprintf( |
|
| 328 | + return sprintf( |
|
| 329 | 329 | |
| 330 | - // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
| 331 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
| 332 | - $initial, |
|
| 333 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
| 334 | - $recurring, |
|
| 335 | - $period |
|
| 330 | + // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
| 331 | + _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
| 332 | + $initial, |
|
| 333 | + getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
| 334 | + $recurring, |
|
| 335 | + $period |
|
| 336 | 336 | |
| 337 | - ); |
|
| 337 | + ); |
|
| 338 | 338 | |
| 339 | - } |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - return sprintf( |
|
| 341 | + return sprintf( |
|
| 342 | 342 | |
| 343 | - // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times |
|
| 344 | - _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
| 345 | - $initial, |
|
| 346 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
| 347 | - $recurring, |
|
| 348 | - $period, |
|
| 349 | - $bill_times |
|
| 350 | - ); |
|
| 343 | + // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times |
|
| 344 | + _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
| 345 | + $initial, |
|
| 346 | + getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
| 347 | + $recurring, |
|
| 348 | + $period, |
|
| 349 | + $bill_times |
|
| 350 | + ); |
|
| 351 | 351 | |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - if ( $initial != $recurring ) { |
|
| 354 | + if ( $initial != $recurring ) { |
|
| 355 | 355 | |
| 356 | - if ( empty( $bill_times ) ) { |
|
| 356 | + if ( empty( $bill_times ) ) { |
|
| 357 | 357 | |
| 358 | - return sprintf( |
|
| 358 | + return sprintf( |
|
| 359 | 359 | |
| 360 | - // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
|
| 361 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
| 362 | - $initial, |
|
| 363 | - $recurring, |
|
| 364 | - $period |
|
| 360 | + // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
|
| 361 | + _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
| 362 | + $initial, |
|
| 363 | + $recurring, |
|
| 364 | + $period |
|
| 365 | 365 | |
| 366 | - ); |
|
| 366 | + ); |
|
| 367 | 367 | |
| 368 | - } |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - return sprintf( |
|
| 370 | + return sprintf( |
|
| 371 | 371 | |
| 372 | - // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times |
|
| 373 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ), |
|
| 374 | - $initial, |
|
| 375 | - $recurring, |
|
| 376 | - $period, |
|
| 377 | - $bill_times |
|
| 372 | + // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times |
|
| 373 | + _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ), |
|
| 374 | + $initial, |
|
| 375 | + $recurring, |
|
| 376 | + $period, |
|
| 377 | + $bill_times |
|
| 378 | 378 | |
| 379 | - ); |
|
| 379 | + ); |
|
| 380 | 380 | |
| 381 | - } |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - if ( empty( $bill_times ) ) { |
|
| 383 | + if ( empty( $bill_times ) ) { |
|
| 384 | 384 | |
| 385 | - return sprintf( |
|
| 385 | + return sprintf( |
|
| 386 | 386 | |
| 387 | - // translators: $1: is the recurring amount, $2: is the recurring period |
|
| 388 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
| 389 | - $initial, |
|
| 390 | - $period |
|
| 387 | + // translators: $1: is the recurring amount, $2: is the recurring period |
|
| 388 | + _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
| 389 | + $initial, |
|
| 390 | + $period |
|
| 391 | 391 | |
| 392 | - ); |
|
| 392 | + ); |
|
| 393 | 393 | |
| 394 | - } |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - return sprintf( |
|
| 396 | + return sprintf( |
|
| 397 | 397 | |
| 398 | - // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period |
|
| 399 | - _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
| 400 | - $bill_times, |
|
| 401 | - $initial, |
|
| 402 | - $period |
|
| 398 | + // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period |
|
| 399 | + _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
| 400 | + $bill_times, |
|
| 401 | + $initial, |
|
| 402 | + $period |
|
| 403 | 403 | |
| 404 | - ); |
|
| 404 | + ); |
|
| 405 | 405 | |
| 406 | 406 | } |
| 407 | 407 | |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | * @return WPInv_Subscription|false |
| 413 | 413 | */ |
| 414 | 414 | function getpaid_get_invoice_subscription( $invoice ) { |
| 415 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 415 | + return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | * @param WPInv_Invoice $invoice |
| 422 | 422 | */ |
| 423 | 423 | function getpaid_activate_invoice_subscription( $invoice ) { |
| 424 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 425 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
| 426 | - $subscription->activate(); |
|
| 427 | - } |
|
| 424 | + $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 425 | + if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
| 426 | + $subscription->activate(); |
|
| 427 | + } |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * @return WPInv_Subscriptions |
| 434 | 434 | */ |
| 435 | 435 | function getpaid_subscriptions() { |
| 436 | - return getpaid()->get( 'subscriptions' ); |
|
| 436 | + return getpaid()->get( 'subscriptions' ); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | /** |
@@ -452,15 +452,15 @@ discard block |
||
| 452 | 452 | return false; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - // Fetch the invoice subscription. |
|
| 456 | - $subscription = getpaid_get_subscriptions( |
|
| 457 | - array( |
|
| 458 | - 'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(), |
|
| 459 | - 'number' => 1, |
|
| 460 | - ) |
|
| 461 | - ); |
|
| 455 | + // Fetch the invoice subscription. |
|
| 456 | + $subscription = getpaid_get_subscriptions( |
|
| 457 | + array( |
|
| 458 | + 'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(), |
|
| 459 | + 'number' => 1, |
|
| 460 | + ) |
|
| 461 | + ); |
|
| 462 | 462 | |
| 463 | - return empty( $subscription ) ? false : $subscription[0]; |
|
| 463 | + return empty( $subscription ) ? false : $subscription[0]; |
|
| 464 | 464 | |
| 465 | 465 | } |
| 466 | 466 | |
@@ -477,48 +477,48 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | function getpaid_get_recurring_item_key( $cart_item ) { |
| 479 | 479 | |
| 480 | - $cart_key = 'renews_'; |
|
| 481 | - $interval = $cart_item->get_recurring_interval(); |
|
| 482 | - $period = $cart_item->get_recurring_period( true ); |
|
| 483 | - $length = $cart_item->get_recurring_limit() * $interval; |
|
| 484 | - $trial_period = $cart_item->get_trial_period( true ); |
|
| 485 | - $trial_length = $cart_item->get_trial_interval(); |
|
| 486 | - |
|
| 487 | - // First start with the billing interval and period |
|
| 488 | - switch ( $interval ) { |
|
| 489 | - case 1 : |
|
| 490 | - if ( 'day' == $period ) { |
|
| 491 | - $cart_key .= 'daily'; |
|
| 492 | - } else { |
|
| 493 | - $cart_key .= sprintf( '%sly', $period ); |
|
| 494 | - } |
|
| 495 | - break; |
|
| 496 | - case 2 : |
|
| 497 | - $cart_key .= sprintf( 'every_2nd_%s', $period ); |
|
| 498 | - break; |
|
| 499 | - case 3 : |
|
| 500 | - $cart_key .= sprintf( 'every_3rd_%s', $period ); |
|
| 501 | - break; |
|
| 502 | - default: |
|
| 503 | - $cart_key .= sprintf( 'every_%dth_%s', $interval, $period ); |
|
| 504 | - break; |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - // Maybe add the optional maximum billing periods... |
|
| 508 | - if ( $length > 0 ) { |
|
| 509 | - $cart_key .= '_for_'; |
|
| 510 | - $cart_key .= sprintf( '%d_%s', $length, $period ); |
|
| 511 | - if ( $length > 1 ) { |
|
| 512 | - $cart_key .= 's'; |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - // And an optional free trial. |
|
| 517 | - if ( $cart_item->has_free_trial() ) { |
|
| 518 | - $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period ); |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item ); |
|
| 480 | + $cart_key = 'renews_'; |
|
| 481 | + $interval = $cart_item->get_recurring_interval(); |
|
| 482 | + $period = $cart_item->get_recurring_period( true ); |
|
| 483 | + $length = $cart_item->get_recurring_limit() * $interval; |
|
| 484 | + $trial_period = $cart_item->get_trial_period( true ); |
|
| 485 | + $trial_length = $cart_item->get_trial_interval(); |
|
| 486 | + |
|
| 487 | + // First start with the billing interval and period |
|
| 488 | + switch ( $interval ) { |
|
| 489 | + case 1 : |
|
| 490 | + if ( 'day' == $period ) { |
|
| 491 | + $cart_key .= 'daily'; |
|
| 492 | + } else { |
|
| 493 | + $cart_key .= sprintf( '%sly', $period ); |
|
| 494 | + } |
|
| 495 | + break; |
|
| 496 | + case 2 : |
|
| 497 | + $cart_key .= sprintf( 'every_2nd_%s', $period ); |
|
| 498 | + break; |
|
| 499 | + case 3 : |
|
| 500 | + $cart_key .= sprintf( 'every_3rd_%s', $period ); |
|
| 501 | + break; |
|
| 502 | + default: |
|
| 503 | + $cart_key .= sprintf( 'every_%dth_%s', $interval, $period ); |
|
| 504 | + break; |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + // Maybe add the optional maximum billing periods... |
|
| 508 | + if ( $length > 0 ) { |
|
| 509 | + $cart_key .= '_for_'; |
|
| 510 | + $cart_key .= sprintf( '%d_%s', $length, $period ); |
|
| 511 | + if ( $length > 1 ) { |
|
| 512 | + $cart_key .= 's'; |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + // And an optional free trial. |
|
| 517 | + if ( $cart_item->has_free_trial() ) { |
|
| 518 | + $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period ); |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item ); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -529,17 +529,17 @@ discard block |
||
| 529 | 529 | */ |
| 530 | 530 | function getpaid_get_subscription_groups( $invoice ) { |
| 531 | 531 | |
| 532 | - // Generate subscription groups. |
|
| 533 | - $subscription_groups = array(); |
|
| 534 | - foreach ( $invoice->get_items() as $item ) { |
|
| 532 | + // Generate subscription groups. |
|
| 533 | + $subscription_groups = array(); |
|
| 534 | + foreach ( $invoice->get_items() as $item ) { |
|
| 535 | 535 | |
| 536 | - if ( $item->is_recurring() ) { |
|
| 537 | - $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item; |
|
| 538 | - } |
|
| 536 | + if ( $item->is_recurring() ) { |
|
| 537 | + $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item; |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | - } |
|
| 540 | + } |
|
| 541 | 541 | |
| 542 | - return $subscription_groups; |
|
| 542 | + return $subscription_groups; |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -553,57 +553,57 @@ discard block |
||
| 553 | 553 | */ |
| 554 | 554 | function getpaid_calculate_subscription_totals( $invoice ) { |
| 555 | 555 | |
| 556 | - // Generate subscription groups. |
|
| 557 | - $subscription_groups = getpaid_get_subscription_groups( $invoice ); |
|
| 556 | + // Generate subscription groups. |
|
| 557 | + $subscription_groups = getpaid_get_subscription_groups( $invoice ); |
|
| 558 | 558 | |
| 559 | - // Now let's calculate the totals for each group of subscriptions |
|
| 560 | - $subscription_totals = array(); |
|
| 559 | + // Now let's calculate the totals for each group of subscriptions |
|
| 560 | + $subscription_totals = array(); |
|
| 561 | 561 | |
| 562 | - foreach ( $subscription_groups as $subscription_key => $items ) { |
|
| 562 | + foreach ( $subscription_groups as $subscription_key => $items ) { |
|
| 563 | 563 | |
| 564 | - if ( empty( $subscription_totals[ $subscription_key ] ) ) { |
|
| 564 | + if ( empty( $subscription_totals[ $subscription_key ] ) ) { |
|
| 565 | 565 | |
| 566 | - $subscription_totals[ $subscription_key ] = array( |
|
| 567 | - 'initial_total' => 0, |
|
| 568 | - 'recurring_total' => 0, |
|
| 569 | - 'items' => array(), |
|
| 570 | - 'trialling' => false, |
|
| 571 | - ); |
|
| 566 | + $subscription_totals[ $subscription_key ] = array( |
|
| 567 | + 'initial_total' => 0, |
|
| 568 | + 'recurring_total' => 0, |
|
| 569 | + 'items' => array(), |
|
| 570 | + 'trialling' => false, |
|
| 571 | + ); |
|
| 572 | 572 | |
| 573 | - } |
|
| 573 | + } |
|
| 574 | 574 | |
| 575 | - /** |
|
| 576 | - * Get the totals of the group. |
|
| 577 | - * @var GetPaid_Form_Item $item |
|
| 578 | - */ |
|
| 579 | - foreach ( $items as $item ) { |
|
| 575 | + /** |
|
| 576 | + * Get the totals of the group. |
|
| 577 | + * @var GetPaid_Form_Item $item |
|
| 578 | + */ |
|
| 579 | + foreach ( $items as $item ) { |
|
| 580 | 580 | |
| 581 | - $subscription_totals[ $subscription_key ]['items'][$item->get_id()] = $item->prepare_data_for_saving(); |
|
| 582 | - $subscription_totals[ $subscription_key ]['item_id'] = $item->get_id(); |
|
| 583 | - $subscription_totals[ $subscription_key ]['period'] = $item->get_recurring_period( true ); |
|
| 584 | - $subscription_totals[ $subscription_key ]['interval'] = $item->get_recurring_interval(); |
|
| 585 | - $subscription_totals[ $subscription_key ]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
| 586 | - $subscription_totals[ $subscription_key ]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
| 587 | - $subscription_totals[ $subscription_key ]['recurring_limit'] = $item->get_recurring_limit(); |
|
| 581 | + $subscription_totals[ $subscription_key ]['items'][$item->get_id()] = $item->prepare_data_for_saving(); |
|
| 582 | + $subscription_totals[ $subscription_key ]['item_id'] = $item->get_id(); |
|
| 583 | + $subscription_totals[ $subscription_key ]['period'] = $item->get_recurring_period( true ); |
|
| 584 | + $subscription_totals[ $subscription_key ]['interval'] = $item->get_recurring_interval(); |
|
| 585 | + $subscription_totals[ $subscription_key ]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
| 586 | + $subscription_totals[ $subscription_key ]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
| 587 | + $subscription_totals[ $subscription_key ]['recurring_limit'] = $item->get_recurring_limit(); |
|
| 588 | 588 | |
| 589 | - // Calculate the next renewal date. |
|
| 590 | - $period = $item->get_recurring_period( true ); |
|
| 591 | - $interval = $item->get_recurring_interval(); |
|
| 589 | + // Calculate the next renewal date. |
|
| 590 | + $period = $item->get_recurring_period( true ); |
|
| 591 | + $interval = $item->get_recurring_interval(); |
|
| 592 | 592 | |
| 593 | - // If the subscription item has a trial period... |
|
| 594 | - if ( $item->has_free_trial() ) { |
|
| 595 | - $period = $item->get_trial_period( true ); |
|
| 596 | - $interval = $item->get_trial_interval(); |
|
| 597 | - $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period; |
|
| 598 | - } |
|
| 593 | + // If the subscription item has a trial period... |
|
| 594 | + if ( $item->has_free_trial() ) { |
|
| 595 | + $period = $item->get_trial_period( true ); |
|
| 596 | + $interval = $item->get_trial_interval(); |
|
| 597 | + $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period; |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) ); |
|
| 600 | + $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) ); |
|
| 601 | 601 | |
| 602 | - } |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | - } |
|
| 604 | + } |
|
| 605 | 605 | |
| 606 | - return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice ); |
|
| 606 | + return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice ); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | /** |
@@ -614,17 +614,17 @@ discard block |
||
| 614 | 614 | */ |
| 615 | 615 | function getpaid_should_group_subscriptions( $invoice ) { |
| 616 | 616 | |
| 617 | - $recurring_items = 0; |
|
| 617 | + $recurring_items = 0; |
|
| 618 | 618 | |
| 619 | - foreach ( $invoice->get_items() as $item ) { |
|
| 619 | + foreach ( $invoice->get_items() as $item ) { |
|
| 620 | 620 | |
| 621 | - if ( $item->is_recurring() ) { |
|
| 622 | - $recurring_items ++; |
|
| 623 | - } |
|
| 621 | + if ( $item->is_recurring() ) { |
|
| 622 | + $recurring_items ++; |
|
| 623 | + } |
|
| 624 | 624 | |
| 625 | - } |
|
| 625 | + } |
|
| 626 | 626 | |
| 627 | - return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice ); |
|
| 627 | + return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice ); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
@@ -635,40 +635,40 @@ discard block |
||
| 635 | 635 | * @return int |
| 636 | 636 | */ |
| 637 | 637 | function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) { |
| 638 | - global $wpdb; |
|
| 638 | + global $wpdb; |
|
| 639 | 639 | |
| 640 | - $parent_invoice_id = (int) $parent_invoice_id; |
|
| 640 | + $parent_invoice_id = (int) $parent_invoice_id; |
|
| 641 | 641 | |
| 642 | - if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) { |
|
| 642 | + if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) { |
|
| 643 | 643 | |
| 644 | - return (int) $wpdb->get_var( |
|
| 645 | - $wpdb->prepare( |
|
| 646 | - "SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )", |
|
| 647 | - $parent_invoice_id, |
|
| 648 | - $parent_invoice_id |
|
| 649 | - ) |
|
| 650 | - ); |
|
| 644 | + return (int) $wpdb->get_var( |
|
| 645 | + $wpdb->prepare( |
|
| 646 | + "SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )", |
|
| 647 | + $parent_invoice_id, |
|
| 648 | + $parent_invoice_id |
|
| 649 | + ) |
|
| 650 | + ); |
|
| 651 | 651 | |
| 652 | - } |
|
| 652 | + } |
|
| 653 | 653 | |
| 654 | - $invoice_ids = $wpdb->get_col( |
|
| 655 | - $wpdb->prepare( |
|
| 656 | - "SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )", |
|
| 657 | - $parent_invoice_id, |
|
| 658 | - $parent_invoice_id |
|
| 659 | - ) |
|
| 660 | - ); |
|
| 654 | + $invoice_ids = $wpdb->get_col( |
|
| 655 | + $wpdb->prepare( |
|
| 656 | + "SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )", |
|
| 657 | + $parent_invoice_id, |
|
| 658 | + $parent_invoice_id |
|
| 659 | + ) |
|
| 660 | + ); |
|
| 661 | 661 | |
| 662 | - $count = 0; |
|
| 662 | + $count = 0; |
|
| 663 | 663 | |
| 664 | - foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) { |
|
| 664 | + foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) { |
|
| 665 | 665 | |
| 666 | - if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) { |
|
| 667 | - $count ++; |
|
| 668 | - continue; |
|
| 669 | - } |
|
| 666 | + if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) { |
|
| 667 | + $count ++; |
|
| 668 | + continue; |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | - } |
|
| 671 | + } |
|
| 672 | 672 | |
| 673 | - return $count; |
|
| 673 | + return $count; |
|
| 674 | 674 | } |
@@ -13,18 +13,18 @@ discard block |
||
| 13 | 13 | * @return WPInv_Subscription[]|WPInv_Subscription|false |
| 14 | 14 | * @since 2.3.0 |
| 15 | 15 | */ |
| 16 | -function getpaid_get_invoice_subscriptions( $invoice ) { |
|
| 16 | +function getpaid_get_invoice_subscriptions($invoice) { |
|
| 17 | 17 | |
| 18 | 18 | // Retrieve subscription groups. |
| 19 | - $subscription_ids = wp_list_pluck( getpaid_get_invoice_subscription_groups( $invoice->get_id() ), 'subscription_id' ); |
|
| 19 | + $subscription_ids = wp_list_pluck(getpaid_get_invoice_subscription_groups($invoice->get_id()), 'subscription_id'); |
|
| 20 | 20 | |
| 21 | 21 | // No subscription groups, normal subscription. |
| 22 | - if ( empty( $subscription_ids ) ) { |
|
| 23 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 22 | + if (empty($subscription_ids)) { |
|
| 23 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // Subscription groups. |
| 27 | - return array_filter( array_map( 'getpaid_get_subscription', $subscription_ids ) ); |
|
| 27 | + return array_filter(array_map('getpaid_get_subscription', $subscription_ids)); |
|
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | * @return array |
| 36 | 36 | * @since 2.3.0 |
| 37 | 37 | */ |
| 38 | -function getpaid_get_invoice_subscription_groups( $invoice_id ) { |
|
| 39 | - $subscription_groups = get_post_meta( $invoice_id, 'getpaid_subscription_groups', true ); |
|
| 40 | - return empty( $subscription_groups ) ? array() : $subscription_groups; |
|
| 38 | +function getpaid_get_invoice_subscription_groups($invoice_id) { |
|
| 39 | + $subscription_groups = get_post_meta($invoice_id, 'getpaid_subscription_groups', true); |
|
| 40 | + return empty($subscription_groups) ? array() : $subscription_groups; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | * @return array|false |
| 49 | 49 | * @since 2.3.0 |
| 50 | 50 | */ |
| 51 | -function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) { |
|
| 52 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id ); |
|
| 53 | - $matching_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 54 | - return reset( $matching_group ); |
|
| 51 | +function getpaid_get_invoice_subscription_group($invoice_id, $subscription_id) { |
|
| 52 | + $subscription_groups = getpaid_get_invoice_subscription_groups($invoice_id); |
|
| 53 | + $matching_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
| 54 | + return reset($matching_group); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | * @since 2.3.0 |
| 62 | 62 | * @return WPInv_Subscription|false |
| 63 | 63 | */ |
| 64 | -function getpaid_get_subscription( $subscription ) { |
|
| 64 | +function getpaid_get_subscription($subscription) { |
|
| 65 | 65 | |
| 66 | - if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
| 67 | - $subscription = new WPInv_Subscription( $subscription ); |
|
| 66 | + if (!is_a($subscription, 'WPInv_Subscription')) { |
|
| 67 | + $subscription = new WPInv_Subscription($subscription); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | return $subscription->exists() ? $subscription : false; |
@@ -79,26 +79,26 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query |
| 81 | 81 | */ |
| 82 | -function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
|
| 82 | +function getpaid_get_subscriptions($args = array(), $return = 'results') { |
|
| 83 | 83 | |
| 84 | 84 | // Do not retrieve all fields if we just want the count. |
| 85 | - if ( 'count' == $return ) { |
|
| 85 | + if ('count' == $return) { |
|
| 86 | 86 | $args['fields'] = 'id'; |
| 87 | 87 | $args['number'] = 1; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Do not count all matches if we just want the results. |
| 91 | - if ( 'results' == $return ) { |
|
| 91 | + if ('results' == $return) { |
|
| 92 | 92 | $args['count_total'] = false; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
| 95 | + $query = new GetPaid_Subscriptions_Query($args); |
|
| 96 | 96 | |
| 97 | - if ( 'results' == $return ) { |
|
| 97 | + if ('results' == $return) { |
|
| 98 | 98 | return $query->get_results(); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ( 'count' == $return ) { |
|
| 101 | + if ('count' == $return) { |
|
| 102 | 102 | return $query->get_total(); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -115,13 +115,13 @@ discard block |
||
| 115 | 115 | return apply_filters( |
| 116 | 116 | 'getpaid_get_subscription_statuses', |
| 117 | 117 | array( |
| 118 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
| 119 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
| 120 | - 'active' => __( 'Active', 'invoicing' ), |
|
| 121 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
| 122 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
| 123 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
| 124 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
| 118 | + 'pending' => __('Pending', 'invoicing'), |
|
| 119 | + 'trialling' => __('Trialing', 'invoicing'), |
|
| 120 | + 'active' => __('Active', 'invoicing'), |
|
| 121 | + 'failing' => __('Failing', 'invoicing'), |
|
| 122 | + 'expired' => __('Expired', 'invoicing'), |
|
| 123 | + 'completed' => __('Complete', 'invoicing'), |
|
| 124 | + 'cancelled' => __('Cancelled', 'invoicing'), |
|
| 125 | 125 | ) |
| 126 | 126 | ); |
| 127 | 127 | |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | -function getpaid_get_subscription_status_label( $status ) { |
|
| 135 | +function getpaid_get_subscription_status_label($status) { |
|
| 136 | 136 | $statuses = getpaid_get_subscription_statuses(); |
| 137 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
| 137 | + return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status)); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @return array |
| 166 | 166 | */ |
| 167 | -function getpaid_get_subscription_status_counts( $args = array() ) { |
|
| 167 | +function getpaid_get_subscription_status_counts($args = array()) { |
|
| 168 | 168 | |
| 169 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
| 169 | + $statuses = array_keys(getpaid_get_subscription_statuses()); |
|
| 170 | 170 | $counts = array(); |
| 171 | 171 | |
| 172 | - foreach ( $statuses as $status ) { |
|
| 173 | - $_args = wp_parse_args( "status=$status", $args ); |
|
| 174 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
| 172 | + foreach ($statuses as $status) { |
|
| 173 | + $_args = wp_parse_args("status=$status", $args); |
|
| 174 | + $counts[$status] = getpaid_get_subscriptions($_args, 'count'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | return $counts; |
@@ -190,23 +190,23 @@ discard block |
||
| 190 | 190 | array( |
| 191 | 191 | |
| 192 | 192 | 'day' => array( |
| 193 | - 'singular' => __( '%s day', 'invoicing' ), |
|
| 194 | - 'plural' => __( '%d days', 'invoicing' ), |
|
| 193 | + 'singular' => __('%s day', 'invoicing'), |
|
| 194 | + 'plural' => __('%d days', 'invoicing'), |
|
| 195 | 195 | ), |
| 196 | 196 | |
| 197 | 197 | 'week' => array( |
| 198 | - 'singular' => __( '%s week', 'invoicing' ), |
|
| 199 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
| 198 | + 'singular' => __('%s week', 'invoicing'), |
|
| 199 | + 'plural' => __('%d weeks', 'invoicing'), |
|
| 200 | 200 | ), |
| 201 | 201 | |
| 202 | 202 | 'month' => array( |
| 203 | - 'singular' => __( '%s month', 'invoicing' ), |
|
| 204 | - 'plural' => __( '%d months', 'invoicing' ), |
|
| 203 | + 'singular' => __('%s month', 'invoicing'), |
|
| 204 | + 'plural' => __('%d months', 'invoicing'), |
|
| 205 | 205 | ), |
| 206 | 206 | |
| 207 | 207 | 'year' => array( |
| 208 | - 'singular' => __( '%s year', 'invoicing' ), |
|
| 209 | - 'plural' => __( '%d years', 'invoicing' ), |
|
| 208 | + 'singular' => __('%s year', 'invoicing'), |
|
| 209 | + 'plural' => __('%d years', 'invoicing'), |
|
| 210 | 210 | ), |
| 211 | 211 | |
| 212 | 212 | ) |
@@ -220,8 +220,8 @@ discard block |
||
| 220 | 220 | * @param string $trial_period |
| 221 | 221 | * @return int |
| 222 | 222 | */ |
| 223 | -function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
|
| 224 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
| 223 | +function getpaid_get_subscription_trial_period_interval($trial_period) { |
|
| 224 | + return (int) preg_replace('/[^0-9]/', '', $trial_period); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | * @param string $trial_period |
| 231 | 231 | * @return string |
| 232 | 232 | */ |
| 233 | -function getpaid_get_subscription_trial_period_period( $trial_period ) { |
|
| 234 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
| 233 | +function getpaid_get_subscription_trial_period_period($trial_period) { |
|
| 234 | + return preg_replace('/[^a-z]/', '', strtolower($trial_period)); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | * @param int $interval |
| 242 | 242 | * @return string |
| 243 | 243 | */ |
| 244 | -function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
|
| 245 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
| 246 | - return strtolower( sanitize_text_field( $label ) ); |
|
| 244 | +function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') { |
|
| 245 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix); |
|
| 246 | + return strtolower(sanitize_text_field($label)); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -252,19 +252,19 @@ discard block |
||
| 252 | 252 | * @param string $period |
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | -function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
|
| 255 | +function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') { |
|
| 256 | 256 | |
| 257 | 257 | $periods = getpaid_get_subscription_periods(); |
| 258 | - $period = strtolower( $period ); |
|
| 258 | + $period = strtolower($period); |
|
| 259 | 259 | |
| 260 | - if ( isset( $periods[ $period ] ) ) { |
|
| 261 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
| 260 | + if (isset($periods[$period])) { |
|
| 261 | + return sprintf($periods[$period]['singular'], $singular_prefix); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // Backwards compatibility. |
| 265 | - foreach ( $periods as $key => $data ) { |
|
| 266 | - if ( strpos( $key, $period ) === 0 ) { |
|
| 267 | - return sprintf( $data['singular'], $singular_prefix ); |
|
| 265 | + foreach ($periods as $key => $data) { |
|
| 266 | + if (strpos($key, $period) === 0) { |
|
| 267 | + return sprintf($data['singular'], $singular_prefix); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
@@ -279,19 +279,19 @@ discard block |
||
| 279 | 279 | * @param int $interval |
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | -function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
|
| 282 | +function getpaid_get_plural_subscription_period_label($period, $interval) { |
|
| 283 | 283 | |
| 284 | 284 | $periods = getpaid_get_subscription_periods(); |
| 285 | - $period = strtolower( $period ); |
|
| 285 | + $period = strtolower($period); |
|
| 286 | 286 | |
| 287 | - if ( isset( $periods[ $period ] ) ) { |
|
| 288 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
| 287 | + if (isset($periods[$period])) { |
|
| 288 | + return sprintf($periods[$period]['plural'], $interval); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // Backwards compatibility. |
| 292 | - foreach ( $periods as $key => $data ) { |
|
| 293 | - if ( strpos( $key, $period ) === 0 ) { |
|
| 294 | - return sprintf( $data['plural'], $interval ); |
|
| 292 | + foreach ($periods as $key => $data) { |
|
| 293 | + if (strpos($key, $period) === 0) { |
|
| 294 | + return sprintf($data['plural'], $interval); |
|
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | |
@@ -305,32 +305,32 @@ discard block |
||
| 305 | 305 | * @param WPInv_Subscription $subscription |
| 306 | 306 | * @return string |
| 307 | 307 | */ |
| 308 | -function getpaid_get_formatted_subscription_amount( $subscription ) { |
|
| 308 | +function getpaid_get_formatted_subscription_amount($subscription) { |
|
| 309 | 309 | |
| 310 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 311 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 312 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
| 310 | + $initial = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
| 311 | + $recurring = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
| 312 | + $period = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
| 313 | 313 | $bill_times = $subscription->get_bill_times(); |
| 314 | 314 | |
| 315 | - if ( ! empty( $bill_times ) ) { |
|
| 315 | + if (!empty($bill_times)) { |
|
| 316 | 316 | $bill_times = $subscription->get_frequency() * $bill_times; |
| 317 | - $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times ); |
|
| 317 | + $bill_times = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Trial periods. |
| 321 | - if ( $subscription->has_trial_period() ) { |
|
| 321 | + if ($subscription->has_trial_period()) { |
|
| 322 | 322 | |
| 323 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
| 324 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
| 323 | + $trial_period = getpaid_get_subscription_trial_period_period($subscription->get_trial_period()); |
|
| 324 | + $trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period()); |
|
| 325 | 325 | |
| 326 | - if ( empty( $bill_times ) ) { |
|
| 326 | + if (empty($bill_times)) { |
|
| 327 | 327 | |
| 328 | 328 | return sprintf( |
| 329 | 329 | |
| 330 | 330 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
| 331 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
| 331 | + _x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
| 332 | 332 | $initial, |
| 333 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
| 333 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
| 334 | 334 | $recurring, |
| 335 | 335 | $period |
| 336 | 336 | |
@@ -341,9 +341,9 @@ discard block |
||
| 341 | 341 | return sprintf( |
| 342 | 342 | |
| 343 | 343 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times |
| 344 | - _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
| 344 | + _x('%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
| 345 | 345 | $initial, |
| 346 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
| 346 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
| 347 | 347 | $recurring, |
| 348 | 348 | $period, |
| 349 | 349 | $bill_times |
@@ -351,14 +351,14 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if ( $initial != $recurring ) { |
|
| 354 | + if ($initial != $recurring) { |
|
| 355 | 355 | |
| 356 | - if ( empty( $bill_times ) ) { |
|
| 356 | + if (empty($bill_times)) { |
|
| 357 | 357 | |
| 358 | 358 | return sprintf( |
| 359 | 359 | |
| 360 | 360 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
| 361 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
| 361 | + _x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'), |
|
| 362 | 362 | $initial, |
| 363 | 363 | $recurring, |
| 364 | 364 | $period |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | return sprintf( |
| 371 | 371 | |
| 372 | 372 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times |
| 373 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ), |
|
| 373 | + _x('Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing'), |
|
| 374 | 374 | $initial, |
| 375 | 375 | $recurring, |
| 376 | 376 | $period, |
@@ -380,12 +380,12 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if ( empty( $bill_times ) ) { |
|
| 383 | + if (empty($bill_times)) { |
|
| 384 | 384 | |
| 385 | 385 | return sprintf( |
| 386 | 386 | |
| 387 | 387 | // translators: $1: is the recurring amount, $2: is the recurring period |
| 388 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
| 388 | + _x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
| 389 | 389 | $initial, |
| 390 | 390 | $period |
| 391 | 391 | |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | return sprintf( |
| 397 | 397 | |
| 398 | 398 | // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period |
| 399 | - _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
| 399 | + _x('%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
| 400 | 400 | $bill_times, |
| 401 | 401 | $initial, |
| 402 | 402 | $period |
@@ -411,8 +411,8 @@ discard block |
||
| 411 | 411 | * @param WPInv_Invoice $invoice |
| 412 | 412 | * @return WPInv_Subscription|false |
| 413 | 413 | */ |
| 414 | -function getpaid_get_invoice_subscription( $invoice ) { |
|
| 415 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
| 414 | +function getpaid_get_invoice_subscription($invoice) { |
|
| 415 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -420,9 +420,9 @@ discard block |
||
| 420 | 420 | * |
| 421 | 421 | * @param WPInv_Invoice $invoice |
| 422 | 422 | */ |
| 423 | -function getpaid_activate_invoice_subscription( $invoice ) { |
|
| 424 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 425 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
| 423 | +function getpaid_activate_invoice_subscription($invoice) { |
|
| 424 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
| 425 | + if (is_a($subscription, 'WPInv_Subscription')) { |
|
| 426 | 426 | $subscription->activate(); |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * @return WPInv_Subscriptions |
| 434 | 434 | */ |
| 435 | 435 | function getpaid_subscriptions() { |
| 436 | - return getpaid()->get( 'subscriptions' ); |
|
| 436 | + return getpaid()->get('subscriptions'); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | /** |
@@ -442,13 +442,13 @@ discard block |
||
| 442 | 442 | * @since 2.3.0 |
| 443 | 443 | * @return WPInv_Subscription|bool |
| 444 | 444 | */ |
| 445 | -function wpinv_get_invoice_subscription( $invoice ) { |
|
| 445 | +function wpinv_get_invoice_subscription($invoice) { |
|
| 446 | 446 | |
| 447 | 447 | // Retrieve the invoice. |
| 448 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 448 | + $invoice = new WPInv_Invoice($invoice); |
|
| 449 | 449 | |
| 450 | 450 | // Ensure it is a recurring invoice. |
| 451 | - if ( ! $invoice->is_recurring() ) { |
|
| 451 | + if (!$invoice->is_recurring()) { |
|
| 452 | 452 | return false; |
| 453 | 453 | } |
| 454 | 454 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | ) |
| 461 | 461 | ); |
| 462 | 462 | |
| 463 | - return empty( $subscription ) ? false : $subscription[0]; |
|
| 463 | + return empty($subscription) ? false : $subscription[0]; |
|
| 464 | 464 | |
| 465 | 465 | } |
| 466 | 466 | |
@@ -475,50 +475,50 @@ discard block |
||
| 475 | 475 | * @param GetPaid_Form_Item|WPInv_Item $cart_item |
| 476 | 476 | * @return string |
| 477 | 477 | */ |
| 478 | -function getpaid_get_recurring_item_key( $cart_item ) { |
|
| 478 | +function getpaid_get_recurring_item_key($cart_item) { |
|
| 479 | 479 | |
| 480 | 480 | $cart_key = 'renews_'; |
| 481 | 481 | $interval = $cart_item->get_recurring_interval(); |
| 482 | - $period = $cart_item->get_recurring_period( true ); |
|
| 482 | + $period = $cart_item->get_recurring_period(true); |
|
| 483 | 483 | $length = $cart_item->get_recurring_limit() * $interval; |
| 484 | - $trial_period = $cart_item->get_trial_period( true ); |
|
| 484 | + $trial_period = $cart_item->get_trial_period(true); |
|
| 485 | 485 | $trial_length = $cart_item->get_trial_interval(); |
| 486 | 486 | |
| 487 | 487 | // First start with the billing interval and period |
| 488 | - switch ( $interval ) { |
|
| 488 | + switch ($interval) { |
|
| 489 | 489 | case 1 : |
| 490 | - if ( 'day' == $period ) { |
|
| 490 | + if ('day' == $period) { |
|
| 491 | 491 | $cart_key .= 'daily'; |
| 492 | 492 | } else { |
| 493 | - $cart_key .= sprintf( '%sly', $period ); |
|
| 493 | + $cart_key .= sprintf('%sly', $period); |
|
| 494 | 494 | } |
| 495 | 495 | break; |
| 496 | 496 | case 2 : |
| 497 | - $cart_key .= sprintf( 'every_2nd_%s', $period ); |
|
| 497 | + $cart_key .= sprintf('every_2nd_%s', $period); |
|
| 498 | 498 | break; |
| 499 | 499 | case 3 : |
| 500 | - $cart_key .= sprintf( 'every_3rd_%s', $period ); |
|
| 500 | + $cart_key .= sprintf('every_3rd_%s', $period); |
|
| 501 | 501 | break; |
| 502 | 502 | default: |
| 503 | - $cart_key .= sprintf( 'every_%dth_%s', $interval, $period ); |
|
| 503 | + $cart_key .= sprintf('every_%dth_%s', $interval, $period); |
|
| 504 | 504 | break; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | // Maybe add the optional maximum billing periods... |
| 508 | - if ( $length > 0 ) { |
|
| 508 | + if ($length > 0) { |
|
| 509 | 509 | $cart_key .= '_for_'; |
| 510 | - $cart_key .= sprintf( '%d_%s', $length, $period ); |
|
| 511 | - if ( $length > 1 ) { |
|
| 510 | + $cart_key .= sprintf('%d_%s', $length, $period); |
|
| 511 | + if ($length > 1) { |
|
| 512 | 512 | $cart_key .= 's'; |
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | // And an optional free trial. |
| 517 | - if ( $cart_item->has_free_trial() ) { |
|
| 518 | - $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period ); |
|
| 517 | + if ($cart_item->has_free_trial()) { |
|
| 518 | + $cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item ); |
|
| 521 | + return apply_filters('getpaid_get_recurring_item_key', $cart_key, $cart_item); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -527,14 +527,14 @@ discard block |
||
| 527 | 527 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
| 528 | 528 | * @return array |
| 529 | 529 | */ |
| 530 | -function getpaid_get_subscription_groups( $invoice ) { |
|
| 530 | +function getpaid_get_subscription_groups($invoice) { |
|
| 531 | 531 | |
| 532 | 532 | // Generate subscription groups. |
| 533 | 533 | $subscription_groups = array(); |
| 534 | - foreach ( $invoice->get_items() as $item ) { |
|
| 534 | + foreach ($invoice->get_items() as $item) { |
|
| 535 | 535 | |
| 536 | - if ( $item->is_recurring() ) { |
|
| 537 | - $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item; |
|
| 536 | + if ($item->is_recurring()) { |
|
| 537 | + $subscription_groups[getpaid_get_recurring_item_key($item)][] = $item; |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | } |
@@ -551,19 +551,19 @@ discard block |
||
| 551 | 551 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
| 552 | 552 | * @return array |
| 553 | 553 | */ |
| 554 | -function getpaid_calculate_subscription_totals( $invoice ) { |
|
| 554 | +function getpaid_calculate_subscription_totals($invoice) { |
|
| 555 | 555 | |
| 556 | 556 | // Generate subscription groups. |
| 557 | - $subscription_groups = getpaid_get_subscription_groups( $invoice ); |
|
| 557 | + $subscription_groups = getpaid_get_subscription_groups($invoice); |
|
| 558 | 558 | |
| 559 | 559 | // Now let's calculate the totals for each group of subscriptions |
| 560 | 560 | $subscription_totals = array(); |
| 561 | 561 | |
| 562 | - foreach ( $subscription_groups as $subscription_key => $items ) { |
|
| 562 | + foreach ($subscription_groups as $subscription_key => $items) { |
|
| 563 | 563 | |
| 564 | - if ( empty( $subscription_totals[ $subscription_key ] ) ) { |
|
| 564 | + if (empty($subscription_totals[$subscription_key])) { |
|
| 565 | 565 | |
| 566 | - $subscription_totals[ $subscription_key ] = array( |
|
| 566 | + $subscription_totals[$subscription_key] = array( |
|
| 567 | 567 | 'initial_total' => 0, |
| 568 | 568 | 'recurring_total' => 0, |
| 569 | 569 | 'items' => array(), |
@@ -576,34 +576,34 @@ discard block |
||
| 576 | 576 | * Get the totals of the group. |
| 577 | 577 | * @var GetPaid_Form_Item $item |
| 578 | 578 | */ |
| 579 | - foreach ( $items as $item ) { |
|
| 579 | + foreach ($items as $item) { |
|
| 580 | 580 | |
| 581 | - $subscription_totals[ $subscription_key ]['items'][$item->get_id()] = $item->prepare_data_for_saving(); |
|
| 582 | - $subscription_totals[ $subscription_key ]['item_id'] = $item->get_id(); |
|
| 583 | - $subscription_totals[ $subscription_key ]['period'] = $item->get_recurring_period( true ); |
|
| 584 | - $subscription_totals[ $subscription_key ]['interval'] = $item->get_recurring_interval(); |
|
| 585 | - $subscription_totals[ $subscription_key ]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
| 586 | - $subscription_totals[ $subscription_key ]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
| 587 | - $subscription_totals[ $subscription_key ]['recurring_limit'] = $item->get_recurring_limit(); |
|
| 581 | + $subscription_totals[$subscription_key]['items'][$item->get_id()] = $item->prepare_data_for_saving(); |
|
| 582 | + $subscription_totals[$subscription_key]['item_id'] = $item->get_id(); |
|
| 583 | + $subscription_totals[$subscription_key]['period'] = $item->get_recurring_period(true); |
|
| 584 | + $subscription_totals[$subscription_key]['interval'] = $item->get_recurring_interval(); |
|
| 585 | + $subscription_totals[$subscription_key]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
| 586 | + $subscription_totals[$subscription_key]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
| 587 | + $subscription_totals[$subscription_key]['recurring_limit'] = $item->get_recurring_limit(); |
|
| 588 | 588 | |
| 589 | 589 | // Calculate the next renewal date. |
| 590 | - $period = $item->get_recurring_period( true ); |
|
| 590 | + $period = $item->get_recurring_period(true); |
|
| 591 | 591 | $interval = $item->get_recurring_interval(); |
| 592 | 592 | |
| 593 | 593 | // If the subscription item has a trial period... |
| 594 | - if ( $item->has_free_trial() ) { |
|
| 595 | - $period = $item->get_trial_period( true ); |
|
| 594 | + if ($item->has_free_trial()) { |
|
| 595 | + $period = $item->get_trial_period(true); |
|
| 596 | 596 | $interval = $item->get_trial_interval(); |
| 597 | - $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period; |
|
| 597 | + $subscription_totals[$subscription_key]['trialling'] = $interval . ' ' . $period; |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) ); |
|
| 600 | + $subscription_totals[$subscription_key]['renews_on'] = date('Y-m-d H:i:s', strtotime("+$interval $period", current_time('timestamp'))); |
|
| 601 | 601 | |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice ); |
|
| 606 | + return apply_filters('getpaid_calculate_subscription_totals', $subscription_totals, $invoice); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | /** |
@@ -612,19 +612,19 @@ discard block |
||
| 612 | 612 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
| 613 | 613 | * @return array |
| 614 | 614 | */ |
| 615 | -function getpaid_should_group_subscriptions( $invoice ) { |
|
| 615 | +function getpaid_should_group_subscriptions($invoice) { |
|
| 616 | 616 | |
| 617 | 617 | $recurring_items = 0; |
| 618 | 618 | |
| 619 | - foreach ( $invoice->get_items() as $item ) { |
|
| 619 | + foreach ($invoice->get_items() as $item) { |
|
| 620 | 620 | |
| 621 | - if ( $item->is_recurring() ) { |
|
| 622 | - $recurring_items ++; |
|
| 621 | + if ($item->is_recurring()) { |
|
| 622 | + $recurring_items++; |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice ); |
|
| 627 | + return apply_filters('getpaid_should_group_subscriptions', $recurring_items > 1, $invoice); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
@@ -634,12 +634,12 @@ discard block |
||
| 634 | 634 | * @param int|false $subscription_id |
| 635 | 635 | * @return int |
| 636 | 636 | */ |
| 637 | -function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) { |
|
| 637 | +function getpaid_count_subscription_invoices($parent_invoice_id, $subscription_id = false) { |
|
| 638 | 638 | global $wpdb; |
| 639 | 639 | |
| 640 | 640 | $parent_invoice_id = (int) $parent_invoice_id; |
| 641 | 641 | |
| 642 | - if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) { |
|
| 642 | + if (false === $subscription_id || !(bool) get_post_meta($parent_invoice_id, '_wpinv_subscription_id', true)) { |
|
| 643 | 643 | |
| 644 | 644 | return (int) $wpdb->get_var( |
| 645 | 645 | $wpdb->prepare( |
@@ -661,10 +661,10 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | $count = 0; |
| 663 | 663 | |
| 664 | - foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) { |
|
| 664 | + foreach (wp_parse_id_list($invoice_ids) as $invoice_id) { |
|
| 665 | 665 | |
| 666 | - if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) { |
|
| 667 | - $count ++; |
|
| 666 | + if ($invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta($invoice_id, '_wpinv_subscription_id', true)) { |
|
| 667 | + $count++; |
|
| 668 | 668 | continue; |
| 669 | 669 | } |
| 670 | 670 | |
@@ -12,230 +12,230 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Payment_Form_Submission_Taxes { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Submission taxes. |
|
| 17 | - * @var array |
|
| 18 | - */ |
|
| 19 | - public $taxes = array(); |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * Whether or not we should skip the taxes. |
|
| 23 | - * @var bool |
|
| 24 | - */ |
|
| 25 | - protected $skip_taxes = false; |
|
| 15 | + /** |
|
| 16 | + * Submission taxes. |
|
| 17 | + * @var array |
|
| 18 | + */ |
|
| 19 | + public $taxes = array(); |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * Whether or not we should skip the taxes. |
|
| 23 | + * @var bool |
|
| 24 | + */ |
|
| 25 | + protected $skip_taxes = false; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * Class constructor |
|
| 29 | - * |
|
| 30 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 31 | - */ |
|
| 32 | - public function __construct( $submission ) { |
|
| 33 | - |
|
| 34 | - // Validate VAT number. |
|
| 35 | - $this->validate_vat( $submission ); |
|
| 36 | - |
|
| 37 | - if ( $this->skip_taxes ) { |
|
| 38 | - return; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - foreach ( $submission->get_items() as $item ) { |
|
| 42 | - $this->process_item_tax( $item, $submission ); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - // Process any existing invoice taxes. |
|
| 46 | - if ( $submission->has_invoice() ) { |
|
| 47 | - $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Maybe process tax. |
|
| 54 | - * |
|
| 55 | - * @since 1.0.19 |
|
| 56 | - * @param GetPaid_Form_Item $item |
|
| 57 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 58 | - */ |
|
| 59 | - public function process_item_tax( $item, $submission ) { |
|
| 60 | - |
|
| 61 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
| 62 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 63 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 64 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 65 | - |
|
| 66 | - foreach ( $taxes as $name => $amount ) { |
|
| 67 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 68 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 69 | - |
|
| 70 | - $item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
| 71 | - |
|
| 72 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
| 73 | - $this->taxes[ $name ] = $tax; |
|
| 74 | - continue; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 78 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 79 | - |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Checks if the submission has a digital item. |
|
| 86 | - * |
|
| 87 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 88 | - * @since 1.0.19 |
|
| 89 | - * @return bool |
|
| 90 | - */ |
|
| 91 | - public function has_digital_item( $submission ) { |
|
| 92 | - |
|
| 93 | - foreach ( $submission->get_items() as $item ) { |
|
| 94 | - |
|
| 95 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
| 96 | - return true; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return false; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Checks if this is an eu store. |
|
| 106 | - * |
|
| 107 | - * @since 1.0.19 |
|
| 108 | - * @return bool |
|
| 109 | - */ |
|
| 110 | - public static function is_eu_store() { |
|
| 111 | - return self::is_eu_country( wpinv_get_default_country() ); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Checks if this is an eu country. |
|
| 116 | - * |
|
| 117 | - * @param string $country |
|
| 118 | - * @since 1.0.19 |
|
| 119 | - * @return bool |
|
| 120 | - */ |
|
| 121 | - public static function is_eu_country( $country ) { |
|
| 122 | - return getpaid_is_eu_state( $country ); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Checks if this is an eu purchase. |
|
| 127 | - * |
|
| 128 | - * @param string $customer_country |
|
| 129 | - * @since 1.0.19 |
|
| 130 | - * @return bool |
|
| 131 | - */ |
|
| 132 | - public static function is_eu_transaction( $customer_country ) { |
|
| 133 | - return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Retrieves the vat number. |
|
| 138 | - * |
|
| 139 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 140 | - * @since 1.0.19 |
|
| 141 | - * @return string |
|
| 142 | - */ |
|
| 143 | - public function get_vat_number( $submission ) { |
|
| 144 | - |
|
| 145 | - // Retrieve from the posted number. |
|
| 146 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
| 147 | - if ( ! is_null( $vat_number ) ) { |
|
| 148 | - return wpinv_clean( $vat_number ); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Retrieves the company. |
|
| 156 | - * |
|
| 157 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 158 | - * @since 1.0.19 |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - public function get_company( $submission ) { |
|
| 162 | - |
|
| 163 | - // Retrieve from the posted data. |
|
| 164 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
| 165 | - if ( ! empty( $company ) ) { |
|
| 166 | - return wpinv_clean( $company ); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - // Retrieve from the invoice. |
|
| 170 | - return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Checks if we require a VAT number. |
|
| 175 | - * |
|
| 176 | - * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
| 177 | - * @param bool $country_in_eu Whether the customer country is from the EU |
|
| 178 | - * @since 1.0.19 |
|
| 179 | - * @return string |
|
| 180 | - */ |
|
| 181 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
| 182 | - |
|
| 183 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
| 184 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
| 185 | - $is_eu = $ip_in_eu || $country_in_eu; |
|
| 186 | - |
|
| 187 | - return $prevent_b2c && $is_eu; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Validate VAT data. |
|
| 192 | - * |
|
| 193 | - * @param GetPaid_Payment_Form_Submission $submission |
|
| 194 | - * @since 1.0.19 |
|
| 195 | - */ |
|
| 196 | - public function validate_vat( $submission ) { |
|
| 197 | - |
|
| 198 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
| 199 | - |
|
| 200 | - // Abort if we are not validating vat numbers. |
|
| 201 | - if ( ! $in_eu ) { |
|
| 28 | + * Class constructor |
|
| 29 | + * |
|
| 30 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 31 | + */ |
|
| 32 | + public function __construct( $submission ) { |
|
| 33 | + |
|
| 34 | + // Validate VAT number. |
|
| 35 | + $this->validate_vat( $submission ); |
|
| 36 | + |
|
| 37 | + if ( $this->skip_taxes ) { |
|
| 202 | 38 | return; |
| 203 | - } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + foreach ( $submission->get_items() as $item ) { |
|
| 42 | + $this->process_item_tax( $item, $submission ); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + // Process any existing invoice taxes. |
|
| 46 | + if ( $submission->has_invoice() ) { |
|
| 47 | + $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Maybe process tax. |
|
| 54 | + * |
|
| 55 | + * @since 1.0.19 |
|
| 56 | + * @param GetPaid_Form_Item $item |
|
| 57 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 58 | + */ |
|
| 59 | + public function process_item_tax( $item, $submission ) { |
|
| 60 | + |
|
| 61 | + $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
| 62 | + $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 63 | + $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 64 | + $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 65 | + |
|
| 66 | + foreach ( $taxes as $name => $amount ) { |
|
| 67 | + $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 68 | + $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 69 | + |
|
| 70 | + $item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
| 71 | + |
|
| 72 | + if ( ! isset( $this->taxes[ $name ] ) ) { |
|
| 73 | + $this->taxes[ $name ] = $tax; |
|
| 74 | + continue; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 78 | + $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 79 | + |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Checks if the submission has a digital item. |
|
| 86 | + * |
|
| 87 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 88 | + * @since 1.0.19 |
|
| 89 | + * @return bool |
|
| 90 | + */ |
|
| 91 | + public function has_digital_item( $submission ) { |
|
| 92 | + |
|
| 93 | + foreach ( $submission->get_items() as $item ) { |
|
| 94 | + |
|
| 95 | + if ( 'digital' == $item->get_vat_rule() ) { |
|
| 96 | + return true; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + } |
|
| 204 | 100 | |
| 205 | - // Prepare variables. |
|
| 206 | - $vat_number = $this->get_vat_number( $submission ); |
|
| 207 | - $ip_country = getpaid_get_ip_country(); |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Checks if this is an eu store. |
|
| 106 | + * |
|
| 107 | + * @since 1.0.19 |
|
| 108 | + * @return bool |
|
| 109 | + */ |
|
| 110 | + public static function is_eu_store() { |
|
| 111 | + return self::is_eu_country( wpinv_get_default_country() ); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Checks if this is an eu country. |
|
| 116 | + * |
|
| 117 | + * @param string $country |
|
| 118 | + * @since 1.0.19 |
|
| 119 | + * @return bool |
|
| 120 | + */ |
|
| 121 | + public static function is_eu_country( $country ) { |
|
| 122 | + return getpaid_is_eu_state( $country ); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Checks if this is an eu purchase. |
|
| 127 | + * |
|
| 128 | + * @param string $customer_country |
|
| 129 | + * @since 1.0.19 |
|
| 130 | + * @return bool |
|
| 131 | + */ |
|
| 132 | + public static function is_eu_transaction( $customer_country ) { |
|
| 133 | + return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Retrieves the vat number. |
|
| 138 | + * |
|
| 139 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 140 | + * @since 1.0.19 |
|
| 141 | + * @return string |
|
| 142 | + */ |
|
| 143 | + public function get_vat_number( $submission ) { |
|
| 144 | + |
|
| 145 | + // Retrieve from the posted number. |
|
| 146 | + $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
| 147 | + if ( ! is_null( $vat_number ) ) { |
|
| 148 | + return wpinv_clean( $vat_number ); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Retrieves the company. |
|
| 156 | + * |
|
| 157 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 158 | + * @since 1.0.19 |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + public function get_company( $submission ) { |
|
| 162 | + |
|
| 163 | + // Retrieve from the posted data. |
|
| 164 | + $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
| 165 | + if ( ! empty( $company ) ) { |
|
| 166 | + return wpinv_clean( $company ); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + // Retrieve from the invoice. |
|
| 170 | + return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Checks if we require a VAT number. |
|
| 175 | + * |
|
| 176 | + * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
| 177 | + * @param bool $country_in_eu Whether the customer country is from the EU |
|
| 178 | + * @since 1.0.19 |
|
| 179 | + * @return string |
|
| 180 | + */ |
|
| 181 | + public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
| 182 | + |
|
| 183 | + $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
| 184 | + $prevent_b2c = ! empty( $prevent_b2c ); |
|
| 185 | + $is_eu = $ip_in_eu || $country_in_eu; |
|
| 186 | + |
|
| 187 | + return $prevent_b2c && $is_eu; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Validate VAT data. |
|
| 192 | + * |
|
| 193 | + * @param GetPaid_Payment_Form_Submission $submission |
|
| 194 | + * @since 1.0.19 |
|
| 195 | + */ |
|
| 196 | + public function validate_vat( $submission ) { |
|
| 197 | + |
|
| 198 | + $in_eu = $this->is_eu_transaction( $submission->country ); |
|
| 199 | + |
|
| 200 | + // Abort if we are not validating vat numbers. |
|
| 201 | + if ( ! $in_eu ) { |
|
| 202 | + return; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + // Prepare variables. |
|
| 206 | + $vat_number = $this->get_vat_number( $submission ); |
|
| 207 | + $ip_country = getpaid_get_ip_country(); |
|
| 208 | 208 | $is_eu = $this->is_eu_country( $submission->country ); |
| 209 | 209 | $is_ip_eu = $this->is_eu_country( $ip_country ); |
| 210 | 210 | |
| 211 | - // Maybe abort early for initial fetches. |
|
| 212 | - if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
| 213 | - return; |
|
| 214 | - } |
|
| 211 | + // Maybe abort early for initial fetches. |
|
| 212 | + if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
| 213 | + return; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - // If we're preventing business to consumer purchases, |
|
| 217 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
| 216 | + // If we're preventing business to consumer purchases, |
|
| 217 | + if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
| 218 | 218 | |
| 219 | - // Ensure that a vat number has been specified. |
|
| 220 | - throw new Exception( |
|
| 221 | - __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
| 222 | - ); |
|
| 219 | + // Ensure that a vat number has been specified. |
|
| 220 | + throw new Exception( |
|
| 221 | + __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
| 222 | + ); |
|
| 223 | 223 | |
| 224 | - } |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - if ( empty( $vat_number ) ) { |
|
| 227 | - return; |
|
| 228 | - } |
|
| 226 | + if ( empty( $vat_number ) ) { |
|
| 227 | + return; |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
| 231 | - throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
| 232 | - } |
|
| 230 | + if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
| 231 | + throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 235 | - return; |
|
| 236 | - } |
|
| 234 | + if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 235 | + return; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - $this->skip_taxes = true; |
|
| 239 | - } |
|
| 238 | + $this->skip_taxes = true; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Payment form submission taxes class |
@@ -29,22 +29,22 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @param GetPaid_Payment_Form_Submission $submission |
| 31 | 31 | */ |
| 32 | - public function __construct( $submission ) { |
|
| 32 | + public function __construct($submission) { |
|
| 33 | 33 | |
| 34 | 34 | // Validate VAT number. |
| 35 | - $this->validate_vat( $submission ); |
|
| 35 | + $this->validate_vat($submission); |
|
| 36 | 36 | |
| 37 | - if ( $this->skip_taxes ) { |
|
| 37 | + if ($this->skip_taxes) { |
|
| 38 | 38 | return; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - foreach ( $submission->get_items() as $item ) { |
|
| 42 | - $this->process_item_tax( $item, $submission ); |
|
| 41 | + foreach ($submission->get_items() as $item) { |
|
| 42 | + $this->process_item_tax($item, $submission); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Process any existing invoice taxes. |
| 46 | - if ( $submission->has_invoice() ) { |
|
| 47 | - $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
| 46 | + if ($submission->has_invoice()) { |
|
| 47 | + $this->taxes = array_replace($submission->get_invoice()->get_taxes(), $this->taxes); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | } |
@@ -56,26 +56,26 @@ discard block |
||
| 56 | 56 | * @param GetPaid_Form_Item $item |
| 57 | 57 | * @param GetPaid_Payment_Form_Submission $submission |
| 58 | 58 | */ |
| 59 | - public function process_item_tax( $item, $submission ) { |
|
| 59 | + public function process_item_tax($item, $submission) { |
|
| 60 | 60 | |
| 61 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
| 62 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
| 63 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
| 64 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
| 61 | + $rates = getpaid_get_item_tax_rates($item, $submission->country, $submission->state); |
|
| 62 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
| 63 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
| 64 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
| 65 | 65 | |
| 66 | - foreach ( $taxes as $name => $amount ) { |
|
| 67 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
| 68 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
| 66 | + foreach ($taxes as $name => $amount) { |
|
| 67 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
| 68 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
| 69 | 69 | |
| 70 | - $item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
| 70 | + $item->item_tax += wpinv_sanitize_amount($tax['initial_tax']); |
|
| 71 | 71 | |
| 72 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
| 73 | - $this->taxes[ $name ] = $tax; |
|
| 72 | + if (!isset($this->taxes[$name])) { |
|
| 73 | + $this->taxes[$name] = $tax; |
|
| 74 | 74 | continue; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
| 78 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
| 77 | + $this->taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
| 78 | + $this->taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | * @since 1.0.19 |
| 89 | 89 | * @return bool |
| 90 | 90 | */ |
| 91 | - public function has_digital_item( $submission ) { |
|
| 91 | + public function has_digital_item($submission) { |
|
| 92 | 92 | |
| 93 | - foreach ( $submission->get_items() as $item ) { |
|
| 93 | + foreach ($submission->get_items() as $item) { |
|
| 94 | 94 | |
| 95 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
| 95 | + if ('digital' == $item->get_vat_rule()) { |
|
| 96 | 96 | return true; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @return bool |
| 109 | 109 | */ |
| 110 | 110 | public static function is_eu_store() { |
| 111 | - return self::is_eu_country( wpinv_get_default_country() ); |
|
| 111 | + return self::is_eu_country(wpinv_get_default_country()); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | * @since 1.0.19 |
| 119 | 119 | * @return bool |
| 120 | 120 | */ |
| 121 | - public static function is_eu_country( $country ) { |
|
| 122 | - return getpaid_is_eu_state( $country ); |
|
| 121 | + public static function is_eu_country($country) { |
|
| 122 | + return getpaid_is_eu_state($country); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | * @since 1.0.19 |
| 130 | 130 | * @return bool |
| 131 | 131 | */ |
| 132 | - public static function is_eu_transaction( $customer_country ) { |
|
| 133 | - return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
| 132 | + public static function is_eu_transaction($customer_country) { |
|
| 133 | + return self::is_eu_country($customer_country) && self::is_eu_store(); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | * @since 1.0.19 |
| 141 | 141 | * @return string |
| 142 | 142 | */ |
| 143 | - public function get_vat_number( $submission ) { |
|
| 143 | + public function get_vat_number($submission) { |
|
| 144 | 144 | |
| 145 | 145 | // Retrieve from the posted number. |
| 146 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
| 147 | - if ( ! is_null( $vat_number ) ) { |
|
| 148 | - return wpinv_clean( $vat_number ); |
|
| 146 | + $vat_number = $submission->get_field('wpinv_vat_number', 'billing'); |
|
| 147 | + if (!is_null($vat_number)) { |
|
| 148 | + return wpinv_clean($vat_number); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
@@ -158,12 +158,12 @@ discard block |
||
| 158 | 158 | * @since 1.0.19 |
| 159 | 159 | * @return string |
| 160 | 160 | */ |
| 161 | - public function get_company( $submission ) { |
|
| 161 | + public function get_company($submission) { |
|
| 162 | 162 | |
| 163 | 163 | // Retrieve from the posted data. |
| 164 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
| 165 | - if ( ! empty( $company ) ) { |
|
| 166 | - return wpinv_clean( $company ); |
|
| 164 | + $company = $submission->get_field('wpinv_company', 'billing'); |
|
| 165 | + if (!empty($company)) { |
|
| 166 | + return wpinv_clean($company); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // Retrieve from the invoice. |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | * @since 1.0.19 |
| 179 | 179 | * @return string |
| 180 | 180 | */ |
| 181 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
| 181 | + public function requires_vat($ip_in_eu, $country_in_eu) { |
|
| 182 | 182 | |
| 183 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
| 184 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
| 183 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
| 184 | + $prevent_b2c = !empty($prevent_b2c); |
|
| 185 | 185 | $is_eu = $ip_in_eu || $country_in_eu; |
| 186 | 186 | |
| 187 | 187 | return $prevent_b2c && $is_eu; |
@@ -193,45 +193,45 @@ discard block |
||
| 193 | 193 | * @param GetPaid_Payment_Form_Submission $submission |
| 194 | 194 | * @since 1.0.19 |
| 195 | 195 | */ |
| 196 | - public function validate_vat( $submission ) { |
|
| 196 | + public function validate_vat($submission) { |
|
| 197 | 197 | |
| 198 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
| 198 | + $in_eu = $this->is_eu_transaction($submission->country); |
|
| 199 | 199 | |
| 200 | 200 | // Abort if we are not validating vat numbers. |
| 201 | - if ( ! $in_eu ) { |
|
| 201 | + if (!$in_eu) { |
|
| 202 | 202 | return; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // Prepare variables. |
| 206 | - $vat_number = $this->get_vat_number( $submission ); |
|
| 206 | + $vat_number = $this->get_vat_number($submission); |
|
| 207 | 207 | $ip_country = getpaid_get_ip_country(); |
| 208 | - $is_eu = $this->is_eu_country( $submission->country ); |
|
| 209 | - $is_ip_eu = $this->is_eu_country( $ip_country ); |
|
| 208 | + $is_eu = $this->is_eu_country($submission->country); |
|
| 209 | + $is_ip_eu = $this->is_eu_country($ip_country); |
|
| 210 | 210 | |
| 211 | 211 | // Maybe abort early for initial fetches. |
| 212 | - if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
| 212 | + if ($submission->is_initial_fetch() && empty($vat_number)) { |
|
| 213 | 213 | return; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // If we're preventing business to consumer purchases, |
| 217 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
| 217 | + if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) { |
|
| 218 | 218 | |
| 219 | 219 | // Ensure that a vat number has been specified. |
| 220 | 220 | throw new Exception( |
| 221 | - __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
| 221 | + __('Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing') |
|
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ( empty( $vat_number ) ) { |
|
| 226 | + if (empty($vat_number)) { |
|
| 227 | 227 | return; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
| 231 | - throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
| 230 | + if (wpinv_should_validate_vat_number() && !wpinv_validate_vat_number($vat_number, $submission->country)) { |
|
| 231 | + throw new Exception(__('Your VAT number is invalid', 'invoicing')); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
| 234 | + if (wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
| 235 | 235 | return; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | do_action( 'getpaid_checkout_invoice_exception', $invoice ); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - // Do we have any errors? |
|
| 242 | + // Do we have any errors? |
|
| 243 | 243 | if ( wpinv_get_errors() ) { |
| 244 | 244 | $response['data'] = getpaid_get_errors_html( true, false ); |
| 245 | 245 | } else { |
@@ -1,155 +1,155 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -function wpinv_is_subscription_payment( $invoice = '' ) { |
|
| 3 | - if ( empty( $invoice ) ) { |
|
| 2 | +function wpinv_is_subscription_payment($invoice = '') { |
|
| 3 | + if (empty($invoice)) { |
|
| 4 | 4 | return false; |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 8 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 7 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 8 | + $invoice = wpinv_get_invoice($invoice); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - if ( empty( $invoice ) ) { |
|
| 11 | + if (empty($invoice)) { |
|
| 12 | 12 | return false; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if ( $invoice->is_renewal() ) { |
|
| 15 | + if ($invoice->is_renewal()) { |
|
| 16 | 16 | return true; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -function wpinv_payment_link_transaction_id( $invoice = '' ) { |
|
| 23 | - if ( empty( $invoice ) ) { |
|
| 22 | +function wpinv_payment_link_transaction_id($invoice = '') { |
|
| 23 | + if (empty($invoice)) { |
|
| 24 | 24 | return false; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 28 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 27 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 28 | + $invoice = wpinv_get_invoice($invoice); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if ( empty( $invoice ) ) { |
|
| 31 | + if (empty($invoice)) { |
|
| 32 | 32 | return false; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice ); |
|
| 35 | + return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | -function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) { |
|
| 39 | - $interval = (int)$interval > 0 ? (int)$interval : 1; |
|
| 38 | +function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) { |
|
| 39 | + $interval = (int) $interval > 0 ? (int) $interval : 1; |
|
| 40 | 40 | |
| 41 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 42 | - $amount = __( 'Free', 'invoicing' ); |
|
| 41 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 42 | + $amount = __('Free', 'invoicing'); |
|
| 43 | 43 | $interval = $trial_interval; |
| 44 | 44 | $period = $trial_period; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $description = ''; |
| 48 | - switch ( $period ) { |
|
| 48 | + switch ($period) { |
|
| 49 | 49 | case 'D' : |
| 50 | 50 | case 'day' : |
| 51 | - $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 51 | + $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 52 | 52 | break; |
| 53 | 53 | case 'W' : |
| 54 | 54 | case 'week' : |
| 55 | - $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 55 | + $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 56 | 56 | break; |
| 57 | 57 | case 'M' : |
| 58 | 58 | case 'month' : |
| 59 | - $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 59 | + $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 60 | 60 | break; |
| 61 | 61 | case 'Y' : |
| 62 | 62 | case 'year' : |
| 63 | - $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 63 | + $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 64 | 64 | break; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 67 | + return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | -function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) { |
|
| 71 | - $interval = (int)$interval > 0 ? (int)$interval : 1; |
|
| 72 | - $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0; |
|
| 70 | +function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) { |
|
| 71 | + $interval = (int) $interval > 0 ? (int) $interval : 1; |
|
| 72 | + $bill_times = (int) $bill_times > 0 ? (int) $bill_times : 0; |
|
| 73 | 73 | |
| 74 | 74 | $description = ''; |
| 75 | - switch ( $period ) { |
|
| 75 | + switch ($period) { |
|
| 76 | 76 | case 'D' : |
| 77 | 77 | case 'day' : |
| 78 | - if ( (int)$bill_times > 0 ) { |
|
| 79 | - if ( $interval > 1 ) { |
|
| 80 | - if ( $bill_times > 1 ) { |
|
| 81 | - $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 78 | + if ((int) $bill_times > 0) { |
|
| 79 | + if ($interval > 1) { |
|
| 80 | + if ($bill_times > 1) { |
|
| 81 | + $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 82 | 82 | } else { |
| 83 | - $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval ); |
|
| 83 | + $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval); |
|
| 84 | 84 | } |
| 85 | 85 | } else { |
| 86 | - $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 86 | + $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 87 | 87 | } |
| 88 | 88 | } else { |
| 89 | - $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval ); |
|
| 89 | + $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 90 | 90 | } |
| 91 | 91 | break; |
| 92 | 92 | case 'W' : |
| 93 | 93 | case 'week' : |
| 94 | - if ( (int)$bill_times > 0 ) { |
|
| 95 | - if ( $interval > 1 ) { |
|
| 96 | - if ( $bill_times > 1 ) { |
|
| 97 | - $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 94 | + if ((int) $bill_times > 0) { |
|
| 95 | + if ($interval > 1) { |
|
| 96 | + if ($bill_times > 1) { |
|
| 97 | + $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 98 | 98 | } else { |
| 99 | - $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval ); |
|
| 99 | + $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval); |
|
| 100 | 100 | } |
| 101 | 101 | } else { |
| 102 | - $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 102 | + $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 103 | 103 | } |
| 104 | 104 | } else { |
| 105 | - $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 105 | + $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 106 | 106 | } |
| 107 | 107 | break; |
| 108 | 108 | case 'M' : |
| 109 | 109 | case 'month' : |
| 110 | - if ( (int)$bill_times > 0 ) { |
|
| 111 | - if ( $interval > 1 ) { |
|
| 112 | - if ( $bill_times > 1 ) { |
|
| 113 | - $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 110 | + if ((int) $bill_times > 0) { |
|
| 111 | + if ($interval > 1) { |
|
| 112 | + if ($bill_times > 1) { |
|
| 113 | + $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 114 | 114 | } else { |
| 115 | - $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval ); |
|
| 115 | + $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval); |
|
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | - $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 118 | + $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 119 | 119 | } |
| 120 | 120 | } else { |
| 121 | - $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 121 | + $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 122 | 122 | } |
| 123 | 123 | break; |
| 124 | 124 | case 'Y' : |
| 125 | 125 | case 'year' : |
| 126 | - if ( (int)$bill_times > 0 ) { |
|
| 127 | - if ( $interval > 1 ) { |
|
| 128 | - if ( $bill_times > 1 ) { |
|
| 129 | - $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 126 | + if ((int) $bill_times > 0) { |
|
| 127 | + if ($interval > 1) { |
|
| 128 | + if ($bill_times > 1) { |
|
| 129 | + $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 130 | 130 | } else { |
| 131 | - $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval ); |
|
| 131 | + $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval); |
|
| 132 | 132 | } |
| 133 | 133 | } else { |
| 134 | - $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 134 | + $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 135 | 135 | } |
| 136 | 136 | } else { |
| 137 | - $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 137 | + $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 138 | 138 | } |
| 139 | 139 | break; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 142 | + return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | -function wpinv_subscription_payment_desc( $invoice ) { |
|
| 146 | - if ( empty( $invoice ) ) { |
|
| 145 | +function wpinv_subscription_payment_desc($invoice) { |
|
| 146 | + if (empty($invoice)) { |
|
| 147 | 147 | return NULL; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $description = ''; |
| 151 | - if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) { |
|
| 152 | - if ( $item->has_free_trial() ) { |
|
| 151 | + if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) { |
|
| 152 | + if ($item->has_free_trial()) { |
|
| 153 | 153 | $trial_period = $item->get_trial_period(); |
| 154 | 154 | $trial_interval = $item->get_trial_interval(); |
| 155 | 155 | } else { |
@@ -157,40 +157,40 @@ discard block |
||
| 157 | 157 | $trial_interval = 0; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() ); |
|
| 160 | + $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency()); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice ); |
|
| 163 | + return apply_filters('wpinv_subscription_payment_desc', $description, $invoice); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | -function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) { |
|
| 167 | - $initial_total = wpinv_round_amount( $initial ); |
|
| 168 | - $recurring_total = wpinv_round_amount( $recurring ); |
|
| 166 | +function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') { |
|
| 167 | + $initial_total = wpinv_round_amount($initial); |
|
| 168 | + $recurring_total = wpinv_round_amount($recurring); |
|
| 169 | 169 | |
| 170 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 170 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 171 | 171 | // Free trial |
| 172 | 172 | } else { |
| 173 | - if ( $bill_times == 1 ) { |
|
| 173 | + if ($bill_times == 1) { |
|
| 174 | 174 | $recurring_total = $initial_total; |
| 175 | - } else if ( $bill_times > 1 && $initial_total != $recurring_total ) { |
|
| 175 | + } else if ($bill_times > 1 && $initial_total != $recurring_total) { |
|
| 176 | 176 | $bill_times--; |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $initial_amount = wpinv_price( $initial_total, $currency ); |
|
| 181 | - $recurring_amount = wpinv_price( $recurring_total, $currency ); |
|
| 180 | + $initial_amount = wpinv_price($initial_total, $currency); |
|
| 181 | + $recurring_amount = wpinv_price($recurring_total, $currency); |
|
| 182 | 182 | |
| 183 | - $recurring = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 183 | + $recurring = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 184 | 184 | |
| 185 | - if ( $initial_total != $recurring_total ) { |
|
| 186 | - $initial = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 185 | + if ($initial_total != $recurring_total) { |
|
| 186 | + $initial = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval); |
|
| 187 | 187 | |
| 188 | - $description = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring ); |
|
| 188 | + $description = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring); |
|
| 189 | 189 | } else { |
| 190 | 190 | $description = $recurring; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency ); |
|
| 193 | + return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -200,27 +200,27 @@ discard block |
||
| 200 | 200 | * @param string $card_number Card number. |
| 201 | 201 | * @return string |
| 202 | 202 | */ |
| 203 | -function getpaid_get_card_name( $card_number ) { |
|
| 203 | +function getpaid_get_card_name($card_number) { |
|
| 204 | 204 | |
| 205 | 205 | // Known regexes. |
| 206 | 206 | $regexes = array( |
| 207 | - '/^4/' => __( 'Visa', 'invoicing' ), |
|
| 208 | - '/^5[1-5]/' => __( 'Mastercard', 'invoicing' ), |
|
| 209 | - '/^3[47]/' => __( 'Amex', 'invoicing' ), |
|
| 210 | - '/^3(?:0[0-5]|[68])/' => __( 'Diners Club', 'invoicing' ), |
|
| 211 | - '/^6(?:011|5)/' => __( 'Discover', 'invoicing' ), |
|
| 212 | - '/^(?:2131|1800|35\d{3})/' => __( 'JCB', 'invoicing' ), |
|
| 207 | + '/^4/' => __('Visa', 'invoicing'), |
|
| 208 | + '/^5[1-5]/' => __('Mastercard', 'invoicing'), |
|
| 209 | + '/^3[47]/' => __('Amex', 'invoicing'), |
|
| 210 | + '/^3(?:0[0-5]|[68])/' => __('Diners Club', 'invoicing'), |
|
| 211 | + '/^6(?:011|5)/' => __('Discover', 'invoicing'), |
|
| 212 | + '/^(?:2131|1800|35\d{3})/' => __('JCB', 'invoicing'), |
|
| 213 | 213 | ); |
| 214 | 214 | |
| 215 | 215 | // Confirm if one matches. |
| 216 | - foreach ( $regexes as $regex => $card ) { |
|
| 217 | - if ( preg_match ( $regex, $card_number ) >= 1 ) { |
|
| 216 | + foreach ($regexes as $regex => $card) { |
|
| 217 | + if (preg_match($regex, $card_number) >= 1) { |
|
| 218 | 218 | return $card; |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // None matched. |
| 223 | - return __( 'Card', 'invoicing' ); |
|
| 223 | + return __('Card', 'invoicing'); |
|
| 224 | 224 | |
| 225 | 225 | } |
| 226 | 226 | |
@@ -229,23 +229,23 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @param WPInv_Invoice|int|null $invoice |
| 231 | 231 | */ |
| 232 | -function wpinv_send_back_to_checkout( $invoice = null ) { |
|
| 233 | - $response = array( 'success' => false ); |
|
| 234 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 232 | +function wpinv_send_back_to_checkout($invoice = null) { |
|
| 233 | + $response = array('success' => false); |
|
| 234 | + $invoice = wpinv_get_invoice($invoice); |
|
| 235 | 235 | |
| 236 | 236 | // Was an invoice created? |
| 237 | - if ( ! empty( $invoice ) ) { |
|
| 238 | - $invoice = is_scalar( $invoice ) ? new WPInv_Invoice( $invoice ) : $invoice; |
|
| 237 | + if (!empty($invoice)) { |
|
| 238 | + $invoice = is_scalar($invoice) ? new WPInv_Invoice($invoice) : $invoice; |
|
| 239 | 239 | $response['invoice'] = $invoice->get_id(); |
| 240 | - do_action( 'getpaid_checkout_invoice_exception', $invoice ); |
|
| 240 | + do_action('getpaid_checkout_invoice_exception', $invoice); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // Do we have any errors? |
| 244 | - if ( wpinv_get_errors() ) { |
|
| 245 | - $response['data'] = getpaid_get_errors_html( true, false ); |
|
| 244 | + if (wpinv_get_errors()) { |
|
| 245 | + $response['data'] = getpaid_get_errors_html(true, false); |
|
| 246 | 246 | } else { |
| 247 | - $response['data'] = __( 'An error occured while processing your payment. Please try again.', 'invoicing' ); |
|
| 247 | + $response['data'] = __('An error occured while processing your payment. Please try again.', 'invoicing'); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - wp_send_json( $response ); |
|
| 250 | + wp_send_json($response); |
|
| 251 | 251 | } |
@@ -24,14 +24,14 @@ |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * Highlights sub menus. |
|
| 28 | - */ |
|
| 29 | - public function set_admin_menu_class() { |
|
| 30 | - global $current_screen, $parent_file, $submenu_file; |
|
| 27 | + * Highlights sub menus. |
|
| 28 | + */ |
|
| 29 | + public function set_admin_menu_class() { |
|
| 30 | + global $current_screen, $parent_file, $submenu_file; |
|
| 31 | 31 | |
| 32 | 32 | if ( ! empty( $current_screen->id ) && in_array( $current_screen->id , array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) { |
| 33 | - $parent_file = 'wpinv'; |
|
| 34 | - $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
|
| 33 | + $parent_file = 'wpinv'; |
|
| 34 | + $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * Setup menus in WP admin. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -defined( 'ABSPATH' ) || exit; |
|
| 6 | +defined('ABSPATH') || exit; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * WC_Admin_Menus Class. |
@@ -13,14 +13,14 @@ discard block |
||
| 13 | 13 | * Hook in tabs. |
| 14 | 14 | */ |
| 15 | 15 | public function __construct() { |
| 16 | - add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) ); |
|
| 17 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
| 18 | - add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 ); |
|
| 19 | - add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 ); |
|
| 20 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 ); |
|
| 21 | - add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 ); |
|
| 22 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
| 23 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
| 16 | + add_action('admin_head', array($this, 'set_admin_menu_class')); |
|
| 17 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
| 18 | + add_action('admin_menu', array($this, 'add_customers_menu'), 18); |
|
| 19 | + add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40); |
|
| 20 | + add_action('admin_menu', array($this, 'add_addons_menu'), 100); |
|
| 21 | + add_action('admin_menu', array($this, 'add_settings_menu'), 60); |
|
| 22 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
| 23 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function set_admin_menu_class() { |
| 30 | 30 | global $current_screen, $parent_file, $submenu_file; |
| 31 | 31 | |
| 32 | - if ( ! empty( $current_screen->id ) && in_array( $current_screen->id , array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) { |
|
| 32 | + if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) { |
|
| 33 | 33 | $parent_file = 'wpinv'; |
| 34 | 34 | $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
| 35 | 35 | } |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function admin_menu() { |
| 40 | 40 | |
| 41 | - $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() ); |
|
| 41 | + $capability = apply_filters('invoicing_capability', wpinv_get_capability()); |
|
| 42 | 42 | add_menu_page( |
| 43 | - __( 'GetPaid', 'invoicing' ), |
|
| 44 | - __( 'GetPaid', 'invoicing' ), |
|
| 43 | + __('GetPaid', 'invoicing'), |
|
| 44 | + __('GetPaid', 'invoicing'), |
|
| 45 | 45 | $capability, |
| 46 | 46 | 'wpinv', |
| 47 | 47 | null, |
| 48 | - 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ), |
|
| 48 | + 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')), |
|
| 49 | 49 | '54.123460' |
| 50 | 50 | ); |
| 51 | 51 | |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | public function add_customers_menu() { |
| 58 | 58 | add_submenu_page( |
| 59 | 59 | 'wpinv', |
| 60 | - __( 'Customers', 'invoicing' ), |
|
| 61 | - __( 'Customers', 'invoicing' ), |
|
| 60 | + __('Customers', 'invoicing'), |
|
| 61 | + __('Customers', 'invoicing'), |
|
| 62 | 62 | wpinv_get_capability(), |
| 63 | 63 | 'wpinv-customers', |
| 64 | - array( $this, 'customers_page' ) |
|
| 64 | + array($this, 'customers_page') |
|
| 65 | 65 | ); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | public function add_subscriptions_menu() { |
| 72 | 72 | add_submenu_page( |
| 73 | 73 | 'wpinv', |
| 74 | - __( 'Subscriptions', 'invoicing' ), |
|
| 75 | - __( 'Subscriptions', 'invoicing' ), |
|
| 74 | + __('Subscriptions', 'invoicing'), |
|
| 75 | + __('Subscriptions', 'invoicing'), |
|
| 76 | 76 | wpinv_get_capability(), |
| 77 | 77 | 'wpinv-subscriptions', |
| 78 | 78 | 'wpinv_subscriptions_page' |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * Displays the customers page. |
| 84 | 84 | */ |
| 85 | 85 | public function customers_page() { |
| 86 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' ); |
|
| 86 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php'); |
|
| 87 | 87 | ?> |
| 88 | 88 | <div class="wrap wpi-customers-wrap"> |
| 89 | 89 | <style> |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | width: 30%; |
| 92 | 92 | } |
| 93 | 93 | </style> |
| 94 | - <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?> <a href="<?php echo wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ); ?>" class="page-title-action"><?php _e( 'Export', 'invoicing' ); ?></a></h1> |
|
| 94 | + <h1><?php echo esc_html(__('Customers', 'invoicing')); ?> <a href="<?php echo wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce'); ?>" class="page-title-action"><?php _e('Export', 'invoicing'); ?></a></h1> |
|
| 95 | 95 | <form method="post"> |
| 96 | 96 | <?php |
| 97 | 97 | $table = new WPInv_Customers_Table(); |
| 98 | 98 | $table->prepare_items(); |
| 99 | - $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' ); |
|
| 99 | + $table->search_box(__('Search Customers', 'invoicing'), 'search-customers'); |
|
| 100 | 100 | $table->display(); |
| 101 | 101 | ?> |
| 102 | 102 | </form> |
@@ -110,16 +110,16 @@ discard block |
||
| 110 | 110 | public function add_settings_menu() { |
| 111 | 111 | add_submenu_page( |
| 112 | 112 | 'wpinv', |
| 113 | - __( 'Invoice Settings', 'invoicing' ), |
|
| 114 | - __( 'Settings', 'invoicing' ), |
|
| 115 | - apply_filters( 'invoicing_capability', wpinv_get_capability() ), |
|
| 113 | + __('Invoice Settings', 'invoicing'), |
|
| 114 | + __('Settings', 'invoicing'), |
|
| 115 | + apply_filters('invoicing_capability', wpinv_get_capability()), |
|
| 116 | 116 | 'wpinv-settings', |
| 117 | - array( $this, 'options_page' ) |
|
| 117 | + array($this, 'options_page') |
|
| 118 | 118 | ); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function add_addons_menu(){ |
|
| 122 | - if ( !apply_filters( 'wpi_show_addons_page', true ) ) { |
|
| 121 | + public function add_addons_menu() { |
|
| 122 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
| 123 | 123 | return; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -129,80 +129,80 @@ discard block |
||
| 129 | 129 | __('Extensions', 'invoicing'), |
| 130 | 130 | 'manage_options', |
| 131 | 131 | 'wpi-addons', |
| 132 | - array( $this, 'addons_page' ) |
|
| 132 | + array($this, 'addons_page') |
|
| 133 | 133 | ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public function addons_page(){ |
|
| 136 | + public function addons_page() { |
|
| 137 | 137 | $addon_obj = new WPInv_Admin_Addons(); |
| 138 | 138 | $addon_obj->output(); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | function options_page() { |
| 142 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 142 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 143 | 143 | |
| 144 | - if ( $page !== 'wpinv-settings' ) { |
|
| 144 | + if ($page !== 'wpinv-settings') { |
|
| 145 | 145 | return; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $settings_tabs = wpinv_get_settings_tabs(); |
| 149 | 149 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
| 150 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
| 151 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
| 150 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
| 151 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
| 152 | 152 | $key = 'main'; |
| 153 | 153 | |
| 154 | - if ( is_array( $sections ) ) { |
|
| 155 | - $key = key( $sections ); |
|
| 154 | + if (is_array($sections)) { |
|
| 155 | + $key = key($sections); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | add_thickbox(); |
| 159 | 159 | |
| 160 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
| 161 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
| 160 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
| 161 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
| 162 | 162 | ob_start(); |
| 163 | 163 | ?> |
| 164 | 164 | <div class="wrap"> |
| 165 | 165 | <h1 class="nav-tab-wrapper"> |
| 166 | 166 | <?php |
| 167 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
| 168 | - $tab_url = add_query_arg( array( |
|
| 167 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
| 168 | + $tab_url = add_query_arg(array( |
|
| 169 | 169 | 'settings-updated' => false, |
| 170 | 170 | 'tab' => $tab_id, |
| 171 | - ) ); |
|
| 171 | + )); |
|
| 172 | 172 | |
| 173 | 173 | // Remove the section from the tabs so we always end up at the main section |
| 174 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
| 175 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
| 174 | + $tab_url = remove_query_arg('section', $tab_url); |
|
| 175 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
| 176 | 176 | |
| 177 | 177 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
| 178 | 178 | |
| 179 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
| 180 | - echo esc_html( $tab_name ); |
|
| 179 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
| 180 | + echo esc_html($tab_name); |
|
| 181 | 181 | echo '</a>'; |
| 182 | 182 | } |
| 183 | 183 | ?> |
| 184 | 184 | </h1> |
| 185 | 185 | <?php |
| 186 | - $number_of_sections = count( $sections ); |
|
| 186 | + $number_of_sections = count($sections); |
|
| 187 | 187 | $number = 0; |
| 188 | - if ( $number_of_sections > 1 ) { |
|
| 188 | + if ($number_of_sections > 1) { |
|
| 189 | 189 | echo '<div><ul class="subsubsub">'; |
| 190 | - foreach( $sections as $section_id => $section_name ) { |
|
| 190 | + foreach ($sections as $section_id => $section_name) { |
|
| 191 | 191 | echo '<li>'; |
| 192 | 192 | $number++; |
| 193 | - $tab_url = add_query_arg( array( |
|
| 193 | + $tab_url = add_query_arg(array( |
|
| 194 | 194 | 'settings-updated' => false, |
| 195 | 195 | 'tab' => $active_tab, |
| 196 | 196 | 'section' => $section_id |
| 197 | - ) ); |
|
| 198 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
| 197 | + )); |
|
| 198 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
| 199 | 199 | $class = ''; |
| 200 | - if ( $section == $section_id ) { |
|
| 200 | + if ($section == $section_id) { |
|
| 201 | 201 | $class = 'current'; |
| 202 | 202 | } |
| 203 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
| 203 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
| 204 | 204 | |
| 205 | - if ( $number != $number_of_sections ) { |
|
| 205 | + if ($number != $number_of_sections) { |
|
| 206 | 206 | echo ' | '; |
| 207 | 207 | } |
| 208 | 208 | echo '</li>'; |
@@ -214,20 +214,20 @@ discard block |
||
| 214 | 214 | <form method="post" action="options.php"> |
| 215 | 215 | <table class="form-table"> |
| 216 | 216 | <?php |
| 217 | - settings_fields( 'wpinv_settings' ); |
|
| 217 | + settings_fields('wpinv_settings'); |
|
| 218 | 218 | |
| 219 | - if ( 'main' === $section ) { |
|
| 220 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
| 219 | + if ('main' === $section) { |
|
| 220 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
| 224 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
| 225 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
| 226 | - do_action( 'getpaid_settings_tab_bottom', $active_tab, $section ); |
|
| 223 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
| 224 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
| 225 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
| 226 | + do_action('getpaid_settings_tab_bottom', $active_tab, $section); |
|
| 227 | 227 | |
| 228 | 228 | // For backwards compatibility |
| 229 | - if ( 'main' === $section ) { |
|
| 230 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
| 229 | + if ('main' === $section) { |
|
| 230 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
| 231 | 231 | } |
| 232 | 232 | ?> |
| 233 | 233 | </table> |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | public function remove_admin_submenus() { |
| 244 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
| 244 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -251,8 +251,8 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | add_meta_box( |
| 253 | 253 | 'wpinv_endpoints_nav_link', |
| 254 | - __( 'GetPaid endpoints', 'invoicing' ), |
|
| 255 | - array( $this, 'nav_menu_links' ), |
|
| 254 | + __('GetPaid endpoints', 'invoicing'), |
|
| 255 | + array($this, 'nav_menu_links'), |
|
| 256 | 256 | 'nav-menus', |
| 257 | 257 | 'side', |
| 258 | 258 | 'low' |
@@ -267,12 +267,12 @@ discard block |
||
| 267 | 267 | $endpoints = $this->get_menu_items(); |
| 268 | 268 | ?> |
| 269 | 269 | <div id="invoicing-endpoints" class="posttypediv"> |
| 270 | - <?php if ( ! empty( $endpoints['pages'] ) ) : ?> |
|
| 270 | + <?php if (!empty($endpoints['pages'])) : ?> |
|
| 271 | 271 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
| 272 | 272 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
| 273 | 273 | <?php |
| 274 | - $walker = new Walker_Nav_Menu_Checklist( array() ); |
|
| 275 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) ); |
|
| 274 | + $walker = new Walker_Nav_Menu_Checklist(array()); |
|
| 275 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker)); |
|
| 276 | 276 | ?> |
| 277 | 277 | </ul> |
| 278 | 278 | </div> |
@@ -281,11 +281,11 @@ discard block |
||
| 281 | 281 | <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints"> |
| 282 | 282 | <span class="list-controls hide-if-no-js"> |
| 283 | 283 | <input type="checkbox" id="invoicing-endpoints-tab" class="select-all"> |
| 284 | - <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label> |
|
| 284 | + <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label> |
|
| 285 | 285 | </span> |
| 286 | 286 | |
| 287 | 287 | <span class="add-to-menu"> |
| 288 | - <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
| 288 | + <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
| 289 | 289 | <span class="spinner"></span> |
| 290 | 290 | </span> |
| 291 | 291 | </p> |
@@ -298,35 +298,35 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @return array. |
| 300 | 300 | */ |
| 301 | - public function get_menu_items(){ |
|
| 301 | + public function get_menu_items() { |
|
| 302 | 302 | $items = array(); |
| 303 | 303 | |
| 304 | 304 | $pages = array( |
| 305 | 305 | array( |
| 306 | - 'id' => wpinv_get_option( 'invoice_history_page' ), |
|
| 307 | - 'label' => __( 'My Invoices', 'invoicing' ), |
|
| 306 | + 'id' => wpinv_get_option('invoice_history_page'), |
|
| 307 | + 'label' => __('My Invoices', 'invoicing'), |
|
| 308 | 308 | ), |
| 309 | 309 | array( |
| 310 | - 'id' => wpinv_get_option( 'invoice_subscription_page' ), |
|
| 311 | - 'label' => __( 'My Subscriptions', 'invoicing' ), |
|
| 310 | + 'id' => wpinv_get_option('invoice_subscription_page'), |
|
| 311 | + 'label' => __('My Subscriptions', 'invoicing'), |
|
| 312 | 312 | ) |
| 313 | 313 | ); |
| 314 | 314 | |
| 315 | - foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) { |
|
| 315 | + foreach (apply_filters('getpaid_menu_pages', $pages) as $page) { |
|
| 316 | 316 | |
| 317 | - if ( (int) $page['id'] > 0 ) { |
|
| 317 | + if ((int) $page['id'] > 0) { |
|
| 318 | 318 | |
| 319 | 319 | $item = new stdClass(); |
| 320 | 320 | $item->object_id = (int) $page['id']; |
| 321 | 321 | $item->db_id = 0; |
| 322 | - $item->object = 'page'; |
|
| 322 | + $item->object = 'page'; |
|
| 323 | 323 | $item->menu_item_parent = 0; |
| 324 | 324 | $item->type = 'post_type'; |
| 325 | - $item->title = sanitize_text_field( $page['label'] ); |
|
| 326 | - $item->url = get_permalink( (int) $page['id'] ); |
|
| 325 | + $item->title = sanitize_text_field($page['label']); |
|
| 326 | + $item->url = get_permalink((int) $page['id']); |
|
| 327 | 327 | $item->target = ''; |
| 328 | 328 | $item->attr_title = ''; |
| 329 | - $item->classes = array( 'wpinv-menu-item' ); |
|
| 329 | + $item->classes = array('wpinv-menu-item'); |
|
| 330 | 330 | $item->xfn = ''; |
| 331 | 331 | |
| 332 | 332 | $items['pages'][] = $item; |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
| 338 | + return apply_filters('wpinv_menu_items', $items); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | - exit; // Exit if accessed directly |
|
| 11 | + exit; // Exit if accessed directly |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | class GetPaid_Meta_Box_Item_Details { |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * Output the metabox. |
|
| 21 | - * |
|
| 22 | - * @param WP_Post $post |
|
| 23 | - */ |
|
| 20 | + * Output the metabox. |
|
| 21 | + * |
|
| 22 | + * @param WP_Post $post |
|
| 23 | + */ |
|
| 24 | 24 | public static function output( $post ) { |
| 25 | 25 | |
| 26 | 26 | // Prepare the item. |
@@ -270,35 +270,35 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
| 273 | - * Save meta box data. |
|
| 274 | - * |
|
| 275 | - * @param int $post_id |
|
| 276 | - */ |
|
| 277 | - public static function save( $post_id ) { |
|
| 273 | + * Save meta box data. |
|
| 274 | + * |
|
| 275 | + * @param int $post_id |
|
| 276 | + */ |
|
| 277 | + public static function save( $post_id ) { |
|
| 278 | 278 | |
| 279 | 279 | // Prepare the item. |
| 280 | 280 | $item = new WPInv_Item( $post_id ); |
| 281 | 281 | |
| 282 | 282 | // Load new data. |
| 283 | 283 | $item->set_props( |
| 284 | - array( |
|
| 285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
| 286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
| 287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
| 288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
| 289 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
| 284 | + array( |
|
| 285 | + 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
| 286 | + 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
| 287 | + 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
| 288 | + 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
| 289 | + 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
| 290 | 290 | 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
| 291 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
| 292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
| 293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
| 294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
| 295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
| 296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
| 297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
| 298 | - ) |
|
| 291 | + 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
| 292 | + 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
| 293 | + 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
| 294 | + 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
| 295 | + 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
| 296 | + 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
| 297 | + 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
| 298 | + ) |
|
| 299 | 299 | ); |
| 300 | 300 | |
| 301 | - $item->save(); |
|
| 302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
| 303 | - } |
|
| 301 | + $item->save(); |
|
| 302 | + do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
| 303 | + } |
|
| 304 | 304 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if (!defined('ABSPATH')) { |
|
| 11 | 11 | exit; // Exit if accessed directly |
| 12 | 12 | } |
| 13 | 13 | |
@@ -21,27 +21,27 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param WP_Post $post |
| 23 | 23 | */ |
| 24 | - public static function output( $post ) { |
|
| 24 | + public static function output($post) { |
|
| 25 | 25 | |
| 26 | 26 | // Prepare the item. |
| 27 | - $item = new WPInv_Item( $post ); |
|
| 27 | + $item = new WPInv_Item($post); |
|
| 28 | 28 | |
| 29 | 29 | // Nonce field. |
| 30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
| 30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
| 31 | 31 | |
| 32 | 32 | // Set the currency position. |
| 33 | 33 | $position = wpinv_currency_position(); |
| 34 | 34 | |
| 35 | - if ( $position == 'left_space' ) { |
|
| 35 | + if ($position == 'left_space') { |
|
| 36 | 36 | $position = 'left'; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( $position == 'right_space' ) { |
|
| 39 | + if ($position == 'right_space') { |
|
| 40 | 40 | $position = 'right'; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | ?> |
| 44 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
| 44 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
| 45 | 45 | <style> |
| 46 | 46 | #poststuff .input-group-text, |
| 47 | 47 | #poststuff .form-control { |
@@ -55,21 +55,21 @@ discard block |
||
| 55 | 55 | </style> |
| 56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
| 57 | 57 | |
| 58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
| 58 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
| 59 | 59 | <div class="form-group row"> |
| 60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label> |
|
| 60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label> |
|
| 61 | 61 | <div class="col-sm-8"> |
| 62 | 62 | <div class="row"> |
| 63 | 63 | <div class="col-sm-4 getpaid-price-input"> |
| 64 | 64 | <div class="input-group input-group-sm"> |
| 65 | - <?php if( 'left' == $position ) : ?> |
|
| 65 | + <?php if ('left' == $position) : ?> |
|
| 66 | 66 | <div class="input-group-prepend"> |
| 67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 68 | 68 | </div> |
| 69 | 69 | <?php endif; ?> |
| 70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( $item->get_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
| 70 | + <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr($item->get_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
| 71 | 71 | |
| 72 | - <?php if( 'left' != $position ) : ?> |
|
| 72 | + <?php if ('left' != $position) : ?> |
|
| 73 | 73 | <div class="input-group-append"> |
| 74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 75 | 75 | </div> |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | </div> |
| 80 | 80 | <div class="col-sm-4 wpinv_show_if_recurring"> |
| 81 | 81 | <?php |
| 82 | - _e( 'every' ); |
|
| 82 | + _e('every'); |
|
| 83 | 83 | echo " "; |
| 84 | 84 | ?> |
| 85 | - <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
| 85 | + <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" /> |
|
| 86 | 86 | </div> |
| 87 | 87 | <div class="col-sm-4 wpinv_show_if_recurring"> |
| 88 | 88 | <?php |
@@ -90,16 +90,16 @@ discard block |
||
| 90 | 90 | array( |
| 91 | 91 | 'id' => 'wpinv_recurring_period', |
| 92 | 92 | 'name' => 'wpinv_recurring_period', |
| 93 | - 'label' => __( 'Period', 'invoicing' ), |
|
| 94 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
| 95 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
| 93 | + 'label' => __('Period', 'invoicing'), |
|
| 94 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
| 95 | + 'value' => $item->get_recurring_period('edit'), |
|
| 96 | 96 | 'select2' => true, |
| 97 | 97 | 'data-allow-clear' => 'false', |
| 98 | 98 | 'options' => array( |
| 99 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
| 100 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
| 101 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
| 102 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
| 99 | + 'D' => __('day(s)', 'invoicing'), |
|
| 100 | + 'W' => __('week(s)', 'invoicing'), |
|
| 101 | + 'M' => __('month(s)', 'invoicing'), |
|
| 102 | + 'Y' => __('year(s)', 'invoicing'), |
|
| 103 | 103 | ) |
| 104 | 104 | ) |
| 105 | 105 | ); |
@@ -111,9 +111,9 @@ discard block |
||
| 111 | 111 | <?php |
| 112 | 112 | |
| 113 | 113 | // Dynamic pricing. |
| 114 | - if( $item->supports_dynamic_pricing() ) { |
|
| 114 | + if ($item->supports_dynamic_pricing()) { |
|
| 115 | 115 | |
| 116 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
| 116 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
| 117 | 117 | |
| 118 | 118 | // NYP toggle. |
| 119 | 119 | echo aui()->input( |
@@ -121,31 +121,31 @@ discard block |
||
| 121 | 121 | 'id' => 'wpinv_name_your_price', |
| 122 | 122 | 'name' => 'wpinv_name_your_price', |
| 123 | 123 | 'type' => 'checkbox', |
| 124 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
| 124 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
| 125 | 125 | 'value' => '1', |
| 126 | 126 | 'checked' => $item->user_can_set_their_price(), |
| 127 | 127 | 'no_wrap' => true, |
| 128 | 128 | ) |
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
| 131 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Subscriptions. |
| 136 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
| 136 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
| 137 | 137 | echo aui()->input( |
| 138 | 138 | array( |
| 139 | 139 | 'id' => 'wpinv_is_recurring', |
| 140 | 140 | 'name' => 'wpinv_is_recurring', |
| 141 | 141 | 'type' => 'checkbox', |
| 142 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
| 142 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
| 143 | 143 | 'value' => '1', |
| 144 | 144 | 'checked' => $item->is_recurring(), |
| 145 | 145 | 'no_wrap' => true, |
| 146 | 146 | ) |
| 147 | 147 | ); |
| 148 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
| 148 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
| 149 | 149 | |
| 150 | 150 | ?> |
| 151 | 151 | <div class="wpinv_show_if_recurring"> |
@@ -155,30 +155,30 @@ discard block |
||
| 155 | 155 | </div> |
| 156 | 156 | </div> |
| 157 | 157 | <div class="col-sm-1 pt-2 pl-0"> |
| 158 | - <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span> |
|
| 158 | + <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span> |
|
| 159 | 159 | </div> |
| 160 | 160 | </div> |
| 161 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
| 161 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
| 162 | 162 | |
| 163 | - <?php if( $item->supports_dynamic_pricing() ) : ?> |
|
| 164 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
| 163 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
| 164 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
| 165 | 165 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
| 166 | 166 | |
| 167 | 167 | <div class="form-group row"> |
| 168 | 168 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
| 169 | - <?php _e( 'Minimum Price', 'invoicing' );?> |
|
| 169 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
| 170 | 170 | </label> |
| 171 | 171 | <div class="col-sm-8"> |
| 172 | 172 | <div class="input-group input-group-sm"> |
| 173 | - <?php if( 'left' == $position ) : ?> |
|
| 173 | + <?php if ('left' == $position) : ?> |
|
| 174 | 174 | <div class="input-group-prepend"> |
| 175 | 175 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 176 | 176 | </div> |
| 177 | 177 | <?php endif; ?> |
| 178 | 178 | |
| 179 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( $item->get_minimum_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
| 179 | + <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr($item->get_minimum_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
| 180 | 180 | |
| 181 | - <?php if( 'left' != $position ) : ?> |
|
| 181 | + <?php if ('left' != $position) : ?> |
|
| 182 | 182 | <div class="input-group-append"> |
| 183 | 183 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
| 184 | 184 | </div> |
@@ -187,45 +187,45 @@ discard block |
||
| 187 | 187 | </div> |
| 188 | 188 | |
| 189 | 189 | <div class="col-sm-1 pt-2 pl-0"> |
| 190 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span> |
|
| 190 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span> |
|
| 191 | 191 | </div> |
| 192 | 192 | </div> |
| 193 | 193 | |
| 194 | 194 | </div> |
| 195 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
| 195 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
| 196 | 196 | <?php endif; ?> |
| 197 | 197 | |
| 198 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
| 198 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
| 199 | 199 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
| 200 | 200 | |
| 201 | 201 | <div class="form-group row"> |
| 202 | 202 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
| 203 | - <?php _e( 'Maximum Renewals', 'invoicing' );?> |
|
| 203 | + <?php _e('Maximum Renewals', 'invoicing'); ?> |
|
| 204 | 204 | </label> |
| 205 | 205 | <div class="col-sm-8"> |
| 206 | - <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
| 206 | + <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
| 207 | 207 | </div> |
| 208 | 208 | <div class="col-sm-1 pt-2 pl-0"> |
| 209 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span> |
|
| 209 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span> |
|
| 210 | 210 | </div> |
| 211 | 211 | </div> |
| 212 | 212 | |
| 213 | 213 | </div> |
| 214 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
| 214 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
| 215 | 215 | |
| 216 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
| 216 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
| 217 | 217 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
| 218 | 218 | |
| 219 | 219 | <div class="form-group row"> |
| 220 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label> |
|
| 220 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label> |
|
| 221 | 221 | |
| 222 | 222 | <div class="col-sm-8"> |
| 223 | 223 | <div class="row"> |
| 224 | 224 | <div class="col-sm-6"> |
| 225 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?> |
|
| 225 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
| 226 | 226 | |
| 227 | 227 | <div> |
| 228 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
| 228 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
| 229 | 229 | </div> |
| 230 | 230 | </div> |
| 231 | 231 | <div class="col-sm-6"> |
@@ -234,17 +234,17 @@ discard block |
||
| 234 | 234 | array( |
| 235 | 235 | 'id' => 'wpinv_trial_period', |
| 236 | 236 | 'name' => 'wpinv_trial_period', |
| 237 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
| 238 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
| 239 | - 'value' => $item->get_trial_period( 'edit' ), |
|
| 237 | + 'label' => __('Trial Period', 'invoicing'), |
|
| 238 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
| 239 | + 'value' => $item->get_trial_period('edit'), |
|
| 240 | 240 | 'select2' => true, |
| 241 | 241 | 'data-allow-clear' => 'false', |
| 242 | 242 | 'no_wrap' => true, |
| 243 | 243 | 'options' => array( |
| 244 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
| 245 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
| 246 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
| 247 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
| 244 | + 'D' => __('day(s)', 'invoicing'), |
|
| 245 | + 'W' => __('week(s)', 'invoicing'), |
|
| 246 | + 'M' => __('month(s)', 'invoicing'), |
|
| 247 | + 'Y' => __('year(s)', 'invoicing'), |
|
| 248 | 248 | ) |
| 249 | 249 | ) |
| 250 | 250 | ); |
@@ -255,15 +255,15 @@ discard block |
||
| 255 | 255 | </div> |
| 256 | 256 | |
| 257 | 257 | <div class="col-sm-1 pt-2 pl-0"> |
| 258 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span> |
|
| 258 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span> |
|
| 259 | 259 | </div> |
| 260 | 260 | |
| 261 | 261 | </div> |
| 262 | 262 | |
| 263 | 263 | </div> |
| 264 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
| 264 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
| 265 | 265 | |
| 266 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
| 266 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
| 267 | 267 | </div> |
| 268 | 268 | <?php |
| 269 | 269 | |
@@ -274,31 +274,31 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @param int $post_id |
| 276 | 276 | */ |
| 277 | - public static function save( $post_id ) { |
|
| 277 | + public static function save($post_id) { |
|
| 278 | 278 | |
| 279 | 279 | // Prepare the item. |
| 280 | - $item = new WPInv_Item( $post_id ); |
|
| 280 | + $item = new WPInv_Item($post_id); |
|
| 281 | 281 | |
| 282 | 282 | // Load new data. |
| 283 | 283 | $item->set_props( |
| 284 | 284 | array( |
| 285 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
| 286 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
| 287 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
| 288 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
| 289 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
| 290 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
| 291 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
| 292 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
| 293 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
| 294 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
| 295 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
| 296 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
| 297 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
| 285 | + 'price' => isset($_POST['wpinv_item_price']) ? (float) $_POST['wpinv_item_price'] : null, |
|
| 286 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
| 287 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
| 288 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
| 289 | + 'is_dynamic_pricing' => isset($_POST['wpinv_name_your_price']), |
|
| 290 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
| 291 | + 'is_recurring' => isset($_POST['wpinv_is_recurring']), |
|
| 292 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
| 293 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1, |
|
| 294 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
| 295 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
| 296 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
| 297 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
| 298 | 298 | ) |
| 299 | 299 | ); |
| 300 | 300 | |
| 301 | 301 | $item->save(); |
| 302 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
| 302 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
| 303 | 303 | } |
| 304 | 304 | } |
@@ -13,648 +13,648 @@ discard block |
||
| 13 | 13 | class GetPaid_Post_Types_Admin { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Hook in methods. |
|
| 17 | - */ |
|
| 18 | - public static function init() { |
|
| 19 | - |
|
| 20 | - // Init metaboxes. |
|
| 21 | - GetPaid_Metaboxes::init(); |
|
| 22 | - |
|
| 23 | - // Filter the post updated messages. |
|
| 24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
| 25 | - |
|
| 26 | - // Filter post actions. |
|
| 27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
| 28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
| 29 | - |
|
| 30 | - // Invoice table columns. |
|
| 31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
| 32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
| 33 | - |
|
| 34 | - // Items table columns. |
|
| 35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
| 36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
| 37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
| 38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
| 39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
| 40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
| 41 | - |
|
| 42 | - // Payment forms columns. |
|
| 43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
| 44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
| 45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
| 46 | - |
|
| 47 | - // Discount table columns. |
|
| 48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
| 49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
| 50 | - |
|
| 51 | - // Deleting posts. |
|
| 52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
| 53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
| 54 | - |
|
| 55 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Post updated messages. |
|
| 60 | - */ |
|
| 61 | - public static function post_updated_messages( $messages ) { |
|
| 62 | - global $post; |
|
| 63 | - |
|
| 64 | - $messages['wpi_discount'] = array( |
|
| 65 | - 0 => '', |
|
| 66 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 67 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 68 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 69 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 70 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 71 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 72 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 73 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 74 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 75 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 76 | - ); |
|
| 77 | - |
|
| 78 | - $messages['wpi_payment_form'] = array( |
|
| 79 | - 0 => '', |
|
| 80 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 81 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 82 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 83 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 84 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 85 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 86 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
| 87 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
| 88 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 89 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
| 90 | - ); |
|
| 91 | - |
|
| 92 | - return $messages; |
|
| 93 | - |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Post row actions. |
|
| 98 | - */ |
|
| 99 | - public static function post_row_actions( $actions, $post ) { |
|
| 100 | - |
|
| 101 | - $post = get_post( $post ); |
|
| 102 | - |
|
| 103 | - // We do not want to edit the default payment form. |
|
| 104 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
| 105 | - unset( $actions['trash'] ); |
|
| 106 | - unset( $actions['inline hide-if-no-js'] ); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - return $actions; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 16 | + * Hook in methods. |
|
| 17 | + */ |
|
| 18 | + public static function init() { |
|
| 19 | + |
|
| 20 | + // Init metaboxes. |
|
| 21 | + GetPaid_Metaboxes::init(); |
|
| 22 | + |
|
| 23 | + // Filter the post updated messages. |
|
| 24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
| 25 | + |
|
| 26 | + // Filter post actions. |
|
| 27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
| 28 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
| 29 | + |
|
| 30 | + // Invoice table columns. |
|
| 31 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
| 32 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
| 33 | + |
|
| 34 | + // Items table columns. |
|
| 35 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
| 36 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
| 37 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
| 38 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
| 39 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
| 40 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
| 41 | + |
|
| 42 | + // Payment forms columns. |
|
| 43 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
| 44 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
| 45 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
| 46 | + |
|
| 47 | + // Discount table columns. |
|
| 48 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
| 49 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
| 50 | + |
|
| 51 | + // Deleting posts. |
|
| 52 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
| 53 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
| 54 | + |
|
| 55 | + add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Post updated messages. |
|
| 60 | + */ |
|
| 61 | + public static function post_updated_messages( $messages ) { |
|
| 62 | + global $post; |
|
| 63 | + |
|
| 64 | + $messages['wpi_discount'] = array( |
|
| 65 | + 0 => '', |
|
| 66 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 67 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 68 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 69 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 70 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 71 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 72 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 73 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 74 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 75 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 76 | + ); |
|
| 77 | + |
|
| 78 | + $messages['wpi_payment_form'] = array( |
|
| 79 | + 0 => '', |
|
| 80 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 81 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 82 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 83 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 84 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 85 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 86 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
| 87 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
| 88 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 89 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
| 90 | + ); |
|
| 91 | + |
|
| 92 | + return $messages; |
|
| 93 | + |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Post row actions. |
|
| 98 | + */ |
|
| 99 | + public static function post_row_actions( $actions, $post ) { |
|
| 100 | + |
|
| 101 | + $post = get_post( $post ); |
|
| 102 | + |
|
| 103 | + // We do not want to edit the default payment form. |
|
| 104 | + if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
| 105 | + unset( $actions['trash'] ); |
|
| 106 | + unset( $actions['inline hide-if-no-js'] ); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + return $actions; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | 113 | * Remove bulk edit option from admin side quote listing |
| 114 | 114 | * |
| 115 | 115 | * @since 1.0.0 |
| 116 | 116 | * @param array $actions post actions |
| 117 | - * @param WP_Post $post |
|
| 117 | + * @param WP_Post $post |
|
| 118 | 118 | * @return array $actions actions without edit option |
| 119 | 119 | */ |
| 120 | 120 | public static function filter_invoice_row_actions( $actions, $post ) { |
| 121 | 121 | |
| 122 | 122 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
| 123 | 123 | |
| 124 | - $actions = array(); |
|
| 125 | - $invoice = new WPInv_Invoice( $post ); |
|
| 126 | - |
|
| 127 | - $actions['edit'] = sprintf( |
|
| 128 | - '<a href="%1$s">%2$s</a>', |
|
| 129 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 130 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
| 131 | - ); |
|
| 132 | - |
|
| 133 | - if ( ! $invoice->is_draft() ) { |
|
| 134 | - |
|
| 135 | - $actions['view'] = sprintf( |
|
| 136 | - '<a href="%1$s">%2$s</a>', |
|
| 137 | - esc_url( $invoice->get_view_url() ), |
|
| 138 | - sprintf( |
|
| 139 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
| 140 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
| 141 | - ) |
|
| 142 | - ); |
|
| 143 | - |
|
| 144 | - $actions['send'] = sprintf( |
|
| 145 | - '<a href="%1$s">%2$s</a>', |
|
| 146 | - esc_url( |
|
| 147 | - wp_nonce_url( |
|
| 148 | - add_query_arg( |
|
| 149 | - array( |
|
| 150 | - 'getpaid-admin-action' => 'send_invoice', |
|
| 151 | - 'invoice_id' => $invoice->get_id() |
|
| 152 | - ) |
|
| 153 | - ), |
|
| 154 | - 'getpaid-nonce', |
|
| 155 | - 'getpaid-nonce' |
|
| 156 | - ) |
|
| 157 | - ), |
|
| 158 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
| 159 | - ); |
|
| 160 | - |
|
| 161 | - } |
|
| 124 | + $actions = array(); |
|
| 125 | + $invoice = new WPInv_Invoice( $post ); |
|
| 126 | + |
|
| 127 | + $actions['edit'] = sprintf( |
|
| 128 | + '<a href="%1$s">%2$s</a>', |
|
| 129 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 130 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
| 131 | + ); |
|
| 132 | + |
|
| 133 | + if ( ! $invoice->is_draft() ) { |
|
| 134 | + |
|
| 135 | + $actions['view'] = sprintf( |
|
| 136 | + '<a href="%1$s">%2$s</a>', |
|
| 137 | + esc_url( $invoice->get_view_url() ), |
|
| 138 | + sprintf( |
|
| 139 | + esc_html( __( 'View %s', 'invoicing' ) ), |
|
| 140 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
| 141 | + ) |
|
| 142 | + ); |
|
| 143 | + |
|
| 144 | + $actions['send'] = sprintf( |
|
| 145 | + '<a href="%1$s">%2$s</a>', |
|
| 146 | + esc_url( |
|
| 147 | + wp_nonce_url( |
|
| 148 | + add_query_arg( |
|
| 149 | + array( |
|
| 150 | + 'getpaid-admin-action' => 'send_invoice', |
|
| 151 | + 'invoice_id' => $invoice->get_id() |
|
| 152 | + ) |
|
| 153 | + ), |
|
| 154 | + 'getpaid-nonce', |
|
| 155 | + 'getpaid-nonce' |
|
| 156 | + ) |
|
| 157 | + ), |
|
| 158 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
| 159 | + ); |
|
| 160 | + |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | return $actions; |
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Returns an array of invoice table columns. |
|
| 170 | - */ |
|
| 171 | - public static function invoice_columns( $columns ) { |
|
| 172 | - |
|
| 173 | - $columns = array( |
|
| 174 | - 'cb' => $columns['cb'], |
|
| 175 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
| 176 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 177 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
| 178 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
| 179 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 180 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
| 181 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 182 | - ); |
|
| 183 | - |
|
| 184 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Displays invoice table columns. |
|
| 189 | - */ |
|
| 190 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
| 191 | - |
|
| 192 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 193 | - |
|
| 194 | - switch ( $column_name ) { |
|
| 195 | - |
|
| 196 | - case 'invoice_date' : |
|
| 197 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
| 198 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
| 199 | - echo "<span title='$date_time'>$date</span>"; |
|
| 200 | - break; |
|
| 201 | - |
|
| 202 | - case 'payment_date' : |
|
| 203 | - |
|
| 204 | - if ( $invoice->is_paid() ) { |
|
| 205 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
| 206 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
| 207 | - echo "<span title='$date_time'>$date</span>"; |
|
| 208 | - } else { |
|
| 209 | - echo "—"; |
|
| 210 | - } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Returns an array of invoice table columns. |
|
| 170 | + */ |
|
| 171 | + public static function invoice_columns( $columns ) { |
|
| 172 | + |
|
| 173 | + $columns = array( |
|
| 174 | + 'cb' => $columns['cb'], |
|
| 175 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
| 176 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
| 177 | + 'invoice_date' => __( 'Created', 'invoicing' ), |
|
| 178 | + 'payment_date' => __( 'Completed', 'invoicing' ), |
|
| 179 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 180 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
| 181 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 182 | + ); |
|
| 183 | + |
|
| 184 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Displays invoice table columns. |
|
| 189 | + */ |
|
| 190 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
| 191 | + |
|
| 192 | + $invoice = new WPInv_Invoice( $post_id ); |
|
| 193 | + |
|
| 194 | + switch ( $column_name ) { |
|
| 195 | + |
|
| 196 | + case 'invoice_date' : |
|
| 197 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
| 198 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
| 199 | + echo "<span title='$date_time'>$date</span>"; |
|
| 200 | + break; |
|
| 201 | + |
|
| 202 | + case 'payment_date' : |
|
| 203 | + |
|
| 204 | + if ( $invoice->is_paid() ) { |
|
| 205 | + $date_time = esc_attr( $invoice->get_completed_date() ); |
|
| 206 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
| 207 | + echo "<span title='$date_time'>$date</span>"; |
|
| 208 | + } else { |
|
| 209 | + echo "—"; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - break; |
|
| 212 | + break; |
|
| 213 | 213 | |
| 214 | - case 'amount' : |
|
| 214 | + case 'amount' : |
|
| 215 | 215 | |
| 216 | - $amount = $invoice->get_total(); |
|
| 217 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
| 216 | + $amount = $invoice->get_total(); |
|
| 217 | + $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
| 218 | 218 | |
| 219 | - if ( $invoice->is_refunded() ) { |
|
| 220 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
| 221 | - echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
| 222 | - } else { |
|
| 219 | + if ( $invoice->is_refunded() ) { |
|
| 220 | + $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
| 221 | + echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
| 222 | + } else { |
|
| 223 | 223 | |
| 224 | - $discount = $invoice->get_total_discount(); |
|
| 224 | + $discount = $invoice->get_total_discount(); |
|
| 225 | 225 | |
| 226 | - if ( ! empty( $discount ) ) { |
|
| 227 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
| 228 | - echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
| 229 | - } else { |
|
| 230 | - echo $formated_amount; |
|
| 231 | - } |
|
| 226 | + if ( ! empty( $discount ) ) { |
|
| 227 | + $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
| 228 | + echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
| 229 | + } else { |
|
| 230 | + echo $formated_amount; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - } |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - break; |
|
| 235 | + break; |
|
| 236 | 236 | |
| 237 | - case 'status' : |
|
| 238 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
| 239 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
| 237 | + case 'status' : |
|
| 238 | + $status = sanitize_text_field( $invoice->get_status() ); |
|
| 239 | + $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
| 240 | 240 | |
| 241 | - // If it is paid, show the gateway title. |
|
| 242 | - if ( $invoice->is_paid() ) { |
|
| 243 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
| 244 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
| 241 | + // If it is paid, show the gateway title. |
|
| 242 | + if ( $invoice->is_paid() ) { |
|
| 243 | + $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
| 244 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
| 245 | 245 | |
| 246 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
| 247 | - } else { |
|
| 248 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
| 249 | - } |
|
| 246 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
| 247 | + } else { |
|
| 248 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - // If it is not paid, display the overdue and view status. |
|
| 252 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 251 | + // If it is not paid, display the overdue and view status. |
|
| 252 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 253 | 253 | |
| 254 | - // Invoice view status. |
|
| 255 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
| 256 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 257 | - } else { |
|
| 258 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 259 | - } |
|
| 254 | + // Invoice view status. |
|
| 255 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
| 256 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 257 | + } else { |
|
| 258 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - // Display the overview status. |
|
| 262 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
| 263 | - $due_date = $invoice->get_due_date(); |
|
| 264 | - $fomatted = getpaid_format_date( $due_date ); |
|
| 261 | + // Display the overview status. |
|
| 262 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
| 263 | + $due_date = $invoice->get_due_date(); |
|
| 264 | + $fomatted = getpaid_format_date( $due_date ); |
|
| 265 | 265 | |
| 266 | - if ( ! empty( $fomatted ) ) { |
|
| 267 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
| 268 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
| 269 | - } |
|
| 270 | - } |
|
| 266 | + if ( ! empty( $fomatted ) ) { |
|
| 267 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
| 268 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - } |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - break; |
|
| 274 | + break; |
|
| 275 | 275 | |
| 276 | - case 'recurring': |
|
| 276 | + case 'recurring': |
|
| 277 | 277 | |
| 278 | - if ( $invoice->is_recurring() ) { |
|
| 279 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
| 280 | - } else { |
|
| 281 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
| 282 | - } |
|
| 283 | - break; |
|
| 278 | + if ( $invoice->is_recurring() ) { |
|
| 279 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
| 280 | + } else { |
|
| 281 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
| 282 | + } |
|
| 283 | + break; |
|
| 284 | 284 | |
| 285 | - case 'number' : |
|
| 285 | + case 'number' : |
|
| 286 | 286 | |
| 287 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
| 288 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
| 289 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
| 287 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
| 288 | + $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
| 289 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
| 290 | 290 | |
| 291 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
| 291 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
| 292 | 292 | |
| 293 | - break; |
|
| 293 | + break; |
|
| 294 | 294 | |
| 295 | - case 'customer' : |
|
| 295 | + case 'customer' : |
|
| 296 | 296 | |
| 297 | - $customer_name = $invoice->get_user_full_name(); |
|
| 297 | + $customer_name = $invoice->get_user_full_name(); |
|
| 298 | 298 | |
| 299 | - if ( empty( $customer_name ) ) { |
|
| 300 | - $customer_name = $invoice->get_email(); |
|
| 301 | - } |
|
| 299 | + if ( empty( $customer_name ) ) { |
|
| 300 | + $customer_name = $invoice->get_email(); |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - if ( ! empty( $customer_name ) ) { |
|
| 304 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
| 305 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
| 306 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
| 307 | - } else { |
|
| 308 | - echo '<div>—</div>'; |
|
| 309 | - } |
|
| 303 | + if ( ! empty( $customer_name ) ) { |
|
| 304 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
| 305 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
| 306 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
| 307 | + } else { |
|
| 308 | + echo '<div>—</div>'; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - break; |
|
| 311 | + break; |
|
| 312 | 312 | |
| 313 | - } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - } |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * Returns an array of payment forms table columns. |
|
| 319 | - */ |
|
| 320 | - public static function payment_form_columns( $columns ) { |
|
| 317 | + /** |
|
| 318 | + * Returns an array of payment forms table columns. |
|
| 319 | + */ |
|
| 320 | + public static function payment_form_columns( $columns ) { |
|
| 321 | 321 | |
| 322 | - $columns = array( |
|
| 323 | - 'cb' => $columns['cb'], |
|
| 324 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 325 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 326 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
| 327 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
| 328 | - 'items' => __( 'Items', 'invoicing' ), |
|
| 329 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 330 | - ); |
|
| 322 | + $columns = array( |
|
| 323 | + 'cb' => $columns['cb'], |
|
| 324 | + 'title' => __( 'Name', 'invoicing' ), |
|
| 325 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 326 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
| 327 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
| 328 | + 'items' => __( 'Items', 'invoicing' ), |
|
| 329 | + 'date' => __( 'Date', 'invoicing' ), |
|
| 330 | + ); |
|
| 331 | 331 | |
| 332 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
| 332 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
| 333 | 333 | |
| 334 | - } |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - /** |
|
| 337 | - * Displays payment form table columns. |
|
| 338 | - */ |
|
| 339 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
| 336 | + /** |
|
| 337 | + * Displays payment form table columns. |
|
| 338 | + */ |
|
| 339 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
| 340 | 340 | |
| 341 | - // Retrieve the payment form. |
|
| 342 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
| 341 | + // Retrieve the payment form. |
|
| 342 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
| 343 | 343 | |
| 344 | - switch ( $column_name ) { |
|
| 344 | + switch ( $column_name ) { |
|
| 345 | 345 | |
| 346 | - case 'earnings' : |
|
| 347 | - echo wpinv_price( $form->get_earned() ); |
|
| 348 | - break; |
|
| 346 | + case 'earnings' : |
|
| 347 | + echo wpinv_price( $form->get_earned() ); |
|
| 348 | + break; |
|
| 349 | 349 | |
| 350 | - case 'refunds' : |
|
| 351 | - echo wpinv_price( $form->get_refunded() ); |
|
| 352 | - break; |
|
| 350 | + case 'refunds' : |
|
| 351 | + echo wpinv_price( $form->get_refunded() ); |
|
| 352 | + break; |
|
| 353 | 353 | |
| 354 | - case 'refunds' : |
|
| 355 | - echo wpinv_price( $form->get_refunded() ); |
|
| 356 | - break; |
|
| 354 | + case 'refunds' : |
|
| 355 | + echo wpinv_price( $form->get_refunded() ); |
|
| 356 | + break; |
|
| 357 | 357 | |
| 358 | - case 'shortcode' : |
|
| 358 | + case 'shortcode' : |
|
| 359 | 359 | |
| 360 | - if ( $form->is_default() ) { |
|
| 361 | - echo '—'; |
|
| 362 | - } else { |
|
| 363 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
| 364 | - } |
|
| 360 | + if ( $form->is_default() ) { |
|
| 361 | + echo '—'; |
|
| 362 | + } else { |
|
| 363 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | - break; |
|
| 366 | + break; |
|
| 367 | 367 | |
| 368 | - case 'items' : |
|
| 368 | + case 'items' : |
|
| 369 | 369 | |
| 370 | - $items = $form->get_items(); |
|
| 370 | + $items = $form->get_items(); |
|
| 371 | 371 | |
| 372 | - if ( $form->is_default() || empty( $items ) ) { |
|
| 373 | - echo '—'; |
|
| 374 | - return; |
|
| 375 | - } |
|
| 372 | + if ( $form->is_default() || empty( $items ) ) { |
|
| 373 | + echo '—'; |
|
| 374 | + return; |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - $_items = array(); |
|
| 377 | + $_items = array(); |
|
| 378 | 378 | |
| 379 | - foreach ( $items as $item ) { |
|
| 380 | - $url = $item->get_edit_url(); |
|
| 379 | + foreach ( $items as $item ) { |
|
| 380 | + $url = $item->get_edit_url(); |
|
| 381 | 381 | |
| 382 | - if ( empty( $url ) ) { |
|
| 383 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
| 384 | - } else { |
|
| 385 | - $_items[] = sprintf( |
|
| 386 | - '<a href="%s">%s</a>', |
|
| 387 | - esc_url( $url ), |
|
| 388 | - sanitize_text_field( $item->get_name() ) |
|
| 389 | - ); |
|
| 390 | - } |
|
| 382 | + if ( empty( $url ) ) { |
|
| 383 | + $_items[] = sanitize_text_field( $item->get_name() ); |
|
| 384 | + } else { |
|
| 385 | + $_items[] = sprintf( |
|
| 386 | + '<a href="%s">%s</a>', |
|
| 387 | + esc_url( $url ), |
|
| 388 | + sanitize_text_field( $item->get_name() ) |
|
| 389 | + ); |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | - } |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - echo implode( '<br>', $_items ); |
|
| 394 | + echo implode( '<br>', $_items ); |
|
| 395 | 395 | |
| 396 | - break; |
|
| 396 | + break; |
|
| 397 | 397 | |
| 398 | - } |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | - } |
|
| 400 | + } |
|
| 401 | 401 | |
| 402 | - /** |
|
| 403 | - * Filters post states. |
|
| 404 | - */ |
|
| 405 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
| 402 | + /** |
|
| 403 | + * Filters post states. |
|
| 404 | + */ |
|
| 405 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
| 406 | 406 | |
| 407 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
| 408 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
| 409 | - } |
|
| 407 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
| 408 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - return $post_states; |
|
| 412 | - |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * Returns an array of coupon table columns. |
|
| 417 | - */ |
|
| 418 | - public static function discount_columns( $columns ) { |
|
| 419 | - |
|
| 420 | - $columns = array( |
|
| 421 | - 'cb' => $columns['cb'], |
|
| 422 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 423 | - 'code' => __( 'Code', 'invoicing' ), |
|
| 424 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 425 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
| 426 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 427 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
| 428 | - ); |
|
| 429 | - |
|
| 430 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * Filters post states. |
|
| 435 | - */ |
|
| 436 | - public static function filter_discount_state( $post_states, $post ) { |
|
| 437 | - |
|
| 438 | - if ( 'wpi_discount' == $post->post_type ) { |
|
| 439 | - |
|
| 440 | - $discount = new WPInv_Discount( $post ); |
|
| 441 | - |
|
| 442 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
| 443 | - |
|
| 444 | - if ( $status != 'publish' ) { |
|
| 445 | - return array( |
|
| 446 | - 'discount_status' => wpinv_discount_status( $status ), |
|
| 447 | - ); |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - return array(); |
|
| 451 | - |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - return $post_states; |
|
| 455 | - |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * Returns an array of items table columns. |
|
| 460 | - */ |
|
| 461 | - public static function item_columns( $columns ) { |
|
| 462 | - |
|
| 463 | - $columns = array( |
|
| 464 | - 'cb' => $columns['cb'], |
|
| 465 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 466 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 467 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
| 468 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
| 469 | - 'type' => __( 'Type', 'invoicing' ), |
|
| 470 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 471 | - ); |
|
| 472 | - |
|
| 473 | - if ( ! wpinv_use_taxes() ) { |
|
| 474 | - unset( $columns['vat_rule'] ); |
|
| 475 | - unset( $columns['vat_class'] ); |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - /** |
|
| 482 | - * Returns an array of sortable items table columns. |
|
| 483 | - */ |
|
| 484 | - public static function sortable_item_columns( $columns ) { |
|
| 485 | - |
|
| 486 | - return array_merge( |
|
| 487 | - $columns, |
|
| 488 | - array( |
|
| 489 | - 'price' => 'price', |
|
| 490 | - 'vat_rule' => 'vat_rule', |
|
| 491 | - 'vat_class' => 'vat_class', |
|
| 492 | - 'type' => 'type', |
|
| 493 | - ) |
|
| 494 | - ); |
|
| 495 | - |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - /** |
|
| 499 | - * Displays items table columns. |
|
| 500 | - */ |
|
| 501 | - public static function display_item_columns( $column_name, $post_id ) { |
|
| 411 | + return $post_states; |
|
| 412 | + |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * Returns an array of coupon table columns. |
|
| 417 | + */ |
|
| 418 | + public static function discount_columns( $columns ) { |
|
| 419 | + |
|
| 420 | + $columns = array( |
|
| 421 | + 'cb' => $columns['cb'], |
|
| 422 | + 'title' => __( 'Name', 'invoicing' ), |
|
| 423 | + 'code' => __( 'Code', 'invoicing' ), |
|
| 424 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 425 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
| 426 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 427 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
| 428 | + ); |
|
| 429 | + |
|
| 430 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * Filters post states. |
|
| 435 | + */ |
|
| 436 | + public static function filter_discount_state( $post_states, $post ) { |
|
| 437 | + |
|
| 438 | + if ( 'wpi_discount' == $post->post_type ) { |
|
| 439 | + |
|
| 440 | + $discount = new WPInv_Discount( $post ); |
|
| 441 | + |
|
| 442 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
| 443 | + |
|
| 444 | + if ( $status != 'publish' ) { |
|
| 445 | + return array( |
|
| 446 | + 'discount_status' => wpinv_discount_status( $status ), |
|
| 447 | + ); |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + return array(); |
|
| 451 | + |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + return $post_states; |
|
| 455 | + |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + /** |
|
| 459 | + * Returns an array of items table columns. |
|
| 460 | + */ |
|
| 461 | + public static function item_columns( $columns ) { |
|
| 462 | + |
|
| 463 | + $columns = array( |
|
| 464 | + 'cb' => $columns['cb'], |
|
| 465 | + 'title' => __( 'Name', 'invoicing' ), |
|
| 466 | + 'price' => __( 'Price', 'invoicing' ), |
|
| 467 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
| 468 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
| 469 | + 'type' => __( 'Type', 'invoicing' ), |
|
| 470 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 471 | + ); |
|
| 472 | + |
|
| 473 | + if ( ! wpinv_use_taxes() ) { |
|
| 474 | + unset( $columns['vat_rule'] ); |
|
| 475 | + unset( $columns['vat_class'] ); |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + /** |
|
| 482 | + * Returns an array of sortable items table columns. |
|
| 483 | + */ |
|
| 484 | + public static function sortable_item_columns( $columns ) { |
|
| 485 | + |
|
| 486 | + return array_merge( |
|
| 487 | + $columns, |
|
| 488 | + array( |
|
| 489 | + 'price' => 'price', |
|
| 490 | + 'vat_rule' => 'vat_rule', |
|
| 491 | + 'vat_class' => 'vat_class', |
|
| 492 | + 'type' => 'type', |
|
| 493 | + ) |
|
| 494 | + ); |
|
| 495 | + |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + /** |
|
| 499 | + * Displays items table columns. |
|
| 500 | + */ |
|
| 501 | + public static function display_item_columns( $column_name, $post_id ) { |
|
| 502 | 502 | |
| 503 | - $item = new WPInv_Item( $post_id ); |
|
| 503 | + $item = new WPInv_Item( $post_id ); |
|
| 504 | 504 | |
| 505 | - switch ( $column_name ) { |
|
| 505 | + switch ( $column_name ) { |
|
| 506 | 506 | |
| 507 | - case 'price' : |
|
| 507 | + case 'price' : |
|
| 508 | 508 | |
| 509 | - if ( ! $item->is_recurring() ) { |
|
| 510 | - echo $item->get_the_price(); |
|
| 511 | - break; |
|
| 512 | - } |
|
| 509 | + if ( ! $item->is_recurring() ) { |
|
| 510 | + echo $item->get_the_price(); |
|
| 511 | + break; |
|
| 512 | + } |
|
| 513 | 513 | |
| 514 | - $price = wp_sprintf( |
|
| 515 | - __( '%s / %s', 'invoicing' ), |
|
| 516 | - $item->get_the_price(), |
|
| 517 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
| 518 | - ); |
|
| 514 | + $price = wp_sprintf( |
|
| 515 | + __( '%s / %s', 'invoicing' ), |
|
| 516 | + $item->get_the_price(), |
|
| 517 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
| 518 | + ); |
|
| 519 | 519 | |
| 520 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
| 521 | - echo $price; |
|
| 522 | - break; |
|
| 523 | - } |
|
| 520 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
| 521 | + echo $price; |
|
| 522 | + break; |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | - echo $item->get_the_initial_price(); |
|
| 525 | + echo $item->get_the_initial_price(); |
|
| 526 | 526 | |
| 527 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
| 528 | - break; |
|
| 527 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
| 528 | + break; |
|
| 529 | 529 | |
| 530 | - case 'vat_rule' : |
|
| 531 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
| 532 | - break; |
|
| 530 | + case 'vat_rule' : |
|
| 531 | + echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
| 532 | + break; |
|
| 533 | 533 | |
| 534 | - case 'vat_class' : |
|
| 535 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
| 536 | - break; |
|
| 534 | + case 'vat_class' : |
|
| 535 | + echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
| 536 | + break; |
|
| 537 | 537 | |
| 538 | - case 'shortcode' : |
|
| 539 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 540 | - break; |
|
| 538 | + case 'shortcode' : |
|
| 539 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 540 | + break; |
|
| 541 | 541 | |
| 542 | - case 'type' : |
|
| 543 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
| 544 | - break; |
|
| 542 | + case 'type' : |
|
| 543 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
| 544 | + break; |
|
| 545 | 545 | |
| 546 | - } |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - } |
|
| 548 | + } |
|
| 549 | 549 | |
| 550 | - /** |
|
| 551 | - * Lets users filter items using taxes. |
|
| 552 | - */ |
|
| 553 | - public static function add_item_filters( $post_type ) { |
|
| 550 | + /** |
|
| 551 | + * Lets users filter items using taxes. |
|
| 552 | + */ |
|
| 553 | + public static function add_item_filters( $post_type ) { |
|
| 554 | 554 | |
| 555 | - // Abort if we're not dealing with items. |
|
| 556 | - if ( $post_type != 'wpi_item' ) { |
|
| 557 | - return; |
|
| 558 | - } |
|
| 555 | + // Abort if we're not dealing with items. |
|
| 556 | + if ( $post_type != 'wpi_item' ) { |
|
| 557 | + return; |
|
| 558 | + } |
|
| 559 | 559 | |
| 560 | - // Filter by vat rules. |
|
| 561 | - if ( wpinv_use_taxes() ) { |
|
| 560 | + // Filter by vat rules. |
|
| 561 | + if ( wpinv_use_taxes() ) { |
|
| 562 | 562 | |
| 563 | - // Sanitize selected vat rule. |
|
| 564 | - $vat_rule = ''; |
|
| 565 | - $vat_rules = getpaid_get_tax_rules(); |
|
| 566 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
| 567 | - $vat_rule = $_GET['vat_rule']; |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - // Filter by VAT rule. |
|
| 571 | - echo wpinv_html_select( |
|
| 572 | - array( |
|
| 573 | - 'options' => array_merge( |
|
| 574 | - array( |
|
| 575 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
| 576 | - ), |
|
| 577 | - $vat_rules |
|
| 578 | - ), |
|
| 579 | - 'name' => 'vat_rule', |
|
| 580 | - 'id' => 'vat_rule', |
|
| 581 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
| 582 | - 'show_option_all' => false, |
|
| 583 | - 'show_option_none' => false, |
|
| 584 | - ) |
|
| 585 | - ); |
|
| 586 | - |
|
| 587 | - // Filter by VAT class. |
|
| 563 | + // Sanitize selected vat rule. |
|
| 564 | + $vat_rule = ''; |
|
| 565 | + $vat_rules = getpaid_get_tax_rules(); |
|
| 566 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
| 567 | + $vat_rule = $_GET['vat_rule']; |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + // Filter by VAT rule. |
|
| 571 | + echo wpinv_html_select( |
|
| 572 | + array( |
|
| 573 | + 'options' => array_merge( |
|
| 574 | + array( |
|
| 575 | + '' => __( 'All VAT rules', 'invoicing' ) |
|
| 576 | + ), |
|
| 577 | + $vat_rules |
|
| 578 | + ), |
|
| 579 | + 'name' => 'vat_rule', |
|
| 580 | + 'id' => 'vat_rule', |
|
| 581 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
| 582 | + 'show_option_all' => false, |
|
| 583 | + 'show_option_none' => false, |
|
| 584 | + ) |
|
| 585 | + ); |
|
| 586 | + |
|
| 587 | + // Filter by VAT class. |
|
| 588 | 588 | |
| 589 | - // Sanitize selected vat rule. |
|
| 590 | - $vat_class = ''; |
|
| 591 | - $vat_classes = getpaid_get_tax_classes(); |
|
| 592 | - if ( isset( $_GET['vat_class'] ) ) { |
|
| 593 | - $vat_class = $_GET['vat_class']; |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - echo wpinv_html_select( |
|
| 597 | - array( |
|
| 598 | - 'options' => array_merge( |
|
| 599 | - array( |
|
| 600 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
| 601 | - ), |
|
| 602 | - $vat_classes |
|
| 603 | - ), |
|
| 604 | - 'name' => 'vat_class', |
|
| 605 | - 'id' => 'vat_class', |
|
| 606 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
| 607 | - 'show_option_all' => false, |
|
| 608 | - 'show_option_none' => false, |
|
| 609 | - ) |
|
| 610 | - ); |
|
| 611 | - |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - // Filter by item type. |
|
| 615 | - $type = ''; |
|
| 616 | - if ( isset( $_GET['type'] ) ) { |
|
| 617 | - $type = $_GET['type']; |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - echo wpinv_html_select( |
|
| 621 | - array( |
|
| 622 | - 'options' => array_merge( |
|
| 623 | - array( |
|
| 624 | - '' => __( 'All item types', 'invoicing' ) |
|
| 625 | - ), |
|
| 626 | - wpinv_get_item_types() |
|
| 627 | - ), |
|
| 628 | - 'name' => 'type', |
|
| 629 | - 'id' => 'type', |
|
| 630 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
| 631 | - 'show_option_all' => false, |
|
| 632 | - 'show_option_none' => false, |
|
| 633 | - ) |
|
| 634 | - ); |
|
| 635 | - |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - /** |
|
| 639 | - * Filters the item query. |
|
| 640 | - */ |
|
| 641 | - public static function filter_item_query( $query ) { |
|
| 642 | - |
|
| 643 | - // modify the query only if it admin and main query. |
|
| 644 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
| 645 | - return $query; |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - // we want to modify the query for our items. |
|
| 649 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
| 650 | - return $query; |
|
| 651 | - } |
|
| 652 | - |
|
| 653 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
| 654 | - $query->query_vars['meta_query'] = array(); |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - // Filter vat rule type |
|
| 589 | + // Sanitize selected vat rule. |
|
| 590 | + $vat_class = ''; |
|
| 591 | + $vat_classes = getpaid_get_tax_classes(); |
|
| 592 | + if ( isset( $_GET['vat_class'] ) ) { |
|
| 593 | + $vat_class = $_GET['vat_class']; |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + echo wpinv_html_select( |
|
| 597 | + array( |
|
| 598 | + 'options' => array_merge( |
|
| 599 | + array( |
|
| 600 | + '' => __( 'All VAT classes', 'invoicing' ) |
|
| 601 | + ), |
|
| 602 | + $vat_classes |
|
| 603 | + ), |
|
| 604 | + 'name' => 'vat_class', |
|
| 605 | + 'id' => 'vat_class', |
|
| 606 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
| 607 | + 'show_option_all' => false, |
|
| 608 | + 'show_option_none' => false, |
|
| 609 | + ) |
|
| 610 | + ); |
|
| 611 | + |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + // Filter by item type. |
|
| 615 | + $type = ''; |
|
| 616 | + if ( isset( $_GET['type'] ) ) { |
|
| 617 | + $type = $_GET['type']; |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + echo wpinv_html_select( |
|
| 621 | + array( |
|
| 622 | + 'options' => array_merge( |
|
| 623 | + array( |
|
| 624 | + '' => __( 'All item types', 'invoicing' ) |
|
| 625 | + ), |
|
| 626 | + wpinv_get_item_types() |
|
| 627 | + ), |
|
| 628 | + 'name' => 'type', |
|
| 629 | + 'id' => 'type', |
|
| 630 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
| 631 | + 'show_option_all' => false, |
|
| 632 | + 'show_option_none' => false, |
|
| 633 | + ) |
|
| 634 | + ); |
|
| 635 | + |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + /** |
|
| 639 | + * Filters the item query. |
|
| 640 | + */ |
|
| 641 | + public static function filter_item_query( $query ) { |
|
| 642 | + |
|
| 643 | + // modify the query only if it admin and main query. |
|
| 644 | + if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
| 645 | + return $query; |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + // we want to modify the query for our items. |
|
| 649 | + if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
| 650 | + return $query; |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
| 654 | + $query->query_vars['meta_query'] = array(); |
|
| 655 | + } |
|
| 656 | + |
|
| 657 | + // Filter vat rule type |
|
| 658 | 658 | if ( ! empty( $_GET['vat_rule'] ) ) { |
| 659 | 659 | $query->query_vars['meta_query'][] = array( |
| 660 | 660 | 'key' => '_wpinv_vat_rule', |
@@ -679,97 +679,97 @@ discard block |
||
| 679 | 679 | 'value' => sanitize_text_field( $_GET['type'] ), |
| 680 | 680 | 'compare' => '=' |
| 681 | 681 | ); |
| 682 | - } |
|
| 683 | - |
|
| 684 | - } |
|
| 685 | - |
|
| 686 | - /** |
|
| 687 | - * Reorders items. |
|
| 688 | - */ |
|
| 689 | - public static function reorder_items( $vars ) { |
|
| 690 | - global $typenow; |
|
| 691 | - |
|
| 692 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
| 693 | - return $vars; |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - // By item type. |
|
| 697 | - if ( 'type' == $vars['orderby'] ) { |
|
| 698 | - return array_merge( |
|
| 699 | - $vars, |
|
| 700 | - array( |
|
| 701 | - 'meta_key' => '_wpinv_type', |
|
| 702 | - 'orderby' => 'meta_value' |
|
| 703 | - ) |
|
| 704 | - ); |
|
| 705 | - } |
|
| 706 | - |
|
| 707 | - // By vat class. |
|
| 708 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
| 709 | - return array_merge( |
|
| 710 | - $vars, |
|
| 711 | - array( |
|
| 712 | - 'meta_key' => '_wpinv_vat_class', |
|
| 713 | - 'orderby' => 'meta_value' |
|
| 714 | - ) |
|
| 715 | - ); |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - // By vat rule. |
|
| 719 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
| 720 | - return array_merge( |
|
| 721 | - $vars, |
|
| 722 | - array( |
|
| 723 | - 'meta_key' => '_wpinv_vat_rule', |
|
| 724 | - 'orderby' => 'meta_value' |
|
| 725 | - ) |
|
| 726 | - ); |
|
| 727 | - } |
|
| 728 | - |
|
| 729 | - // By price. |
|
| 730 | - if ( 'price' == $vars['orderby'] ) { |
|
| 731 | - return array_merge( |
|
| 732 | - $vars, |
|
| 733 | - array( |
|
| 734 | - 'meta_key' => '_wpinv_price', |
|
| 735 | - 'orderby' => 'meta_value_num' |
|
| 736 | - ) |
|
| 737 | - ); |
|
| 738 | - } |
|
| 739 | - |
|
| 740 | - return $vars; |
|
| 741 | - |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - /** |
|
| 745 | - * Fired when deleting a post. |
|
| 746 | - */ |
|
| 747 | - public static function delete_post( $post_id ) { |
|
| 748 | - |
|
| 749 | - switch ( get_post_type( $post_id ) ) { |
|
| 750 | - |
|
| 751 | - case 'wpi_item' : |
|
| 752 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
| 753 | - break; |
|
| 754 | - |
|
| 755 | - case 'wpi_payment_form' : |
|
| 756 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
| 757 | - break; |
|
| 758 | - |
|
| 759 | - case 'wpi_discount' : |
|
| 760 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
| 761 | - break; |
|
| 762 | - |
|
| 763 | - case 'wpi_invoice' : |
|
| 764 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 765 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
| 766 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
| 767 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
| 768 | - break; |
|
| 769 | - } |
|
| 770 | - } |
|
| 771 | - |
|
| 772 | - /** |
|
| 682 | + } |
|
| 683 | + |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + /** |
|
| 687 | + * Reorders items. |
|
| 688 | + */ |
|
| 689 | + public static function reorder_items( $vars ) { |
|
| 690 | + global $typenow; |
|
| 691 | + |
|
| 692 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
| 693 | + return $vars; |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + // By item type. |
|
| 697 | + if ( 'type' == $vars['orderby'] ) { |
|
| 698 | + return array_merge( |
|
| 699 | + $vars, |
|
| 700 | + array( |
|
| 701 | + 'meta_key' => '_wpinv_type', |
|
| 702 | + 'orderby' => 'meta_value' |
|
| 703 | + ) |
|
| 704 | + ); |
|
| 705 | + } |
|
| 706 | + |
|
| 707 | + // By vat class. |
|
| 708 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
| 709 | + return array_merge( |
|
| 710 | + $vars, |
|
| 711 | + array( |
|
| 712 | + 'meta_key' => '_wpinv_vat_class', |
|
| 713 | + 'orderby' => 'meta_value' |
|
| 714 | + ) |
|
| 715 | + ); |
|
| 716 | + } |
|
| 717 | + |
|
| 718 | + // By vat rule. |
|
| 719 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
| 720 | + return array_merge( |
|
| 721 | + $vars, |
|
| 722 | + array( |
|
| 723 | + 'meta_key' => '_wpinv_vat_rule', |
|
| 724 | + 'orderby' => 'meta_value' |
|
| 725 | + ) |
|
| 726 | + ); |
|
| 727 | + } |
|
| 728 | + |
|
| 729 | + // By price. |
|
| 730 | + if ( 'price' == $vars['orderby'] ) { |
|
| 731 | + return array_merge( |
|
| 732 | + $vars, |
|
| 733 | + array( |
|
| 734 | + 'meta_key' => '_wpinv_price', |
|
| 735 | + 'orderby' => 'meta_value_num' |
|
| 736 | + ) |
|
| 737 | + ); |
|
| 738 | + } |
|
| 739 | + |
|
| 740 | + return $vars; |
|
| 741 | + |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + /** |
|
| 745 | + * Fired when deleting a post. |
|
| 746 | + */ |
|
| 747 | + public static function delete_post( $post_id ) { |
|
| 748 | + |
|
| 749 | + switch ( get_post_type( $post_id ) ) { |
|
| 750 | + |
|
| 751 | + case 'wpi_item' : |
|
| 752 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
| 753 | + break; |
|
| 754 | + |
|
| 755 | + case 'wpi_payment_form' : |
|
| 756 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
| 757 | + break; |
|
| 758 | + |
|
| 759 | + case 'wpi_discount' : |
|
| 760 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
| 761 | + break; |
|
| 762 | + |
|
| 763 | + case 'wpi_invoice' : |
|
| 764 | + $invoice = new WPInv_Invoice( $post_id ); |
|
| 765 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
| 766 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
| 767 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
| 768 | + break; |
|
| 769 | + } |
|
| 770 | + } |
|
| 771 | + |
|
| 772 | + /** |
|
| 773 | 773 | * Add a post display state for special GetPaid pages in the page list table. |
| 774 | 774 | * |
| 775 | 775 | * @param array $post_states An array of post display states. |
@@ -783,22 +783,22 @@ discard block |
||
| 783 | 783 | $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
| 786 | + foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
| 787 | 787 | |
| 788 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
| 789 | - $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
| 790 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
| 791 | - $label |
|
| 792 | - ); |
|
| 793 | - } |
|
| 788 | + if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
| 789 | + $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
| 790 | + __( 'GetPaid %s History Page', 'invoicing' ), |
|
| 791 | + $label |
|
| 792 | + ); |
|
| 793 | + } |
|
| 794 | 794 | |
| 795 | - } |
|
| 795 | + } |
|
| 796 | 796 | |
| 797 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
| 797 | + if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
| 798 | 798 | $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
| 801 | + if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
| 802 | 802 | $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
| 803 | 803 | } |
| 804 | 804 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Post types Admin Class |
@@ -21,72 +21,72 @@ discard block |
||
| 21 | 21 | GetPaid_Metaboxes::init(); |
| 22 | 22 | |
| 23 | 23 | // Filter the post updated messages. |
| 24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
| 24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
| 25 | 25 | |
| 26 | 26 | // Filter post actions. |
| 27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
| 28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
| 27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
| 28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
| 29 | 29 | |
| 30 | 30 | // Invoice table columns. |
| 31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
| 32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
| 31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
| 32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
| 33 | 33 | |
| 34 | 34 | // Items table columns. |
| 35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
| 36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
| 37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
| 38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
| 39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
| 40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
| 35 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
| 36 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
| 37 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
| 38 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
| 39 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
| 40 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
| 41 | 41 | |
| 42 | 42 | // Payment forms columns. |
| 43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
| 44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
| 45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
| 43 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
| 44 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
| 45 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
| 46 | 46 | |
| 47 | 47 | // Discount table columns. |
| 48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
| 49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
| 48 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
| 49 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
| 50 | 50 | |
| 51 | 51 | // Deleting posts. |
| 52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
| 53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
| 52 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
| 53 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
| 54 | 54 | |
| 55 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
| 55 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Post updated messages. |
| 60 | 60 | */ |
| 61 | - public static function post_updated_messages( $messages ) { |
|
| 61 | + public static function post_updated_messages($messages) { |
|
| 62 | 62 | global $post; |
| 63 | 63 | |
| 64 | 64 | $messages['wpi_discount'] = array( |
| 65 | 65 | 0 => '', |
| 66 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 67 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 68 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 69 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 70 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 71 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 72 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 73 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 74 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 75 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 66 | + 1 => __('Discount updated.', 'invoicing'), |
|
| 67 | + 2 => __('Custom field updated.', 'invoicing'), |
|
| 68 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
| 69 | + 4 => __('Discount updated.', 'invoicing'), |
|
| 70 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
| 71 | + 6 => __('Discount updated.', 'invoicing'), |
|
| 72 | + 7 => __('Discount saved.', 'invoicing'), |
|
| 73 | + 8 => __('Discount submitted.', 'invoicing'), |
|
| 74 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
| 75 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | 78 | $messages['wpi_payment_form'] = array( |
| 79 | 79 | 0 => '', |
| 80 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 81 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 82 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 83 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 84 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 85 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 86 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
| 87 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
| 88 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 89 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
| 80 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
| 81 | + 2 => __('Custom field updated.', 'invoicing'), |
|
| 82 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
| 83 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
| 84 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
| 85 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
| 86 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
| 87 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
| 88 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
| 89 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | 92 | return $messages; |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | /** |
| 97 | 97 | * Post row actions. |
| 98 | 98 | */ |
| 99 | - public static function post_row_actions( $actions, $post ) { |
|
| 99 | + public static function post_row_actions($actions, $post) { |
|
| 100 | 100 | |
| 101 | - $post = get_post( $post ); |
|
| 101 | + $post = get_post($post); |
|
| 102 | 102 | |
| 103 | 103 | // We do not want to edit the default payment form. |
| 104 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
| 105 | - unset( $actions['trash'] ); |
|
| 106 | - unset( $actions['inline hide-if-no-js'] ); |
|
| 104 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
| 105 | + unset($actions['trash']); |
|
| 106 | + unset($actions['inline hide-if-no-js']); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | return $actions; |
@@ -117,31 +117,31 @@ discard block |
||
| 117 | 117 | * @param WP_Post $post |
| 118 | 118 | * @return array $actions actions without edit option |
| 119 | 119 | */ |
| 120 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
| 120 | + public static function filter_invoice_row_actions($actions, $post) { |
|
| 121 | 121 | |
| 122 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 122 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
| 123 | 123 | |
| 124 | 124 | $actions = array(); |
| 125 | - $invoice = new WPInv_Invoice( $post ); |
|
| 125 | + $invoice = new WPInv_Invoice($post); |
|
| 126 | 126 | |
| 127 | - $actions['edit'] = sprintf( |
|
| 127 | + $actions['edit'] = sprintf( |
|
| 128 | 128 | '<a href="%1$s">%2$s</a>', |
| 129 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 130 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
| 129 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
| 130 | + esc_html(__('Edit', 'invoicing')) |
|
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | - if ( ! $invoice->is_draft() ) { |
|
| 133 | + if (!$invoice->is_draft()) { |
|
| 134 | 134 | |
| 135 | - $actions['view'] = sprintf( |
|
| 135 | + $actions['view'] = sprintf( |
|
| 136 | 136 | '<a href="%1$s">%2$s</a>', |
| 137 | - esc_url( $invoice->get_view_url() ), |
|
| 137 | + esc_url($invoice->get_view_url()), |
|
| 138 | 138 | sprintf( |
| 139 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
| 140 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
| 139 | + esc_html(__('View %s', 'invoicing')), |
|
| 140 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
| 141 | 141 | ) |
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | - $actions['send'] = sprintf( |
|
| 144 | + $actions['send'] = sprintf( |
|
| 145 | 145 | '<a href="%1$s">%2$s</a>', |
| 146 | 146 | esc_url( |
| 147 | 147 | wp_nonce_url( |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | 'getpaid-nonce' |
| 156 | 156 | ) |
| 157 | 157 | ), |
| 158 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
| 158 | + esc_html(__('Send to Customer', 'invoicing')) |
|
| 159 | 159 | ); |
| 160 | 160 | |
| 161 | 161 | } |
@@ -168,42 +168,42 @@ discard block |
||
| 168 | 168 | /** |
| 169 | 169 | * Returns an array of invoice table columns. |
| 170 | 170 | */ |
| 171 | - public static function invoice_columns( $columns ) { |
|
| 171 | + public static function invoice_columns($columns) { |
|
| 172 | 172 | |
| 173 | 173 | $columns = array( |
| 174 | 174 | 'cb' => $columns['cb'], |
| 175 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
| 176 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 177 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
| 178 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
| 179 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 180 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
| 181 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 175 | + 'number' => __('Invoice', 'invoicing'), |
|
| 176 | + 'customer' => __('Customer', 'invoicing'), |
|
| 177 | + 'invoice_date' => __('Created', 'invoicing'), |
|
| 178 | + 'payment_date' => __('Completed', 'invoicing'), |
|
| 179 | + 'amount' => __('Amount', 'invoicing'), |
|
| 180 | + 'recurring' => __('Recurring', 'invoicing'), |
|
| 181 | + 'status' => __('Status', 'invoicing'), |
|
| 182 | 182 | ); |
| 183 | 183 | |
| 184 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 184 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | 188 | * Displays invoice table columns. |
| 189 | 189 | */ |
| 190 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
| 190 | + public static function display_invoice_columns($column_name, $post_id) { |
|
| 191 | 191 | |
| 192 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 192 | + $invoice = new WPInv_Invoice($post_id); |
|
| 193 | 193 | |
| 194 | - switch ( $column_name ) { |
|
| 194 | + switch ($column_name) { |
|
| 195 | 195 | |
| 196 | 196 | case 'invoice_date' : |
| 197 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
| 198 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
| 197 | + $date_time = esc_attr($invoice->get_created_date()); |
|
| 198 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
| 199 | 199 | echo "<span title='$date_time'>$date</span>"; |
| 200 | 200 | break; |
| 201 | 201 | |
| 202 | 202 | case 'payment_date' : |
| 203 | 203 | |
| 204 | - if ( $invoice->is_paid() ) { |
|
| 205 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
| 206 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
| 204 | + if ($invoice->is_paid()) { |
|
| 205 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
| 206 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
| 207 | 207 | echo "<span title='$date_time'>$date</span>"; |
| 208 | 208 | } else { |
| 209 | 209 | echo "—"; |
@@ -214,17 +214,17 @@ discard block |
||
| 214 | 214 | case 'amount' : |
| 215 | 215 | |
| 216 | 216 | $amount = $invoice->get_total(); |
| 217 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
| 217 | + $formated_amount = wpinv_price($amount, $invoice->get_currency()); |
|
| 218 | 218 | |
| 219 | - if ( $invoice->is_refunded() ) { |
|
| 220 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
| 219 | + if ($invoice->is_refunded()) { |
|
| 220 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
| 221 | 221 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
| 222 | 222 | } else { |
| 223 | 223 | |
| 224 | 224 | $discount = $invoice->get_total_discount(); |
| 225 | 225 | |
| 226 | - if ( ! empty( $discount ) ) { |
|
| 227 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
| 226 | + if (!empty($discount)) { |
|
| 227 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
| 228 | 228 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
| 229 | 229 | } else { |
| 230 | 230 | echo $formated_amount; |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | break; |
| 236 | 236 | |
| 237 | 237 | case 'status' : |
| 238 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
| 239 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
| 238 | + $status = sanitize_text_field($invoice->get_status()); |
|
| 239 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
| 240 | 240 | |
| 241 | 241 | // If it is paid, show the gateway title. |
| 242 | - if ( $invoice->is_paid() ) { |
|
| 243 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
| 244 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
| 242 | + if ($invoice->is_paid()) { |
|
| 243 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
| 244 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
| 245 | 245 | |
| 246 | 246 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
| 247 | 247 | } else { |
@@ -249,22 +249,22 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // If it is not paid, display the overdue and view status. |
| 252 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 252 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 253 | 253 | |
| 254 | 254 | // Invoice view status. |
| 255 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
| 256 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 255 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
| 256 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
| 257 | 257 | } else { |
| 258 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 258 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // Display the overview status. |
| 262 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
| 262 | + if (wpinv_get_option('overdue_active')) { |
|
| 263 | 263 | $due_date = $invoice->get_due_date(); |
| 264 | - $fomatted = getpaid_format_date( $due_date ); |
|
| 264 | + $fomatted = getpaid_format_date($due_date); |
|
| 265 | 265 | |
| 266 | - if ( ! empty( $fomatted ) ) { |
|
| 267 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
| 266 | + if (!empty($fomatted)) { |
|
| 267 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
| 268 | 268 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
| 269 | 269 | } |
| 270 | 270 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | case 'recurring': |
| 277 | 277 | |
| 278 | - if ( $invoice->is_recurring() ) { |
|
| 278 | + if ($invoice->is_recurring()) { |
|
| 279 | 279 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
| 280 | 280 | } else { |
| 281 | 281 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | case 'number' : |
| 286 | 286 | |
| 287 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
| 288 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
| 289 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
| 287 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
| 288 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
| 289 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
| 290 | 290 | |
| 291 | 291 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
| 292 | 292 | |
@@ -296,13 +296,13 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | $customer_name = $invoice->get_user_full_name(); |
| 298 | 298 | |
| 299 | - if ( empty( $customer_name ) ) { |
|
| 299 | + if (empty($customer_name)) { |
|
| 300 | 300 | $customer_name = $invoice->get_email(); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - if ( ! empty( $customer_name ) ) { |
|
| 304 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
| 305 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
| 303 | + if (!empty($customer_name)) { |
|
| 304 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
| 305 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
| 306 | 306 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
| 307 | 307 | } else { |
| 308 | 308 | echo '<div>—</div>'; |
@@ -317,50 +317,50 @@ discard block |
||
| 317 | 317 | /** |
| 318 | 318 | * Returns an array of payment forms table columns. |
| 319 | 319 | */ |
| 320 | - public static function payment_form_columns( $columns ) { |
|
| 320 | + public static function payment_form_columns($columns) { |
|
| 321 | 321 | |
| 322 | 322 | $columns = array( |
| 323 | 323 | 'cb' => $columns['cb'], |
| 324 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 325 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 326 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
| 327 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
| 328 | - 'items' => __( 'Items', 'invoicing' ), |
|
| 329 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 324 | + 'title' => __('Name', 'invoicing'), |
|
| 325 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
| 326 | + 'earnings' => __('Revenue', 'invoicing'), |
|
| 327 | + 'refunds' => __('Refunded', 'invoicing'), |
|
| 328 | + 'items' => __('Items', 'invoicing'), |
|
| 329 | + 'date' => __('Date', 'invoicing'), |
|
| 330 | 330 | ); |
| 331 | 331 | |
| 332 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
| 332 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
| 333 | 333 | |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | 337 | * Displays payment form table columns. |
| 338 | 338 | */ |
| 339 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
| 339 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
| 340 | 340 | |
| 341 | 341 | // Retrieve the payment form. |
| 342 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
| 342 | + $form = new GetPaid_Payment_Form($post_id); |
|
| 343 | 343 | |
| 344 | - switch ( $column_name ) { |
|
| 344 | + switch ($column_name) { |
|
| 345 | 345 | |
| 346 | 346 | case 'earnings' : |
| 347 | - echo wpinv_price( $form->get_earned() ); |
|
| 347 | + echo wpinv_price($form->get_earned()); |
|
| 348 | 348 | break; |
| 349 | 349 | |
| 350 | 350 | case 'refunds' : |
| 351 | - echo wpinv_price( $form->get_refunded() ); |
|
| 351 | + echo wpinv_price($form->get_refunded()); |
|
| 352 | 352 | break; |
| 353 | 353 | |
| 354 | 354 | case 'refunds' : |
| 355 | - echo wpinv_price( $form->get_refunded() ); |
|
| 355 | + echo wpinv_price($form->get_refunded()); |
|
| 356 | 356 | break; |
| 357 | 357 | |
| 358 | 358 | case 'shortcode' : |
| 359 | 359 | |
| 360 | - if ( $form->is_default() ) { |
|
| 360 | + if ($form->is_default()) { |
|
| 361 | 361 | echo '—'; |
| 362 | 362 | } else { |
| 363 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
| 363 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | break; |
@@ -369,29 +369,29 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | $items = $form->get_items(); |
| 371 | 371 | |
| 372 | - if ( $form->is_default() || empty( $items ) ) { |
|
| 372 | + if ($form->is_default() || empty($items)) { |
|
| 373 | 373 | echo '—'; |
| 374 | 374 | return; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | $_items = array(); |
| 378 | 378 | |
| 379 | - foreach ( $items as $item ) { |
|
| 379 | + foreach ($items as $item) { |
|
| 380 | 380 | $url = $item->get_edit_url(); |
| 381 | 381 | |
| 382 | - if ( empty( $url ) ) { |
|
| 383 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
| 382 | + if (empty($url)) { |
|
| 383 | + $_items[] = sanitize_text_field($item->get_name()); |
|
| 384 | 384 | } else { |
| 385 | 385 | $_items[] = sprintf( |
| 386 | 386 | '<a href="%s">%s</a>', |
| 387 | - esc_url( $url ), |
|
| 388 | - sanitize_text_field( $item->get_name() ) |
|
| 387 | + esc_url($url), |
|
| 388 | + sanitize_text_field($item->get_name()) |
|
| 389 | 389 | ); |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - echo implode( '<br>', $_items ); |
|
| 394 | + echo implode('<br>', $_items); |
|
| 395 | 395 | |
| 396 | 396 | break; |
| 397 | 397 | |
@@ -402,10 +402,10 @@ discard block |
||
| 402 | 402 | /** |
| 403 | 403 | * Filters post states. |
| 404 | 404 | */ |
| 405 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
| 405 | + public static function filter_payment_form_state($post_states, $post) { |
|
| 406 | 406 | |
| 407 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
| 408 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
| 407 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
| 408 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | return $post_states; |
@@ -415,35 +415,35 @@ discard block |
||
| 415 | 415 | /** |
| 416 | 416 | * Returns an array of coupon table columns. |
| 417 | 417 | */ |
| 418 | - public static function discount_columns( $columns ) { |
|
| 418 | + public static function discount_columns($columns) { |
|
| 419 | 419 | |
| 420 | 420 | $columns = array( |
| 421 | 421 | 'cb' => $columns['cb'], |
| 422 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 423 | - 'code' => __( 'Code', 'invoicing' ), |
|
| 424 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 425 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
| 426 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 427 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
| 422 | + 'title' => __('Name', 'invoicing'), |
|
| 423 | + 'code' => __('Code', 'invoicing'), |
|
| 424 | + 'amount' => __('Amount', 'invoicing'), |
|
| 425 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
| 426 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 427 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
| 428 | 428 | ); |
| 429 | 429 | |
| 430 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
| 430 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | 434 | * Filters post states. |
| 435 | 435 | */ |
| 436 | - public static function filter_discount_state( $post_states, $post ) { |
|
| 436 | + public static function filter_discount_state($post_states, $post) { |
|
| 437 | 437 | |
| 438 | - if ( 'wpi_discount' == $post->post_type ) { |
|
| 438 | + if ('wpi_discount' == $post->post_type) { |
|
| 439 | 439 | |
| 440 | - $discount = new WPInv_Discount( $post ); |
|
| 440 | + $discount = new WPInv_Discount($post); |
|
| 441 | 441 | |
| 442 | 442 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
| 443 | 443 | |
| 444 | - if ( $status != 'publish' ) { |
|
| 444 | + if ($status != 'publish') { |
|
| 445 | 445 | return array( |
| 446 | - 'discount_status' => wpinv_discount_status( $status ), |
|
| 446 | + 'discount_status' => wpinv_discount_status($status), |
|
| 447 | 447 | ); |
| 448 | 448 | } |
| 449 | 449 | |
@@ -458,30 +458,30 @@ discard block |
||
| 458 | 458 | /** |
| 459 | 459 | * Returns an array of items table columns. |
| 460 | 460 | */ |
| 461 | - public static function item_columns( $columns ) { |
|
| 461 | + public static function item_columns($columns) { |
|
| 462 | 462 | |
| 463 | 463 | $columns = array( |
| 464 | 464 | 'cb' => $columns['cb'], |
| 465 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 466 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 467 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
| 468 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
| 469 | - 'type' => __( 'Type', 'invoicing' ), |
|
| 470 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 465 | + 'title' => __('Name', 'invoicing'), |
|
| 466 | + 'price' => __('Price', 'invoicing'), |
|
| 467 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
| 468 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
| 469 | + 'type' => __('Type', 'invoicing'), |
|
| 470 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
| 471 | 471 | ); |
| 472 | 472 | |
| 473 | - if ( ! wpinv_use_taxes() ) { |
|
| 474 | - unset( $columns['vat_rule'] ); |
|
| 475 | - unset( $columns['vat_class'] ); |
|
| 473 | + if (!wpinv_use_taxes()) { |
|
| 474 | + unset($columns['vat_rule']); |
|
| 475 | + unset($columns['vat_class']); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
| 478 | + return apply_filters('wpi_item_table_columns', $columns); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
| 482 | 482 | * Returns an array of sortable items table columns. |
| 483 | 483 | */ |
| 484 | - public static function sortable_item_columns( $columns ) { |
|
| 484 | + public static function sortable_item_columns($columns) { |
|
| 485 | 485 | |
| 486 | 486 | return array_merge( |
| 487 | 487 | $columns, |
@@ -498,49 +498,49 @@ discard block |
||
| 498 | 498 | /** |
| 499 | 499 | * Displays items table columns. |
| 500 | 500 | */ |
| 501 | - public static function display_item_columns( $column_name, $post_id ) { |
|
| 501 | + public static function display_item_columns($column_name, $post_id) { |
|
| 502 | 502 | |
| 503 | - $item = new WPInv_Item( $post_id ); |
|
| 503 | + $item = new WPInv_Item($post_id); |
|
| 504 | 504 | |
| 505 | - switch ( $column_name ) { |
|
| 505 | + switch ($column_name) { |
|
| 506 | 506 | |
| 507 | 507 | case 'price' : |
| 508 | 508 | |
| 509 | - if ( ! $item->is_recurring() ) { |
|
| 509 | + if (!$item->is_recurring()) { |
|
| 510 | 510 | echo $item->get_the_price(); |
| 511 | 511 | break; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | $price = wp_sprintf( |
| 515 | - __( '%s / %s', 'invoicing' ), |
|
| 515 | + __('%s / %s', 'invoicing'), |
|
| 516 | 516 | $item->get_the_price(), |
| 517 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
| 517 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
| 518 | 518 | ); |
| 519 | 519 | |
| 520 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
| 520 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
| 521 | 521 | echo $price; |
| 522 | 522 | break; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | echo $item->get_the_initial_price(); |
| 526 | 526 | |
| 527 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
| 527 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
| 528 | 528 | break; |
| 529 | 529 | |
| 530 | 530 | case 'vat_rule' : |
| 531 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
| 531 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
| 532 | 532 | break; |
| 533 | 533 | |
| 534 | 534 | case 'vat_class' : |
| 535 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
| 535 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
| 536 | 536 | break; |
| 537 | 537 | |
| 538 | 538 | case 'shortcode' : |
| 539 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 539 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 540 | 540 | break; |
| 541 | 541 | |
| 542 | 542 | case 'type' : |
| 543 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
| 543 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
| 544 | 544 | break; |
| 545 | 545 | |
| 546 | 546 | } |
@@ -550,21 +550,21 @@ discard block |
||
| 550 | 550 | /** |
| 551 | 551 | * Lets users filter items using taxes. |
| 552 | 552 | */ |
| 553 | - public static function add_item_filters( $post_type ) { |
|
| 553 | + public static function add_item_filters($post_type) { |
|
| 554 | 554 | |
| 555 | 555 | // Abort if we're not dealing with items. |
| 556 | - if ( $post_type != 'wpi_item' ) { |
|
| 556 | + if ($post_type != 'wpi_item') { |
|
| 557 | 557 | return; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | // Filter by vat rules. |
| 561 | - if ( wpinv_use_taxes() ) { |
|
| 561 | + if (wpinv_use_taxes()) { |
|
| 562 | 562 | |
| 563 | 563 | // Sanitize selected vat rule. |
| 564 | 564 | $vat_rule = ''; |
| 565 | 565 | $vat_rules = getpaid_get_tax_rules(); |
| 566 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
| 567 | - $vat_rule = $_GET['vat_rule']; |
|
| 566 | + if (isset($_GET['vat_rule'])) { |
|
| 567 | + $vat_rule = $_GET['vat_rule']; |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | // Filter by VAT rule. |
@@ -572,13 +572,13 @@ discard block |
||
| 572 | 572 | array( |
| 573 | 573 | 'options' => array_merge( |
| 574 | 574 | array( |
| 575 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
| 575 | + '' => __('All VAT rules', 'invoicing') |
|
| 576 | 576 | ), |
| 577 | 577 | $vat_rules |
| 578 | 578 | ), |
| 579 | 579 | 'name' => 'vat_rule', |
| 580 | 580 | 'id' => 'vat_rule', |
| 581 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
| 581 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
| 582 | 582 | 'show_option_all' => false, |
| 583 | 583 | 'show_option_none' => false, |
| 584 | 584 | ) |
@@ -589,21 +589,21 @@ discard block |
||
| 589 | 589 | // Sanitize selected vat rule. |
| 590 | 590 | $vat_class = ''; |
| 591 | 591 | $vat_classes = getpaid_get_tax_classes(); |
| 592 | - if ( isset( $_GET['vat_class'] ) ) { |
|
| 593 | - $vat_class = $_GET['vat_class']; |
|
| 592 | + if (isset($_GET['vat_class'])) { |
|
| 593 | + $vat_class = $_GET['vat_class']; |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | echo wpinv_html_select( |
| 597 | 597 | array( |
| 598 | 598 | 'options' => array_merge( |
| 599 | 599 | array( |
| 600 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
| 600 | + '' => __('All VAT classes', 'invoicing') |
|
| 601 | 601 | ), |
| 602 | 602 | $vat_classes |
| 603 | 603 | ), |
| 604 | 604 | 'name' => 'vat_class', |
| 605 | 605 | 'id' => 'vat_class', |
| 606 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
| 606 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
| 607 | 607 | 'show_option_all' => false, |
| 608 | 608 | 'show_option_none' => false, |
| 609 | 609 | ) |
@@ -612,22 +612,22 @@ discard block |
||
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | // Filter by item type. |
| 615 | - $type = ''; |
|
| 616 | - if ( isset( $_GET['type'] ) ) { |
|
| 617 | - $type = $_GET['type']; |
|
| 615 | + $type = ''; |
|
| 616 | + if (isset($_GET['type'])) { |
|
| 617 | + $type = $_GET['type']; |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | echo wpinv_html_select( |
| 621 | 621 | array( |
| 622 | 622 | 'options' => array_merge( |
| 623 | 623 | array( |
| 624 | - '' => __( 'All item types', 'invoicing' ) |
|
| 624 | + '' => __('All item types', 'invoicing') |
|
| 625 | 625 | ), |
| 626 | 626 | wpinv_get_item_types() |
| 627 | 627 | ), |
| 628 | 628 | 'name' => 'type', |
| 629 | 629 | 'id' => 'type', |
| 630 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
| 630 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
| 631 | 631 | 'show_option_all' => false, |
| 632 | 632 | 'show_option_none' => false, |
| 633 | 633 | ) |
@@ -638,45 +638,45 @@ discard block |
||
| 638 | 638 | /** |
| 639 | 639 | * Filters the item query. |
| 640 | 640 | */ |
| 641 | - public static function filter_item_query( $query ) { |
|
| 641 | + public static function filter_item_query($query) { |
|
| 642 | 642 | |
| 643 | 643 | // modify the query only if it admin and main query. |
| 644 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
| 644 | + if (!(is_admin() && $query->is_main_query())) { |
|
| 645 | 645 | return $query; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | // we want to modify the query for our items. |
| 649 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
| 649 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
| 650 | 650 | return $query; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
| 653 | + if (empty($query->query_vars['meta_query'])) { |
|
| 654 | 654 | $query->query_vars['meta_query'] = array(); |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // Filter vat rule type |
| 658 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
| 658 | + if (!empty($_GET['vat_rule'])) { |
|
| 659 | 659 | $query->query_vars['meta_query'][] = array( |
| 660 | 660 | 'key' => '_wpinv_vat_rule', |
| 661 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
| 661 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
| 662 | 662 | 'compare' => '=' |
| 663 | 663 | ); |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | // Filter vat class |
| 667 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
| 667 | + if (!empty($_GET['vat_class'])) { |
|
| 668 | 668 | $query->query_vars['meta_query'][] = array( |
| 669 | 669 | 'key' => '_wpinv_vat_class', |
| 670 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
| 670 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
| 671 | 671 | 'compare' => '=' |
| 672 | 672 | ); |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | // Filter item type |
| 676 | - if ( ! empty( $_GET['type'] ) ) { |
|
| 676 | + if (!empty($_GET['type'])) { |
|
| 677 | 677 | $query->query_vars['meta_query'][] = array( |
| 678 | 678 | 'key' => '_wpinv_type', |
| 679 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
| 679 | + 'value' => sanitize_text_field($_GET['type']), |
|
| 680 | 680 | 'compare' => '=' |
| 681 | 681 | ); |
| 682 | 682 | } |
@@ -686,15 +686,15 @@ discard block |
||
| 686 | 686 | /** |
| 687 | 687 | * Reorders items. |
| 688 | 688 | */ |
| 689 | - public static function reorder_items( $vars ) { |
|
| 689 | + public static function reorder_items($vars) { |
|
| 690 | 690 | global $typenow; |
| 691 | 691 | |
| 692 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
| 692 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
| 693 | 693 | return $vars; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | // By item type. |
| 697 | - if ( 'type' == $vars['orderby'] ) { |
|
| 697 | + if ('type' == $vars['orderby']) { |
|
| 698 | 698 | return array_merge( |
| 699 | 699 | $vars, |
| 700 | 700 | array( |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | // By vat class. |
| 708 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
| 708 | + if ('vat_class' == $vars['orderby']) { |
|
| 709 | 709 | return array_merge( |
| 710 | 710 | $vars, |
| 711 | 711 | array( |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | // By vat rule. |
| 719 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
| 719 | + if ('vat_rule' == $vars['orderby']) { |
|
| 720 | 720 | return array_merge( |
| 721 | 721 | $vars, |
| 722 | 722 | array( |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | // By price. |
| 730 | - if ( 'price' == $vars['orderby'] ) { |
|
| 730 | + if ('price' == $vars['orderby']) { |
|
| 731 | 731 | return array_merge( |
| 732 | 732 | $vars, |
| 733 | 733 | array( |
@@ -744,27 +744,27 @@ discard block |
||
| 744 | 744 | /** |
| 745 | 745 | * Fired when deleting a post. |
| 746 | 746 | */ |
| 747 | - public static function delete_post( $post_id ) { |
|
| 747 | + public static function delete_post($post_id) { |
|
| 748 | 748 | |
| 749 | - switch ( get_post_type( $post_id ) ) { |
|
| 749 | + switch (get_post_type($post_id)) { |
|
| 750 | 750 | |
| 751 | 751 | case 'wpi_item' : |
| 752 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
| 752 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
| 753 | 753 | break; |
| 754 | 754 | |
| 755 | 755 | case 'wpi_payment_form' : |
| 756 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
| 756 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
| 757 | 757 | break; |
| 758 | 758 | |
| 759 | 759 | case 'wpi_discount' : |
| 760 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
| 760 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
| 761 | 761 | break; |
| 762 | 762 | |
| 763 | 763 | case 'wpi_invoice' : |
| 764 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 765 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
| 766 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
| 767 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
| 764 | + $invoice = new WPInv_Invoice($post_id); |
|
| 765 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
| 766 | + $invoice->get_data_store()->delete_items($invoice); |
|
| 767 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
| 768 | 768 | break; |
| 769 | 769 | } |
| 770 | 770 | } |
@@ -777,29 +777,29 @@ discard block |
||
| 777 | 777 | * |
| 778 | 778 | * @return mixed |
| 779 | 779 | */ |
| 780 | - public static function add_display_post_states( $post_states, $post ) { |
|
| 780 | + public static function add_display_post_states($post_states, $post) { |
|
| 781 | 781 | |
| 782 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
| 783 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
| 782 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
| 783 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
| 786 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
| 787 | 787 | |
| 788 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
| 788 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
| 789 | 789 | $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
| 790 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
| 790 | + __('GetPaid %s History Page', 'invoicing'), |
|
| 791 | 791 | $label |
| 792 | 792 | ); |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
| 798 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
| 797 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
| 798 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
| 802 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
| 801 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
| 802 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | return $post_states; |