| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 4 |
|
| 5 |
|
| 6 |
function etimeclockwp_button_shortcode($atts) { |
| 7 |
|
| 8 |
// get shortcode attributes |
| 9 |
$atts = shortcode_atts(array( |
| 10 |
'align' => '', |
| 11 |
), $atts); |
| 12 |
|
| 13 |
|
| 14 |
// set action url |
| 15 |
$action_url = add_query_arg('etimeclockwp-action','charge',home_url( 'index.php')); |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
$result = ""; |
| 20 |
|
| 21 |
$result .= "<div class='etimeclock-main'>"; |
| 22 |
$result .= "<div class='etimeclock-body'>"; |
| 23 |
|
| 24 |
// time section |
| 25 |
$result .= "<span id='etimeclock-date'></span>"; |
| 26 |
$result .= "<br />"; |
| 27 |
$result .= "<span id='etimeclock-time'></span>"; |
| 28 |
$result .= "<br /><br />"; |
| 29 |
|
| 30 |
// login section |
| 31 |
$result .= "<div class='etimeclock-text'>".etimeclockwp_get_option('employee-id').": <br /><input id='etimeclock-eid' class='etimeclock-input' type='text' autocomplete='off' autocomplete='false'></div>"; |
| 32 |
$result .= "<br /><br />"; |
| 33 |
$result .= "<div class='etimeclock-text'>".etimeclockwp_get_option('employee-password').": <br /><input id='etimeclock-epw' class='etimeclock-button etimeclock-input' type='password' autocomplete='off' autocomplete='false'></div>"; |
| 34 |
$result .= "<br /><br />"; |
| 35 |
|
| 36 |
// button section |
| 37 |
$result .= "<div class='etimeclock-in etimeclock-button' style='background-color: ".etimeclockwp_get_option('clock-in-button-color')."'><a class='etimeclock-action' data-id='in' href='#'>".etimeclockwp_get_option('clock-in')."</a></div>"; |
| 38 |
$result .= "<div class='etimeclock-out etimeclock-button' style='background-color: ".etimeclockwp_get_option('clock-out-button-color')."'><a class='etimeclock-action' data-id='out' href='#'>".etimeclockwp_get_option('clock-out')."</a></div>"; |
| 39 |
$result .= "<br />"; |
| 40 |
|
| 41 |
$show_break_options = etimeclockwp_get_option('show_break_options'); |
| 42 |
|
| 43 |
if ($show_break_options == '0') { |
| 44 |
$result .= "<div class='etimeclock-break-out etimeclock-button' style='background-color: ".etimeclockwp_get_option('leave-on-break-button-color')."'><a href='#' class='etimeclock-action' data-id='breakon'>".etimeclockwp_get_option('leave-on-break')."</a></div>"; |
| 45 |
$result .= "<div class='etimeclock-break-in etimeclock-button' style='background-color: ".etimeclockwp_get_option('return-from-break-button-color')."'><a href='#' class='etimeclock-action' data-id='breakoff'>".etimeclockwp_get_option('return-from-break')."</a></div>"; |
| 46 |
} |
| 47 |
|
| 48 |
// create nonce |
| 49 |
$ajax_nonce = wp_create_nonce('etimeclock_nonce'); |
| 50 |
$result .= "<input type='hidden' id='etimeclock_nonce' value='$ajax_nonce'>"; |
| 51 |
|
| 52 |
$result .= "</div>"; |
| 53 |
$result .= "</div>"; |
| 54 |
|
| 55 |
|
| 56 |
return $result; |
| 57 |
} |
| 58 |
add_shortcode('timeclock', 'etimeclockwp_button_shortcode'); |