Skip to content

Commit

Permalink
comments in functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Levdbas committed Oct 1, 2017
1 parent 7234255 commit 2a9ac01
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
9 changes: 3 additions & 6 deletions admin/js/support-hours-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@
})
})
}

// remove workFields row.
$('.remove-row').click(function(e){
$(this).parents('.repeating').remove();
});

// set date field to todays date.
$('.today').click(function(e){
var today = $('.currentDate').text();
e.preventDefault();
$(this).prev().val(today);
});

// Clone the previous section, and remove all of the values
// Clone the previous workField, and remove all of the values
$('.repeat').click(function(e){
e.preventDefault();
var lastRepeatingGroup = jQuery('.repeating').last();
Expand All @@ -91,7 +91,4 @@
resetAttributeNames(cloned)
});
});
$(window).resize(function() {
$(".progress-bar").loading();
});
})(jQuery);
6 changes: 4 additions & 2 deletions admin/partials/support-hours-admin-settings-workTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
</tr>
</thead>
<tbody>
<?php if ( $workFields ) : foreach ( $workFields as $field ) { ?>
<?php
// loop the $workFields. Show all.
if ( $workFields ) : foreach ( $workFields as $field ) {
?>


<tr class="repeating">

<td class="remove">
<a class="button remove-row" href="#">-</a>
<?php // TODO: <span class="button sort hndle">|||</span> ?>
</td>

<td data-th="<?php _e('Date', $this->plugin_name); ?>">
Expand Down
9 changes: 5 additions & 4 deletions admin/partials/support-hours-functions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php


// function to explode on hours and calculates them to minutes.
function hoursToMinutes($hours){
$minutes = 0;
if (strpos($hours, ':') !== false)
Expand All @@ -10,7 +10,7 @@ function hoursToMinutes($hours){
return $hours * 60 + $minutes;
}


// function to strip the hours displayed in the clock of minutes if the hour is round.
function minuszeros($hours2) {
$minutes = 0;
if (preg_match("/0+([1-9]:)/", $hours2) == true) {
Expand Down Expand Up @@ -48,7 +48,7 @@ function AddTime($workFields) {
}
}


// set of vars used in different files and functions.
$options = get_option($this->plugin_name);
$users = $options['users'];
$email = $options['email'];
Expand All @@ -61,8 +61,9 @@ function AddTime($workFields) {
$bought_hours = $options['bought_hours'];
$bought_hours = minuszeros($bought_hours);
$current_color = get_user_option( 'admin_color' );
$size = 'big';


// TODO:set code to functions.
if (strpos($used_hours, ':') !== false){
$size = 'small';
} else{
Expand Down
9 changes: 5 additions & 4 deletions admin/support-hours-admin-overview.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

/**
* Provide a admin area view for the plugin
*
* This file is used to markup the admin-facing aspects of the plugin.
* Provide a page that can be seen from editor to admin. Shows all the time entries.
*
* @link http://basedonline.nl
* @since 1.0.0
Expand All @@ -13,6 +11,7 @@
*/
?>
<?php
// load options and functions.
$options = get_option($this->plugin_name);
$bought_hours = $options['bought_hours'];
$workFields = $options['workFields'];
Expand All @@ -34,7 +33,9 @@
</thead>
<tbody>
<?php
foreach ( array_reverse($workFields) as $field ) { ?>
// loop the $workFields. Show all.
foreach ( array_reverse($workFields) as $field ) {
?>
<tr>
<td><?php if(!empty($field['used'])) echo $field['date'] ?></td>
<td><?php if(!empty($field['used'])) echo $field['description'] ?></td>
Expand Down
8 changes: 4 additions & 4 deletions admin/support-hours-admin-settings.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

/**
* Provide a admin area view for the plugin
* Settings page of Support Hours
*
* This file is used to markup the admin-facing aspects of the plugin.
*
* @link http://basedonline.nl
* @since 1.0.0
* @since 1.4.0
*
* @package Support_Hours
* @subpackage Support_Hours/admin
*/
?>
<?php

$options = get_option($this->plugin_name);
$bought_hours = $options['bought_hours'];
$users = $options['users'];
Expand All @@ -25,6 +24,7 @@
<h2><?php echo esc_html(get_admin_page_title()); ?></h2>
<form method="post" name="cleanup_options" action="options.php">
<?php
// load fields and include sub-parts of this form.
settings_fields($this->plugin_name);
do_settings_sections($this->plugin_name);
include_once( 'partials/support-hours-admin-settings-textFields.php' );
Expand Down
10 changes: 8 additions & 2 deletions admin/support-hours-admin-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
* @package Support_Hours
* @subpackage Support_Hours/admin/partials
*/

// check if user is set or is empty.
if(!empty($users) && !empty($bought_hours)):
$user_ID = get_current_user_id();

// several includes to modulize the code.
include_once( 'partials/support-hours-admin-widget-clock.php' );
include_once( 'partials/support-hours-admin-widget-hourTable.php' );
include_once( 'partials/support-hours-admin-widget-bottomMessage.php' );
elseif(empty($users)):
// if $users is empty or users do not match.
?>

<p>
Expand All @@ -26,7 +29,10 @@
</a>
</p>

<?php else: ?>
<?php
else:
// user is set but $bought_hours is empty.
?>

<h4>
<?php _e( 'No support Hours bought', $this->plugin_name); ?>.
Expand Down

0 comments on commit 2a9ac01

Please sign in to comment.