Plugin Directory

Changeset 1326501


Ignore:
Timestamp:
01/12/2016 10:57:03 AM (10 years ago)
Author:
rclick
Message:

1.2

Location:
i-am-human/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • i-am-human/trunk/iamhuman.php

    r1244419 r1326501  
    33  Plugin Name: I am human
    44  Plugin URI:  http://programminglinuxblog.blogspot.com/2014/06/i-am-human.html
    5   Description: Human vs machine. Who will pass the test? Customisable machine
    6   filtering (otherwise known as captcha), that can be imbeded into forms.
     5  Description: Human vs machine. Who will pass the test? Customisable machine filtering (otherwise known as captcha), that can be imbeded into forms.
    76  Author: Benjamin Leov
    87  Version: 1.1
     
    4645       
    4746            <div id=\"iamhuman_grid\" class='iamhuman_grid'></div>
    48             <div class='iamhuman_message'>" . get_option(IamHumanConstants::IAMHUMAN_OPTION_INCORRECT_ATTEMPT_MESSAGE) ."</div>
     47            <div class='iamhuman_message'>" . iamhuman_get_incorrect_attempt_message() ."</div>
    4948        </div>
    5049    </div>
     
    5352        jQuery(document).ready(function($) {
    5453       
    55             $('html > head').append($('<style> .colour_bg { background: " . get_option(IamHumanConstants::IAMHUMAN_OPTION_BACKGROUND_COLOUR) . "; }</style>'));
    56             $('html > head').append($('<style> .colour_one { background: " . get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_ONE) . "; }</style>'));
    57             $('html > head').append($('<style> .colour_two { background: " . get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_TWO) . "; }</style>'));
     54            $('html > head').append($('<style> .colour_bg { background: " . iamhuman_get_background_colour() . "; }</style>'));
     55            $('html > head').append($('<style> .colour_one { background: " . iamhuman_get_colour_one() . "; }</style>'));
     56            $('html > head').append($('<style> .colour_two { background: " . iamhuman_get_colour_two() . "; }</style>'));
    5857            $('html > head').append($('<style> .cell_mouse_over { background: " . get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_HOVER) . "; }</style>'));
    5958               
     
    7069            //var form = jQuery(this).parents('form:first');
    7170            var form = $(\"#commentform\");
    72            
     71            var answer_passed = false;
     72
    7373            form.append($('<div style=\"display:none\"><input id=\"alt_submit\" type=\"submit\" /></div>'));
    7474
     
    107107
    108108                                        result = $(response).find('success').first().text();
    109                                        
     109
    110110                                        if(result == 'true') {
    111111                                            jQuery('.iamhuman_message').hide();
    112112                                            answer_field.val(selection_string);
     113                                            answer_passed = true;
    113114                                            jQuery('#alt_submit').click();
    114115                                       } else {
    115116                                            // display error message
     117                                            answer_passed = false;
    116118                                            jQuery('.iamhuman_message').show();
    117119                                        }
     
    137139            form.submit(function (event) {
    138140           
    139                answer_field = form.children('input[name=\"iamhuman_answer\"]:first').val();
     141               //answer_field = form.children('input[name=\"iamhuman_answer\"]:first').val();
    140142               
    141                if(!answer_field) {
     143               if(!answer_passed) {
    142144                    event.preventDefault();
    143145                    handle_submit();
     
    214216       
    215217            if(empty($_POST['iamhuman_answer'])) {
    216                wp_die( get_option(IamHumanConstants::IAMHUMAN_OPTION_INCORRECT_ATTEMPT_MESSAGE)); 
     218               wp_die(iamhuman_get_incorrect_attempt_message()); 
    217219            } else {
    218220
     
    220222
    221223                if($test_answer !== $answer_string) {
    222                     wp_die( get_option(IamHumanConstants::IAMHUMAN_OPTION_INCORRECT_ATTEMPT_MESSAGE));
     224                    wp_die(iamhuman_get_incorrect_attempt_message());
    223225                }
    224226            }
  • i-am-human/trunk/iamhuman_options.php

    r1243970 r1326501  
    11<?php
    2 include_once 'iamhuman_options.php';
    32
    43function iamhuman_register_settings() {
     
    2625
    2726    register_setting(IamHumanConstants::$IAMHUMAN_SETTINGS_ID, IamHumanConstants::IAMHUMAN_OPTION_ENABLE_POST_COMMENTS);
     27}
     28
     29function iamhuman_get_colour_one() {
     30    return get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_ONE, '#006495');
     31}
     32
     33function iamhuman_get_colour_two() {
     34    return get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_TWO, '#E0A026');
     35}
     36
     37function iamhuman_get_background_colour() {
     38    return get_option(IamHumanConstants::IAMHUMAN_OPTION_BACKGROUND_COLOUR, 'white');
     39}
     40
     41function iamhuman_get_incorrect_attempt_message() {
     42    return get_option(IamHumanConstants::IAMHUMAN_OPTION_INCORRECT_ATTEMPT_MESSAGE, 'Incorrect Attempt');
     43}
     44
     45/**
     46 * Gets the grid size, with the default option set.
     47 *
     48 * @return int
     49 */
     50function iamhuman_get_grid_size_setting() {
     51    return get_option(IamHumanConstants::IAMHUMAN_OPTION_GRID_SIZE, 22);
    2852}
    2953
     
    165189                <tr valign="top">
    166190                    <th scope="row"><?php echo __('Incorrect Attempt Message', IamHumanConstants::$IAMHUMAN_TEXT_DOMAIN) ?></th>
    167                     <td><textarea name="incorrect_attempt_message"><?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_INCORRECT_ATTEMPT_MESSAGE); ?></textarea></td>
     191                    <td><textarea name="incorrect_attempt_message"><?php echo iamhuman_get_incorrect_attempt_message(); ?></textarea></td>
    168192                </tr>
    169193
    170194                <tr valign="top">
    171195                    <td  colspan="2">
    172 
    173196                        <p>
    174197                            <strong>
     
    193216                ?>
    194217            </p>
    195 
     218     
    196219            <table class="form-table">
    197220                <tr valign="top">
    198221                    <th scope="row"><?php echo __('Colour one', IamHumanConstants::$IAMHUMAN_TEXT_DOMAIN) ?></th>
    199                     <td><input type="text" class='colour_field' id="colour_one" name="colour_one" value="<?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_ONE); ?>" /></td>
     222                    <td><input type="text" class='colour_field' id="colour_one" name="colour_one" value="<?php echo iamhuman_get_colour_one(); ?>" /></td>
    200223                </tr>
    201224                <tr valign="top">
    202225                    <th scope="row"><?php echo __('Colour two', IamHumanConstants::$IAMHUMAN_TEXT_DOMAIN) ?></th>
    203                     <td><input type="text" class='colour_field' id="colour_two" name="colour_two" value="<?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_TWO); ?>" /></td>
     226                    <td><input type="text" class='colour_field' id="colour_two" name="colour_two" value="<?php echo iamhuman_get_colour_two(); ?>" /></td>
    204227                </tr>
    205228                <tr valign="top">
    206229                    <th scope="row"><?php echo __('Hover colour', IamHumanConstants::$IAMHUMAN_TEXT_DOMAIN) ?></th>
    207                     <td><input type="text" class='colour_field' id="colour_hover" name="colour_hover" value="<?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_HOVER); ?>" /></td>
     230                    <td><input type="text" class='colour_field' id="colour_hover" name="colour_hover" value="<?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_HOVER, '#F4D00C'); ?>" /></td>
    208231                </tr>
    209232                <tr valign="top">
    210233                    <th scope="row"><?php echo __('Background colour', IamHumanConstants::$IAMHUMAN_TEXT_DOMAIN) ?></th>
    211                     <td><input type="text" class='colour_field' id="background_colour" name="background_colour" value="<?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_BACKGROUND_COLOUR); ?>" /></td>
     234                    <td><input type="text" class='colour_field' id="background_colour" name="background_colour" value="<?php echo iamhuman_get_background_colour(); ?>" /></td>
    212235                </tr>
    213236            </table>   
     
    238261
    239262                    // setup the custom styles
    240                     $('html > head').append($('<style> .colour_bg { background: <?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_BACKGROUND_COLOUR); ?>; }</style>'));
    241                     $('html > head').append($('<style> .colour_one { background: <?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_ONE); ?>; }</style>'));
    242                     $('html > head').append($('<style> .colour_two { background: <?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_COLOUR_TWO); ?>; }</style>'));
    243                     $(".grid_cell").css('background-color', '<?php echo get_option(IamHumanConstants::IAMHUMAN_OPTION_BACKGROUND_COLOUR) ?>');
     263                    $('html > head').append($('<style> .colour_bg { background: <?php echo iamhuman_get_background_colour(); ?>; }</style>'));
     264                    $('html > head').append($('<style> .colour_one { background: <?php echo iamhuman_get_colour_one(); ?>; }</style>'));
     265                    $('html > head').append($('<style> .colour_two { background: <?php echo iamhuman_get_colour_two(); ?>; }</style>'));
     266                    $(".grid_cell").css('background-color', '<?php echo iamhuman_get_background_colour(); ?>');
    244267
    245268                    create_grid("#iamhuman_grid_question", <?php echo iamhuman_get_grid_size_setting(); ?>);
     
    357380}
    358381
    359 /**
    360  * Gets the grid size, with the default option set.
    361  *
    362  * @return int
    363  */
    364 function iamhuman_get_grid_size_setting() {
    365     return get_option(IamHumanConstants::IAMHUMAN_OPTION_GRID_SIZE, 22);
    366 }
    367382
    368383/**
     
    392407    } else {
    393408        $response->success = false;
    394         $response->messsage = __("No template matched was specifie.", IamHumanConstants::$IAMHUMAN_TEXT_DOMAIN);
     409        $response->messsage = __("No template matched was specified.", IamHumanConstants::$IAMHUMAN_TEXT_DOMAIN);
    395410    }
    396411
  • i-am-human/trunk/readme.txt

    r1244246 r1326501  
    7272Initial release of I Am Human!
    7373
     74= 1.1 =
     75
     76Bug fixes.
     77
     78= 1.2 =
     79
     80Bug fixes.
     81
    7482== Upgrade Notice ==
    7583
Note: See TracChangeset for help on using the changeset viewer.