register(); // Add our namespace and the folder it maps to $loader->addNamespace('\XeroPHP', dirname(__FILE__) . '/xero-php-master/src/XeroPHP'); $loader->addNamespace('\Biukop', dirname(__FILE__) . '/' ); $this->xero = new Xero(); } // // ///check auth public function check_auth(){ global $pagename; //echo $pagename; } /// // enqueue / register css /js // public function register_js_css() { $this->nonce = wp_create_nonce('acaresydney'); $this->acaresydney_userid = get_query_var( 'acaresydney_userid' ) ; $this->register_bts_js(); $this->register_timesheet_js_css(); } private function register_bts_js() { wp_enqueue_style( 'bts', plugins_url('css/ts.css', __FILE__)); wp_enqueue_script('bts', plugins_url('js/ts.js', __FILE__), array('jquery', 'jquery-ui-core')); wp_localize_script( 'bts', 'bts1', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => $this->nonce, // It is common practice to comma after 'display_name' => wp_get_current_user()->display_name, 'anonymous' => !is_user_logged_in(), 'me'=> get_current_user_id(), 'userid'=> $this->acaresydney_userid, ) ); } private function register_timesheet_js_css(){ global $pagename; if ($pagename != 'time-sheets'){ return; } wp_enqueue_style( 'bts_ts', plugins_url('css/bts_timesheet.css', __FILE__)); wp_enqueue_script( 'bts_ts', plugins_url('js/bts_timesheet.js', __FILE__), array( 'jquery' , 'bts' )); wp_enqueue_script('mustache', plugins_url('js/mustache.min.js', __FILE__), array('jquery')); } public function sync_users() { $a=1; return; } // Usage: `wp sync_users --mininterval=123 public function sync_user_cli($args = array(), $assoc_args = array()){ $arguments = wp_parse_args( $assoc_args, array( 'mininterval' => 600, ) ); $this->xero->sync_users($arguments['mininterval']); return; } public function bts_people_item($attr){ return $this->template('people_template', 'peopleitem.html'); } //generate template based on html file private function template($id, $file) { $text = ''; return $text; } } $bb = new AcareOffice(); if ( defined( 'WP_CLI' ) && WP_CLI ) { \WP_CLI::add_command( 'sync_users', array($bb, 'sync_user_cli')); }