Plugin Directory

Changeset 1967906


Ignore:
Timestamp:
11/02/2018 04:45:24 PM (7 years ago)
Author:
ndoublehwp
Message:

Update v1.0.7

Location:
woo-simple-buy-now
Files:
16 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • woo-simple-buy-now/trunk/assets/css/woocommerce-simple-buy-now.css

    r1939463 r1967906  
    11/* Page wrapper */
    22.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;
    77}
    88
    99/* Icons */
    1010.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;
    1616}
    1717
     
    2222/* 1. Ensure this sits above everything when visible */
    2323.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%;
    3131}
    3232
    3333.wsb-modal.is-visible {
    34     visibility: visible;
     34    visibility: visible;
    3535}
    3636
    3737.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;
    4848}
    4949
    5050.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;
    5454}
    5555
    5656.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;
    6969}
    7070
    7171.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;
    7575}
    7676
    7777.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%;
    8181}
    8282
    8383@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    }
    8787}
    8888
    8989@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    }
    9393}
    9494
    9595.wsb-modal-header,
    9696.wsb-modal-content {
    97     padding: 1em;
     97    padding: 1em;
    9898}
    9999
    100100.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;
    105105}
    106106
    107107.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;
    116116}
    117117
    118118.wsb-modal-close:hover {
    119     color: #ff6029;
    120     background-color: transparent;
     119    color: #ff6029;
     120    background-color: transparent;
    121121}
    122122
    123123.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;
    128128}
    129129
    130130.wsb-modal-content > *:first-child {
    131     margin-top: 0;
     131    margin-top: 0;
    132132}
    133133
    134134.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;
    144144}
    145145
    146146.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;
    148158}
    149159
    150160.wsb-button.wsb-loading {
    151     cursor: not-allowed;
     161    cursor: not-allowed;
    152162}
    153163
    154164.wsb-button.disabled {
    155     cursor: not-allowed;
     165    cursor: not-allowed;
    156166}
    157167
    158168.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;
    168178}
    169179
    170180.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;
    185195}
    186196
    187197/* 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  
    11<?php
    22/**
    3  * WooCommerce General Settings
     3 * WooCommerce Simple Buy Now Settings
    44 *
    5  * @author      WooThemes
    6  * @category    Admin
    7  * @package     WooCommerce/Admin
    8  * @version     2.1.0
     5 * @author      ndoublehwp
     6 * @version     1.0.8
    97 */
    108
     
    1412
    1513/**
    16  * WC_Admin_Settings_General
     14 * WooCommerce_Simple_Buy_Settings_Buy_Now_Settings
    1715 */
    1816class WooCommerce_Simple_Buy_Settings_Buy_Now_Settings extends WC_Settings_Page {
     
    2523        $this->label = esc_html__( 'WC Simple Buy Now', 'woocommerce-simple-buy-now' );
    2624
    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' ] );
    3129    }
    3230
     
    3735     */
    3836    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
    4242        return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
    4343    }
     
    4949     */
    5050    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        ] );
    5659    }
    5760
     
    6265     */
    6366    public function get_redirects() {
    64         return apply_filters( 'woocommerce_simple_buy_get_redirects', array(
     67        return apply_filters( 'woocommerce_simple_buy_get_redirects', [
    6568            'popup'    => esc_html__( 'Use pop-up', 'woocommerce-simple-buy-now' ),
    6669            'checkout' => esc_html__( 'Redirect to the checkout page (skip the cart page)', 'woocommerce-simple-buy-now' ),
    67         ) );
     70        ] );
    6871    }
    6972
     
    8184     * Gets settings.
    8285     *
    83      * @param  array $section section.
    84      * @return array
    85      */
    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 );
    9699    }
    97100
     
    102105     */
    103106    public function get_general() {
    104         $settings_array = array();
    105 
    106         $settings_array[] = array(
     107        $settings = [];
     108
     109        $settings[] = [
    107110            'name' => esc_html__( 'General Settings', 'woocommerce-simple-buy-now' ),
    108111            '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' ),
    110113            '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[] = [
    121124            'name'     => esc_html__( 'Redirect', 'woocommerce-simple-buy-now' ),
    122125            'desc_tip' => esc_html__( 'Use pop-up or redirect to the checkout page', 'woocommerce-simple-buy-now' ),
     
    125128            'default'  => 'popup',
    126129            'options'  => $this->get_redirects(),
    127         );
    128 
    129         $settings_array[] = array(
     130        ];
     131
     132        $settings[] = [
    130133            'name'     => esc_html__( 'Simple Buy Now Button Position', 'woocommerce-simple-buy-now' ),
    131134            'desc_tip' => esc_html__( 'Where the button need to be added in single page .. before / after / replace', 'woocommerce-simple-buy-now' ),
     
    135138            'default'  => 'before',
    136139            'options'  => $this->get_positions(),
    137         );
    138 
    139         $settings_array[] = array(
     140        ];
     141
     142        $settings[] = [
    140143            'name'     => esc_html__( 'Simple Buy Button Title', 'woocommerce-simple-buy-now' ),
    141144            'desc_tip' => esc_html__( 'Simple Buy Button Title', 'woocommerce-simple-buy-now' ),
     
    143146            'type'     => 'text',
    144147            '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[] = [
    160163            'type' => 'sectionend',
    161164            '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 );
    165279    }
    166280
     
    173287        WC_Admin_Settings::save_fields( $settings );
    174288    }
    175 
    176289}
    177290
  • woo-simple-buy-now/trunk/readme.txt

    r1939463 r1967906  
    44Requires at least: 4.6
    55Tested up to: 4.9.8
    6 Stable tag: 1.0.6
     6Stable tag: 1.0.7
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2525* Contact me and hire me [Website](http://ndoublehwp.com/)
    2626* I would be happy if you leave a review :) [Review](https://wordpress.org/support/plugin/woo-simple-buy-now/reviews/)
     27
     28= Settings =
     29Go to `Dashboard > WooCommerce > Settings > WC Simple Buy Now` tab
     30General:
     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]`
     41Arguments:
     42*title*
     43*class*
     44If 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.
     45For example, `<?php do_shortcode( '[woocommerce_simple_buy_now_button title="Buy Now" class="wsb-button"]' ); ?>`
    2746
    2847== Installation ==
     
    5877== Changelog ==
    5978
     79= 1.0.7 - 2018-11-02 =
     80* Add - Add button positions.
     81* Add - Support a shortcode for developer.
     82
    6083= 1.0.6 - 2018-09-10 =
    6184* Fix - Variable product when selected.
  • woo-simple-buy-now/trunk/woocommerce-simple-buy-now.php

    r1939463 r1967906  
    88 * Text Domain:     woocommerce-simple-buy-now
    99 * Domain Path:     /languages
    10  * Version:         1.0.6
     10 * Version:         1.0.7
    1111 *
    1212 * @package         Woocommerce_Simple_Buy_Now
     
    6363}
    6464
    65 define( 'WOO_SIMPLE_BUY_VERSION', '1.0.6' );
     65define( 'WOO_SIMPLE_BUY_VERSION', '1.0.7' );
    6666define( 'WOO_SIMPLE_BUY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
    6767define( 'WOO_SIMPLE_BUY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     
    160160            if ( $this->is_before_button() ) {
    161161                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 );
    164170            }
    165171
    166172            add_action( 'wsb_before_add_to_cart', [ $this, 'reset_cart' ], 10 );
     173            add_shortcode( 'woocommerce_simple_buy_now_button', [ $this, 'add_shortcode_button' ] );
    167174        }
    168175
     
    178185     */
    179186    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';
    183188
    184189        return $integrations;
     
    222227     */
    223228    public function body_class( $classes ) {
    224         $button_position = get_option( 'woocommerce_simple_buy_single_product_position' );
    225 
    226229        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';
    232233
    233234            if ( $this->is_remove_quantity() ) {
    234                 $classes[] = 'woocommerce-simple-buy-now--remove_quantity_input';
     235                $classes[] = 'woocommerce-simple-buy-now--remove-quantity';
    235236            }
    236237        }
     
    333334
    334335    /**
     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    /**
    335363     * If remove quantity input.
    336364     *
     
    347375     */
    348376    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();
    362378
    363379        $this->button_template( $args );
     
    375391
    376392        ?>
    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. ?>>
    378394            <?php echo isset( $args['title'] ) ? esc_html( $args['title'] ) : ''; ?>
    379         </button>
     395        </button>
    380396        <?php
    381397    }
     
    389405        }
    390406        ?>
    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">
    394410
    395411                <?php do_action( 'wsb_modal_header_content' ); ?>
    396412
    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">
    403419                    <?php do_action( 'wsb_before_modal_body_content' ); ?>
    404420
    405                     <div class="wsb-modal-content"></div>
     421                    <div class="wsb-modal-content"></div>
    406422
    407423                    <?php do_action( 'wsb_after_modal_body_content' ); ?>
    408424
    409                 </div>
    410             </div>
    411         </div>
     425                </div>
     426            </div>
     427        </div>
    412428        <?php
    413429    }
     
    503519        }
    504520    }
    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.