@@ -7,22 +7,22 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
| 12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
| 13 | 13 | |
| 14 | -if ( ! empty( $required ) ) { |
|
| 14 | +if (!empty($required)) { |
|
| 15 | 15 | $label .= "<span class='text-danger'> *</span>"; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | echo aui()->input( |
| 19 | 19 | array( |
| 20 | 20 | 'type' => 'checkbox', |
| 21 | - 'name' => esc_attr( $id ), |
|
| 22 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
| 23 | - 'required' => ! empty( $required ), |
|
| 21 | + 'name' => esc_attr($id), |
|
| 22 | + 'id' => esc_attr($id) . uniqid('_'), |
|
| 23 | + 'required' => !empty($required), |
|
| 24 | 24 | 'label' => $label, |
| 25 | - 'value' => esc_attr__( 'Yes', 'invoicing' ), |
|
| 26 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
| 25 | + 'value' => esc_attr__('Yes', 'invoicing'), |
|
| 26 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
| 27 | 27 | ) |
| 28 | 28 | ); |
@@ -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,199 +21,199 @@ 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 = '1.0.1'; |
|
| 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.3.1"; |
|
| 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 | - } |
|
| 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 = '1.0.1'; |
|
| 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.3.1"; |
|
| 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 | 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 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 156 | - } |
|
| 157 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 158 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - // Maybe set the HTML font size |
|
| 162 | - if ( $this->settings['html_font_size'] ) { |
|
| 163 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * Check if we should load the admin scripts or not. |
|
| 171 | - * |
|
| 172 | - * @return bool |
|
| 173 | - */ |
|
| 174 | - public function load_admin_scripts(){ |
|
| 175 | - $result = true; |
|
| 176 | - |
|
| 177 | - if(!empty($this->settings['disable_admin'])){ |
|
| 178 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 179 | - foreach($url_parts as $part){ |
|
| 180 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 181 | - return false; // return early, no point checking further |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - } |
|
| 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 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 156 | + } |
|
| 157 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 158 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + // Maybe set the HTML font size |
|
| 162 | + if ( $this->settings['html_font_size'] ) { |
|
| 163 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * Check if we should load the admin scripts or not. |
|
| 171 | + * |
|
| 172 | + * @return bool |
|
| 173 | + */ |
|
| 174 | + public function load_admin_scripts(){ |
|
| 175 | + $result = true; |
|
| 176 | + |
|
| 177 | + if(!empty($this->settings['disable_admin'])){ |
|
| 178 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 179 | + foreach($url_parts as $part){ |
|
| 180 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 181 | + return false; // return early, no point checking further |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - return $result; |
|
| 187 | - } |
|
| 186 | + return $result; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - /** |
|
| 190 | - * Add a html font size to the footer. |
|
| 191 | - */ |
|
| 192 | - public function html_font_size(){ |
|
| 193 | - $this->settings = $this->get_settings(); |
|
| 194 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 195 | - } |
|
| 189 | + /** |
|
| 190 | + * Add a html font size to the footer. |
|
| 191 | + */ |
|
| 192 | + public function html_font_size(){ |
|
| 193 | + $this->settings = $this->get_settings(); |
|
| 194 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * Adds the Font Awesome styles. |
|
| 199 | - */ |
|
| 200 | - public function enqueue_style() { |
|
| 197 | + /** |
|
| 198 | + * Adds the Font Awesome styles. |
|
| 199 | + */ |
|
| 200 | + public function enqueue_style() { |
|
| 201 | 201 | |
| 202 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 202 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 203 | 203 | |
| 204 | - if($this->settings[$css_setting]){ |
|
| 205 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 206 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui.css' : $this->url.'assets/css/ayecode-ui-compatibility.css'; |
|
| 207 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
| 208 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 204 | + if($this->settings[$css_setting]){ |
|
| 205 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 206 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui.css' : $this->url.'assets/css/ayecode-ui-compatibility.css'; |
|
| 207 | + wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
| 208 | + wp_enqueue_style( 'ayecode-ui' ); |
|
| 209 | 209 | |
| 210 | - // flatpickr |
|
| 211 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
| 210 | + // flatpickr |
|
| 211 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
| 212 | 212 | |
| 213 | 213 | |
| 214 | - // fix some wp-admin issues |
|
| 215 | - if(is_admin()){ |
|
| 216 | - $custom_css = " |
|
| 214 | + // fix some wp-admin issues |
|
| 215 | + if(is_admin()){ |
|
| 216 | + $custom_css = " |
|
| 217 | 217 | body{ |
| 218 | 218 | background-color: #f1f1f1; |
| 219 | 219 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -249,29 +249,29 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | "; |
| 251 | 251 | |
| 252 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 253 | - $custom_css .= " |
|
| 252 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 253 | + $custom_css .= " |
|
| 254 | 254 | .edit-post-sidebar input[type=color].components-text-control__input{ |
| 255 | 255 | padding: 0; |
| 256 | 256 | } |
| 257 | 257 | "; |
| 258 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 259 | - } |
|
| 258 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - // custom changes |
|
| 262 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 261 | + // custom changes |
|
| 262 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 263 | 263 | |
| 264 | - } |
|
| 265 | - } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - /** |
|
| 268 | - * Get inline script used if bootstrap enqueued |
|
| 269 | - * |
|
| 270 | - * If this remains small then its best to use this than to add another JS file. |
|
| 271 | - */ |
|
| 272 | - public function inline_script(){ |
|
| 273 | - ob_start(); |
|
| 274 | - ?> |
|
| 267 | + /** |
|
| 268 | + * Get inline script used if bootstrap enqueued |
|
| 269 | + * |
|
| 270 | + * If this remains small then its best to use this than to add another JS file. |
|
| 271 | + */ |
|
| 272 | + public function inline_script(){ |
|
| 273 | + ob_start(); |
|
| 274 | + ?> |
|
| 275 | 275 | <script> |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -758,25 +758,25 @@ discard block |
||
| 758 | 758 | |
| 759 | 759 | </script> |
| 760 | 760 | <?php |
| 761 | - $output = ob_get_clean(); |
|
| 761 | + $output = ob_get_clean(); |
|
| 762 | 762 | |
| 763 | - /* |
|
| 763 | + /* |
|
| 764 | 764 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 765 | 765 | */ |
| 766 | - return str_replace( array( |
|
| 767 | - '<script>', |
|
| 768 | - '</script>' |
|
| 769 | - ), '', $output ); |
|
| 770 | - } |
|
| 771 | - |
|
| 772 | - /** |
|
| 773 | - * Get inline script used if bootstrap file browser enqueued. |
|
| 774 | - * |
|
| 775 | - * If this remains small then its best to use this than to add another JS file. |
|
| 776 | - */ |
|
| 777 | - public function inline_script_file_browser(){ |
|
| 778 | - ob_start(); |
|
| 779 | - ?> |
|
| 766 | + return str_replace( array( |
|
| 767 | + '<script>', |
|
| 768 | + '</script>' |
|
| 769 | + ), '', $output ); |
|
| 770 | + } |
|
| 771 | + |
|
| 772 | + /** |
|
| 773 | + * Get inline script used if bootstrap file browser enqueued. |
|
| 774 | + * |
|
| 775 | + * If this remains small then its best to use this than to add another JS file. |
|
| 776 | + */ |
|
| 777 | + public function inline_script_file_browser(){ |
|
| 778 | + ob_start(); |
|
| 779 | + ?> |
|
| 780 | 780 | <script> |
| 781 | 781 | // run on doc ready |
| 782 | 782 | jQuery(document).ready(function () { |
@@ -784,184 +784,184 @@ discard block |
||
| 784 | 784 | }); |
| 785 | 785 | </script> |
| 786 | 786 | <?php |
| 787 | - $output = ob_get_clean(); |
|
| 787 | + $output = ob_get_clean(); |
|
| 788 | 788 | |
| 789 | - /* |
|
| 789 | + /* |
|
| 790 | 790 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 791 | 791 | */ |
| 792 | - return str_replace( array( |
|
| 793 | - '<script>', |
|
| 794 | - '</script>' |
|
| 795 | - ), '', $output ); |
|
| 796 | - } |
|
| 797 | - |
|
| 798 | - /** |
|
| 799 | - * Adds the Font Awesome JS. |
|
| 800 | - */ |
|
| 801 | - public function enqueue_scripts() { |
|
| 802 | - |
|
| 803 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 804 | - |
|
| 805 | - // select2 |
|
| 806 | - wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version ); |
|
| 807 | - |
|
| 808 | - // flatpickr |
|
| 809 | - wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
| 810 | - |
|
| 811 | - // Bootstrap file browser |
|
| 812 | - wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version ); |
|
| 813 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 814 | - |
|
| 815 | - $load_inline = false; |
|
| 816 | - |
|
| 817 | - if($this->settings[$js_setting]=='core-popper'){ |
|
| 818 | - // Bootstrap bundle |
|
| 819 | - $url = $this->url.'assets/js/bootstrap.bundle.min.js'; |
|
| 820 | - wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest ); |
|
| 821 | - // if in admin then add to footer for compatibility. |
|
| 822 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle'); |
|
| 823 | - $script = $this->inline_script(); |
|
| 824 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 825 | - }elseif($this->settings[$js_setting]=='popper'){ |
|
| 826 | - $url = $this->url.'assets/js/popper.min.js'; |
|
| 827 | - wp_register_script( 'bootstrap-js-popper', $url, array('select2','jquery'), $this->latest ); |
|
| 828 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 829 | - $load_inline = true; |
|
| 830 | - }else{ |
|
| 831 | - $load_inline = true; |
|
| 832 | - } |
|
| 833 | - |
|
| 834 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 835 | - if($load_inline){ |
|
| 836 | - wp_register_script( 'bootstrap-dummy', '',array('select2','jquery') ); |
|
| 837 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 838 | - $script = $this->inline_script(); |
|
| 839 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - /** |
|
| 845 | - * Enqueue flatpickr if called. |
|
| 846 | - */ |
|
| 847 | - public function enqueue_flatpickr(){ |
|
| 848 | - wp_enqueue_style( 'flatpickr' ); |
|
| 849 | - wp_enqueue_script( 'flatpickr' ); |
|
| 850 | - } |
|
| 851 | - |
|
| 852 | - /** |
|
| 853 | - * Get the url path to the current folder. |
|
| 854 | - * |
|
| 855 | - * @return string |
|
| 856 | - */ |
|
| 857 | - public function get_url() { |
|
| 858 | - |
|
| 859 | - $url = ''; |
|
| 860 | - // check if we are inside a plugin |
|
| 861 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 862 | - |
|
| 863 | - // add check in-case user has changed wp-content dir name. |
|
| 864 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 865 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 866 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 867 | - |
|
| 868 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 869 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 870 | - } |
|
| 871 | - |
|
| 872 | - return $url; |
|
| 873 | - } |
|
| 874 | - |
|
| 875 | - /** |
|
| 876 | - * Register the database settings with WordPress. |
|
| 877 | - */ |
|
| 878 | - public function register_settings() { |
|
| 879 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 880 | - } |
|
| 881 | - |
|
| 882 | - /** |
|
| 883 | - * Add the WordPress settings menu item. |
|
| 884 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 885 | - */ |
|
| 886 | - public function menu_item() { |
|
| 887 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 888 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 889 | - $this, |
|
| 890 | - 'settings_page' |
|
| 891 | - ) ); |
|
| 892 | - } |
|
| 893 | - |
|
| 894 | - /** |
|
| 895 | - * Get a list of themes and their default JS settings. |
|
| 896 | - * |
|
| 897 | - * @return array |
|
| 898 | - */ |
|
| 899 | - public function theme_js_settings(){ |
|
| 900 | - return array( |
|
| 901 | - 'ayetheme' => 'popper', |
|
| 902 | - 'listimia' => 'required', |
|
| 903 | - 'listimia_backend' => 'core-popper', |
|
| 904 | - 'avada' => 'required', |
|
| 905 | - ); |
|
| 906 | - } |
|
| 907 | - |
|
| 908 | - /** |
|
| 909 | - * Get the current Font Awesome output settings. |
|
| 910 | - * |
|
| 911 | - * @return array The array of settings. |
|
| 912 | - */ |
|
| 913 | - public function get_settings() { |
|
| 914 | - |
|
| 915 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 916 | - $js_default = 'core-popper'; |
|
| 917 | - $js_default_backend = $js_default; |
|
| 918 | - |
|
| 919 | - // maybe set defaults (if no settings set) |
|
| 920 | - if(empty($db_settings)){ |
|
| 921 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 922 | - $theme_js_settings = self::theme_js_settings(); |
|
| 923 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 924 | - $js_default = $theme_js_settings[$active_theme]; |
|
| 925 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 926 | - } |
|
| 927 | - } |
|
| 928 | - |
|
| 929 | - $defaults = array( |
|
| 930 | - 'css' => 'compatibility', // core, compatibility |
|
| 931 | - 'js' => $js_default, // js to load, core-popper, popper |
|
| 932 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 933 | - 'css_backend' => 'compatibility', // core, compatibility |
|
| 934 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 935 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 936 | - ); |
|
| 937 | - |
|
| 938 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 939 | - |
|
| 940 | - /** |
|
| 941 | - * Filter the Bootstrap settings. |
|
| 942 | - * |
|
| 943 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 944 | - */ |
|
| 945 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 946 | - } |
|
| 947 | - |
|
| 948 | - |
|
| 949 | - /** |
|
| 950 | - * The settings page html output. |
|
| 951 | - */ |
|
| 952 | - public function settings_page() { |
|
| 953 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 954 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 955 | - } |
|
| 956 | - ?> |
|
| 792 | + return str_replace( array( |
|
| 793 | + '<script>', |
|
| 794 | + '</script>' |
|
| 795 | + ), '', $output ); |
|
| 796 | + } |
|
| 797 | + |
|
| 798 | + /** |
|
| 799 | + * Adds the Font Awesome JS. |
|
| 800 | + */ |
|
| 801 | + public function enqueue_scripts() { |
|
| 802 | + |
|
| 803 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 804 | + |
|
| 805 | + // select2 |
|
| 806 | + wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version ); |
|
| 807 | + |
|
| 808 | + // flatpickr |
|
| 809 | + wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
| 810 | + |
|
| 811 | + // Bootstrap file browser |
|
| 812 | + wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version ); |
|
| 813 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 814 | + |
|
| 815 | + $load_inline = false; |
|
| 816 | + |
|
| 817 | + if($this->settings[$js_setting]=='core-popper'){ |
|
| 818 | + // Bootstrap bundle |
|
| 819 | + $url = $this->url.'assets/js/bootstrap.bundle.min.js'; |
|
| 820 | + wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest ); |
|
| 821 | + // if in admin then add to footer for compatibility. |
|
| 822 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle'); |
|
| 823 | + $script = $this->inline_script(); |
|
| 824 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 825 | + }elseif($this->settings[$js_setting]=='popper'){ |
|
| 826 | + $url = $this->url.'assets/js/popper.min.js'; |
|
| 827 | + wp_register_script( 'bootstrap-js-popper', $url, array('select2','jquery'), $this->latest ); |
|
| 828 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 829 | + $load_inline = true; |
|
| 830 | + }else{ |
|
| 831 | + $load_inline = true; |
|
| 832 | + } |
|
| 833 | + |
|
| 834 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 835 | + if($load_inline){ |
|
| 836 | + wp_register_script( 'bootstrap-dummy', '',array('select2','jquery') ); |
|
| 837 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 838 | + $script = $this->inline_script(); |
|
| 839 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 840 | + } |
|
| 841 | + |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + /** |
|
| 845 | + * Enqueue flatpickr if called. |
|
| 846 | + */ |
|
| 847 | + public function enqueue_flatpickr(){ |
|
| 848 | + wp_enqueue_style( 'flatpickr' ); |
|
| 849 | + wp_enqueue_script( 'flatpickr' ); |
|
| 850 | + } |
|
| 851 | + |
|
| 852 | + /** |
|
| 853 | + * Get the url path to the current folder. |
|
| 854 | + * |
|
| 855 | + * @return string |
|
| 856 | + */ |
|
| 857 | + public function get_url() { |
|
| 858 | + |
|
| 859 | + $url = ''; |
|
| 860 | + // check if we are inside a plugin |
|
| 861 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 862 | + |
|
| 863 | + // add check in-case user has changed wp-content dir name. |
|
| 864 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 865 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 866 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 867 | + |
|
| 868 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 869 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 870 | + } |
|
| 871 | + |
|
| 872 | + return $url; |
|
| 873 | + } |
|
| 874 | + |
|
| 875 | + /** |
|
| 876 | + * Register the database settings with WordPress. |
|
| 877 | + */ |
|
| 878 | + public function register_settings() { |
|
| 879 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 880 | + } |
|
| 881 | + |
|
| 882 | + /** |
|
| 883 | + * Add the WordPress settings menu item. |
|
| 884 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 885 | + */ |
|
| 886 | + public function menu_item() { |
|
| 887 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 888 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 889 | + $this, |
|
| 890 | + 'settings_page' |
|
| 891 | + ) ); |
|
| 892 | + } |
|
| 893 | + |
|
| 894 | + /** |
|
| 895 | + * Get a list of themes and their default JS settings. |
|
| 896 | + * |
|
| 897 | + * @return array |
|
| 898 | + */ |
|
| 899 | + public function theme_js_settings(){ |
|
| 900 | + return array( |
|
| 901 | + 'ayetheme' => 'popper', |
|
| 902 | + 'listimia' => 'required', |
|
| 903 | + 'listimia_backend' => 'core-popper', |
|
| 904 | + 'avada' => 'required', |
|
| 905 | + ); |
|
| 906 | + } |
|
| 907 | + |
|
| 908 | + /** |
|
| 909 | + * Get the current Font Awesome output settings. |
|
| 910 | + * |
|
| 911 | + * @return array The array of settings. |
|
| 912 | + */ |
|
| 913 | + public function get_settings() { |
|
| 914 | + |
|
| 915 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 916 | + $js_default = 'core-popper'; |
|
| 917 | + $js_default_backend = $js_default; |
|
| 918 | + |
|
| 919 | + // maybe set defaults (if no settings set) |
|
| 920 | + if(empty($db_settings)){ |
|
| 921 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 922 | + $theme_js_settings = self::theme_js_settings(); |
|
| 923 | + if(isset($theme_js_settings[$active_theme])){ |
|
| 924 | + $js_default = $theme_js_settings[$active_theme]; |
|
| 925 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 926 | + } |
|
| 927 | + } |
|
| 928 | + |
|
| 929 | + $defaults = array( |
|
| 930 | + 'css' => 'compatibility', // core, compatibility |
|
| 931 | + 'js' => $js_default, // js to load, core-popper, popper |
|
| 932 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 933 | + 'css_backend' => 'compatibility', // core, compatibility |
|
| 934 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 935 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 936 | + ); |
|
| 937 | + |
|
| 938 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 939 | + |
|
| 940 | + /** |
|
| 941 | + * Filter the Bootstrap settings. |
|
| 942 | + * |
|
| 943 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 944 | + */ |
|
| 945 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + |
|
| 949 | + /** |
|
| 950 | + * The settings page html output. |
|
| 951 | + */ |
|
| 952 | + public function settings_page() { |
|
| 953 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 954 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 955 | + } |
|
| 956 | + ?> |
|
| 957 | 957 | <div class="wrap"> |
| 958 | 958 | <h1><?php echo $this->name; ?></h1> |
| 959 | 959 | <p><?php _e("Here you can adjust settings if you are having compatibility issues.","aui");?></p> |
| 960 | 960 | <form method="post" action="options.php"> |
| 961 | 961 | <?php |
| 962 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 963 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 964 | - ?> |
|
| 962 | + settings_fields( 'ayecode-ui-settings' ); |
|
| 963 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
| 964 | + ?> |
|
| 965 | 965 | |
| 966 | 966 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
| 967 | 967 | <table class="form-table wpbs-table-settings"> |
@@ -1041,489 +1041,489 @@ discard block |
||
| 1041 | 1041 | </table> |
| 1042 | 1042 | |
| 1043 | 1043 | <?php |
| 1044 | - submit_button(); |
|
| 1045 | - ?> |
|
| 1044 | + submit_button(); |
|
| 1045 | + ?> |
|
| 1046 | 1046 | </form> |
| 1047 | 1047 | |
| 1048 | 1048 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
| 1049 | 1049 | </div> |
| 1050 | 1050 | |
| 1051 | 1051 | <?php |
| 1052 | - } |
|
| 1053 | - |
|
| 1054 | - public function customizer_settings($wp_customize){ |
|
| 1055 | - $wp_customize->add_section('aui_settings', array( |
|
| 1056 | - 'title' => __('AyeCode UI','aui'), |
|
| 1057 | - 'priority' => 120, |
|
| 1058 | - )); |
|
| 1059 | - |
|
| 1060 | - // ============================= |
|
| 1061 | - // = Color Picker = |
|
| 1062 | - // ============================= |
|
| 1063 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1064 | - 'default' => AUI_PRIMARY_COLOR, |
|
| 1065 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1066 | - 'capability' => 'edit_theme_options', |
|
| 1067 | - 'type' => 'option', |
|
| 1068 | - 'transport' => 'refresh', |
|
| 1069 | - )); |
|
| 1070 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1071 | - 'label' => __('Primary Color','aui'), |
|
| 1072 | - 'section' => 'aui_settings', |
|
| 1073 | - 'settings' => 'aui_options[color_primary]', |
|
| 1074 | - ))); |
|
| 1075 | - |
|
| 1076 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1077 | - 'default' => '#6c757d', |
|
| 1078 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1079 | - 'capability' => 'edit_theme_options', |
|
| 1080 | - 'type' => 'option', |
|
| 1081 | - 'transport' => 'refresh', |
|
| 1082 | - )); |
|
| 1083 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1084 | - 'label' => __('Secondary Color','aui'), |
|
| 1085 | - 'section' => 'aui_settings', |
|
| 1086 | - 'settings' => 'aui_options[color_secondary]', |
|
| 1087 | - ))); |
|
| 1088 | - } |
|
| 1089 | - |
|
| 1090 | - |
|
| 1091 | - public static function custom_css($compatibility = true) { |
|
| 1092 | - $settings = get_option('aui_options'); |
|
| 1093 | - |
|
| 1094 | - ob_start(); |
|
| 1095 | - |
|
| 1096 | - $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
| 1097 | - $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
| 1098 | - //AUI_PRIMARY_COLOR_ORIGINAL |
|
| 1099 | - ?> |
|
| 1052 | + } |
|
| 1053 | + |
|
| 1054 | + public function customizer_settings($wp_customize){ |
|
| 1055 | + $wp_customize->add_section('aui_settings', array( |
|
| 1056 | + 'title' => __('AyeCode UI','aui'), |
|
| 1057 | + 'priority' => 120, |
|
| 1058 | + )); |
|
| 1059 | + |
|
| 1060 | + // ============================= |
|
| 1061 | + // = Color Picker = |
|
| 1062 | + // ============================= |
|
| 1063 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1064 | + 'default' => AUI_PRIMARY_COLOR, |
|
| 1065 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1066 | + 'capability' => 'edit_theme_options', |
|
| 1067 | + 'type' => 'option', |
|
| 1068 | + 'transport' => 'refresh', |
|
| 1069 | + )); |
|
| 1070 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1071 | + 'label' => __('Primary Color','aui'), |
|
| 1072 | + 'section' => 'aui_settings', |
|
| 1073 | + 'settings' => 'aui_options[color_primary]', |
|
| 1074 | + ))); |
|
| 1075 | + |
|
| 1076 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1077 | + 'default' => '#6c757d', |
|
| 1078 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1079 | + 'capability' => 'edit_theme_options', |
|
| 1080 | + 'type' => 'option', |
|
| 1081 | + 'transport' => 'refresh', |
|
| 1082 | + )); |
|
| 1083 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1084 | + 'label' => __('Secondary Color','aui'), |
|
| 1085 | + 'section' => 'aui_settings', |
|
| 1086 | + 'settings' => 'aui_options[color_secondary]', |
|
| 1087 | + ))); |
|
| 1088 | + } |
|
| 1089 | + |
|
| 1090 | + |
|
| 1091 | + public static function custom_css($compatibility = true) { |
|
| 1092 | + $settings = get_option('aui_options'); |
|
| 1093 | + |
|
| 1094 | + ob_start(); |
|
| 1095 | + |
|
| 1096 | + $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
| 1097 | + $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
| 1098 | + //AUI_PRIMARY_COLOR_ORIGINAL |
|
| 1099 | + ?> |
|
| 1100 | 1100 | <style> |
| 1101 | 1101 | <?php |
| 1102 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
| 1103 | - echo self::css_primary($primary_color,$compatibility); |
|
| 1104 | - } |
|
| 1102 | + if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
| 1103 | + echo self::css_primary($primary_color,$compatibility); |
|
| 1104 | + } |
|
| 1105 | 1105 | |
| 1106 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
| 1107 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 1108 | - } |
|
| 1106 | + if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
| 1107 | + echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 1108 | + } |
|
| 1109 | 1109 | ?> |
| 1110 | 1110 | </style> |
| 1111 | 1111 | <?php |
| 1112 | 1112 | |
| 1113 | 1113 | |
| 1114 | - /* |
|
| 1114 | + /* |
|
| 1115 | 1115 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1116 | 1116 | */ |
| 1117 | - return str_replace( array( |
|
| 1118 | - '<style>', |
|
| 1119 | - '</style>' |
|
| 1120 | - ), '', ob_get_clean()); |
|
| 1121 | - } |
|
| 1122 | - |
|
| 1123 | - public static function css_primary($color_code,$compatibility){; |
|
| 1124 | - $color_code = sanitize_hex_color($color_code); |
|
| 1125 | - if(!$color_code){return '';} |
|
| 1126 | - /** |
|
| 1127 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1128 | - */ |
|
| 1129 | - $selectors = array( |
|
| 1130 | - 'a' => array('c'), |
|
| 1131 | - '.btn-primary' => array('b','o'), |
|
| 1132 | - '.btn-primary.disabled' => array('b','o'), |
|
| 1133 | - '.btn-primary:disabled' => array('b','o'), |
|
| 1134 | - '.btn-outline-primary' => array('c','o'), |
|
| 1135 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 1136 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1137 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1138 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1139 | - '.btn-link' => array('c'), |
|
| 1140 | - '.dropdown-item.active' => array('b'), |
|
| 1141 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1142 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1117 | + return str_replace( array( |
|
| 1118 | + '<style>', |
|
| 1119 | + '</style>' |
|
| 1120 | + ), '', ob_get_clean()); |
|
| 1121 | + } |
|
| 1122 | + |
|
| 1123 | + public static function css_primary($color_code,$compatibility){; |
|
| 1124 | + $color_code = sanitize_hex_color($color_code); |
|
| 1125 | + if(!$color_code){return '';} |
|
| 1126 | + /** |
|
| 1127 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1128 | + */ |
|
| 1129 | + $selectors = array( |
|
| 1130 | + 'a' => array('c'), |
|
| 1131 | + '.btn-primary' => array('b','o'), |
|
| 1132 | + '.btn-primary.disabled' => array('b','o'), |
|
| 1133 | + '.btn-primary:disabled' => array('b','o'), |
|
| 1134 | + '.btn-outline-primary' => array('c','o'), |
|
| 1135 | + '.btn-outline-primary:hover' => array('b','o'), |
|
| 1136 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1137 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1138 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1139 | + '.btn-link' => array('c'), |
|
| 1140 | + '.dropdown-item.active' => array('b'), |
|
| 1141 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1142 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1143 | 1143 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1144 | 1144 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1145 | 1145 | // '.custom-range::-ms-thumb' => array('b'), |
| 1146 | - '.nav-pills .nav-link.active' => array('b'), |
|
| 1147 | - '.nav-pills .show>.nav-link' => array('b'), |
|
| 1148 | - '.page-link' => array('c'), |
|
| 1149 | - '.page-item.active .page-link' => array('b','o'), |
|
| 1150 | - '.badge-primary' => array('b'), |
|
| 1151 | - '.alert-primary' => array('b','o'), |
|
| 1152 | - '.progress-bar' => array('b'), |
|
| 1153 | - '.list-group-item.active' => array('b','o'), |
|
| 1154 | - '.bg-primary' => array('b','f'), |
|
| 1155 | - '.btn-link.btn-primary' => array('c'), |
|
| 1156 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1157 | - ); |
|
| 1158 | - |
|
| 1159 | - $important_selectors = array( |
|
| 1160 | - '.bg-primary' => array('b','f'), |
|
| 1161 | - '.border-primary' => array('o'), |
|
| 1162 | - '.text-primary' => array('c'), |
|
| 1163 | - ); |
|
| 1164 | - |
|
| 1165 | - $color = array(); |
|
| 1166 | - $color_i = array(); |
|
| 1167 | - $background = array(); |
|
| 1168 | - $background_i = array(); |
|
| 1169 | - $border = array(); |
|
| 1170 | - $border_i = array(); |
|
| 1171 | - $fill = array(); |
|
| 1172 | - $fill_i = array(); |
|
| 1173 | - |
|
| 1174 | - $output = ''; |
|
| 1175 | - |
|
| 1176 | - // build rules into each type |
|
| 1177 | - foreach($selectors as $selector => $types){ |
|
| 1178 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1179 | - $types = array_combine($types,$types); |
|
| 1180 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1181 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1182 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1183 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1184 | - } |
|
| 1185 | - |
|
| 1186 | - // build rules into each type |
|
| 1187 | - foreach($important_selectors as $selector => $types){ |
|
| 1188 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1189 | - $types = array_combine($types,$types); |
|
| 1190 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1191 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1192 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1193 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1194 | - } |
|
| 1195 | - |
|
| 1196 | - // add any color rules |
|
| 1197 | - if(!empty($color)){ |
|
| 1198 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1199 | - } |
|
| 1200 | - if(!empty($color_i)){ |
|
| 1201 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1202 | - } |
|
| 1203 | - |
|
| 1204 | - // add any background color rules |
|
| 1205 | - if(!empty($background)){ |
|
| 1206 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1207 | - } |
|
| 1208 | - if(!empty($background_i)){ |
|
| 1209 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1210 | - } |
|
| 1211 | - |
|
| 1212 | - // add any border color rules |
|
| 1213 | - if(!empty($border)){ |
|
| 1214 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1215 | - } |
|
| 1216 | - if(!empty($border_i)){ |
|
| 1217 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1218 | - } |
|
| 1219 | - |
|
| 1220 | - // add any fill color rules |
|
| 1221 | - if(!empty($fill)){ |
|
| 1222 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1223 | - } |
|
| 1224 | - if(!empty($fill_i)){ |
|
| 1225 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1226 | - } |
|
| 1227 | - |
|
| 1228 | - |
|
| 1229 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 1230 | - |
|
| 1231 | - // darken |
|
| 1232 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1233 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1234 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1235 | - |
|
| 1236 | - // lighten |
|
| 1237 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1238 | - |
|
| 1239 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1240 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1241 | - |
|
| 1242 | - |
|
| 1243 | - // button states |
|
| 1244 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1245 | - $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;} "; |
|
| 1246 | - $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.";} "; |
|
| 1247 | - $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;} "; |
|
| 1248 | - |
|
| 1249 | - |
|
| 1250 | - // dropdown's |
|
| 1251 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1252 | - |
|
| 1253 | - |
|
| 1254 | - // input states |
|
| 1255 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1256 | - |
|
| 1257 | - // page link |
|
| 1258 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1259 | - |
|
| 1260 | - return $output; |
|
| 1261 | - } |
|
| 1262 | - |
|
| 1263 | - public static function css_secondary($color_code,$compatibility){; |
|
| 1264 | - $color_code = sanitize_hex_color($color_code); |
|
| 1265 | - if(!$color_code){return '';} |
|
| 1266 | - /** |
|
| 1267 | - * c = color, b = background color, o = border-color, f = fill |
|
| 1268 | - */ |
|
| 1269 | - $selectors = array( |
|
| 1270 | - '.btn-secondary' => array('b','o'), |
|
| 1271 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 1272 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 1273 | - '.btn-outline-secondary' => array('c','o'), |
|
| 1274 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1275 | - '.btn-outline-secondary.disabled' => array('c'), |
|
| 1276 | - '.btn-outline-secondary:disabled' => array('c'), |
|
| 1277 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1278 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1279 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1280 | - '.badge-secondary' => array('b'), |
|
| 1281 | - '.alert-secondary' => array('b','o'), |
|
| 1282 | - '.btn-link.btn-secondary' => array('c'), |
|
| 1283 | - ); |
|
| 1284 | - |
|
| 1285 | - $important_selectors = array( |
|
| 1286 | - '.bg-secondary' => array('b','f'), |
|
| 1287 | - '.border-secondary' => array('o'), |
|
| 1288 | - '.text-secondary' => array('c'), |
|
| 1289 | - ); |
|
| 1290 | - |
|
| 1291 | - $color = array(); |
|
| 1292 | - $color_i = array(); |
|
| 1293 | - $background = array(); |
|
| 1294 | - $background_i = array(); |
|
| 1295 | - $border = array(); |
|
| 1296 | - $border_i = array(); |
|
| 1297 | - $fill = array(); |
|
| 1298 | - $fill_i = array(); |
|
| 1299 | - |
|
| 1300 | - $output = ''; |
|
| 1301 | - |
|
| 1302 | - // build rules into each type |
|
| 1303 | - foreach($selectors as $selector => $types){ |
|
| 1304 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1305 | - $types = array_combine($types,$types); |
|
| 1306 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1307 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1308 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1309 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1310 | - } |
|
| 1311 | - |
|
| 1312 | - // build rules into each type |
|
| 1313 | - foreach($important_selectors as $selector => $types){ |
|
| 1314 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1315 | - $types = array_combine($types,$types); |
|
| 1316 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1317 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1318 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1319 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1320 | - } |
|
| 1321 | - |
|
| 1322 | - // add any color rules |
|
| 1323 | - if(!empty($color)){ |
|
| 1324 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1325 | - } |
|
| 1326 | - if(!empty($color_i)){ |
|
| 1327 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1328 | - } |
|
| 1329 | - |
|
| 1330 | - // add any background color rules |
|
| 1331 | - if(!empty($background)){ |
|
| 1332 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1333 | - } |
|
| 1334 | - if(!empty($background_i)){ |
|
| 1335 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1336 | - } |
|
| 1337 | - |
|
| 1338 | - // add any border color rules |
|
| 1339 | - if(!empty($border)){ |
|
| 1340 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1341 | - } |
|
| 1342 | - if(!empty($border_i)){ |
|
| 1343 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1344 | - } |
|
| 1345 | - |
|
| 1346 | - // add any fill color rules |
|
| 1347 | - if(!empty($fill)){ |
|
| 1348 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1349 | - } |
|
| 1350 | - if(!empty($fill_i)){ |
|
| 1351 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1352 | - } |
|
| 1353 | - |
|
| 1354 | - |
|
| 1355 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 1356 | - |
|
| 1357 | - // darken |
|
| 1358 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1359 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1360 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1361 | - |
|
| 1362 | - // lighten |
|
| 1363 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1364 | - |
|
| 1365 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1366 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1367 | - |
|
| 1368 | - |
|
| 1369 | - // button states |
|
| 1370 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1371 | - $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;} "; |
|
| 1372 | - $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.";} "; |
|
| 1373 | - $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;} "; |
|
| 1374 | - |
|
| 1375 | - |
|
| 1376 | - return $output; |
|
| 1377 | - } |
|
| 1378 | - |
|
| 1379 | - /** |
|
| 1380 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 1381 | - * |
|
| 1382 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 1383 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 1384 | - * |
|
| 1385 | - * @return string |
|
| 1386 | - */ |
|
| 1387 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 1388 | - $hexCode = ltrim($hexCode, '#'); |
|
| 1389 | - |
|
| 1390 | - if (strlen($hexCode) == 3) { |
|
| 1391 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 1392 | - } |
|
| 1393 | - |
|
| 1394 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 1395 | - |
|
| 1396 | - foreach ($hexCode as & $color) { |
|
| 1397 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 1398 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 1399 | - |
|
| 1400 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 1401 | - } |
|
| 1402 | - |
|
| 1403 | - return '#' . implode($hexCode); |
|
| 1404 | - } |
|
| 1405 | - |
|
| 1406 | - /** |
|
| 1407 | - * Check if we should display examples. |
|
| 1408 | - */ |
|
| 1409 | - public function maybe_show_examples(){ |
|
| 1410 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 1411 | - echo "<head>"; |
|
| 1412 | - wp_head(); |
|
| 1413 | - echo "</head>"; |
|
| 1414 | - echo "<body>"; |
|
| 1415 | - echo $this->get_examples(); |
|
| 1416 | - echo "</body>"; |
|
| 1417 | - exit; |
|
| 1418 | - } |
|
| 1419 | - } |
|
| 1420 | - |
|
| 1421 | - /** |
|
| 1422 | - * Get developer examples. |
|
| 1423 | - * |
|
| 1424 | - * @return string |
|
| 1425 | - */ |
|
| 1426 | - public function get_examples(){ |
|
| 1427 | - $output = ''; |
|
| 1428 | - |
|
| 1429 | - |
|
| 1430 | - // open form |
|
| 1431 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 1432 | - |
|
| 1433 | - // input example |
|
| 1434 | - $output .= aui()->input(array( |
|
| 1435 | - 'type' => 'text', |
|
| 1436 | - 'id' => 'text-example', |
|
| 1437 | - 'name' => 'text-example', |
|
| 1438 | - 'placeholder' => 'text placeholder', |
|
| 1439 | - 'title' => 'Text input example', |
|
| 1440 | - 'value' => '', |
|
| 1441 | - 'required' => false, |
|
| 1442 | - 'help_text' => 'help text', |
|
| 1443 | - 'label' => 'Text input example label' |
|
| 1444 | - )); |
|
| 1445 | - |
|
| 1446 | - // input example |
|
| 1447 | - $output .= aui()->input(array( |
|
| 1448 | - 'type' => 'url', |
|
| 1449 | - 'id' => 'text-example2', |
|
| 1450 | - 'name' => 'text-example', |
|
| 1451 | - 'placeholder' => 'url placeholder', |
|
| 1452 | - 'title' => 'Text input example', |
|
| 1453 | - 'value' => '', |
|
| 1454 | - 'required' => false, |
|
| 1455 | - 'help_text' => 'help text', |
|
| 1456 | - 'label' => 'Text input example label' |
|
| 1457 | - )); |
|
| 1458 | - |
|
| 1459 | - // checkbox example |
|
| 1460 | - $output .= aui()->input(array( |
|
| 1461 | - 'type' => 'checkbox', |
|
| 1462 | - 'id' => 'checkbox-example', |
|
| 1463 | - 'name' => 'checkbox-example', |
|
| 1464 | - 'placeholder' => 'checkbox-example', |
|
| 1465 | - 'title' => 'Checkbox example', |
|
| 1466 | - 'value' => '1', |
|
| 1467 | - 'checked' => true, |
|
| 1468 | - 'required' => false, |
|
| 1469 | - 'help_text' => 'help text', |
|
| 1470 | - 'label' => 'Checkbox checked' |
|
| 1471 | - )); |
|
| 1472 | - |
|
| 1473 | - // checkbox example |
|
| 1474 | - $output .= aui()->input(array( |
|
| 1475 | - 'type' => 'checkbox', |
|
| 1476 | - 'id' => 'checkbox-example2', |
|
| 1477 | - 'name' => 'checkbox-example2', |
|
| 1478 | - 'placeholder' => 'checkbox-example', |
|
| 1479 | - 'title' => 'Checkbox example', |
|
| 1480 | - 'value' => '1', |
|
| 1481 | - 'checked' => false, |
|
| 1482 | - 'required' => false, |
|
| 1483 | - 'help_text' => 'help text', |
|
| 1484 | - 'label' => 'Checkbox un-checked' |
|
| 1485 | - )); |
|
| 1486 | - |
|
| 1487 | - // switch example |
|
| 1488 | - $output .= aui()->input(array( |
|
| 1489 | - 'type' => 'checkbox', |
|
| 1490 | - 'id' => 'switch-example', |
|
| 1491 | - 'name' => 'switch-example', |
|
| 1492 | - 'placeholder' => 'checkbox-example', |
|
| 1493 | - 'title' => 'Switch example', |
|
| 1494 | - 'value' => '1', |
|
| 1495 | - 'checked' => true, |
|
| 1496 | - 'switch' => true, |
|
| 1497 | - 'required' => false, |
|
| 1498 | - 'help_text' => 'help text', |
|
| 1499 | - 'label' => 'Switch on' |
|
| 1500 | - )); |
|
| 1501 | - |
|
| 1502 | - // switch example |
|
| 1503 | - $output .= aui()->input(array( |
|
| 1504 | - 'type' => 'checkbox', |
|
| 1505 | - 'id' => 'switch-example2', |
|
| 1506 | - 'name' => 'switch-example2', |
|
| 1507 | - 'placeholder' => 'checkbox-example', |
|
| 1508 | - 'title' => 'Switch example', |
|
| 1509 | - 'value' => '1', |
|
| 1510 | - 'checked' => false, |
|
| 1511 | - 'switch' => true, |
|
| 1512 | - 'required' => false, |
|
| 1513 | - 'help_text' => 'help text', |
|
| 1514 | - 'label' => 'Switch off' |
|
| 1515 | - )); |
|
| 1516 | - |
|
| 1517 | - // close form |
|
| 1518 | - $output .= "</form>"; |
|
| 1519 | - |
|
| 1520 | - return $output; |
|
| 1521 | - } |
|
| 1522 | - |
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - /** |
|
| 1526 | - * Run the class if found. |
|
| 1527 | - */ |
|
| 1528 | - AyeCode_UI_Settings::instance(); |
|
| 1146 | + '.nav-pills .nav-link.active' => array('b'), |
|
| 1147 | + '.nav-pills .show>.nav-link' => array('b'), |
|
| 1148 | + '.page-link' => array('c'), |
|
| 1149 | + '.page-item.active .page-link' => array('b','o'), |
|
| 1150 | + '.badge-primary' => array('b'), |
|
| 1151 | + '.alert-primary' => array('b','o'), |
|
| 1152 | + '.progress-bar' => array('b'), |
|
| 1153 | + '.list-group-item.active' => array('b','o'), |
|
| 1154 | + '.bg-primary' => array('b','f'), |
|
| 1155 | + '.btn-link.btn-primary' => array('c'), |
|
| 1156 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 1157 | + ); |
|
| 1158 | + |
|
| 1159 | + $important_selectors = array( |
|
| 1160 | + '.bg-primary' => array('b','f'), |
|
| 1161 | + '.border-primary' => array('o'), |
|
| 1162 | + '.text-primary' => array('c'), |
|
| 1163 | + ); |
|
| 1164 | + |
|
| 1165 | + $color = array(); |
|
| 1166 | + $color_i = array(); |
|
| 1167 | + $background = array(); |
|
| 1168 | + $background_i = array(); |
|
| 1169 | + $border = array(); |
|
| 1170 | + $border_i = array(); |
|
| 1171 | + $fill = array(); |
|
| 1172 | + $fill_i = array(); |
|
| 1173 | + |
|
| 1174 | + $output = ''; |
|
| 1175 | + |
|
| 1176 | + // build rules into each type |
|
| 1177 | + foreach($selectors as $selector => $types){ |
|
| 1178 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1179 | + $types = array_combine($types,$types); |
|
| 1180 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1181 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1182 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1183 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1184 | + } |
|
| 1185 | + |
|
| 1186 | + // build rules into each type |
|
| 1187 | + foreach($important_selectors as $selector => $types){ |
|
| 1188 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1189 | + $types = array_combine($types,$types); |
|
| 1190 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1191 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1192 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1193 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + // add any color rules |
|
| 1197 | + if(!empty($color)){ |
|
| 1198 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1199 | + } |
|
| 1200 | + if(!empty($color_i)){ |
|
| 1201 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1202 | + } |
|
| 1203 | + |
|
| 1204 | + // add any background color rules |
|
| 1205 | + if(!empty($background)){ |
|
| 1206 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1207 | + } |
|
| 1208 | + if(!empty($background_i)){ |
|
| 1209 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1210 | + } |
|
| 1211 | + |
|
| 1212 | + // add any border color rules |
|
| 1213 | + if(!empty($border)){ |
|
| 1214 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1215 | + } |
|
| 1216 | + if(!empty($border_i)){ |
|
| 1217 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1218 | + } |
|
| 1219 | + |
|
| 1220 | + // add any fill color rules |
|
| 1221 | + if(!empty($fill)){ |
|
| 1222 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1223 | + } |
|
| 1224 | + if(!empty($fill_i)){ |
|
| 1225 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1226 | + } |
|
| 1227 | + |
|
| 1228 | + |
|
| 1229 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 1230 | + |
|
| 1231 | + // darken |
|
| 1232 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1233 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1234 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1235 | + |
|
| 1236 | + // lighten |
|
| 1237 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1238 | + |
|
| 1239 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1240 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1241 | + |
|
| 1242 | + |
|
| 1243 | + // button states |
|
| 1244 | + $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1245 | + $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;} "; |
|
| 1246 | + $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.";} "; |
|
| 1247 | + $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;} "; |
|
| 1248 | + |
|
| 1249 | + |
|
| 1250 | + // dropdown's |
|
| 1251 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1252 | + |
|
| 1253 | + |
|
| 1254 | + // input states |
|
| 1255 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1256 | + |
|
| 1257 | + // page link |
|
| 1258 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1259 | + |
|
| 1260 | + return $output; |
|
| 1261 | + } |
|
| 1262 | + |
|
| 1263 | + public static function css_secondary($color_code,$compatibility){; |
|
| 1264 | + $color_code = sanitize_hex_color($color_code); |
|
| 1265 | + if(!$color_code){return '';} |
|
| 1266 | + /** |
|
| 1267 | + * c = color, b = background color, o = border-color, f = fill |
|
| 1268 | + */ |
|
| 1269 | + $selectors = array( |
|
| 1270 | + '.btn-secondary' => array('b','o'), |
|
| 1271 | + '.btn-secondary.disabled' => array('b','o'), |
|
| 1272 | + '.btn-secondary:disabled' => array('b','o'), |
|
| 1273 | + '.btn-outline-secondary' => array('c','o'), |
|
| 1274 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1275 | + '.btn-outline-secondary.disabled' => array('c'), |
|
| 1276 | + '.btn-outline-secondary:disabled' => array('c'), |
|
| 1277 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1278 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1279 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1280 | + '.badge-secondary' => array('b'), |
|
| 1281 | + '.alert-secondary' => array('b','o'), |
|
| 1282 | + '.btn-link.btn-secondary' => array('c'), |
|
| 1283 | + ); |
|
| 1284 | + |
|
| 1285 | + $important_selectors = array( |
|
| 1286 | + '.bg-secondary' => array('b','f'), |
|
| 1287 | + '.border-secondary' => array('o'), |
|
| 1288 | + '.text-secondary' => array('c'), |
|
| 1289 | + ); |
|
| 1290 | + |
|
| 1291 | + $color = array(); |
|
| 1292 | + $color_i = array(); |
|
| 1293 | + $background = array(); |
|
| 1294 | + $background_i = array(); |
|
| 1295 | + $border = array(); |
|
| 1296 | + $border_i = array(); |
|
| 1297 | + $fill = array(); |
|
| 1298 | + $fill_i = array(); |
|
| 1299 | + |
|
| 1300 | + $output = ''; |
|
| 1301 | + |
|
| 1302 | + // build rules into each type |
|
| 1303 | + foreach($selectors as $selector => $types){ |
|
| 1304 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1305 | + $types = array_combine($types,$types); |
|
| 1306 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 1307 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 1308 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 1309 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 1310 | + } |
|
| 1311 | + |
|
| 1312 | + // build rules into each type |
|
| 1313 | + foreach($important_selectors as $selector => $types){ |
|
| 1314 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1315 | + $types = array_combine($types,$types); |
|
| 1316 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1317 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1318 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1319 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1320 | + } |
|
| 1321 | + |
|
| 1322 | + // add any color rules |
|
| 1323 | + if(!empty($color)){ |
|
| 1324 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1325 | + } |
|
| 1326 | + if(!empty($color_i)){ |
|
| 1327 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1328 | + } |
|
| 1329 | + |
|
| 1330 | + // add any background color rules |
|
| 1331 | + if(!empty($background)){ |
|
| 1332 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1333 | + } |
|
| 1334 | + if(!empty($background_i)){ |
|
| 1335 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1336 | + } |
|
| 1337 | + |
|
| 1338 | + // add any border color rules |
|
| 1339 | + if(!empty($border)){ |
|
| 1340 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1341 | + } |
|
| 1342 | + if(!empty($border_i)){ |
|
| 1343 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1344 | + } |
|
| 1345 | + |
|
| 1346 | + // add any fill color rules |
|
| 1347 | + if(!empty($fill)){ |
|
| 1348 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1349 | + } |
|
| 1350 | + if(!empty($fill_i)){ |
|
| 1351 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1352 | + } |
|
| 1353 | + |
|
| 1354 | + |
|
| 1355 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 1356 | + |
|
| 1357 | + // darken |
|
| 1358 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1359 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1360 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1361 | + |
|
| 1362 | + // lighten |
|
| 1363 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1364 | + |
|
| 1365 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 1366 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 1367 | + |
|
| 1368 | + |
|
| 1369 | + // button states |
|
| 1370 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1371 | + $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;} "; |
|
| 1372 | + $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.";} "; |
|
| 1373 | + $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;} "; |
|
| 1374 | + |
|
| 1375 | + |
|
| 1376 | + return $output; |
|
| 1377 | + } |
|
| 1378 | + |
|
| 1379 | + /** |
|
| 1380 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 1381 | + * |
|
| 1382 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 1383 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 1384 | + * |
|
| 1385 | + * @return string |
|
| 1386 | + */ |
|
| 1387 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 1388 | + $hexCode = ltrim($hexCode, '#'); |
|
| 1389 | + |
|
| 1390 | + if (strlen($hexCode) == 3) { |
|
| 1391 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 1392 | + } |
|
| 1393 | + |
|
| 1394 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 1395 | + |
|
| 1396 | + foreach ($hexCode as & $color) { |
|
| 1397 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 1398 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 1399 | + |
|
| 1400 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 1401 | + } |
|
| 1402 | + |
|
| 1403 | + return '#' . implode($hexCode); |
|
| 1404 | + } |
|
| 1405 | + |
|
| 1406 | + /** |
|
| 1407 | + * Check if we should display examples. |
|
| 1408 | + */ |
|
| 1409 | + public function maybe_show_examples(){ |
|
| 1410 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 1411 | + echo "<head>"; |
|
| 1412 | + wp_head(); |
|
| 1413 | + echo "</head>"; |
|
| 1414 | + echo "<body>"; |
|
| 1415 | + echo $this->get_examples(); |
|
| 1416 | + echo "</body>"; |
|
| 1417 | + exit; |
|
| 1418 | + } |
|
| 1419 | + } |
|
| 1420 | + |
|
| 1421 | + /** |
|
| 1422 | + * Get developer examples. |
|
| 1423 | + * |
|
| 1424 | + * @return string |
|
| 1425 | + */ |
|
| 1426 | + public function get_examples(){ |
|
| 1427 | + $output = ''; |
|
| 1428 | + |
|
| 1429 | + |
|
| 1430 | + // open form |
|
| 1431 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 1432 | + |
|
| 1433 | + // input example |
|
| 1434 | + $output .= aui()->input(array( |
|
| 1435 | + 'type' => 'text', |
|
| 1436 | + 'id' => 'text-example', |
|
| 1437 | + 'name' => 'text-example', |
|
| 1438 | + 'placeholder' => 'text placeholder', |
|
| 1439 | + 'title' => 'Text input example', |
|
| 1440 | + 'value' => '', |
|
| 1441 | + 'required' => false, |
|
| 1442 | + 'help_text' => 'help text', |
|
| 1443 | + 'label' => 'Text input example label' |
|
| 1444 | + )); |
|
| 1445 | + |
|
| 1446 | + // input example |
|
| 1447 | + $output .= aui()->input(array( |
|
| 1448 | + 'type' => 'url', |
|
| 1449 | + 'id' => 'text-example2', |
|
| 1450 | + 'name' => 'text-example', |
|
| 1451 | + 'placeholder' => 'url placeholder', |
|
| 1452 | + 'title' => 'Text input example', |
|
| 1453 | + 'value' => '', |
|
| 1454 | + 'required' => false, |
|
| 1455 | + 'help_text' => 'help text', |
|
| 1456 | + 'label' => 'Text input example label' |
|
| 1457 | + )); |
|
| 1458 | + |
|
| 1459 | + // checkbox example |
|
| 1460 | + $output .= aui()->input(array( |
|
| 1461 | + 'type' => 'checkbox', |
|
| 1462 | + 'id' => 'checkbox-example', |
|
| 1463 | + 'name' => 'checkbox-example', |
|
| 1464 | + 'placeholder' => 'checkbox-example', |
|
| 1465 | + 'title' => 'Checkbox example', |
|
| 1466 | + 'value' => '1', |
|
| 1467 | + 'checked' => true, |
|
| 1468 | + 'required' => false, |
|
| 1469 | + 'help_text' => 'help text', |
|
| 1470 | + 'label' => 'Checkbox checked' |
|
| 1471 | + )); |
|
| 1472 | + |
|
| 1473 | + // checkbox example |
|
| 1474 | + $output .= aui()->input(array( |
|
| 1475 | + 'type' => 'checkbox', |
|
| 1476 | + 'id' => 'checkbox-example2', |
|
| 1477 | + 'name' => 'checkbox-example2', |
|
| 1478 | + 'placeholder' => 'checkbox-example', |
|
| 1479 | + 'title' => 'Checkbox example', |
|
| 1480 | + 'value' => '1', |
|
| 1481 | + 'checked' => false, |
|
| 1482 | + 'required' => false, |
|
| 1483 | + 'help_text' => 'help text', |
|
| 1484 | + 'label' => 'Checkbox un-checked' |
|
| 1485 | + )); |
|
| 1486 | + |
|
| 1487 | + // switch example |
|
| 1488 | + $output .= aui()->input(array( |
|
| 1489 | + 'type' => 'checkbox', |
|
| 1490 | + 'id' => 'switch-example', |
|
| 1491 | + 'name' => 'switch-example', |
|
| 1492 | + 'placeholder' => 'checkbox-example', |
|
| 1493 | + 'title' => 'Switch example', |
|
| 1494 | + 'value' => '1', |
|
| 1495 | + 'checked' => true, |
|
| 1496 | + 'switch' => true, |
|
| 1497 | + 'required' => false, |
|
| 1498 | + 'help_text' => 'help text', |
|
| 1499 | + 'label' => 'Switch on' |
|
| 1500 | + )); |
|
| 1501 | + |
|
| 1502 | + // switch example |
|
| 1503 | + $output .= aui()->input(array( |
|
| 1504 | + 'type' => 'checkbox', |
|
| 1505 | + 'id' => 'switch-example2', |
|
| 1506 | + 'name' => 'switch-example2', |
|
| 1507 | + 'placeholder' => 'checkbox-example', |
|
| 1508 | + 'title' => 'Switch example', |
|
| 1509 | + 'value' => '1', |
|
| 1510 | + 'checked' => false, |
|
| 1511 | + 'switch' => true, |
|
| 1512 | + 'required' => false, |
|
| 1513 | + 'help_text' => 'help text', |
|
| 1514 | + 'label' => 'Switch off' |
|
| 1515 | + )); |
|
| 1516 | + |
|
| 1517 | + // close form |
|
| 1518 | + $output .= "</form>"; |
|
| 1519 | + |
|
| 1520 | + return $output; |
|
| 1521 | + } |
|
| 1522 | + |
|
| 1523 | + } |
|
| 1524 | + |
|
| 1525 | + /** |
|
| 1526 | + * Run the class if found. |
|
| 1527 | + */ |
|
| 1528 | + AyeCode_UI_Settings::instance(); |
|
| 1529 | 1529 | } |
| 1530 | 1530 | \ 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,24 +143,24 @@ 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'] ) { |
|
| 155 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 154 | + if ($this->settings['js']) { |
|
| 155 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
| 156 | 156 | } |
| 157 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 158 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 157 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
| 158 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Maybe set the HTML font size |
| 162 | - if ( $this->settings['html_font_size'] ) { |
|
| 163 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 162 | + if ($this->settings['html_font_size']) { |
|
| 163 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @return bool |
| 173 | 173 | */ |
| 174 | - public function load_admin_scripts(){ |
|
| 174 | + public function load_admin_scripts() { |
|
| 175 | 175 | $result = true; |
| 176 | 176 | |
| 177 | - if(!empty($this->settings['disable_admin'])){ |
|
| 178 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 179 | - foreach($url_parts as $part){ |
|
| 180 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 177 | + if (!empty($this->settings['disable_admin'])) { |
|
| 178 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
| 179 | + foreach ($url_parts as $part) { |
|
| 180 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
| 181 | 181 | return false; // return early, no point checking further |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -189,9 +189,9 @@ discard block |
||
| 189 | 189 | /** |
| 190 | 190 | * Add a html font size to the footer. |
| 191 | 191 | */ |
| 192 | - public function html_font_size(){ |
|
| 192 | + public function html_font_size() { |
|
| 193 | 193 | $this->settings = $this->get_settings(); |
| 194 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 194 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -201,18 +201,18 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
| 203 | 203 | |
| 204 | - if($this->settings[$css_setting]){ |
|
| 205 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 206 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui.css' : $this->url.'assets/css/ayecode-ui-compatibility.css'; |
|
| 207 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
| 208 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 204 | + if ($this->settings[$css_setting]) { |
|
| 205 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
| 206 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui.css' : $this->url . 'assets/css/ayecode-ui-compatibility.css'; |
|
| 207 | + wp_register_style('ayecode-ui', $url, array(), $this->latest); |
|
| 208 | + wp_enqueue_style('ayecode-ui'); |
|
| 209 | 209 | |
| 210 | 210 | // flatpickr |
| 211 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
| 211 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest); |
|
| 212 | 212 | |
| 213 | 213 | |
| 214 | 214 | // fix some wp-admin issues |
| 215 | - if(is_admin()){ |
|
| 215 | + if (is_admin()) { |
|
| 216 | 216 | $custom_css = " |
| 217 | 217 | body{ |
| 218 | 218 | background-color: #f1f1f1; |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | padding: 0; |
| 256 | 256 | } |
| 257 | 257 | "; |
| 258 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 258 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // custom changes |
| 262 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 262 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
| 263 | 263 | |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * If this remains small then its best to use this than to add another JS file. |
| 271 | 271 | */ |
| 272 | - public function inline_script(){ |
|
| 272 | + public function inline_script() { |
|
| 273 | 273 | ob_start(); |
| 274 | 274 | ?> |
| 275 | 275 | <script> |
@@ -763,10 +763,10 @@ discard block |
||
| 763 | 763 | /* |
| 764 | 764 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 765 | 765 | */ |
| 766 | - return str_replace( array( |
|
| 766 | + return str_replace(array( |
|
| 767 | 767 | '<script>', |
| 768 | 768 | '</script>' |
| 769 | - ), '', $output ); |
|
| 769 | + ), '', $output); |
|
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | /** |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | * |
| 775 | 775 | * If this remains small then its best to use this than to add another JS file. |
| 776 | 776 | */ |
| 777 | - public function inline_script_file_browser(){ |
|
| 777 | + public function inline_script_file_browser() { |
|
| 778 | 778 | ob_start(); |
| 779 | 779 | ?> |
| 780 | 780 | <script> |
@@ -789,10 +789,10 @@ discard block |
||
| 789 | 789 | /* |
| 790 | 790 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 791 | 791 | */ |
| 792 | - return str_replace( array( |
|
| 792 | + return str_replace(array( |
|
| 793 | 793 | '<script>', |
| 794 | 794 | '</script>' |
| 795 | - ), '', $output ); |
|
| 795 | + ), '', $output); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | /** |
@@ -803,40 +803,40 @@ discard block |
||
| 803 | 803 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
| 804 | 804 | |
| 805 | 805 | // select2 |
| 806 | - wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version ); |
|
| 806 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
| 807 | 807 | |
| 808 | 808 | // flatpickr |
| 809 | - wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
| 809 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest); |
|
| 810 | 810 | |
| 811 | 811 | // Bootstrap file browser |
| 812 | - wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version ); |
|
| 813 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 812 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
| 813 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
| 814 | 814 | |
| 815 | 815 | $load_inline = false; |
| 816 | 816 | |
| 817 | - if($this->settings[$js_setting]=='core-popper'){ |
|
| 817 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
| 818 | 818 | // Bootstrap bundle |
| 819 | - $url = $this->url.'assets/js/bootstrap.bundle.min.js'; |
|
| 820 | - wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest ); |
|
| 819 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 820 | + wp_register_script('bootstrap-js-bundle', $url, array('select2', 'jquery'), $this->latest); |
|
| 821 | 821 | // if in admin then add to footer for compatibility. |
| 822 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle'); |
|
| 822 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
| 823 | 823 | $script = $this->inline_script(); |
| 824 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 825 | - }elseif($this->settings[$js_setting]=='popper'){ |
|
| 826 | - $url = $this->url.'assets/js/popper.min.js'; |
|
| 827 | - wp_register_script( 'bootstrap-js-popper', $url, array('select2','jquery'), $this->latest ); |
|
| 828 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 824 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
| 825 | + }elseif ($this->settings[$js_setting] == 'popper') { |
|
| 826 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
| 827 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->latest); |
|
| 828 | + wp_enqueue_script('bootstrap-js-popper'); |
|
| 829 | 829 | $load_inline = true; |
| 830 | - }else{ |
|
| 830 | + } else { |
|
| 831 | 831 | $load_inline = true; |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
| 835 | - if($load_inline){ |
|
| 836 | - wp_register_script( 'bootstrap-dummy', '',array('select2','jquery') ); |
|
| 837 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 835 | + if ($load_inline) { |
|
| 836 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
| 837 | + wp_enqueue_script('bootstrap-dummy'); |
|
| 838 | 838 | $script = $this->inline_script(); |
| 839 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 839 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | } |
@@ -844,9 +844,9 @@ discard block |
||
| 844 | 844 | /** |
| 845 | 845 | * Enqueue flatpickr if called. |
| 846 | 846 | */ |
| 847 | - public function enqueue_flatpickr(){ |
|
| 848 | - wp_enqueue_style( 'flatpickr' ); |
|
| 849 | - wp_enqueue_script( 'flatpickr' ); |
|
| 847 | + public function enqueue_flatpickr() { |
|
| 848 | + wp_enqueue_style('flatpickr'); |
|
| 849 | + wp_enqueue_script('flatpickr'); |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
@@ -858,15 +858,15 @@ discard block |
||
| 858 | 858 | |
| 859 | 859 | $url = ''; |
| 860 | 860 | // check if we are inside a plugin |
| 861 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 861 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
| 862 | 862 | |
| 863 | 863 | // add check in-case user has changed wp-content dir name. |
| 864 | 864 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
| 865 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 866 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 865 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
| 866 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
| 867 | 867 | |
| 868 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 869 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 868 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
| 869 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | return $url; |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | * Register the database settings with WordPress. |
| 877 | 877 | */ |
| 878 | 878 | public function register_settings() { |
| 879 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 879 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | /** |
@@ -885,10 +885,10 @@ discard block |
||
| 885 | 885 | */ |
| 886 | 886 | public function menu_item() { |
| 887 | 887 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
| 888 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 888 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 889 | 889 | $this, |
| 890 | 890 | 'settings_page' |
| 891 | - ) ); |
|
| 891 | + )); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | /** |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | * |
| 897 | 897 | * @return array |
| 898 | 898 | */ |
| 899 | - public function theme_js_settings(){ |
|
| 899 | + public function theme_js_settings() { |
|
| 900 | 900 | return array( |
| 901 | 901 | 'ayetheme' => 'popper', |
| 902 | 902 | 'listimia' => 'required', |
@@ -912,17 +912,17 @@ discard block |
||
| 912 | 912 | */ |
| 913 | 913 | public function get_settings() { |
| 914 | 914 | |
| 915 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 915 | + $db_settings = get_option('ayecode-ui-settings'); |
|
| 916 | 916 | $js_default = 'core-popper'; |
| 917 | 917 | $js_default_backend = $js_default; |
| 918 | 918 | |
| 919 | 919 | // maybe set defaults (if no settings set) |
| 920 | - if(empty($db_settings)){ |
|
| 921 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 920 | + if (empty($db_settings)) { |
|
| 921 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
| 922 | 922 | $theme_js_settings = self::theme_js_settings(); |
| 923 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 923 | + if (isset($theme_js_settings[$active_theme])) { |
|
| 924 | 924 | $js_default = $theme_js_settings[$active_theme]; |
| 925 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 925 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
| 926 | 926 | } |
| 927 | 927 | } |
| 928 | 928 | |
@@ -935,14 +935,14 @@ discard block |
||
| 935 | 935 | 'disable_admin' => '', // URL snippets to disable loading on admin |
| 936 | 936 | ); |
| 937 | 937 | |
| 938 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 938 | + $settings = wp_parse_args($db_settings, $defaults); |
|
| 939 | 939 | |
| 940 | 940 | /** |
| 941 | 941 | * Filter the Bootstrap settings. |
| 942 | 942 | * |
| 943 | 943 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
| 944 | 944 | */ |
| 945 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 945 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | |
@@ -950,90 +950,90 @@ discard block |
||
| 950 | 950 | * The settings page html output. |
| 951 | 951 | */ |
| 952 | 952 | public function settings_page() { |
| 953 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 954 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 953 | + if (!current_user_can('manage_options')) { |
|
| 954 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
| 955 | 955 | } |
| 956 | 956 | ?> |
| 957 | 957 | <div class="wrap"> |
| 958 | 958 | <h1><?php echo $this->name; ?></h1> |
| 959 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.","aui");?></p> |
|
| 959 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", "aui"); ?></p> |
|
| 960 | 960 | <form method="post" action="options.php"> |
| 961 | 961 | <?php |
| 962 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 963 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 962 | + settings_fields('ayecode-ui-settings'); |
|
| 963 | + do_settings_sections('ayecode-ui-settings'); |
|
| 964 | 964 | ?> |
| 965 | 965 | |
| 966 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
| 966 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
| 967 | 967 | <table class="form-table wpbs-table-settings"> |
| 968 | 968 | <tr valign="top"> |
| 969 | 969 | <th scope="row"><label |
| 970 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 970 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 971 | 971 | <td> |
| 972 | 972 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
| 973 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode', 'aui' ); ?></option> |
|
| 974 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
| 975 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 973 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode', 'aui'); ?></option> |
|
| 974 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
| 975 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 976 | 976 | </select> |
| 977 | 977 | </td> |
| 978 | 978 | </tr> |
| 979 | 979 | |
| 980 | 980 | <tr valign="top"> |
| 981 | 981 | <th scope="row"><label |
| 982 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 982 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 983 | 983 | <td> |
| 984 | 984 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
| 985 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 986 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 987 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 988 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 985 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 986 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 987 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 988 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 989 | 989 | </select> |
| 990 | 990 | </td> |
| 991 | 991 | </tr> |
| 992 | 992 | |
| 993 | 993 | <tr valign="top"> |
| 994 | 994 | <th scope="row"><label |
| 995 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
| 995 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
| 996 | 996 | <td> |
| 997 | - <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" /> |
|
| 998 | - <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> |
|
| 997 | + <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" /> |
|
| 998 | + <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> |
|
| 999 | 999 | </td> |
| 1000 | 1000 | </tr> |
| 1001 | 1001 | |
| 1002 | 1002 | </table> |
| 1003 | 1003 | |
| 1004 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
| 1004 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
| 1005 | 1005 | <table class="form-table wpbs-table-settings"> |
| 1006 | 1006 | <tr valign="top"> |
| 1007 | 1007 | <th scope="row"><label |
| 1008 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 1008 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 1009 | 1009 | <td> |
| 1010 | 1010 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
| 1011 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode', 'aui' ); ?></option> |
|
| 1012 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
| 1013 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 1011 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode', 'aui'); ?></option> |
|
| 1012 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
| 1013 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 1014 | 1014 | </select> |
| 1015 | 1015 | </td> |
| 1016 | 1016 | </tr> |
| 1017 | 1017 | |
| 1018 | 1018 | <tr valign="top"> |
| 1019 | 1019 | <th scope="row"><label |
| 1020 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 1020 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 1021 | 1021 | <td> |
| 1022 | 1022 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
| 1023 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 1024 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 1025 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 1026 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 1023 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 1024 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 1025 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 1026 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 1027 | 1027 | </select> |
| 1028 | 1028 | </td> |
| 1029 | 1029 | </tr> |
| 1030 | 1030 | |
| 1031 | 1031 | <tr valign="top"> |
| 1032 | 1032 | <th scope="row"><label |
| 1033 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
| 1033 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
| 1034 | 1034 | <td> |
| 1035 | - <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> |
|
| 1036 | - <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> |
|
| 1035 | + <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> |
|
| 1036 | + <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> |
|
| 1037 | 1037 | |
| 1038 | 1038 | </td> |
| 1039 | 1039 | </tr> |
@@ -1051,9 +1051,9 @@ discard block |
||
| 1051 | 1051 | <?php |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - public function customizer_settings($wp_customize){ |
|
| 1054 | + public function customizer_settings($wp_customize) { |
|
| 1055 | 1055 | $wp_customize->add_section('aui_settings', array( |
| 1056 | - 'title' => __('AyeCode UI','aui'), |
|
| 1056 | + 'title' => __('AyeCode UI', 'aui'), |
|
| 1057 | 1057 | 'priority' => 120, |
| 1058 | 1058 | )); |
| 1059 | 1059 | |
@@ -1067,8 +1067,8 @@ discard block |
||
| 1067 | 1067 | 'type' => 'option', |
| 1068 | 1068 | 'transport' => 'refresh', |
| 1069 | 1069 | )); |
| 1070 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1071 | - 'label' => __('Primary Color','aui'), |
|
| 1070 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1071 | + 'label' => __('Primary Color', 'aui'), |
|
| 1072 | 1072 | 'section' => 'aui_settings', |
| 1073 | 1073 | 'settings' => 'aui_options[color_primary]', |
| 1074 | 1074 | ))); |
@@ -1080,8 +1080,8 @@ discard block |
||
| 1080 | 1080 | 'type' => 'option', |
| 1081 | 1081 | 'transport' => 'refresh', |
| 1082 | 1082 | )); |
| 1083 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1084 | - 'label' => __('Secondary Color','aui'), |
|
| 1083 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1084 | + 'label' => __('Secondary Color', 'aui'), |
|
| 1085 | 1085 | 'section' => 'aui_settings', |
| 1086 | 1086 | 'settings' => 'aui_options[color_secondary]', |
| 1087 | 1087 | ))); |
@@ -1099,12 +1099,12 @@ discard block |
||
| 1099 | 1099 | ?> |
| 1100 | 1100 | <style> |
| 1101 | 1101 | <?php |
| 1102 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
| 1103 | - echo self::css_primary($primary_color,$compatibility); |
|
| 1102 | + if (!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL) { |
|
| 1103 | + echo self::css_primary($primary_color, $compatibility); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
| 1107 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
| 1106 | + if (!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL) { |
|
| 1107 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | ?> |
| 1110 | 1110 | </style> |
@@ -1114,50 +1114,50 @@ discard block |
||
| 1114 | 1114 | /* |
| 1115 | 1115 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1116 | 1116 | */ |
| 1117 | - return str_replace( array( |
|
| 1117 | + return str_replace(array( |
|
| 1118 | 1118 | '<style>', |
| 1119 | 1119 | '</style>' |
| 1120 | 1120 | ), '', ob_get_clean()); |
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | - public static function css_primary($color_code,$compatibility){; |
|
| 1123 | + public static function css_primary($color_code, $compatibility) {; |
|
| 1124 | 1124 | $color_code = sanitize_hex_color($color_code); |
| 1125 | - if(!$color_code){return '';} |
|
| 1125 | + if (!$color_code) {return ''; } |
|
| 1126 | 1126 | /** |
| 1127 | 1127 | * c = color, b = background color, o = border-color, f = fill |
| 1128 | 1128 | */ |
| 1129 | 1129 | $selectors = array( |
| 1130 | 1130 | 'a' => array('c'), |
| 1131 | - '.btn-primary' => array('b','o'), |
|
| 1132 | - '.btn-primary.disabled' => array('b','o'), |
|
| 1133 | - '.btn-primary:disabled' => array('b','o'), |
|
| 1134 | - '.btn-outline-primary' => array('c','o'), |
|
| 1135 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 1136 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1137 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1138 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 1131 | + '.btn-primary' => array('b', 'o'), |
|
| 1132 | + '.btn-primary.disabled' => array('b', 'o'), |
|
| 1133 | + '.btn-primary:disabled' => array('b', 'o'), |
|
| 1134 | + '.btn-outline-primary' => array('c', 'o'), |
|
| 1135 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
| 1136 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 1137 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 1138 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
| 1139 | 1139 | '.btn-link' => array('c'), |
| 1140 | 1140 | '.dropdown-item.active' => array('b'), |
| 1141 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 1142 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 1141 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
| 1142 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
| 1143 | 1143 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 1144 | 1144 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 1145 | 1145 | // '.custom-range::-ms-thumb' => array('b'), |
| 1146 | 1146 | '.nav-pills .nav-link.active' => array('b'), |
| 1147 | 1147 | '.nav-pills .show>.nav-link' => array('b'), |
| 1148 | 1148 | '.page-link' => array('c'), |
| 1149 | - '.page-item.active .page-link' => array('b','o'), |
|
| 1149 | + '.page-item.active .page-link' => array('b', 'o'), |
|
| 1150 | 1150 | '.badge-primary' => array('b'), |
| 1151 | - '.alert-primary' => array('b','o'), |
|
| 1151 | + '.alert-primary' => array('b', 'o'), |
|
| 1152 | 1152 | '.progress-bar' => array('b'), |
| 1153 | - '.list-group-item.active' => array('b','o'), |
|
| 1154 | - '.bg-primary' => array('b','f'), |
|
| 1153 | + '.list-group-item.active' => array('b', 'o'), |
|
| 1154 | + '.bg-primary' => array('b', 'f'), |
|
| 1155 | 1155 | '.btn-link.btn-primary' => array('c'), |
| 1156 | 1156 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
| 1157 | 1157 | ); |
| 1158 | 1158 | |
| 1159 | 1159 | $important_selectors = array( |
| 1160 | - '.bg-primary' => array('b','f'), |
|
| 1160 | + '.bg-primary' => array('b', 'f'), |
|
| 1161 | 1161 | '.border-primary' => array('o'), |
| 1162 | 1162 | '.text-primary' => array('c'), |
| 1163 | 1163 | ); |
@@ -1174,116 +1174,116 @@ discard block |
||
| 1174 | 1174 | $output = ''; |
| 1175 | 1175 | |
| 1176 | 1176 | // build rules into each type |
| 1177 | - foreach($selectors as $selector => $types){ |
|
| 1178 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1179 | - $types = array_combine($types,$types); |
|
| 1180 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1181 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1182 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1183 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1177 | + foreach ($selectors as $selector => $types) { |
|
| 1178 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1179 | + $types = array_combine($types, $types); |
|
| 1180 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 1181 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 1182 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 1183 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | 1186 | // build rules into each type |
| 1187 | - foreach($important_selectors as $selector => $types){ |
|
| 1188 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1189 | - $types = array_combine($types,$types); |
|
| 1190 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1191 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1192 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1193 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1187 | + foreach ($important_selectors as $selector => $types) { |
|
| 1188 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1189 | + $types = array_combine($types, $types); |
|
| 1190 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 1191 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 1192 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 1193 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | // add any color rules |
| 1197 | - if(!empty($color)){ |
|
| 1198 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1197 | + if (!empty($color)) { |
|
| 1198 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 1199 | 1199 | } |
| 1200 | - if(!empty($color_i)){ |
|
| 1201 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1200 | + if (!empty($color_i)) { |
|
| 1201 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | // add any background color rules |
| 1205 | - if(!empty($background)){ |
|
| 1206 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1205 | + if (!empty($background)) { |
|
| 1206 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 1207 | 1207 | } |
| 1208 | - if(!empty($background_i)){ |
|
| 1209 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1208 | + if (!empty($background_i)) { |
|
| 1209 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | // add any border color rules |
| 1213 | - if(!empty($border)){ |
|
| 1214 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1213 | + if (!empty($border)) { |
|
| 1214 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 1215 | 1215 | } |
| 1216 | - if(!empty($border_i)){ |
|
| 1217 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1216 | + if (!empty($border_i)) { |
|
| 1217 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | 1220 | // add any fill color rules |
| 1221 | - if(!empty($fill)){ |
|
| 1222 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1221 | + if (!empty($fill)) { |
|
| 1222 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 1223 | 1223 | } |
| 1224 | - if(!empty($fill_i)){ |
|
| 1225 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1224 | + if (!empty($fill_i)) { |
|
| 1225 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | |
| 1229 | 1229 | $prefix = $compatibility ? ".bsui " : ""; |
| 1230 | 1230 | |
| 1231 | 1231 | // darken |
| 1232 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1233 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1234 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1232 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 1233 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 1234 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 1235 | 1235 | |
| 1236 | 1236 | // lighten |
| 1237 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1237 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 1238 | 1238 | |
| 1239 | 1239 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 1240 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1240 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 1241 | 1241 | |
| 1242 | 1242 | |
| 1243 | 1243 | // button states |
| 1244 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1245 | - $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;} "; |
|
| 1246 | - $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.";} "; |
|
| 1247 | - $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;} "; |
|
| 1244 | + $output .= $prefix . " .btn-primary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 1245 | + $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;} "; |
|
| 1246 | + $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 . ";} "; |
|
| 1247 | + $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;} "; |
|
| 1248 | 1248 | |
| 1249 | 1249 | |
| 1250 | 1250 | // dropdown's |
| 1251 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1251 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 1252 | 1252 | |
| 1253 | 1253 | |
| 1254 | 1254 | // input states |
| 1255 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1255 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1256 | 1256 | |
| 1257 | 1257 | // page link |
| 1258 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1258 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 1259 | 1259 | |
| 1260 | 1260 | return $output; |
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | - public static function css_secondary($color_code,$compatibility){; |
|
| 1263 | + public static function css_secondary($color_code, $compatibility) {; |
|
| 1264 | 1264 | $color_code = sanitize_hex_color($color_code); |
| 1265 | - if(!$color_code){return '';} |
|
| 1265 | + if (!$color_code) {return ''; } |
|
| 1266 | 1266 | /** |
| 1267 | 1267 | * c = color, b = background color, o = border-color, f = fill |
| 1268 | 1268 | */ |
| 1269 | 1269 | $selectors = array( |
| 1270 | - '.btn-secondary' => array('b','o'), |
|
| 1271 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 1272 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 1273 | - '.btn-outline-secondary' => array('c','o'), |
|
| 1274 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 1270 | + '.btn-secondary' => array('b', 'o'), |
|
| 1271 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
| 1272 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
| 1273 | + '.btn-outline-secondary' => array('c', 'o'), |
|
| 1274 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
| 1275 | 1275 | '.btn-outline-secondary.disabled' => array('c'), |
| 1276 | 1276 | '.btn-outline-secondary:disabled' => array('c'), |
| 1277 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 1278 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 1279 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 1277 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 1278 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 1279 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
| 1280 | 1280 | '.badge-secondary' => array('b'), |
| 1281 | - '.alert-secondary' => array('b','o'), |
|
| 1281 | + '.alert-secondary' => array('b', 'o'), |
|
| 1282 | 1282 | '.btn-link.btn-secondary' => array('c'), |
| 1283 | 1283 | ); |
| 1284 | 1284 | |
| 1285 | 1285 | $important_selectors = array( |
| 1286 | - '.bg-secondary' => array('b','f'), |
|
| 1286 | + '.bg-secondary' => array('b', 'f'), |
|
| 1287 | 1287 | '.border-secondary' => array('o'), |
| 1288 | 1288 | '.text-secondary' => array('c'), |
| 1289 | 1289 | ); |
@@ -1300,77 +1300,77 @@ discard block |
||
| 1300 | 1300 | $output = ''; |
| 1301 | 1301 | |
| 1302 | 1302 | // build rules into each type |
| 1303 | - foreach($selectors as $selector => $types){ |
|
| 1304 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1305 | - $types = array_combine($types,$types); |
|
| 1306 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 1307 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 1308 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 1309 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 1303 | + foreach ($selectors as $selector => $types) { |
|
| 1304 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1305 | + $types = array_combine($types, $types); |
|
| 1306 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 1307 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 1308 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 1309 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | 1312 | // build rules into each type |
| 1313 | - foreach($important_selectors as $selector => $types){ |
|
| 1314 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 1315 | - $types = array_combine($types,$types); |
|
| 1316 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 1317 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 1318 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 1319 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 1313 | + foreach ($important_selectors as $selector => $types) { |
|
| 1314 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 1315 | + $types = array_combine($types, $types); |
|
| 1316 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 1317 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 1318 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 1319 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | 1322 | // add any color rules |
| 1323 | - if(!empty($color)){ |
|
| 1324 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 1323 | + if (!empty($color)) { |
|
| 1324 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 1325 | 1325 | } |
| 1326 | - if(!empty($color_i)){ |
|
| 1327 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 1326 | + if (!empty($color_i)) { |
|
| 1327 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | // add any background color rules |
| 1331 | - if(!empty($background)){ |
|
| 1332 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 1331 | + if (!empty($background)) { |
|
| 1332 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 1333 | 1333 | } |
| 1334 | - if(!empty($background_i)){ |
|
| 1335 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 1334 | + if (!empty($background_i)) { |
|
| 1335 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | // add any border color rules |
| 1339 | - if(!empty($border)){ |
|
| 1340 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 1339 | + if (!empty($border)) { |
|
| 1340 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 1341 | 1341 | } |
| 1342 | - if(!empty($border_i)){ |
|
| 1343 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 1342 | + if (!empty($border_i)) { |
|
| 1343 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | // add any fill color rules |
| 1347 | - if(!empty($fill)){ |
|
| 1348 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 1347 | + if (!empty($fill)) { |
|
| 1348 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 1349 | 1349 | } |
| 1350 | - if(!empty($fill_i)){ |
|
| 1351 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 1350 | + if (!empty($fill_i)) { |
|
| 1351 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | |
| 1355 | 1355 | $prefix = $compatibility ? ".bsui " : ""; |
| 1356 | 1356 | |
| 1357 | 1357 | // darken |
| 1358 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 1359 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 1360 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 1358 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 1359 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 1360 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 1361 | 1361 | |
| 1362 | 1362 | // lighten |
| 1363 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 1363 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 1364 | 1364 | |
| 1365 | 1365 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 1366 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 1366 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 1367 | 1367 | |
| 1368 | 1368 | |
| 1369 | 1369 | // button states |
| 1370 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 1371 | - $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;} "; |
|
| 1372 | - $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.";} "; |
|
| 1373 | - $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;} "; |
|
| 1370 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 1371 | + $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;} "; |
|
| 1372 | + $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 . ";} "; |
|
| 1373 | + $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;} "; |
|
| 1374 | 1374 | |
| 1375 | 1375 | |
| 1376 | 1376 | return $output; |
@@ -1406,8 +1406,8 @@ discard block |
||
| 1406 | 1406 | /** |
| 1407 | 1407 | * Check if we should display examples. |
| 1408 | 1408 | */ |
| 1409 | - public function maybe_show_examples(){ |
|
| 1410 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 1409 | + public function maybe_show_examples() { |
|
| 1410 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
| 1411 | 1411 | echo "<head>"; |
| 1412 | 1412 | wp_head(); |
| 1413 | 1413 | echo "</head>"; |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | * |
| 1424 | 1424 | * @return string |
| 1425 | 1425 | */ |
| 1426 | - public function get_examples(){ |
|
| 1426 | + public function get_examples() { |
|
| 1427 | 1427 | $output = ''; |
| 1428 | 1428 | |
| 1429 | 1429 | |
@@ -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 | /** |
@@ -822,12 +826,12 @@ discard block |
||
| 822 | 826 | is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle'); |
| 823 | 827 | $script = $this->inline_script(); |
| 824 | 828 | wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
| 825 | - }elseif($this->settings[$js_setting]=='popper'){ |
|
| 829 | + } elseif($this->settings[$js_setting]=='popper'){ |
|
| 826 | 830 | $url = $this->url.'assets/js/popper.min.js'; |
| 827 | 831 | wp_register_script( 'bootstrap-js-popper', $url, array('select2','jquery'), $this->latest ); |
| 828 | 832 | wp_enqueue_script( 'bootstrap-js-popper' ); |
| 829 | 833 | $load_inline = true; |
| 830 | - }else{ |
|
| 834 | + } else{ |
|
| 831 | 835 | $load_inline = true; |
| 832 | 836 | } |
| 833 | 837 | |
@@ -2,12 +2,12 @@ discard block |
||
| 2 | 2 | global $wpi_invoice; |
| 3 | 3 | |
| 4 | 4 | // Backwards compatibility. |
| 5 | -if ( empty( $invoice ) ) { |
|
| 5 | +if (empty($invoice)) { |
|
| 6 | 6 | $invoice = $wpi_invoice; |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $success_page_uri = wpinv_get_success_page_uri(); |
| 10 | -if ( ! empty( $invoice ) ) { |
|
| 10 | +if (!empty($invoice)) { |
|
| 11 | 11 | $success_page_uri = $invoice->get_receipt_url(); |
| 12 | 12 | } |
| 13 | 13 | ?> |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | <?php |
| 18 | 18 | echo |
| 19 | 19 | wp_sprintf( |
| 20 | - __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ), |
|
| 21 | - esc_url( $success_page_uri ) |
|
| 20 | + __('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing'), |
|
| 21 | + esc_url($success_page_uri) |
|
| 22 | 22 | ); |
| 23 | 23 | ?> |
| 24 | 24 | <i class="fa fa-spin fa-refresh"></i> |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | <script type="text/javascript"> |
| 28 | 28 | setTimeout( |
| 29 | 29 | function(){ |
| 30 | - window.location = '<?php echo esc_url( $success_page_uri ); ?>'; |
|
| 30 | + window.location = '<?php echo esc_url($success_page_uri); ?>'; |
|
| 31 | 31 | }, |
| 32 | 32 | 10000 |
| 33 | 33 | ); |
@@ -7,14 +7,14 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | 14 | <div v-if='!is_default'> |
| 15 | - <div class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here. Click to set items.', 'invoicing' ) ?></div> |
|
| 15 | + <div class='alert alert-info' role='alert'><?php _e('Item totals will appear here. Click to set items.', 'invoicing') ?></div> |
|
| 16 | 16 | </div> |
| 17 | 17 | |
| 18 | 18 | <div v-if='is_default'> |
| 19 | - <div class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here.', 'invoicing' ) ?></div> |
|
| 19 | + <div class='alert alert-info' role='alert'><?php _e('Item totals will appear here.', 'invoicing') ?></div> |
|
| 20 | 20 | </div> |
@@ -7,29 +7,29 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Cart table columns. |
| 13 | 13 | $columns = array( |
| 14 | - 'name' => __( 'Item', 'invoicing' ), |
|
| 15 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 16 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 17 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 14 | + 'name' => __('Item', 'invoicing'), |
|
| 15 | + 'price' => __('Price', 'invoicing'), |
|
| 16 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 17 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | -if ( ! empty( $form->invoice ) ) { |
|
| 21 | - $columns = getpaid_invoice_item_columns( $form->invoice ); |
|
| 20 | +if (!empty($form->invoice)) { |
|
| 21 | + $columns = getpaid_invoice_item_columns($form->invoice); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form ); |
|
| 24 | +$columns = apply_filters('getpaid_payment_form_cart_table_columns', $columns, $form); |
|
| 25 | 25 | |
| 26 | 26 | ?> |
| 27 | 27 | <div class="getpaid-payment-form-items-cart border form-group"> |
| 28 | 28 | <div class="getpaid-payment-form-items-cart-header"> |
| 29 | 29 | <div class="form-row"> |
| 30 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
| 31 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>"> |
|
| 32 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 30 | + <?php foreach ($columns as $key => $label) : ?> |
|
| 31 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?>"> |
|
| 32 | + <?php echo sanitize_text_field($label); ?> |
|
| 33 | 33 | </div> |
| 34 | 34 | <?php endforeach; ?> |
| 35 | 35 | </div> |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | <?php |
| 38 | 38 | |
| 39 | 39 | // Display the item totals. |
| 40 | - foreach ( $form->get_items() as $item ) { |
|
| 41 | - wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
| 40 | + foreach ($form->get_items() as $item) { |
|
| 41 | + wpinv_get_template('payment-forms/cart-item.php', compact('form', 'item', 'columns')); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Display the cart totals. |
| 45 | - wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) ); |
|
| 45 | + wpinv_get_template('payment-forms/cart-totals.php', compact('form')); |
|
| 46 | 46 | |
| 47 | 47 | ?> |
| 48 | 48 | </div> |
@@ -7,17 +7,17 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Prepare the selectable items. |
| 13 | 13 | $selectable = array(); |
| 14 | -foreach ( $form->get_items() as $item ) { |
|
| 15 | - if ( ! $item->is_required ) { |
|
| 16 | - $selectable[$item->get_id()] = strip_tags( $item->get_name() . ' — ' . wpinv_price( wpinv_format_amount( $item->get_initial_price() ) ) ); |
|
| 14 | +foreach ($form->get_items() as $item) { |
|
| 15 | + if (!$item->is_required) { |
|
| 16 | + $selectable[$item->get_id()] = strip_tags($item->get_name() . ' — ' . wpinv_price(wpinv_format_amount($item->get_initial_price()))); |
|
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -if ( empty( $selectable ) ) { |
|
| 20 | +if (empty($selectable)) { |
|
| 21 | 21 | return; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | echo aui()->select( |
| 28 | 28 | array( |
| 29 | 29 | 'name' => 'getpaid-payment-form-selected-item', |
| 30 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ), |
|
| 30 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_'), |
|
| 31 | 31 | 'required' => true, |
| 32 | - 'label' => __( 'Select Item', 'invoicing' ), |
|
| 32 | + 'label' => __('Select Item', 'invoicing'), |
|
| 33 | 33 | 'label_type' => 'vertical', |
| 34 | 34 | 'inline' => false, |
| 35 | 35 | 'options' => $selectable, |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -10,60 +10,60 @@ discard block |
||
| 10 | 10 | class GetPaid_Form_Item extends WPInv_Item { |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * Stores a custom description for the item. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - protected $custom_description = null; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Stores the item quantity. |
|
| 21 | - * |
|
| 22 | - * @var int |
|
| 23 | - */ |
|
| 24 | - protected $quantity = 1; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Stores the item meta. |
|
| 28 | - * |
|
| 29 | - * @var array |
|
| 30 | - */ |
|
| 31 | - protected $meta = array(); |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Is this item required? |
|
| 35 | - * |
|
| 36 | - * @var int |
|
| 37 | - */ |
|
| 38 | - protected $is_required = true; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Are quantities allowed? |
|
| 42 | - * |
|
| 43 | - * @var int |
|
| 44 | - */ |
|
| 45 | - protected $allow_quantities = false; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Associated invoice. |
|
| 49 | - * |
|
| 50 | - * @var int |
|
| 51 | - */ |
|
| 52 | - public $invoice_id = 0; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Item discount. |
|
| 56 | - * |
|
| 57 | - * @var float |
|
| 58 | - */ |
|
| 59 | - public $item_discount = 0; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Item tax. |
|
| 63 | - * |
|
| 64 | - * @var float |
|
| 65 | - */ |
|
| 66 | - public $item_tax = 0; |
|
| 13 | + * Stores a custom description for the item. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + protected $custom_description = null; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Stores the item quantity. |
|
| 21 | + * |
|
| 22 | + * @var int |
|
| 23 | + */ |
|
| 24 | + protected $quantity = 1; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Stores the item meta. |
|
| 28 | + * |
|
| 29 | + * @var array |
|
| 30 | + */ |
|
| 31 | + protected $meta = array(); |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Is this item required? |
|
| 35 | + * |
|
| 36 | + * @var int |
|
| 37 | + */ |
|
| 38 | + protected $is_required = true; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Are quantities allowed? |
|
| 42 | + * |
|
| 43 | + * @var int |
|
| 44 | + */ |
|
| 45 | + protected $allow_quantities = false; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Associated invoice. |
|
| 49 | + * |
|
| 50 | + * @var int |
|
| 51 | + */ |
|
| 52 | + public $invoice_id = 0; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Item discount. |
|
| 56 | + * |
|
| 57 | + * @var float |
|
| 58 | + */ |
|
| 59 | + public $item_discount = 0; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Item tax. |
|
| 63 | + * |
|
| 64 | + * @var float |
|
| 65 | + */ |
|
| 66 | + public $item_tax = 0; |
|
| 67 | 67 | |
| 68 | 68 | /* |
| 69 | 69 | |-------------------------------------------------------------------------- |
@@ -81,232 +81,232 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | - * Get the item name. |
|
| 85 | - * |
|
| 86 | - * @since 1.0.19 |
|
| 87 | - * @param string $context View or edit context. |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 90 | - public function get_name( $context = 'view' ) { |
|
| 91 | - $name = parent::get_name( $context ); |
|
| 92 | - return $name . wpinv_get_item_suffix( $this ); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Get the item name without a suffix. |
|
| 97 | - * |
|
| 98 | - * @since 1.0.19 |
|
| 99 | - * @param string $context View or edit context. |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - public function get_raw_name( $context = 'view' ) { |
|
| 103 | - return parent::get_name( $context ); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Get the item description. |
|
| 108 | - * |
|
| 109 | - * @since 1.0.19 |
|
| 110 | - * @param string $context View or edit context. |
|
| 111 | - * @return string |
|
| 112 | - */ |
|
| 113 | - public function get_description( $context = 'view' ) { |
|
| 114 | - |
|
| 115 | - if ( isset( $this->custom_description ) ) { |
|
| 116 | - return $this->custom_description; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - return parent::get_description( $context ); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Returns the sub total. |
|
| 124 | - * |
|
| 125 | - * @since 1.0.19 |
|
| 126 | - * @param string $context View or edit context. |
|
| 127 | - * @return float |
|
| 128 | - */ |
|
| 129 | - public function get_sub_total( $context = 'view' ) { |
|
| 130 | - return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Returns the recurring sub total. |
|
| 135 | - * |
|
| 136 | - * @since 1.0.19 |
|
| 137 | - * @param string $context View or edit context. |
|
| 138 | - * @return float |
|
| 139 | - */ |
|
| 140 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
| 141 | - |
|
| 142 | - if ( $this->is_recurring() ) { |
|
| 143 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return 0; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * @deprecated |
|
| 151 | - */ |
|
| 152 | - public function get_qantity( $context = 'view' ) { |
|
| 153 | - return $this->get_quantity( $context ); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Get the item quantity. |
|
| 158 | - * |
|
| 159 | - * @since 1.0.19 |
|
| 160 | - * @param string $context View or edit context. |
|
| 161 | - * @return int |
|
| 162 | - */ |
|
| 163 | - public function get_quantity( $context = 'view' ) { |
|
| 164 | - $quantity = (int) $this->quantity; |
|
| 165 | - |
|
| 166 | - if ( empty( $quantity ) || 1 > $quantity ) { |
|
| 167 | - $quantity = 1; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - if ( 'view' == $context ) { |
|
| 171 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - return $quantity; |
|
| 175 | - |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Get the item meta data. |
|
| 180 | - * |
|
| 181 | - * @since 1.0.19 |
|
| 182 | - * @param string $context View or edit context. |
|
| 183 | - * @return meta |
|
| 184 | - */ |
|
| 185 | - public function get_item_meta( $context = 'view' ) { |
|
| 186 | - $meta = $this->meta; |
|
| 187 | - |
|
| 188 | - if ( 'view' == $context ) { |
|
| 189 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - return $meta; |
|
| 193 | - |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Returns whether or not customers can update the item quantity. |
|
| 198 | - * |
|
| 199 | - * @since 1.0.19 |
|
| 200 | - * @param string $context View or edit context. |
|
| 201 | - * @return bool |
|
| 202 | - */ |
|
| 203 | - public function get_allow_quantities( $context = 'view' ) { |
|
| 204 | - $allow_quantities = (bool) $this->allow_quantities; |
|
| 205 | - |
|
| 206 | - if ( 'view' == $context ) { |
|
| 207 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - return $allow_quantities; |
|
| 211 | - |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Returns whether or not the item is required. |
|
| 216 | - * |
|
| 217 | - * @since 1.0.19 |
|
| 218 | - * @param string $context View or edit context. |
|
| 219 | - * @return bool |
|
| 220 | - */ |
|
| 221 | - public function get_is_required( $context = 'view' ) { |
|
| 222 | - $is_required = (bool) $this->is_required; |
|
| 223 | - |
|
| 224 | - if ( 'view' == $context ) { |
|
| 225 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - return $is_required; |
|
| 229 | - |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * Prepares form data for use. |
|
| 234 | - * |
|
| 235 | - * @since 1.0.19 |
|
| 236 | - * @return array |
|
| 237 | - */ |
|
| 238 | - public function prepare_data_for_use( $required = null ) { |
|
| 239 | - |
|
| 240 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
| 241 | - return array( |
|
| 242 | - 'title' => strip_tags( $this->get_name() ), |
|
| 243 | - 'id' => $this->get_id(), |
|
| 244 | - 'price' => $this->get_price(), |
|
| 245 | - 'recurring' => $this->is_recurring(), |
|
| 246 | - 'description' => $this->get_description(), |
|
| 247 | - 'allow_quantities' => $this->allows_quantities(), |
|
| 248 | - 'required' => $required, |
|
| 249 | - ); |
|
| 250 | - |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * Prepares form data for ajax use. |
|
| 255 | - * |
|
| 256 | - * @since 1.0.19 |
|
| 257 | - * @return array |
|
| 258 | - */ |
|
| 259 | - public function prepare_data_for_invoice_edit_ajax( $currency = '' ) { |
|
| 260 | - |
|
| 261 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
| 262 | - |
|
| 263 | - if ( $description ) { |
|
| 264 | - $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return array( |
|
| 268 | - 'id' => $this->get_id(), |
|
| 269 | - 'texts' => array( |
|
| 270 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
| 271 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
| 272 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
| 273 | - 'item-price' => wpinv_price( wpinv_format_amount ( $this->get_price() ), $currency ), |
|
| 274 | - 'item-total' => wpinv_price( wpinv_format_amount( $this->get_sub_total() ), $currency ), |
|
| 275 | - ), |
|
| 276 | - 'inputs' => array( |
|
| 277 | - 'item-id' => $this->get_id(), |
|
| 278 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
| 279 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
| 280 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
| 281 | - 'item-price' => $this->get_price(), |
|
| 282 | - ) |
|
| 283 | - ); |
|
| 284 | - |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * Prepares form data for saving (cart_details). |
|
| 289 | - * |
|
| 290 | - * @since 1.0.19 |
|
| 291 | - * @return array |
|
| 292 | - */ |
|
| 293 | - public function prepare_data_for_saving() { |
|
| 294 | - |
|
| 295 | - return array( |
|
| 296 | - 'post_id' => $this->invoice_id, |
|
| 297 | - 'item_id' => $this->get_id(), |
|
| 298 | - 'item_name' => sanitize_text_field( $this->get_raw_name() ), |
|
| 299 | - 'item_description' => $this->get_description(), |
|
| 300 | - 'tax' => $this->item_tax, |
|
| 301 | - 'item_price' => $this->get_price(), |
|
| 302 | - 'quantity' => (int) $this->get_quantity(), |
|
| 303 | - 'discount' => $this->item_discount, |
|
| 304 | - 'subtotal' => $this->get_sub_total(), |
|
| 305 | - 'price' => $this->get_sub_total() + $this->item_tax + $this->item_discount, |
|
| 306 | - 'meta' => $this->get_item_meta(), |
|
| 307 | - ); |
|
| 308 | - |
|
| 309 | - } |
|
| 84 | + * Get the item name. |
|
| 85 | + * |
|
| 86 | + * @since 1.0.19 |
|
| 87 | + * @param string $context View or edit context. |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | + public function get_name( $context = 'view' ) { |
|
| 91 | + $name = parent::get_name( $context ); |
|
| 92 | + return $name . wpinv_get_item_suffix( $this ); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Get the item name without a suffix. |
|
| 97 | + * |
|
| 98 | + * @since 1.0.19 |
|
| 99 | + * @param string $context View or edit context. |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + public function get_raw_name( $context = 'view' ) { |
|
| 103 | + return parent::get_name( $context ); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Get the item description. |
|
| 108 | + * |
|
| 109 | + * @since 1.0.19 |
|
| 110 | + * @param string $context View or edit context. |
|
| 111 | + * @return string |
|
| 112 | + */ |
|
| 113 | + public function get_description( $context = 'view' ) { |
|
| 114 | + |
|
| 115 | + if ( isset( $this->custom_description ) ) { |
|
| 116 | + return $this->custom_description; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + return parent::get_description( $context ); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Returns the sub total. |
|
| 124 | + * |
|
| 125 | + * @since 1.0.19 |
|
| 126 | + * @param string $context View or edit context. |
|
| 127 | + * @return float |
|
| 128 | + */ |
|
| 129 | + public function get_sub_total( $context = 'view' ) { |
|
| 130 | + return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Returns the recurring sub total. |
|
| 135 | + * |
|
| 136 | + * @since 1.0.19 |
|
| 137 | + * @param string $context View or edit context. |
|
| 138 | + * @return float |
|
| 139 | + */ |
|
| 140 | + public function get_recurring_sub_total( $context = 'view' ) { |
|
| 141 | + |
|
| 142 | + if ( $this->is_recurring() ) { |
|
| 143 | + return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return 0; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * @deprecated |
|
| 151 | + */ |
|
| 152 | + public function get_qantity( $context = 'view' ) { |
|
| 153 | + return $this->get_quantity( $context ); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Get the item quantity. |
|
| 158 | + * |
|
| 159 | + * @since 1.0.19 |
|
| 160 | + * @param string $context View or edit context. |
|
| 161 | + * @return int |
|
| 162 | + */ |
|
| 163 | + public function get_quantity( $context = 'view' ) { |
|
| 164 | + $quantity = (int) $this->quantity; |
|
| 165 | + |
|
| 166 | + if ( empty( $quantity ) || 1 > $quantity ) { |
|
| 167 | + $quantity = 1; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + if ( 'view' == $context ) { |
|
| 171 | + return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + return $quantity; |
|
| 175 | + |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Get the item meta data. |
|
| 180 | + * |
|
| 181 | + * @since 1.0.19 |
|
| 182 | + * @param string $context View or edit context. |
|
| 183 | + * @return meta |
|
| 184 | + */ |
|
| 185 | + public function get_item_meta( $context = 'view' ) { |
|
| 186 | + $meta = $this->meta; |
|
| 187 | + |
|
| 188 | + if ( 'view' == $context ) { |
|
| 189 | + return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + return $meta; |
|
| 193 | + |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Returns whether or not customers can update the item quantity. |
|
| 198 | + * |
|
| 199 | + * @since 1.0.19 |
|
| 200 | + * @param string $context View or edit context. |
|
| 201 | + * @return bool |
|
| 202 | + */ |
|
| 203 | + public function get_allow_quantities( $context = 'view' ) { |
|
| 204 | + $allow_quantities = (bool) $this->allow_quantities; |
|
| 205 | + |
|
| 206 | + if ( 'view' == $context ) { |
|
| 207 | + return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + return $allow_quantities; |
|
| 211 | + |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Returns whether or not the item is required. |
|
| 216 | + * |
|
| 217 | + * @since 1.0.19 |
|
| 218 | + * @param string $context View or edit context. |
|
| 219 | + * @return bool |
|
| 220 | + */ |
|
| 221 | + public function get_is_required( $context = 'view' ) { |
|
| 222 | + $is_required = (bool) $this->is_required; |
|
| 223 | + |
|
| 224 | + if ( 'view' == $context ) { |
|
| 225 | + return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + return $is_required; |
|
| 229 | + |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * Prepares form data for use. |
|
| 234 | + * |
|
| 235 | + * @since 1.0.19 |
|
| 236 | + * @return array |
|
| 237 | + */ |
|
| 238 | + public function prepare_data_for_use( $required = null ) { |
|
| 239 | + |
|
| 240 | + $required = is_null( $required ) ? $this->is_required() : $required; |
|
| 241 | + return array( |
|
| 242 | + 'title' => strip_tags( $this->get_name() ), |
|
| 243 | + 'id' => $this->get_id(), |
|
| 244 | + 'price' => $this->get_price(), |
|
| 245 | + 'recurring' => $this->is_recurring(), |
|
| 246 | + 'description' => $this->get_description(), |
|
| 247 | + 'allow_quantities' => $this->allows_quantities(), |
|
| 248 | + 'required' => $required, |
|
| 249 | + ); |
|
| 250 | + |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * Prepares form data for ajax use. |
|
| 255 | + * |
|
| 256 | + * @since 1.0.19 |
|
| 257 | + * @return array |
|
| 258 | + */ |
|
| 259 | + public function prepare_data_for_invoice_edit_ajax( $currency = '' ) { |
|
| 260 | + |
|
| 261 | + $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
| 262 | + |
|
| 263 | + if ( $description ) { |
|
| 264 | + $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return array( |
|
| 268 | + 'id' => $this->get_id(), |
|
| 269 | + 'texts' => array( |
|
| 270 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
| 271 | + 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
| 272 | + 'item-quantity' => absint( $this->get_quantity() ), |
|
| 273 | + 'item-price' => wpinv_price( wpinv_format_amount ( $this->get_price() ), $currency ), |
|
| 274 | + 'item-total' => wpinv_price( wpinv_format_amount( $this->get_sub_total() ), $currency ), |
|
| 275 | + ), |
|
| 276 | + 'inputs' => array( |
|
| 277 | + 'item-id' => $this->get_id(), |
|
| 278 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
| 279 | + 'item-description' => wp_kses_post( $this->get_description() ), |
|
| 280 | + 'item-quantity' => absint( $this->get_quantity() ), |
|
| 281 | + 'item-price' => $this->get_price(), |
|
| 282 | + ) |
|
| 283 | + ); |
|
| 284 | + |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * Prepares form data for saving (cart_details). |
|
| 289 | + * |
|
| 290 | + * @since 1.0.19 |
|
| 291 | + * @return array |
|
| 292 | + */ |
|
| 293 | + public function prepare_data_for_saving() { |
|
| 294 | + |
|
| 295 | + return array( |
|
| 296 | + 'post_id' => $this->invoice_id, |
|
| 297 | + 'item_id' => $this->get_id(), |
|
| 298 | + 'item_name' => sanitize_text_field( $this->get_raw_name() ), |
|
| 299 | + 'item_description' => $this->get_description(), |
|
| 300 | + 'tax' => $this->item_tax, |
|
| 301 | + 'item_price' => $this->get_price(), |
|
| 302 | + 'quantity' => (int) $this->get_quantity(), |
|
| 303 | + 'discount' => $this->item_discount, |
|
| 304 | + 'subtotal' => $this->get_sub_total(), |
|
| 305 | + 'price' => $this->get_sub_total() + $this->item_tax + $this->item_discount, |
|
| 306 | + 'meta' => $this->get_item_meta(), |
|
| 307 | + ); |
|
| 308 | + |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | 311 | /* |
| 312 | 312 | |-------------------------------------------------------------------------- |
@@ -318,70 +318,70 @@ discard block |
||
| 318 | 318 | | object. |
| 319 | 319 | */ |
| 320 | 320 | |
| 321 | - /** |
|
| 322 | - * Set the item qantity. |
|
| 323 | - * |
|
| 324 | - * @since 1.0.19 |
|
| 325 | - * @param int $quantity The item quantity. |
|
| 326 | - */ |
|
| 327 | - public function set_quantity( $quantity ) { |
|
| 328 | - |
|
| 329 | - if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
| 330 | - $quantity = 1; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - $this->quantity = (int) $quantity; |
|
| 334 | - |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * Set the item meta data. |
|
| 339 | - * |
|
| 340 | - * @since 1.0.19 |
|
| 341 | - * @param array $meta The item meta data. |
|
| 342 | - */ |
|
| 343 | - public function set_item_meta( $meta ) { |
|
| 344 | - $this->meta = maybe_unserialize( $meta ); |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * Set whether or not the quantities are allowed. |
|
| 349 | - * |
|
| 350 | - * @since 1.0.19 |
|
| 351 | - * @param bool $allow_quantities |
|
| 352 | - */ |
|
| 353 | - public function set_allow_quantities( $allow_quantities ) { |
|
| 354 | - $this->allow_quantities = (bool) $allow_quantities; |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * Set whether or not the item is required. |
|
| 359 | - * |
|
| 360 | - * @since 1.0.19 |
|
| 361 | - * @param bool $is_required |
|
| 362 | - */ |
|
| 363 | - public function set_is_required( $is_required ) { |
|
| 364 | - $this->is_required = (bool) $is_required; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * Sets the custom item description. |
|
| 369 | - * |
|
| 370 | - * @since 1.0.19 |
|
| 371 | - * @param string $description |
|
| 372 | - */ |
|
| 373 | - public function set_custom_description( $description ) { |
|
| 374 | - $this->custom_description = $description; |
|
| 375 | - } |
|
| 321 | + /** |
|
| 322 | + * Set the item qantity. |
|
| 323 | + * |
|
| 324 | + * @since 1.0.19 |
|
| 325 | + * @param int $quantity The item quantity. |
|
| 326 | + */ |
|
| 327 | + public function set_quantity( $quantity ) { |
|
| 328 | + |
|
| 329 | + if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
| 330 | + $quantity = 1; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + $this->quantity = (int) $quantity; |
|
| 334 | + |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * Set the item meta data. |
|
| 339 | + * |
|
| 340 | + * @since 1.0.19 |
|
| 341 | + * @param array $meta The item meta data. |
|
| 342 | + */ |
|
| 343 | + public function set_item_meta( $meta ) { |
|
| 344 | + $this->meta = maybe_unserialize( $meta ); |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * Set whether or not the quantities are allowed. |
|
| 349 | + * |
|
| 350 | + * @since 1.0.19 |
|
| 351 | + * @param bool $allow_quantities |
|
| 352 | + */ |
|
| 353 | + public function set_allow_quantities( $allow_quantities ) { |
|
| 354 | + $this->allow_quantities = (bool) $allow_quantities; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * Set whether or not the item is required. |
|
| 359 | + * |
|
| 360 | + * @since 1.0.19 |
|
| 361 | + * @param bool $is_required |
|
| 362 | + */ |
|
| 363 | + public function set_is_required( $is_required ) { |
|
| 364 | + $this->is_required = (bool) $is_required; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Sets the custom item description. |
|
| 369 | + * |
|
| 370 | + * @since 1.0.19 |
|
| 371 | + * @param string $description |
|
| 372 | + */ |
|
| 373 | + public function set_custom_description( $description ) { |
|
| 374 | + $this->custom_description = $description; |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | 377 | /** |
| 378 | 378 | * We do not want to save items to the database. |
| 379 | 379 | * |
| 380 | - * @return int item id |
|
| 380 | + * @return int item id |
|
| 381 | 381 | */ |
| 382 | 382 | public function save( $data = array() ) { |
| 383 | 383 | return $this->get_id(); |
| 384 | - } |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | 386 | /* |
| 387 | 387 | |-------------------------------------------------------------------------- |
@@ -393,23 +393,23 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | - * Checks whether the item has enabled dynamic pricing. |
|
| 397 | - * |
|
| 398 | - * @since 1.0.19 |
|
| 399 | - * @return bool |
|
| 400 | - */ |
|
| 401 | - public function is_required() { |
|
| 396 | + * Checks whether the item has enabled dynamic pricing. |
|
| 397 | + * |
|
| 398 | + * @since 1.0.19 |
|
| 399 | + * @return bool |
|
| 400 | + */ |
|
| 401 | + public function is_required() { |
|
| 402 | 402 | return (bool) $this->get_is_required(); |
| 403 | - } |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * Checks whether users can edit the quantities. |
|
| 407 | - * |
|
| 408 | - * @since 1.0.19 |
|
| 409 | - * @return bool |
|
| 410 | - */ |
|
| 411 | - public function allows_quantities() { |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Checks whether users can edit the quantities. |
|
| 407 | + * |
|
| 408 | + * @since 1.0.19 |
|
| 409 | + * @return bool |
|
| 410 | + */ |
|
| 411 | + public function allows_quantities() { |
|
| 412 | 412 | return (bool) $this->get_allow_quantities(); |
| 413 | - } |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | 415 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | * @param string $context View or edit context. |
| 88 | 88 | * @return string |
| 89 | 89 | */ |
| 90 | - public function get_name( $context = 'view' ) { |
|
| 91 | - $name = parent::get_name( $context ); |
|
| 92 | - return $name . wpinv_get_item_suffix( $this ); |
|
| 90 | + public function get_name($context = 'view') { |
|
| 91 | + $name = parent::get_name($context); |
|
| 92 | + return $name . wpinv_get_item_suffix($this); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | * @param string $context View or edit context. |
| 100 | 100 | * @return string |
| 101 | 101 | */ |
| 102 | - public function get_raw_name( $context = 'view' ) { |
|
| 103 | - return parent::get_name( $context ); |
|
| 102 | + public function get_raw_name($context = 'view') { |
|
| 103 | + return parent::get_name($context); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | * @param string $context View or edit context. |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - public function get_description( $context = 'view' ) { |
|
| 113 | + public function get_description($context = 'view') { |
|
| 114 | 114 | |
| 115 | - if ( isset( $this->custom_description ) ) { |
|
| 115 | + if (isset($this->custom_description)) { |
|
| 116 | 116 | return $this->custom_description; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - return parent::get_description( $context ); |
|
| 119 | + return parent::get_description($context); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | * @param string $context View or edit context. |
| 127 | 127 | * @return float |
| 128 | 128 | */ |
| 129 | - public function get_sub_total( $context = 'view' ) { |
|
| 130 | - return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
| 129 | + public function get_sub_total($context = 'view') { |
|
| 130 | + return $this->get_quantity($context) * $this->get_initial_price($context); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | * @param string $context View or edit context. |
| 138 | 138 | * @return float |
| 139 | 139 | */ |
| 140 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
| 140 | + public function get_recurring_sub_total($context = 'view') { |
|
| 141 | 141 | |
| 142 | - if ( $this->is_recurring() ) { |
|
| 143 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
| 142 | + if ($this->is_recurring()) { |
|
| 143 | + return $this->get_quantity($context) * $this->get_price($context); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return 0; |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | /** |
| 150 | 150 | * @deprecated |
| 151 | 151 | */ |
| 152 | - public function get_qantity( $context = 'view' ) { |
|
| 153 | - return $this->get_quantity( $context ); |
|
| 152 | + public function get_qantity($context = 'view') { |
|
| 153 | + return $this->get_quantity($context); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -160,15 +160,15 @@ discard block |
||
| 160 | 160 | * @param string $context View or edit context. |
| 161 | 161 | * @return int |
| 162 | 162 | */ |
| 163 | - public function get_quantity( $context = 'view' ) { |
|
| 163 | + public function get_quantity($context = 'view') { |
|
| 164 | 164 | $quantity = (int) $this->quantity; |
| 165 | 165 | |
| 166 | - if ( empty( $quantity ) || 1 > $quantity ) { |
|
| 166 | + if (empty($quantity) || 1 > $quantity) { |
|
| 167 | 167 | $quantity = 1; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( 'view' == $context ) { |
|
| 171 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
| 170 | + if ('view' == $context) { |
|
| 171 | + return apply_filters('getpaid_payment_form_item_quantity', $quantity, $this); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return $quantity; |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | * @param string $context View or edit context. |
| 183 | 183 | * @return meta |
| 184 | 184 | */ |
| 185 | - public function get_item_meta( $context = 'view' ) { |
|
| 185 | + public function get_item_meta($context = 'view') { |
|
| 186 | 186 | $meta = $this->meta; |
| 187 | 187 | |
| 188 | - if ( 'view' == $context ) { |
|
| 189 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
| 188 | + if ('view' == $context) { |
|
| 189 | + return apply_filters('getpaid_payment_form_item_meta', $meta, $this); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | return $meta; |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | * @param string $context View or edit context. |
| 201 | 201 | * @return bool |
| 202 | 202 | */ |
| 203 | - public function get_allow_quantities( $context = 'view' ) { |
|
| 203 | + public function get_allow_quantities($context = 'view') { |
|
| 204 | 204 | $allow_quantities = (bool) $this->allow_quantities; |
| 205 | 205 | |
| 206 | - if ( 'view' == $context ) { |
|
| 207 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
| 206 | + if ('view' == $context) { |
|
| 207 | + return apply_filters('getpaid_payment_form_item_allow_quantities', $allow_quantities, $this); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | return $allow_quantities; |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | * @param string $context View or edit context. |
| 219 | 219 | * @return bool |
| 220 | 220 | */ |
| 221 | - public function get_is_required( $context = 'view' ) { |
|
| 221 | + public function get_is_required($context = 'view') { |
|
| 222 | 222 | $is_required = (bool) $this->is_required; |
| 223 | 223 | |
| 224 | - if ( 'view' == $context ) { |
|
| 225 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
| 224 | + if ('view' == $context) { |
|
| 225 | + return apply_filters('getpaid_payment_form_item_is_required', $is_required, $this); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | return $is_required; |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | * @since 1.0.19 |
| 236 | 236 | * @return array |
| 237 | 237 | */ |
| 238 | - public function prepare_data_for_use( $required = null ) { |
|
| 238 | + public function prepare_data_for_use($required = null) { |
|
| 239 | 239 | |
| 240 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
| 240 | + $required = is_null($required) ? $this->is_required() : $required; |
|
| 241 | 241 | return array( |
| 242 | - 'title' => strip_tags( $this->get_name() ), |
|
| 242 | + 'title' => strip_tags($this->get_name()), |
|
| 243 | 243 | 'id' => $this->get_id(), |
| 244 | 244 | 'price' => $this->get_price(), |
| 245 | 245 | 'recurring' => $this->is_recurring(), |
@@ -256,28 +256,28 @@ discard block |
||
| 256 | 256 | * @since 1.0.19 |
| 257 | 257 | * @return array |
| 258 | 258 | */ |
| 259 | - public function prepare_data_for_invoice_edit_ajax( $currency = '' ) { |
|
| 259 | + public function prepare_data_for_invoice_edit_ajax($currency = '') { |
|
| 260 | 260 | |
| 261 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
| 261 | + $description = getpaid_item_recurring_price_help_text($this, $currency); |
|
| 262 | 262 | |
| 263 | - if ( $description ) { |
|
| 263 | + if ($description) { |
|
| 264 | 264 | $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | return array( |
| 268 | 268 | 'id' => $this->get_id(), |
| 269 | 269 | 'texts' => array( |
| 270 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
| 271 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
| 272 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
| 273 | - 'item-price' => wpinv_price( wpinv_format_amount ( $this->get_price() ), $currency ), |
|
| 274 | - 'item-total' => wpinv_price( wpinv_format_amount( $this->get_sub_total() ), $currency ), |
|
| 270 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
| 271 | + 'item-description' => wp_kses_post($this->get_description()) . $description, |
|
| 272 | + 'item-quantity' => absint($this->get_quantity()), |
|
| 273 | + 'item-price' => wpinv_price(wpinv_format_amount($this->get_price()), $currency), |
|
| 274 | + 'item-total' => wpinv_price(wpinv_format_amount($this->get_sub_total()), $currency), |
|
| 275 | 275 | ), |
| 276 | 276 | 'inputs' => array( |
| 277 | 277 | 'item-id' => $this->get_id(), |
| 278 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
| 279 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
| 280 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
| 278 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
| 279 | + 'item-description' => wp_kses_post($this->get_description()), |
|
| 280 | + 'item-quantity' => absint($this->get_quantity()), |
|
| 281 | 281 | 'item-price' => $this->get_price(), |
| 282 | 282 | ) |
| 283 | 283 | ); |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | return array( |
| 296 | 296 | 'post_id' => $this->invoice_id, |
| 297 | 297 | 'item_id' => $this->get_id(), |
| 298 | - 'item_name' => sanitize_text_field( $this->get_raw_name() ), |
|
| 298 | + 'item_name' => sanitize_text_field($this->get_raw_name()), |
|
| 299 | 299 | 'item_description' => $this->get_description(), |
| 300 | 300 | 'tax' => $this->item_tax, |
| 301 | 301 | 'item_price' => $this->get_price(), |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | * @since 1.0.19 |
| 325 | 325 | * @param int $quantity The item quantity. |
| 326 | 326 | */ |
| 327 | - public function set_quantity( $quantity ) { |
|
| 327 | + public function set_quantity($quantity) { |
|
| 328 | 328 | |
| 329 | - if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
| 329 | + if (empty($quantity) || !is_numeric($quantity)) { |
|
| 330 | 330 | $quantity = 1; |
| 331 | 331 | } |
| 332 | 332 | |
@@ -340,8 +340,8 @@ discard block |
||
| 340 | 340 | * @since 1.0.19 |
| 341 | 341 | * @param array $meta The item meta data. |
| 342 | 342 | */ |
| 343 | - public function set_item_meta( $meta ) { |
|
| 344 | - $this->meta = maybe_unserialize( $meta ); |
|
| 343 | + public function set_item_meta($meta) { |
|
| 344 | + $this->meta = maybe_unserialize($meta); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @since 1.0.19 |
| 351 | 351 | * @param bool $allow_quantities |
| 352 | 352 | */ |
| 353 | - public function set_allow_quantities( $allow_quantities ) { |
|
| 353 | + public function set_allow_quantities($allow_quantities) { |
|
| 354 | 354 | $this->allow_quantities = (bool) $allow_quantities; |
| 355 | 355 | } |
| 356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | * @since 1.0.19 |
| 361 | 361 | * @param bool $is_required |
| 362 | 362 | */ |
| 363 | - public function set_is_required( $is_required ) { |
|
| 363 | + public function set_is_required($is_required) { |
|
| 364 | 364 | $this->is_required = (bool) $is_required; |
| 365 | 365 | } |
| 366 | 366 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | * @since 1.0.19 |
| 371 | 371 | * @param string $description |
| 372 | 372 | */ |
| 373 | - public function set_custom_description( $description ) { |
|
| 373 | + public function set_custom_description($description) { |
|
| 374 | 374 | $this->custom_description = $description; |
| 375 | 375 | } |
| 376 | 376 | |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | * |
| 380 | 380 | * @return int item id |
| 381 | 381 | */ |
| 382 | - public function save( $data = array() ) { |
|
| 382 | + public function save($data = array()) { |
|
| 383 | 383 | return $this->get_id(); |
| 384 | 384 | } |
| 385 | 385 | |
@@ -7,18 +7,18 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$watermark = wpinv_watermark( $invoice->get_id() ) |
|
| 12 | +$watermark = wpinv_watermark($invoice->get_id()) |
|
| 13 | 13 | |
| 14 | 14 | ?> |
| 15 | 15 | |
| 16 | - <?php do_action( 'getpaid_before_invoice_details_top', $invoice ); ?> |
|
| 16 | + <?php do_action('getpaid_before_invoice_details_top', $invoice); ?> |
|
| 17 | 17 | |
| 18 | - <?php if ( ! empty( $watermark ) ) : ?> |
|
| 18 | + <?php if (!empty($watermark)) : ?> |
|
| 19 | 19 | |
| 20 | 20 | <div class="getpaid-watermark no-print"> |
| 21 | - <p><?php echo sanitize_text_field( $watermark ) ?></p> |
|
| 21 | + <p><?php echo sanitize_text_field($watermark) ?></p> |
|
| 22 | 22 | </div> |
| 23 | 23 | |
| 24 | 24 | <?php endif; ?> |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | <div class="getpaid-invoice-details-top mb-5"> |
| 27 | 27 | <div class="row"> |
| 28 | 28 | <div class="col-12 col-sm-6 text-left"> |
| 29 | - <?php do_action( 'getpaid_invoice_details_top_left', $invoice ); ?> |
|
| 29 | + <?php do_action('getpaid_invoice_details_top_left', $invoice); ?> |
|
| 30 | 30 | </div> |
| 31 | 31 | |
| 32 | 32 | <div class="col-12 col-sm-6 text-right"> |
| 33 | - <?php do_action( 'getpaid_invoice_details_top_right', $invoice ); ?> |
|
| 33 | + <?php do_action('getpaid_invoice_details_top_right', $invoice); ?> |
|
| 34 | 34 | </div> |
| 35 | 35 | </div> |
| 36 | 36 | </div> |
| 37 | 37 | |
| 38 | - <?php do_action( 'getpaid_after_invoice_details_top', $invoice ); ?> |
|
| 38 | + <?php do_action('getpaid_after_invoice_details_top', $invoice); ?> |
|
| 39 | 39 | |
| 40 | 40 | <?php |
@@ -7,51 +7,51 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -$class = ! is_singular( 'page' ) ? 'table-sm' : ''; |
|
| 12 | +$class = !is_singular('page') ? 'table-sm' : ''; |
|
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | - <?php do_action( 'getpaid_before_invoice_meta', $invoice ); ?> |
|
| 15 | + <?php do_action('getpaid_before_invoice_meta', $invoice); ?> |
|
| 16 | 16 | <div class="getpaid-invoice-meta-data"> |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - <?php do_action( 'getpaid_before_invoice_meta_table', $invoice ); ?> |
|
| 19 | + <?php do_action('getpaid_before_invoice_meta_table', $invoice); ?> |
|
| 20 | 20 | <table class="table <?php echo $class; ?> table-bordered"> |
| 21 | 21 | <tbody> |
| 22 | 22 | |
| 23 | - <?php do_action( "getpaid_before_invoice_meta_rows", $invoice ); ?> |
|
| 24 | - <?php foreach ( $meta as $key => $data ) : ?> |
|
| 23 | + <?php do_action("getpaid_before_invoice_meta_rows", $invoice); ?> |
|
| 24 | + <?php foreach ($meta as $key => $data) : ?> |
|
| 25 | 25 | |
| 26 | - <?php if ( ! empty( $data['value'] ) ) : ?> |
|
| 26 | + <?php if (!empty($data['value'])) : ?> |
|
| 27 | 27 | |
| 28 | - <?php do_action( "getpaid_before_invoice_meta_$key", $invoice, $data ); ?> |
|
| 28 | + <?php do_action("getpaid_before_invoice_meta_$key", $invoice, $data); ?> |
|
| 29 | 29 | |
| 30 | - <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 30 | + <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>"> |
|
| 31 | 31 | |
| 32 | 32 | <th> |
| 33 | - <?php echo sanitize_text_field( $data['label'] ); ?> |
|
| 33 | + <?php echo sanitize_text_field($data['label']); ?> |
|
| 34 | 34 | </th> |
| 35 | 35 | |
| 36 | 36 | <td> |
| 37 | - <span class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span> |
|
| 37 | + <span class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span> |
|
| 38 | 38 | </td> |
| 39 | 39 | |
| 40 | 40 | </tr> |
| 41 | 41 | |
| 42 | - <?php do_action( "getpaid_after_invoice_meta_$key", $invoice, $data ); ?> |
|
| 42 | + <?php do_action("getpaid_after_invoice_meta_$key", $invoice, $data); ?> |
|
| 43 | 43 | |
| 44 | 44 | <?php endif; ?> |
| 45 | 45 | |
| 46 | 46 | <?php endforeach; ?> |
| 47 | - <?php do_action( "getpaid_after_invoice_meta_rows", $invoice ); ?> |
|
| 47 | + <?php do_action("getpaid_after_invoice_meta_rows", $invoice); ?> |
|
| 48 | 48 | |
| 49 | 49 | </tbody> |
| 50 | 50 | </table> |
| 51 | - <?php do_action( 'getpaid_after_invoice_meta_table', $invoice ); ?> |
|
| 51 | + <?php do_action('getpaid_after_invoice_meta_table', $invoice); ?> |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | </div> |
| 55 | - <?php do_action( 'getpaid_after_invoice_meta', $invoice ); ?> |
|
| 55 | + <?php do_action('getpaid_after_invoice_meta', $invoice); ?> |
|
| 56 | 56 | |
| 57 | 57 | <?php |