Plugin Directory

Changeset 1204608


Ignore:
Timestamp:
07/23/2015 08:05:55 AM (11 years ago)
Author:
uiux
Message:

Adding more switches & scoville heat units

Location:
wooheat
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wooheat/trunk/admin/admin-wooheat.php

    r1203784 r1204608  
    1717
    1818        <table class="form-table">
     19            <tr>
     20                <th scope="row">Display 'Heat Rating' Label?</th>
     21                <td>
     22                    <label for="woo_heat_enable_label"><input name="woo_heat_enable_label" id="woo_heat_enable_label" type="checkbox" value="1" <?php checked( '1', get_option( 'woo_heat_enable_label', true) ); ?> /> Enable</label>
     23                </td>
     24            </tr>
     25            <tr>
     26                <th scope="row">Display rating chart?</th>
     27                <td>
     28                    <label for="woo_heat_enable_scale"><input name="woo_heat_enable_scale" id="woo_heat_enable_scale" type="checkbox" value="1" <?php checked( '1', get_option( 'woo_heat_enable_scale', true) ); ?> /> Enable</label>
     29                </td>
     30            </tr>
    1931            <tr>
    2032                <th scope="row">Cold Colour</th>
    2133                <td>
    22                     <input type="text" name="woo_heat_cold_temperature_colour" placeholder="<?php echo get_option('woo_heat_cold_temperature_colour', '#7DB558') ?>" value="<?php echo esc_attr( get_option('woo_heat_cold_temperature_colour') ); ?>" />
     34                    <input type="text" name="woo_heat_cold_temperature_colour" placeholder="<?php echo get_option('woo_heat_cold_temperature_colour', '#7DB558') ?>" value="<?php echo esc_attr( get_option('woo_heat_cold_temperature_colour', '#7DB558' ) ); ?>" />
    2335                    <p>You must enter valid HEX colour code, eg. #7DB558</p>
    2436                </td>
     
    2739                <th scope="row">Hot Colour</th>
    2840                <td>
    29                     <input type="text" name="woo_heat_hot_temperature_colour" placeholder="<?php echo get_option('woo_heat_hot_temperature_colour', '#FF1616') ?>" value="<?php echo esc_attr( get_option('woo_heat_hot_temperature_colour') ); ?>" />
     41                    <input type="text" name="woo_heat_hot_temperature_colour" placeholder="<?php echo get_option('woo_heat_hot_temperature_colour', '#FF1616') ?>" value="<?php echo esc_attr( get_option('woo_heat_hot_temperature_colour', '#FF1616') ); ?>" />
    3042                    <p>You must enter valid HEX colour code, eg. #FF1616</p>
    3143                </td>
     
    4052                </td>
    4153            </tr>
    42 
    43 
     54            <tr>
     55                <th scope="row">Display Scoville rating?</th>
     56                <td>
     57                    <label for="woo_heat_enable_scoville"><input name="woo_heat_enable_scoville" id="woo_heat_enable_scoville" type="checkbox" value="1" <?php checked( '1', get_option( 'woo_heat_enable_scoville', true ) ); ?> /> Enable</label>
     58                </td>
     59            </tr>
    4460
    4561        </table>
  • wooheat/trunk/readme.txt

    r1203787 r1204608  
    28283. How the heat ratings are displayed on a product page
    29294. The heat ratings location when editing a product
    30 5. Changing the colour of the heat rating chart
     305. The plugin admin screen
    3131
    3232== Changelog ==
    3333
     34= 1.2 =
     35* Can use plugin only to provide for sorting options
     36* Added ability to enable display of heat rating label, scoville units and heat chart
     37* Added in Scoville heat unit ratings to products
     38
    3439= 1.1 =
    35 *Added ability to use custom images to represent each rating over 10
    36 *Added ability to choose between and orage and white flame
     40* Added ability to use custom images to represent each rating over 10
     41* Added ability to choose between and orage and white flame
    3742
    3843= 1.0 =
    39 *Initial Release
     44* Initial Release
  • wooheat/trunk/wooheat.php

    r1203787 r1204608  
    55Plugin URI: http://uiux.me
    66Description: Woocommerce Plugin for adding Heat Ratings to products allowing items to be sorted by their heat value.
    7 Version: 1.1
     7Version: 1.2
    88Author: Ben Parry
    99Author URI: http://uiux.me
     
    5858                )
    5959            );
     60
     61        woocommerce_wp_text_input(
     62            array(
     63                'id'            => 'woo_heat_scoville',
     64                'label'         => __( 'Scoville Rating', 'woocommerce'),
     65                'description'   => __('Scoville Heat Units, eg 1000000', 'woocommerce')
     66                )
     67            );
    6068    }
    6169
     
    6573        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
    6674            return;
     75
    6776        if ( isset( $_POST['woo_heat'] ) ) {
    6877            if ( is_numeric( $_POST['woo_heat'] ) )
    6978                update_post_meta( $product_id, 'woo_heat', $_POST['woo_heat'] );
    7079        } else delete_post_meta( $product_id, 'woo_heat' );
     80
     81        if ( isset( $_POST['woo_heat_scoville'] ) ) {
     82            if ( is_numeric( $_POST['woo_heat_scoville'] ) )
     83                update_post_meta( $product_id, 'woo_heat_scoville', $_POST['woo_heat_scoville'] );
     84        } else delete_post_meta( $product_id, 'woo_heat_scoville' );
    7185    }
    7286
     
    7892            $woo_heat_display = get_post_meta( $product->id, 'woo_heat', true );
    7993
     94            $heat_label = get_option('woo_heat_enable_label', 1);
     95            $heat_scale = get_option('woo_heat_enable_scale', 1);
     96            $woo_heat_scoville = '';
     97            $scoville = false;
     98
     99            if(get_option('woo_heat_enable_scoville', false)) {
     100                $scoville = true;
     101                $woo_heat_scoville = get_post_meta( $product->id, 'woo_heat_scoville', true );
     102                if($woo_heat_scoville) {
     103                    $woo_heat_scoville = number_format($woo_heat_scoville);
     104                }
     105            }
     106
    80107            if($woo_heat_display > 10) {
    81108                //only show a maximum of 10 heat points on chart
     
    88115
    89116            if($woo_heat_display > 10) {
    90                 echo '<p class="wooheat-rating">Heat Rating</p>';
     117
     118                if($heat_label) {
     119                    echo '<p class="wooheat-rating">Heat Rating</p>';
     120                }               
     121
     122                if($scoville) {
     123                    echo '<p class="wooheat-scoville">'.$woo_heat_scoville.'</span></p>';
     124                }
     125               
    91126                echo get_heat_rating_image($woo_heat_display);
    92                 echo '<div class="wooheat-scale"><span class="wooheat-fire" style="left:'.$heat_rating.'%;"></span></div>';
     127
     128                if($heat_scale) {
     129                    echo '<div class="wooheat-scale"><span class="wooheat-fire" style="left:'.$heat_rating.'%;"></span></div>';
     130                }
     131
    93132            } else {
    94                 echo '<p class="wooheat-rating">Heat Rating</p>';
    95                 echo '<div class="wooheat-scale"><span class="wooheat-fire" style="left:'.$heat_rating.'%;"></span></div>';
     133
     134                if($heat_label) {
     135                    echo '<p class="wooheat-rating">Heat Rating</p>';
     136                }
     137
     138                if($scoville) {
     139                    echo '<p class="wooheat-scoville">'.$woo_heat_scoville.'</span></p>';
     140                }
     141
     142                if($heat_scale) {
     143                    echo '<div class="wooheat-scale"><span class="wooheat-fire" style="left:'.$heat_rating.'%;"></span></div>';
     144                }
    96145            }
    97146           
     
    183232
    184233    function woo_heat_settings() {
     234        register_setting( 'woo-heat-settings-group', 'woo_heat_enable_label');
     235        register_setting( 'woo-heat-settings-group', 'woo_heat_enable_scale' );
     236        register_setting( 'woo-heat-settings-group', 'woo_heat_enable_scoville' );
    185237        register_setting( 'woo-heat-settings-group', 'woo_heat_scale_limit' );
    186238        register_setting( 'woo-heat-settings-group', 'woo_heat_cold_temperature_colour' );
     
    215267    .wooheat-rating {padding: 0;margin: 0;}
    216268    .wooheat-image {width:250px;height:50px;margin:2px!important;}
     269    .wooheat-scoville {color:#FF1616;}
    217270    .wooheat-scale{
    218271        -webkit-border-radius: 6px;-moz-border-radius: 6px;-ms-border-radius: 6px;-o-border-radius: 6px;border-radius: 6px;
Note: See TracChangeset for help on using the changeset viewer.