Skip to content

Commit

Permalink
Release of version 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Levdbas committed Sep 28, 2017
1 parent 2bba3e2 commit 0d2ae77
Show file tree
Hide file tree
Showing 18 changed files with 352 additions and 275 deletions.
234 changes: 132 additions & 102 deletions admin/class-support-hours-admin.php
Original file line number Diff line number Diff line change
@@ -1,149 +1,175 @@
<?php

/**
* The admin-specific functionality of the plugin.
*
* @link http://basedonline.nl
* @since 1.0.0
*
* @package Support_Hours
* @subpackage Support_Hours/admin
*/
* The admin-specific functionality of the plugin.
*
* @link http://basedonline.nl
* @since 1.0.0
*
* @package Support_Hours
* @subpackage Support_Hours/admin
*/

/**
* The admin-specific functionality of the plugin.
*
* Defines the plugin name, version, and two examples hooks for how to
* enqueue the admin-specific stylesheet and JavaScript.
*
* @package Support_Hours
* @subpackage Support_Hours/admin
* @author Erik van der Bas <[email protected]>
*/
* The admin-specific functionality of the plugin.
*
* Defines the plugin name, version, and two examples hooks for how to
* enqueue the admin-specific stylesheet and JavaScript.
*
* @package Support_Hours
* @subpackage Support_Hours/admin
* @author Erik van der Bas <[email protected]>
*/
class Support_Hours_Admin {

/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;

/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;

/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct( $plugin_name, $version ) {

$this->plugin_name = $plugin_name;
$this->version = $version;

}
public function options_update() {
register_setting($this->plugin_name, $this->plugin_name, array($this, 'validate'));
}
register_setting($this->plugin_name, $this->plugin_name, array($this, 'validate'));
}
/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function enqueue_styles() {

/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Support_Hours_Loader as all of the hooks are defined
* in that particular class.
*
* The Support_Hours_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Support_Hours_Loader as all of the hooks are defined
* in that particular class.
*
* The Support_Hours_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/

wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/support-hours-admin.min.css', array(), $this->version, 'all' );

}

/**
* Register the JavaScript for the admin area.
*
* @since 1.0.0
*/
* Register the JavaScript for the admin area.
*
* @since 1.0.0
*/
public function enqueue_scripts() {

/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Support_Hours_Loader as all of the hooks are defined
* in that particular class.
*
* The Support_Hours_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Support_Hours_Loader as all of the hooks are defined
* in that particular class.
*
* The Support_Hours_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/

wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/support-hours-admin.js', array( 'jquery' ), $this->version, false );

}
public function add_plugin_admin_menu() {

/*
* Add a settings page for this plugin to the Settings menu.
*
* NOTE: Alternative menu locations are available via WordPress administration menu functions.
*
* Administration Menus: http://codex.wordpress.org/Administration_Menus
*
*/
add_options_page( __( 'Support hours', $this->plugin_name), __( 'Support hours', $this->plugin_name), 'manage_options', $this->plugin_name, array($this, 'display_plugin_setup_page')
* Add a settings page for this plugin to the Settings menu.
*
* NOTE: Alternative menu locations are available via WordPress administration menu functions.
*
* Administration Menus: http://codex.wordpress.org/Administration_Menus
*
*/
add_menu_page(
__( 'Support Hours overview', $this->plugin_name),
__( 'Support Hours', $this->plugin_name),
'publish_pages',
'support-hours',
array($this, 'display_plugin_page'),
'dashicons-clock'
);
}
add_submenu_page(
'support-hours',
__( 'Support Hours overview', $this->plugin_name),
__( 'Overview', $this->plugin_name),
'publish_pages',
'support-hours',
array($this, 'display_plugin_page')
);
add_submenu_page(
'support-hours',
__( 'Support Hours settings', $this->plugin_name),
__( 'Settings', $this->plugin_name),
'manage_options',
'support-hours-settings',
array($this, 'display_plugin_setup_page')
);
}

/**
* Add settings action link to the plugins page.
*
* @since 1.0.0
*/
/**
* Add settings action link to the plugins page.
*
* @since 1.0.0
*/
public function add_action_links( $links ) {
/*
* Documentation : https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name)
*/
$settings_link = array(
'<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_name ) . '">' . __('Settings', $this->plugin_name) . '</a>',
);
return array_merge( $settings_link, $links );
/*
* Documentation : https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name)
*/
$settings_link = array(
'<a href="' . admin_url( $this->plugin_name ) . '.php">' . __('Settings', $this->plugin_name) . '</a>',
);
return array_merge( $settings_link, $links );

}
/**
* Render the settings page for this plugin.
*
* @since 1.0.0
*/
* Render the settings page for this plugin.
*
* @since 1.0.0
*/

public function display_plugin_page() {
include_once( 'support-hours-admin-overview.php' );
}
public function display_plugin_setup_page() {
include_once( 'partials/support-hours-admin-page.php' );
include_once( 'support-hours-admin-settings.php' );
}

public function validate($input) {
$valid = array();
if ($input['bought_hours'] == null) {
$input['bought_hours'] = '00:00';
}
$input['bought_hours'] = '00:00';
}
if($input['workFields'] == null){
$input['workFields'] = null;
}
Expand All @@ -153,21 +179,25 @@ public function validate($input) {
$valid['workFields'] = $input['workFields'];
return $valid;
}


function support_hours_add_dashboard_widgets() {
if ( current_user_can( 'publish_pages' ) ) {
wp_add_dashboard_widget(
'support_hours_dashboard_widget', // Widget slug.
__( 'Support Hours', $this->plugin_name), // Title.
array($this, 'support_hours_dashboard_widget_function') // Display function.
'support_hours_dashboard_widget', // Widget slug.
__( 'Support Hours', $this->plugin_name), // Title.
array($this, 'support_hours_dashboard_widget_function') // Display function.
);
global $wp_meta_boxes;
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
$support_hours_dashboard_widget_backup = array( 'support_hours_dashboard_widget' => $normal_dashboard['support_hours_dashboard_widget'] );
unset( $normal_dashboard['support_hours_dashboard_widget'] );
$sorted_dashboard = array_merge( $support_hours_dashboard_widget_backup, $normal_dashboard );
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
$support_hours_dashboard_widget_backup = array( 'support_hours_dashboard_widget' => $normal_dashboard['support_hours_dashboard_widget'] );
unset( $normal_dashboard['support_hours_dashboard_widget'] );
$sorted_dashboard = array_merge( $support_hours_dashboard_widget_backup, $normal_dashboard );
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
}
}
function support_hours_dashboard_widget_function() {
include_once( 'partials/support-hours-functions.php' );
include_once( 'partials/support-hours-admin-widget.php' );
include_once( 'support-hours-admin-widget.php' );
}
}
2 changes: 1 addition & 1 deletion admin/css/support-hours-admin.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions admin/css/support-hours-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,14 @@ $breakpoint-alpha: 480px;
text-align: left;
}
}
.worktable, .total{
border-bottom: 1px solid #eee;
}
.total{
padding-bottom: 10px !important;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
margin: 0 -12px;
margin-top: 10px;
padding: 8px 12px 4px;
font-size: 1rem;
background:#fafafa;
}
.currentDate{
display: none;
Expand Down
1 change: 0 additions & 1 deletion admin/js/support-hours-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
cloned.find("input:radio").attr("checked", false);
resetAttributeNames(cloned)
});

});
$(window).resize(function() {
$(".progress-bar").loading();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<?php
$i = 0;
?>
Expand All @@ -13,19 +14,20 @@
<th><?php _e('Time used', $this->plugin_name); ?></th>
</tr>
</thead>

<tbody>
<?php if ( $workFields ) : foreach ( $workFields as $field ) { ?>

<tbody>

<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); ?>">
<input type="text" placeholder="dd-mm-yyyy" class="regular-text date" id="<?php echo $this->plugin_name; ?>-workFields-date" name="<?php echo $this->plugin_name; ?>[workFields][<?php echo $i; ?>][date]" value="<?php if(!empty($field['date'])) { echo $field['date']; } ?>"/>
<button class="today button button-primary"><?php _e('Today', $this->plugin_name); ?></button>
<button class="today button button-secondary"><?php _e('Today', $this->plugin_name); ?></button>
</td>

<td data-th="<?php _e('Description', $this->plugin_name); ?>">
Expand All @@ -37,11 +39,9 @@
</td>

</tr>
</tbody>

<?php $i++; } else : ?>

<tbody>
<tr class="repeating">

<td class="remove">
Expand All @@ -62,10 +62,9 @@
</td>

</tr>
</tbody>

<?php endif; ?>

</tbody>
</table>
<a href="#" class="repeat button button-primary"><?php _e('Add row', $this->plugin_name); ?></a><?php submit_button(__( 'Save all changes', $this->plugin_name), 'primary','submit', TRUE); ?>
<a href="#" class="repeat button button-secondary"><?php _e('Add activity', $this->plugin_name); ?></a><?php submit_button(__( 'Save all changes', $this->plugin_name), 'primary','submit', true); ?>
</fieldset>
Loading

0 comments on commit 0d2ae77

Please sign in to comment.