Plugin Directory

Changeset 1123885


Ignore:
Timestamp:
03/30/2015 08:17:10 PM (11 years ago)
Author:
genero.us
Message:

Added initial support for the cart.

Location:
generous/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • generous/trunk/admin/class-wp-generous-admin-settings.php

    r1015539 r1123885  
    128128
    129129    /**
    130      * Output the input for permalink.
     130     * Output the input for enabling overlay.
    131131     *
    132132     * @since    0.1.0
     
    146146
    147147    /**
    148      * Output the input for permalink.
     148     * Output the input for enabling load more.
    149149     *
    150150     * @since    0.1.0
     
    164164
    165165    /**
    166      * Output the input for permalink.
     166     * Output the input for sliders per page.
    167167     *
    168168     * @since    0.1.0
     
    172172        echo "<input name=\"{$this->option_group}[sliders_per_page]\" size=\"20\" type=\"text\" value=\"{$this->options['sliders_per_page']}\" /> ";
    173173        echo "<span class=\"description\">Max. 50</span>";
     174
     175    }
     176
     177    /**
     178     * Output the input for enabling cart.
     179     *
     180     * @since    0.1.3
     181     */
     182    public function output_input_enable_cart() {
     183
     184        if( true === $this->options['enable_cart'] ) {
     185            $value = 'checked ';
     186        } else {
     187            $value = '';
     188        }
     189
     190        echo "<input name=\"{$this->option_group}[enable_cart]\" type=\"checkbox\" value=\"true\" {$value}/> ";
     191        echo "<span class=\"description\">Allow users to add sliders to a cart and checkout multiple purchases.</span>";
     192
     193    }
     194
     195    /**
     196     * Output the input for automatically opening cart.
     197     *
     198     * @since    0.1.3
     199     */
     200    public function output_input_cart_auto_open() {
     201
     202        if( true === $this->options['cart_auto_open'] ) {
     203            $value = 'checked ';
     204        } else {
     205            $value = '';
     206        }
     207
     208        echo "<input name=\"{$this->option_group}[cart_auto_open]\" type=\"checkbox\" value=\"true\" {$value}/> ";
     209        echo "<span class=\"description\">Automatically open the cart when a slider is added.</span>";
     210
     211    }
     212
     213    /**
     214     * Output the input for cart primary color.
     215     *
     216     * @since    0.1.3
     217     */
     218    public function output_input_cart_color_primary() {
     219
     220        $value = '';
     221
     222        if( isset( $this->options['cart_color_primary'] ) ) {
     223            $value = $this->options['cart_color_primary'];
     224        }
     225
     226        echo "<input name=\"{$this->option_group}[cart_color_primary]\" size=\"20\" type=\"text\" value=\"{$value}\" /> ";
     227        echo "<span class=\"description\">Color hex code used for background elements.</span>";
     228
     229    }
     230
     231    /**
     232     * Output the input for cart secondary color.
     233     *
     234     * @since    0.1.3
     235     */
     236    public function output_input_cart_color_secondary() {
     237
     238        $value = '';
     239
     240        if( isset( $this->options['cart_color_secondary'] ) ) {
     241            $value = $this->options['cart_color_secondary'];
     242        }
     243
     244        echo "<input name=\"{$this->option_group}[cart_color_secondary]\" size=\"20\" type=\"text\" value=\"{$value}\" /> ";
     245        echo "<span class=\"description\">Color hex code used for foreground and text elements.</span>";
     246
     247    }
     248
     249    /**
     250     * Output the input for cart accent color.
     251     *
     252     * @since    0.1.3
     253     */
     254    public function output_input_cart_color_accent() {
     255
     256        $value = '';
     257
     258        if( isset( $this->options['cart_color_accent'] ) ) {
     259            $value = $this->options['cart_color_accent'];
     260        }
     261
     262        echo "<input name=\"{$this->option_group}[cart_color_accent]\" size=\"20\" type=\"text\" value=\"{$value}\" /> ";
     263        echo "<span class=\"description\">Color hex code used for highlighting elements.</span>";
     264
     265    }
     266
     267    /**
     268     * Output the input for cart secondary color.
     269     *
     270     * @since    0.1.3
     271     */
     272    public function output_input_advanced_disable_overlay() {
     273
     274        if( true === $this->options['js_v1_disable_overlay'] ) {
     275            $value = 'checked ';
     276        } else {
     277            $value = '';
     278        }
     279
     280        echo "<input name=\"{$this->option_group}[js_v1_disable_overlay]\" type=\"checkbox\" value=\"true\" {$value}/> ";
     281        echo "<span class=\"description\">Disables v1 slider overlay.</span>";
    174282
    175283    }
     
    226334        }
    227335
     336        if ( isset( $input['enable_cart'] ) ) {
     337            $results['enable_cart'] = true;
     338        } else {
     339            $results['enable_cart'] = false;
     340        }
     341
     342        if ( isset( $input['cart_auto_open'] ) ) {
     343            $results['cart_auto_open'] = true;
     344        } else {
     345            $results['cart_auto_open'] = false;
     346        }
     347
     348        if ( isset( $input['cart_color_primary'] ) ) {
     349            $results['cart_color_primary'] = str_replace(array('#', ' '), '', $input['cart_color_primary']);
     350        }
     351
     352        if ( isset( $input['cart_color_secondary'] ) ) {
     353            $results['cart_color_secondary'] = str_replace(array('#', ' '), '', $input['cart_color_secondary']);
     354        }
     355
     356        if ( isset( $input['cart_color_accent'] ) ) {
     357            $results['cart_color_accent'] = str_replace(array('#', ' '), '', $input['cart_color_accent']);
     358        }
     359
     360        if ( isset( $input['js_v1_disable_overlay'] ) ) {
     361            $results['js_v1_disable_overlay'] = true;
     362        } else {
     363            $results['js_v1_disable_overlay'] = false;
     364        }
     365
    228366        return $results;
    229367
  • generous/trunk/admin/class-wp-generous-admin.php

    r1015539 r1123885  
    152152        add_settings_section(
    153153            'section_general',
    154             'General Settings',
     154            'General',
    155155            '',
    156156            $this->settings->option_group
     
    159159        add_settings_section(
    160160            'section_sliders',
    161             'Slider Settings',
     161            'Slider',
     162            '',
     163            $this->settings->option_group
     164        );
     165
     166        add_settings_section(
     167            'section_cart',
     168            'Cart',
     169            '',
     170            $this->settings->option_group
     171        );
     172
     173        add_settings_section(
     174            'section_advanced',
     175            'Advanced',
    162176            '',
    163177            $this->settings->option_group
     
    182196
    183197        // Slider Settings
    184         add_settings_section(
    185             'section_sliders',
    186             'Slider Settings',
    187             '',
    188             $this->settings->option_group
    189         );
    190 
    191198        add_settings_field(
    192199            'enable_overlay',
     
    213220        );
    214221
     222        // Cart Settings
     223        add_settings_field(
     224            'enable_cart',
     225            'Enable Cart',
     226            array( $this->settings, 'output_input_enable_cart' ),
     227            $this->settings->option_group,
     228            'section_cart'
     229        );
     230
     231        add_settings_field(
     232            'cart_auto_open',
     233            'Enable Auto Open',
     234            array( $this->settings, 'output_input_cart_auto_open' ),
     235            $this->settings->option_group,
     236            'section_cart'
     237        );
     238
     239        add_settings_field(
     240            'cart_color_primary',
     241            'Primary Color',
     242            array( $this->settings, 'output_input_cart_color_primary' ),
     243            $this->settings->option_group,
     244            'section_cart'
     245        );
     246
     247        add_settings_field(
     248            'cart_color_secondary',
     249            'Secondary Color',
     250            array( $this->settings, 'output_input_cart_color_secondary' ),
     251            $this->settings->option_group,
     252            'section_cart'
     253        );
     254
     255        add_settings_field(
     256            'cart_color_accent',
     257            'Accent Color',
     258            array( $this->settings, 'output_input_cart_color_accent' ),
     259            $this->settings->option_group,
     260            'section_cart'
     261        );
     262
     263        // Advanced Settings
     264        add_settings_field(
     265            'js_v1_disable_overlay',
     266            'Force v0 Slider Overlay',
     267            array( $this->settings, 'output_input_advanced_disable_overlay' ),
     268            $this->settings->option_group,
     269            'section_advanced'
     270        );
     271
    215272    }
    216273
  • generous/trunk/generous.php

    r1037208 r1123885  
    44 * Plugin URI:        https://github.com/generous/generous-wordpress
    55 * Description:       The official Generous plugin that allows you to easily generate a store.
    6  * Version:           0.1.2
     6 * Version:           0.1.3
    77 * Author:            Generous
    88 * Author URI:        https://genero.us
     
    4040     * @var      string                $version         The current version of the plugin.
    4141     */
    42     protected $version = '0.1.2';
     42    protected $version = '0.1.3';
    4343
    4444    /**
  • generous/trunk/public/class-wp-generous-public.php

    r1037208 r1123885  
    193193     */
    194194    public function enqueue_styles() {
    195         wp_enqueue_style( $this->name, plugin_dir_url( dirname( __FILE__ ) ) . 'assets/css/wp-generous.css', array(), $this->version, 'all' );
     195        wp_enqueue_style( $this->name, plugin_dir_url( dirname( __FILE__ ) ) . 'assets/css/wp-generous.css', array(), NULL, 'all' );
    196196    }
    197197
     
    203203    public function enqueue_scripts() {
    204204
    205         wp_register_script( $this->name, plugin_dir_url( dirname( __FILE__ ) ) . 'assets/js/wp-generous.js', array( 'jquery' ), $this->version, false );
     205        wp_register_script( $this->name, plugin_dir_url( dirname( __FILE__ ) ) . 'assets/js/wp-generous.js', array( 'jquery' ), NULL, false );
    206206        wp_enqueue_script( $this->name );
    207207
    208208        $protocol = is_ssl() ? 'https' : 'http';
    209 
    210         wp_register_script( "{$this->name}-js", "$protocol://js.genero.us/", array(), $this->version, false );
     209       
     210        $url = "$protocol://js.genero.us/";
     211        $url_params = "";
     212
     213        if ( $this->options['enable_cart'] ) {
     214
     215            $url_params .= "?enableCart=true";
     216
     217            if ( $this->options['cart_auto_open'] ) {
     218                $url_params .= "&cartAutoOpen=true";
     219            }
     220
     221            if ( $this->options['cart_color_primary'] ) {
     222                $url_params .= "&cartColorPrimary={$this->options['cart_color_primary']}";
     223            }
     224
     225            if ( $this->options['cart_color_secondary'] ) {
     226                $url_params .= "&cartColorSecondary={$this->options['cart_color_secondary']}";
     227            }
     228
     229            if ( $this->options['cart_color_accent'] ) {
     230                $url_params .= "&cartColorAccent={$this->options['cart_color_accent']}";
     231            }
     232
     233        }
     234
     235        if ( $this->options['js_v1_disable_overlay'] ) {
     236
     237            if ( substr( $url_params, 0, 1 ) !== "?" ) {
     238                $url_params .= "?";
     239            } else {
     240                $url_params .= "&";
     241            }
     242
     243            $url_params .= "enableOverlay=false";
     244
     245        }
     246
     247        $url .= $url_params;
     248
     249        wp_register_script( "{$this->name}-js", $url, array(), NULL, false );
    211250        wp_enqueue_script( "{$this->name}-js" );
    212251
  • generous/trunk/readme.txt

    r1037208 r1123885  
    44Requires at least: 3.8
    55Tested up to: 4.0
    6 Stable tag: 0.1.2
     6Stable tag: 0.1.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8484== Changelog ==
    8585
     86= 0.1.3 =
     87* Added initial support for the cart.
     88
    8689= 0.1.2 =
    8790* Fixed a minor bug on the_posts hook.
Note: See TracChangeset for help on using the changeset viewer.