Plugin Directory

Changeset 1318315


Ignore:
Timestamp:
12/30/2015 05:42:05 AM (10 years ago)
Author:
laughlin.david
Message:

Enable user to change button colors from bootstrap css and disable general public usage of point system. You must be a user to change points.

Location:
keeping-points/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • keeping-points/trunk/keeping-points.php

    r1286247 r1318315  
    55Plugin URI: http://www.dlaugh.com/plugins/keeping-points.php/
    66Description: A great plugin to assist in keeping points for a church program or for employees in a rewards system.
    7 Version: 0.9
     7Version: 0.9.7
    88Author: David Laughlin
    99Author URI: http://www.dlaugh.com
     
    297297                </td>
    298298            </tr>
     299            <!-- Select Drop-Down for button color -->
     300            <tr>
     301                <th scope="row">Select button color</th>
     302                <td>
     303                    <select name='keeping_points_options[button_color]'>
     304                        <option value='primary' <?php selected('primary', $options['button_color']); ?>><?php _e( 'primary', 'keeping-points' ); ?></option>
     305                        <option value='success' <?php selected('success', $options['button_color']); ?>><?php _e( 'success', 'keeping-points' ); ?></option>
     306                        <option value='info' <?php selected('info', $options['button_color']); ?>><?php _e( 'info', 'keeping-points' ); ?></option>
     307                        <option value='warning' <?php selected('warning', $options['button_color']); ?>><?php _e( 'warning', 'keeping-points' ); ?></option>
     308                        <option value='danger' <?php selected('danger', $options['button_color']); ?>><?php _e( 'danger', 'keeping-points' ); ?></option>
     309                    </select>
     310                    <span style="color:#666666;margin-left:2px;">Add a comment here to explain more about how to use the option above</span>
     311                </td>
     312            </tr>
     313           
    299314            <?php
    300315            $button_amount = $options["button_amount"];
     
    379394function shortpoints_process_ajax() {
    380395    $options = get_option('keeping_points_options');
     396    $btn_color = $options['button_color'];
     397    $btn_color_build = 'btn btn-' . $btn_color . ' ';
    381398    $btnId = $_POST['name'];
    382399    $btnName = $_POST['btnName'];
    383400    $btnClass = $_POST['btnClass'];
    384     $changed_class = str_replace('btn btn-info ', '', $btnClass);
     401    $changed_class = str_replace( $btn_color_build, '', $btnClass);
    385402    $changed_name = str_replace('_', ' ', $btnName);
    386403    $num_start = $changed_class . "_points";
     
    409426function dlaugh_keeping_points_plugin()
    410427{
     428
     429    if ( is_user_logged_in() ) {
    411430    wp_enqueue_script( 'shortpoints-ajax' , plugin_dir_url(__FILE__) . 'js/shortpoints-ajax.js', array('jquery'), '', true );
    412431
     
    416435
    417436    ));
     437   
    418438    //add bootstrap last
    419439    wp_enqueue_style( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css' );
    420440   $output =  '<div class="container"><div class="row">';
    421441    $options = get_option('keeping_points_options');
     442    $btn_color = $options['button_color'];
     443    $btn_color_build = 'btn btn-' . $btn_color . ' ';
    422444    $number = $options['button_amount'];
    423445    $ppl_num = $options['ppl_amount'];
     
    436458        $output.= '<div style="display:inline-block; margin:5px;">';
    437459        $output.= '<button name="' . $changed_id . '"';
    438         $output.= 'type="button" class="btn btn-info ' . $point . '" id = "' . ($for_margin . $changed_id) . '">';
     460        $output.= 'type="button" class="' . $btn_color_build . $point . '" id = "' . ($for_margin . $changed_id) . '">';
    439461        $output.= $options[$point] . '</button></div>';
    440462        }
     
    445467    $changed_id = str_replace(' ', '_', $name_call);
    446468    $point_total = "point_total_" . $changed_id;
     469    if (!$options[$point_total]) {
     470        $options[$point_total] = 0;
     471    }
    447472    $output.= '<div style="display:inline-block; margin:5px; width:50px;">';
    448     $output.= '<button name="' . $changed_id . '" type="button" class="btn btn-info ' . $point . '"';
     473    $output.= '<button name="' . $changed_id . '" type="button" class="' . $btn_color_build . $point . '"';
    449474    $output.= 'id = "' . ($changed_id . "_neg") . '">-</button></div>';
    450475    $output.= '<br /><div id ="' . ($changed_id . "result") . '">';
     
    455480
    456481    return $output;
     482   
     483    } else {
     484    echo('<h3 style="color:red;">You must be a logged in user to enable point system</h3>');
     485   
     486        //add bootstrap last
     487    wp_enqueue_style( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css' );
     488   $output =  '<div class="container"><div class="row">';
     489    $options = get_option('keeping_points_options');
     490    $btn_color = $options['button_color'];
     491    $btn_color_build = 'btn btn-' . $btn_color . ' ';
     492    $number = $options['button_amount'];
     493    $ppl_num = $options['ppl_amount'];
     494    for($j=0;$j < $ppl_num; $j++) {
     495    $point = "txt_" . $j;
     496    $name_id = "txt_" . $j . '_name';
     497    if ($options[$name_id]) {
     498    $output .= '<section>';
     499    for($i=0;$i < $number; $i++) {
     500        $point = "txt_" . $i;
     501        $for_margin = $options[$point];
     502        $name_id = "txt_" . $j . '_name';
     503        $name_call = $options[$name_id];
     504        $changed_id = str_replace(' ', '_', $name_call);
     505        if ($options[$point] !== "") {
     506        $output.= '<div style="display:inline-block; margin:5px;">';
     507        $output.= '<button name="' . $changed_id . '"';
     508        $output.= 'type="button" class="' . $btn_color_build . $point . '" id = "' . ($for_margin . $changed_id) . '">';
     509        $output.= $options[$point] . '</button></div>';
     510        }
     511    }
     512   
     513    $name_id = "txt_" . $j . "_name";
     514    $name_call = $options[$name_id];
     515    $changed_id = str_replace(' ', '_', $name_call);
     516    $point_total = "point_total_" . $changed_id;
     517    if (!$options[$point_total]) {
     518        $options[$point_total] = 0;
     519    }
     520    $output.= '<div style="display:inline-block; margin:5px; width:50px;">';
     521    $output.= '<button name="' . $changed_id . '" type="button" class="' . $btn_color_build . $point . '"';
     522    $output.= 'id = "' . ($changed_id . "_neg") . '">-</button></div>';
     523    $output.= '<br /><div id ="' . ($changed_id . "result") . '">';
     524    $output.= $options[$name_id] . "'s Total Points: " . $options[$point_total] . '</div><br /> </section>';
     525        }
     526    }
     527    $output.= '</div></div>';
     528
     529    return $output;
     530    }
    457531}
    458532
  • keeping-points/trunk/readme.txt

    r1286247 r1318315  
    88Requires at least: 4.3.1
    99Tested up to: 4.3.1
    10 Stable tag: 0.9.6
    11 Version: 0.9.6
     10Stable tag: 0.9.7
     11Version: 0.9.7
    1212
    1313Keeping Points is a plugin to help create a points reward or tracking system for each person within a program, church, or company.
     
    3434In the future I hope to add the following:
    3535
    36 * Add options for different button designs.
    3736* Add options to change text in the results area where the points are displayed.
    3837* Change the user interface to have the options to exclude buttons and just display points and accomplishments in table format.
Note: See TracChangeset for help on using the changeset viewer.