Changeset 1967906
- Timestamp:
- 11/02/2018 04:45:24 PM (7 years ago)
- Location:
- woo-simple-buy-now
- Files:
-
- 16 added
- 1 deleted
- 4 edited
-
tags/1.0.7 (added)
-
tags/1.0.7/assets (added)
-
tags/1.0.7/assets/css (added)
-
tags/1.0.7/assets/css/woocommerce-simple-buy-now.css (added)
-
tags/1.0.7/assets/js (added)
-
tags/1.0.7/assets/js/woocommerce-simple-buy-now.js (added)
-
tags/1.0.7/bin (added)
-
tags/1.0.7/bin/install-wp-tests.sh (added)
-
tags/1.0.7/includes (added)
-
tags/1.0.7/includes/woocommerce-settings.php (added)
-
tags/1.0.7/languages (added)
-
tags/1.0.7/languages/woocommerce-simple-buy-now.pot (added)
-
tags/1.0.7/readme.txt (added)
-
tags/1.0.7/woocommerce-simple-buy-now.php (added)
-
trunk/assets/css/woocommerce-simple-buy-now.css (modified) (2 diffs)
-
trunk/bin (added)
-
trunk/bin/install-wp-tests.sh (added)
-
trunk/changelog.txt (deleted)
-
trunk/includes/woocommerce-settings.php (modified) (12 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/woocommerce-simple-buy-now.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-simple-buy-now/trunk/assets/css/woocommerce-simple-buy-now.css
r1939463 r1967906 1 1 /* Page wrapper */ 2 2 .wsb-wrapper { 3 width: 90%;4 max-width: 800px;5 margin: 4em auto;6 text-align: center;3 width: 90%; 4 max-width: 800px; 5 margin: 4em auto; 6 text-align: center; 7 7 } 8 8 9 9 /* Icons */ 10 10 .wsb-icon { 11 display: inline-block;12 width: 16px;13 height: 16px;14 vertical-align: middle;15 fill: currentcolor;11 display: inline-block; 12 width: 16px; 13 height: 16px; 14 vertical-align: middle; 15 fill: currentcolor; 16 16 } 17 17 … … 22 22 /* 1. Ensure this sits above everything when visible */ 23 23 .wsb-modal { 24 position: absolute;25 z-index: 999999;26 top: 0;27 left: 0;28 visibility: hidden;29 width: 100%;30 height: 100%;24 position: absolute; 25 z-index: 999999; 26 top: 0; 27 left: 0; 28 visibility: hidden; 29 width: 100%; 30 height: 100%; 31 31 } 32 32 33 33 .wsb-modal.is-visible { 34 visibility: visible;34 visibility: visible; 35 35 } 36 36 37 37 .wsb-modal-overlay { 38 position: fixed;39 z-index: 10;40 top: 0;41 left: 0;42 width: 100%;43 height: 100%;44 background: hsla(0, 0%, 0%, 0.5);45 visibility: hidden;46 opacity: 0;47 transition: visibility 0s linear 0.3s, opacity 0.3s;38 position: fixed; 39 z-index: 10; 40 top: 0; 41 left: 0; 42 width: 100%; 43 height: 100%; 44 background: hsla(0, 0%, 0%, 0.5); 45 visibility: hidden; 46 opacity: 0; 47 transition: visibility 0s linear 0.3s, opacity 0.3s; 48 48 } 49 49 50 50 .wsb-modal.is-visible .wsb-modal-overlay { 51 opacity: 1;52 visibility: visible;53 transition-delay: 0s;51 opacity: 1; 52 visibility: visible; 53 transition-delay: 0s; 54 54 } 55 55 56 56 .wsb-modal-wrapper { 57 position: fixed;58 z-index: 9999;59 top: 50%;60 left: 50%;61 width: 100%;62 background-color: #fff;63 box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35);64 opacity: 1;65 transform: translateY(-50%);66 transform: translateX(-50%);67 height: 100vh;68 overflow: scroll;57 position: fixed; 58 z-index: 9999; 59 top: 50%; 60 left: 50%; 61 width: 100%; 62 background-color: #fff; 63 box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35); 64 opacity: 1; 65 transform: translateY(-50%); 66 transform: translateX(-50%); 67 height: 100vh; 68 overflow: scroll; 69 69 } 70 70 71 71 .wsb-modal-transition { 72 transition: all 0.3s 0.12s;73 transform: translateY(-10%);74 opacity: 0;72 transition: all 0.3s 0.12s; 73 transform: translateY(-10%); 74 opacity: 0; 75 75 } 76 76 77 77 .wsb-modal.is-visible .wsb-modal-transition { 78 transform: translate(-50%, -50%) !important;79 opacity: 1;80 width: 100%;78 transform: translate(-50%, -50%) !important; 79 opacity: 1; 80 width: 100%; 81 81 } 82 82 83 83 @media (min-width: 992px) { 84 .wsb-modal.is-visible .wsb-modal-transition {85 width: 900px;86 }84 .wsb-modal.is-visible .wsb-modal-transition { 85 width: 900px; 86 } 87 87 } 88 88 89 89 @media (min-width: 1200px) { 90 .wsb-modal.is-visible .wsb-modal-transition {91 width: 1024px;92 }90 .wsb-modal.is-visible .wsb-modal-transition { 91 width: 1024px; 92 } 93 93 } 94 94 95 95 .wsb-modal-header, 96 96 .wsb-modal-content { 97 padding: 1em;97 padding: 1em; 98 98 } 99 99 100 100 .wsb-modal-header { 101 position: relative;102 background-color: #fff;103 box-shadow: 0 1px 2px hsla(0, 0%, 0%, 0.06);104 border-bottom: 1px solid #e8e8e8;101 position: relative; 102 background-color: #fff; 103 box-shadow: 0 1px 2px hsla(0, 0%, 0%, 0.06); 104 border-bottom: 1px solid #e8e8e8; 105 105 } 106 106 107 107 .wsb-modal-close { 108 position: absolute;109 top: 0;110 right: 0;111 padding: 15px;112 background: none;113 border: 0;114 color: inherit;115 font-size: 30px;108 position: absolute; 109 top: 0; 110 right: 0; 111 padding: 15px; 112 background: none; 113 border: 0; 114 color: inherit; 115 font-size: 30px; 116 116 } 117 117 118 118 .wsb-modal-close:hover { 119 color: #ff6029;120 background-color: transparent;119 color: #ff6029; 120 background-color: transparent; 121 121 } 122 122 123 123 .wsb-modal-heading { 124 font-size: 1.125em;125 margin: 0;126 -webkit-font-smoothing: antialiased;127 -moz-osx-font-smoothing: grayscale;124 font-size: 1.125em; 125 margin: 0; 126 -webkit-font-smoothing: antialiased; 127 -moz-osx-font-smoothing: grayscale; 128 128 } 129 129 130 130 .wsb-modal-content > *:first-child { 131 margin-top: 0;131 margin-top: 0; 132 132 } 133 133 134 134 .wsb-modal-content > *:last-child { 135 margin-bottom: 0;136 } 137 138 .woocommerce-simple-buy-now-- remove_add_to_cart_btn.single_add_to_cart_button {139 display: none !important;140 } 141 142 .woocommerce-simple-buy-now--remove _quantity_input.cart .quantity {143 display: none !important;135 margin-bottom: 0; 136 } 137 138 .woocommerce-simple-buy-now--button-replace-cart .single_add_to_cart_button { 139 display: none !important; 140 } 141 142 .woocommerce-simple-buy-now--remove-quantity .cart .quantity { 143 display: none !important; 144 144 } 145 145 146 146 .wsb-button { 147 position: relative; 147 position: relative; 148 } 149 150 .woocommerce-simple-buy-now--button-before_quantity-cart .wsb-button { 151 float: left; 152 margin-right: 10px; 153 } 154 155 .woocommerce-simple-buy-now--button-before-cart .wsb-button { 156 float: left; 157 margin-right: 10px; 148 158 } 149 159 150 160 .wsb-button.wsb-loading { 151 cursor: not-allowed;161 cursor: not-allowed; 152 162 } 153 163 154 164 .wsb-button.disabled { 155 cursor: not-allowed;165 cursor: not-allowed; 156 166 } 157 167 158 168 .wsb-button.wsb-loading:before { 159 content: '';160 position: absolute;161 top: 0;162 left: 0;163 display: block;164 width: 100%;165 height: 100%;166 background: #fff;167 opacity: 0.5;169 content: ''; 170 position: absolute; 171 top: 0; 172 left: 0; 173 display: block; 174 width: 100%; 175 height: 100%; 176 background: #fff; 177 opacity: 0.5; 168 178 } 169 179 170 180 .wsb-button.wsb-loading:after { 171 content: '';172 display: block;173 z-index: 9999;174 position: absolute;175 left: 50%;176 top: 50%;177 transform: translate(-50%, -50%);178 border: 5px solid #f3f3f3;179 border-top: 5px solid #1a1a1a;180 border-radius: 50%;181 width: 20px;182 height: 20px;183 -webkit-animation:spin 1s linear infinite; /* Safari */184 animation:spin 1s linear infinite;181 content: ''; 182 display: block; 183 z-index: 9999; 184 position: absolute; 185 left: 50%; 186 top: 50%; 187 transform: translate(-50%, -50%); 188 border: 5px solid #f3f3f3; 189 border-top: 5px solid #1a1a1a; 190 border-radius: 50%; 191 width: 20px; 192 height: 20px; 193 -webkit-animation: wsb-spin 1s linear infinite; /* Safari */ 194 animation: wsb-spin 1s linear infinite; 185 195 } 186 196 187 197 /* Safari */ 188 @-webkit-keyframes spin {189 0% {190 -webkit-transform: translate(-50%, -50%) rotate(0deg);191 }192 100% {193 -webkit-transform: translate(-50%, -50%) rotate(360deg);194 }195 } 196 197 @keyframes spin {198 0% {199 transform: translate(-50%, -50%) rotate(0deg);200 }201 100% {202 transform: translate(-50%, -50%) rotate(360deg);203 }204 } 198 @-webkit-keyframes wsb-spin { 199 0% { 200 -webkit-transform: translate(-50%, -50%) rotate(0deg); 201 } 202 100% { 203 -webkit-transform: translate(-50%, -50%) rotate(360deg); 204 } 205 } 206 207 @keyframes wsb-spin { 208 0% { 209 transform: translate(-50%, -50%) rotate(0deg); 210 } 211 100% { 212 transform: translate(-50%, -50%) rotate(360deg); 213 } 214 } -
woo-simple-buy-now/trunk/includes/woocommerce-settings.php
r1939463 r1967906 1 1 <?php 2 2 /** 3 * WooCommerce GeneralSettings3 * WooCommerce Simple Buy Now Settings 4 4 * 5 * @author WooThemes 6 * @category Admin 7 * @package WooCommerce/Admin 8 * @version 2.1.0 5 * @author ndoublehwp 6 * @version 1.0.8 9 7 */ 10 8 … … 14 12 15 13 /** 16 * W C_Admin_Settings_General14 * WooCommerce_Simple_Buy_Settings_Buy_Now_Settings 17 15 */ 18 16 class WooCommerce_Simple_Buy_Settings_Buy_Now_Settings extends WC_Settings_Page { … … 25 23 $this->label = esc_html__( 'WC Simple Buy Now', 'woocommerce-simple-buy-now' ); 26 24 27 add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );28 add_filter( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ));29 add_filter( 'woocommerce_settings_' . $this->id, array( $this, 'output_settings' ));30 add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ));25 add_filter( 'woocommerce_settings_tabs_array', [ $this, 'add_settings_page' ], 20 ); 26 add_filter( 'woocommerce_sections_' . $this->id, [ $this, 'output_sections' ] ); 27 add_filter( 'woocommerce_settings_' . $this->id, [ $this, 'output_settings' ] ); 28 add_action( 'woocommerce_settings_save_' . $this->id, [ $this, 'save' ] ); 31 29 } 32 30 … … 37 35 */ 38 36 public function get_sections() { 39 $sections = array( 40 '' => esc_html__( 'General', 'woocommerce-simple-buy-now' ), 41 ); 37 $sections = [ 38 '' => esc_html__( 'General', 'woocommerce-simple-buy-now' ), 39 // 'customize' => esc_html__( 'Customize', 'woocommerce-simple-buy-now' ), 40 ]; 41 42 42 return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections ); 43 43 } … … 49 49 */ 50 50 public function get_positions() { 51 return apply_filters( 'woocommerce_simple_buy_get_postitions', array( 52 'before' => esc_html__( 'Before Add To Cart Button', 'woocommerce-simple-buy-now' ), 53 'after' => esc_html__( 'After Add To Cart Button', 'woocommerce-simple-buy-now' ), 54 'replace' => esc_html__( 'Replace Add To Cart Button', 'woocommerce-simple-buy-now' ), 55 ) ); 51 return apply_filters( 'woocommerce_simple_buy_get_postitions', [ 52 'before' => esc_html__( 'Before Add To Cart Button', 'woocommerce-simple-buy-now' ), 53 'after' => esc_html__( 'After Add To Cart Button', 'woocommerce-simple-buy-now' ), 54 'replace' => esc_html__( 'Replace Add To Cart Button', 'woocommerce-simple-buy-now' ), 55 'before_quantity' => esc_html__( 'Before Quantity Input', 'woocommerce-simple-buy-now' ), 56 'after_quantity' => esc_html__( 'After Quantity Input', 'woocommerce-simple-buy-now' ), 57 'shortcode' => esc_html__( 'Use a Shortcode (for developer)', 'woocommerce-simple-buy-now' ), 58 ] ); 56 59 } 57 60 … … 62 65 */ 63 66 public function get_redirects() { 64 return apply_filters( 'woocommerce_simple_buy_get_redirects', array(67 return apply_filters( 'woocommerce_simple_buy_get_redirects', [ 65 68 'popup' => esc_html__( 'Use pop-up', 'woocommerce-simple-buy-now' ), 66 69 'checkout' => esc_html__( 'Redirect to the checkout page (skip the cart page)', 'woocommerce-simple-buy-now' ), 67 ));70 ] ); 68 71 } 69 72 … … 81 84 * Gets settings. 82 85 * 83 * @param array $ sectionsection.84 * @return array85 * /86 public function get_settings( $section = null ) {87 $settings = array();88 89 if ( '' == $section ) {90 return $this->get_general();91 } else {92 $settings = apply_filters( 'woocommerce_simple_buy_section_settings', array() ); 93 }94 95 return $settings;86 * @param array $current_section Current section. 87 * 88 * @return array 89 */ 90 public function get_settings( $current_section = '' ) { 91 // if ( 'customize' === $current_section ) { 92 // $settings = $this->get_customize(); 93 // } else { 94 $settings = $this->get_general(); 95 96 // } 97 98 return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section ); 96 99 } 97 100 … … 102 105 */ 103 106 public function get_general() { 104 $settings _array = array();105 106 $settings _array[] = array(107 $settings = []; 108 109 $settings[] = [ 107 110 'name' => esc_html__( 'General Settings', 'woocommerce-simple-buy-now' ), 108 111 'type' => 'title', 109 'desc' => esc_html__( 'The following options are used to configure WC Simple Buy Now Actions','woocommerce-simple-buy-now' ),112 'desc' => esc_html__( 'The following options are used to configure WC Simple Buy Now actions.', 'woocommerce-simple-buy-now' ), 110 113 'id' => 'woocommerce_simple_buy_settings_start', 111 );112 113 $settings _array[] = array(114 'name' => esc_html__( 'Enable Simple Buy Now', 'woocommerce-simple-buy-now' ),115 'id' => 'woocommerce_simple_buy_single_product_enable',116 'type' => 'checkbox',117 'default' => 'yes',118 );119 120 $settings _array[] = array(114 ]; 115 116 $settings[] = [ 117 'name' => esc_html__( 'Enable Simple Buy Now', 'woocommerce-simple-buy-now' ), 118 'id' => 'woocommerce_simple_buy_single_product_enable', 119 'type' => 'checkbox', 120 'default' => 'yes', 121 ]; 122 123 $settings[] = [ 121 124 'name' => esc_html__( 'Redirect', 'woocommerce-simple-buy-now' ), 122 125 'desc_tip' => esc_html__( 'Use pop-up or redirect to the checkout page', 'woocommerce-simple-buy-now' ), … … 125 128 'default' => 'popup', 126 129 'options' => $this->get_redirects(), 127 );128 129 $settings _array[] = array(130 ]; 131 132 $settings[] = [ 130 133 'name' => esc_html__( 'Simple Buy Now Button Position', 'woocommerce-simple-buy-now' ), 131 134 'desc_tip' => esc_html__( 'Where the button need to be added in single page .. before / after / replace', 'woocommerce-simple-buy-now' ), … … 135 138 'default' => 'before', 136 139 'options' => $this->get_positions(), 137 );138 139 $settings _array[] = array(140 ]; 141 142 $settings[] = [ 140 143 'name' => esc_html__( 'Simple Buy Button Title', 'woocommerce-simple-buy-now' ), 141 144 'desc_tip' => esc_html__( 'Simple Buy Button Title', 'woocommerce-simple-buy-now' ), … … 143 146 'type' => 'text', 144 147 'default' => esc_html__( 'Buy Now', 'woocommerce-simple-buy-now' ), 145 );146 147 $settings _array[] = array(148 'name' => esc_html__( 'Reset Cart before Buy Now', 'woocommerce-simple-buy-now' ),149 'id' => 'woocommerce_simple_buy_single_product_reset_cart',150 'type' => 'checkbox',151 );152 153 $settings _array[] = array(154 'name' => esc_html__( 'Remove Quantity input', 'woocommerce-simple-buy-now' ),155 'id' => 'woocommerce_simple_buy_single_product_remove_quantity',156 'type' => 'checkbox',157 );158 159 $settings _array[] = array(148 ]; 149 150 $settings[] = [ 151 'name' => esc_html__( 'Reset Cart before Buy Now', 'woocommerce-simple-buy-now' ), 152 'id' => 'woocommerce_simple_buy_single_product_reset_cart', 153 'type' => 'checkbox', 154 ]; 155 156 $settings[] = [ 157 'name' => esc_html__( 'Remove Quantity input', 'woocommerce-simple-buy-now' ), 158 'id' => 'woocommerce_simple_buy_single_product_remove_quantity', 159 'type' => 'checkbox', 160 ]; 161 162 $settings[] = [ 160 163 'type' => 'sectionend', 161 164 'id' => 'woocommerce_simple_buy_settings_end', 162 ); 163 164 return apply_filters( 'woocommerce_quick_buy_general_settings', $settings_array ); 165 ]; 166 167 return apply_filters( 'woocommerce_quick_buy_general_settings', $settings ); 168 } 169 170 /** 171 * Gets customize settings. 172 * 173 * @return array 174 */ 175 public function get_customize() { 176 $settings = []; 177 178 $settings[] = [ 179 'name' => esc_html__( 'Customize Settings', 'woocommerce-simple-buy-now' ), 180 'type' => 'title', 181 'desc' => esc_html__( 'The following options are used to configure WC Simple Buy Now style.', 'woocommerce-simple-buy-now' ), 182 'id' => 'woocommerce_simple_buy_settings_start', 183 ]; 184 185 $settings[] = [ 186 'name' => esc_html__( 'Button style', 'woocommerce-simple-buy-now' ), 187 'desc_tip' => esc_html__( 'Use theme style or customize', 'woocommerce-simple-buy-now' ), 188 'id' => 'woocommerce_simple_buy_customize', 189 'type' => 'radio', 190 'default' => 'theme', 191 'options' => [ 192 'theme' => esc_html__( 'Theme style (default)', 'woocommerce-simple-buy-now' ), 193 'customize' => esc_html__( 'Customize', 'woocommerce-simple-buy-now' ), 194 ], 195 ]; 196 197 $settings[] = [ 198 'type' => 'sectionend', 199 'id' => 'woocommerce_simple_buy_customize_end', 200 ]; 201 202 $settings[] = [ 203 'name' => esc_html__( 'Normal colors', 'woocommerce-simple-buy-now' ), 204 'type' => 'title', 205 'id' => 'woocommerce_simple_buy_normal_colors', 206 ]; 207 208 $settings[] = [ 209 'name' => esc_html__( 'Color', 'woocommerce-simple-buy-now' ), 210 'id' => 'woocommerce_simple_buy_button_color', 211 'type' => 'color', 212 'css' => 'width:6em;', 213 'autoload' => false, 214 'desc_tip' => true, 215 ]; 216 217 $settings[] = [ 218 'name' => esc_html__( 'Background color', 'woocommerce-simple-buy-now' ), 219 'id' => 'woocommerce_simple_buy_button_bgcolor', 220 'type' => 'color', 221 'css' => 'width:6em;', 222 'autoload' => false, 223 'desc_tip' => true, 224 ]; 225 226 $settings[] = [ 227 'name' => esc_html__( 'Border color', 'woocommerce-simple-buy-now' ), 228 'id' => 'woocommerce_simple_buy_button_border_color', 229 'type' => 'color', 230 'css' => 'width:6em;', 231 'autoload' => false, 232 'desc_tip' => true, 233 ]; 234 235 $settings[] = [ 236 'type' => 'sectionend', 237 'id' => 'woocommerce_simple_buy_colors_end', 238 ]; 239 240 $settings[] = [ 241 'name' => esc_html__( 'Hover colors', 'woocommerce-simple-buy-now' ), 242 'type' => 'title', 243 'id' => 'woocommerce_simple_buy_hover_colors', 244 ]; 245 246 $settings[] = [ 247 'name' => esc_html__( 'Color', 'woocommerce-simple-buy-now' ), 248 'id' => 'woocommerce_simple_buy_button_hover_color', 249 'type' => 'color', 250 'css' => 'width:6em;', 251 'autoload' => false, 252 'desc_tip' => true, 253 ]; 254 255 $settings[] = [ 256 'name' => esc_html__( 'Background color', 'woocommerce-simple-buy-now' ), 257 'id' => 'woocommerce_simple_buy_button_hover_bgcolor', 258 'type' => 'color', 259 'css' => 'width:6em;', 260 'autoload' => false, 261 'desc_tip' => true, 262 ]; 263 264 $settings[] = [ 265 'name' => esc_html__( 'Border color', 'woocommerce-simple-buy-now' ), 266 'id' => 'woocommerce_simple_buy_button_hover_border_color', 267 'type' => 'color', 268 'css' => 'width:6em;', 269 'autoload' => false, 270 'desc_tip' => true, 271 ]; 272 273 $settings[] = [ 274 'type' => 'sectionend', 275 'id' => 'woocommerce_simple_buy_hover_colors_end', 276 ]; 277 278 return apply_filters( 'woocommerce_quick_buy_customize_settings', $settings ); 165 279 } 166 280 … … 173 287 WC_Admin_Settings::save_fields( $settings ); 174 288 } 175 176 289 } 177 290 -
woo-simple-buy-now/trunk/readme.txt
r1939463 r1967906 4 4 Requires at least: 4.6 5 5 Tested up to: 4.9.8 6 Stable tag: 1.0. 66 Stable tag: 1.0.7 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 25 25 * Contact me and hire me [Website](http://ndoublehwp.com/) 26 26 * I would be happy if you leave a review :) [Review](https://wordpress.org/support/plugin/woo-simple-buy-now/reviews/) 27 28 = Settings = 29 Go to `Dashboard > WooCommerce > Settings > WC Simple Buy Now` tab 30 General: 31 32 * Enable Simple Buy Now: Activate Buy Now feature 33 * Redirect: Use a *Pop-up* or *Redirect to the checkout page (skip the cart page)* 34 * Simple Buy Now Button Position: Set a position for Buy Now button 35 * Simple Buy Button Title: the title default is *Buy Now* 36 * Reset Cart before Buy Now: Apcept reset cart before Buy Now 37 * Remove Quantity input: Hide quantity input by CSS code 38 39 = Shortcode for developer = 40 `[woocommerce_simple_buy_now_button]` 41 Arguments: 42 *title* 43 *class* 44 If you are a developer, you can use this shortcode at `content-single-product` template or its child. It should be written on the inside of the form cart. 45 For example, `<?php do_shortcode( '[woocommerce_simple_buy_now_button title="Buy Now" class="wsb-button"]' ); ?>` 27 46 28 47 == Installation == … … 58 77 == Changelog == 59 78 79 = 1.0.7 - 2018-11-02 = 80 * Add - Add button positions. 81 * Add - Support a shortcode for developer. 82 60 83 = 1.0.6 - 2018-09-10 = 61 84 * Fix - Variable product when selected. -
woo-simple-buy-now/trunk/woocommerce-simple-buy-now.php
r1939463 r1967906 8 8 * Text Domain: woocommerce-simple-buy-now 9 9 * Domain Path: /languages 10 * Version: 1.0. 610 * Version: 1.0.7 11 11 * 12 12 * @package Woocommerce_Simple_Buy_Now … … 63 63 } 64 64 65 define( 'WOO_SIMPLE_BUY_VERSION', '1.0. 6' );65 define( 'WOO_SIMPLE_BUY_VERSION', '1.0.7' ); 66 66 define( 'WOO_SIMPLE_BUY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); 67 67 define( 'WOO_SIMPLE_BUY_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); … … 160 160 if ( $this->is_before_button() ) { 161 161 add_action( 'woocommerce_before_add_to_cart_button', [ $this, 'add_simple_buy_button' ] ); 162 } else { 163 add_action( 'woocommerce_after_add_to_cart_button', [ $this, 'add_simple_buy_button' ] ); 162 } elseif ( $this->is_after_button() ) { 163 add_action( 'woocommerce_after_add_to_cart_button', [ $this, 'add_simple_buy_button' ], 5 ); 164 } elseif ( $this->is_before_quantity_input() ) { 165 add_action( 'woocommerce_before_add_to_cart_quantity', [ $this, 'add_simple_buy_button' ] ); 166 } elseif ( $this->is_after_quantity_input() ) { 167 add_action( 'woocommerce_after_add_to_cart_quantity', [ $this, 'add_simple_buy_button' ], 5 ); 168 } elseif ( $this->is_replace_button() ) { 169 add_action( 'woocommerce_after_add_to_cart_button', [ $this, 'add_simple_buy_button' ], 5 ); 164 170 } 165 171 166 172 add_action( 'wsb_before_add_to_cart', [ $this, 'reset_cart' ], 10 ); 173 add_shortcode( 'woocommerce_simple_buy_now_button', [ $this, 'add_shortcode_button' ] ); 167 174 } 168 175 … … 178 185 */ 179 186 public function settings_page( $integrations ) { 180 foreach ( glob( WOO_SIMPLE_BUY_PLUGIN_PATH . '/includes/woocommerce-settings.php*' ) as $file ) { 181 $integrations[] = require_once( $file ); 182 } 187 $integrations[] = require WOO_SIMPLE_BUY_PLUGIN_PATH . '/includes/woocommerce-settings.php'; 183 188 184 189 return $integrations; … … 222 227 */ 223 228 public function body_class( $classes ) { 224 $button_position = get_option( 'woocommerce_simple_buy_single_product_position' );225 226 229 if ( is_product() ) { 227 $classes[] = 'woocommerce-simple-buy-now'; 228 229 if ( $this->is_replace_button() ) { 230 $classes[] = 'woocommerce-simple-buy-now--remove_add_to_cart_btn'; 231 } 230 $button_position = get_option( 'woocommerce_simple_buy_single_product_position' ); 231 $classes[] = 'woocommerce-simple-buy-now'; 232 $classes[] = 'woocommerce-simple-buy-now--button-' . esc_attr( $button_position ) . '-cart'; 232 233 233 234 if ( $this->is_remove_quantity() ) { 234 $classes[] = 'woocommerce-simple-buy-now--remove _quantity_input';235 $classes[] = 'woocommerce-simple-buy-now--remove-quantity'; 235 236 } 236 237 } … … 333 334 334 335 /** 336 * If button position is before `quantity` input. 337 * 338 * @return boolean 339 */ 340 public function is_before_quantity_input() { 341 return ( 'before_quantity' === $this->get_position() ); 342 } 343 344 /** 345 * If button position is after `quantity` input. 346 * 347 * @return boolean 348 */ 349 public function is_after_quantity_input() { 350 return ( 'after_quantity' === $this->get_position() ); 351 } 352 353 /** 354 * If button position is after `quantity` input. 355 * 356 * @return boolean 357 */ 358 public function is_shortcode() { 359 return ( 'shortcode' === $this->get_position() ); 360 } 361 362 /** 335 363 * If remove quantity input. 336 364 * … … 347 375 */ 348 376 public function add_simple_buy_button() { 349 global $product; 350 351 $btn_class = apply_filters( 'wsb_single_product_button_classes', [ 352 'wsb-button', 353 'js-wsb-add-to-cart', 354 ] ); 355 356 $args = apply_filters( 'wsb_buy_now_button_args', [ 357 'type' => 'submit', 358 'class' => $btn_class, 359 'title' => esc_html( $this->get_button_title() ), 360 'attributes' => '', 361 ], $this->get_redirect(), $this->get_position() ); 377 $args = $this->get_button_default_args(); 362 378 363 379 $this->button_template( $args ); … … 375 391 376 392 ?> 377 <button <?php echo isset( $args['type'] ) ? 'type="' . esc_attr( $args['type'] ) . '"' : ''; ?> value="<?php echo esc_attr( $product->get_id() ); ?>" class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $args['class'] ) ) ); ?>" <?php echo isset( $args['attributes'] ) ? $args['attributes'] : ''; // WPCS: xss ok. ?>>393 <button <?php echo isset( $args['type'] ) ? 'type="' . esc_attr( $args['type'] ) . '"' : ''; ?> value="<?php echo esc_attr( $product->get_id() ); ?>" class="<?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', $args['class'] ) ) ); ?>" <?php echo isset( $args['attributes'] ) ? $args['attributes'] : ''; // WPCS: xss ok. ?>> 378 394 <?php echo isset( $args['title'] ) ? esc_html( $args['title'] ) : ''; ?> 379 </button>395 </button> 380 396 <?php 381 397 } … … 389 405 } 390 406 ?> 391 <div class="wsb-modal">392 <div class="wsb-modal-overlay wsb-modal-toggle"></div>393 <div class="wsb-modal-wrapper wsb-modal-transition">407 <div class="wsb-modal"> 408 <div class="wsb-modal-overlay wsb-modal-toggle"></div> 409 <div class="wsb-modal-wrapper wsb-modal-transition"> 394 410 395 411 <?php do_action( 'wsb_modal_header_content' ); ?> 396 412 397 <div class="wsb-modal-header">398 <button class="wsb-modal-close wsb-modal-toggle">399 <span aria-hidden="true">×</span>400 </button>401 </div>402 <div class="wsb-modal-body">413 <div class="wsb-modal-header"> 414 <button class="wsb-modal-close wsb-modal-toggle"> 415 <span aria-hidden="true">×</span> 416 </button> 417 </div> 418 <div class="wsb-modal-body"> 403 419 <?php do_action( 'wsb_before_modal_body_content' ); ?> 404 420 405 <div class="wsb-modal-content"></div>421 <div class="wsb-modal-content"></div> 406 422 407 423 <?php do_action( 'wsb_after_modal_body_content' ); ?> 408 424 409 </div>410 </div>411 </div>425 </div> 426 </div> 427 </div> 412 428 <?php 413 429 } … … 503 519 } 504 520 } 505 } 521 522 /** 523 * Register shortcode button 524 * 525 * @param array $atts Attributes. 526 */ 527 public function add_shortcode_button( $atts ) { 528 $atts = shortcode_atts( $this->get_button_default_args(), $atts, 'woocommerce_simple_buy_now_button' ); 529 530 ob_start(); 531 532 $this->button_template( $atts ); 533 534 return ob_get_clean(); 535 } 536 537 /** 538 * Gets button default args 539 * 540 * @return array 541 */ 542 public function get_button_default_args() { 543 $btn_class = apply_filters( 'wsb_single_product_button_classes', [ 544 'wsb-button', 545 'js-wsb-add-to-cart', 546 ] ); 547 548 return apply_filters( 'wsb_buy_now_button_args', [ 549 'type' => 'submit', 550 'class' => $btn_class, 551 'title' => esc_html( $this->get_button_title() ), 552 'attributes' => '', 553 ], $this->get_redirect(), $this->get_position() ); 554 } 555 }
Note: See TracChangeset
for help on using the changeset viewer.