default_arguments ); $actions = array( 'download-report' => 'download_report', 'delete-report' => 'delete_report', ); if ( isset( $actions['get-actions'] ) ) { $this->response['get-actions'] = array_keys( $actions ); } foreach ( $arguments as $action => $data ) { $this->current_action = $action; if ( isset( $actions[$action] ) ) { $this->response[$action] = call_user_func( array( $this, $actions[$action] ), $data ); } else { $this->response[$action] = 'This action is not recognized'; } } return $this->response; } private function set_fatal_error_handler() { if ( function_exists( 'error_get_last' ) ) { register_shutdown_function( array( $this, 'handle_fatal_error' ) ); } } private function handle_fatal_error() { $error = error_get_last(); if ( is_array( $error ) ) { $this->response['error'] = array( 'error_trigger_action' => $this->current_action, 'error_details' => $error, ); $GLOBALS['ithemes_sync_request_handler']->send_response( $this->response ); } } private function download_report( $dest_filename ) { if ( ! is_string( $dest_filename ) ) { return new WP_Error( 'invalid-argument', 'The download-report function takes a string representing an individual report.' ); } $report_url = 'https://s3.amazonaws.com/sync-reports.ithemes.com/' . $dest_filename; $upload_path = Ithemes_Sync_Functions::get_upload_reports_dir(); $result = false; if ( wp_is_writable( $upload_path ) ) { if ( ! file_exists( $upload_path . '/index.php' ) ) { @file_put_contents( $upload_path . '/index.php', '