timesheet source code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.8KB

  1. <?php
  2. /**
  3. * Plugin Name: Acare Advanced Office
  4. * Plugin URI: http://biukop.com.au/acaresydney/timesheets
  5. * Description: Advanced Office system, timesheet, Payroll for AcareSydney
  6. * Version: 2.1
  7. * Author: Biukop Intelligence
  8. * Author URI: http://biukop.com.au/
  9. */
  10. namespace Biukop;
  11. require_once(dirname(__FILE__) . '/autoload.php');
  12. require_once (ABSPATH . 'wp-includes/pluggable.php');
  13. class AcareOffice{
  14. private $nonce; //for ajax verification
  15. private $pages = array('time-sheets', 'user-list');
  16. private $acaresydney_userid = 0;
  17. public function __construct() {
  18. add_action('init', array($this, 'class_loader'));
  19. add_action('wp', array($this, 'check_auth'));
  20. add_action('wp_enqueue_scripts', array($this, 'register_js_css'), 99);
  21. add_filter('show_admin_bar', '__return_false');
  22. }
  23. /**
  24. * Autoload the custom theme classes
  25. */
  26. public function class_loader()
  27. {
  28. // Create a new instance of the autoloader
  29. $loader = new \Psr4AutoloaderClass();
  30. // Register this instance
  31. $loader->register();
  32. // Add our namespace and the folder it maps to
  33. $loader->addNamespace('\XeroPHP', dirname(__FILE__) . '/xero-php-master/src/XeroPHP');
  34. $loader->addNamespace('\Biukop', dirname(__FILE__) . '/' );
  35. $n = new Xero();
  36. }
  37. //
  38. //
  39. ///check auth
  40. public function check_auth(){
  41. global $pagename;
  42. //echo $pagename;
  43. }
  44. ///
  45. // enqueue / register css /js
  46. //
  47. public function register_js_css() {
  48. $this->nonce = wp_create_nonce('acaresydney');
  49. $this->acaresydney_userid = get_query_var( 'acaresydney_userid' ) ;
  50. $this->register_bts_js();
  51. $this->register_timesheet_js_css();
  52. }
  53. private function register_bts_js()
  54. {
  55. wp_enqueue_style( 'bts', plugins_url('css/ts.css', __FILE__));
  56. wp_enqueue_script('bts', plugins_url('js/ts.js', __FILE__), array('jquery', 'jquery-ui-core'));
  57. wp_localize_script( 'bts', 'bts1', array(
  58. 'ajax_url' => admin_url( 'admin-ajax.php' ),
  59. 'nonce' => $this->nonce, // It is common practice to comma after
  60. 'display_name' => wp_get_current_user()->display_name,
  61. 'anonymous' => !is_user_logged_in(),
  62. 'me'=> get_current_user_id(),
  63. 'userid'=> $this->acaresydney_userid,
  64. ) );
  65. }
  66. private function register_timesheet_js_css(){
  67. global $pagename;
  68. if ($pagename != 'time-sheets'){
  69. return;
  70. }
  71. wp_enqueue_style( 'bts_ts', plugins_url('css/bts_timesheet.css', __FILE__));
  72. wp_enqueue_script( 'bts_ts', plugins_url('js/bts_timesheet.js', __FILE__), array( 'jquery' , 'bts' ));
  73. }
  74. }
  75. new AcareOffice();