Google_Sheet_Helpers::get_worksheet_rows_gsspreadsheet()

Method get_worksheet_rows_gsspreadsheet


Return Return

(void)


Source Source

File: src/integrations/google-sheet/helpers/google-sheet-helpers.php

	public function get_worksheet_rows_gsspreadsheet() {
		global $uncanny_automator;

		// Nonce and post object validation
		$uncanny_automator->utilities->ajax_auth_check( $_POST );

		$fields = array();

		$response = (object) array(
			'success' => false,
			'samples' => array(),
		);

		if ( ! isset( $_POST ) ) {
			echo wp_json_encode( $response );
			die();
		}

		$gs_spreadsheet_id = sanitize_text_field( $_POST['sheet'] );
		$worksheet_id      = sanitize_text_field( $_POST['worksheet'] );
		$hashed            = sha1( self::$hash_string );
		$sheet_id          = substr( $hashed, 0, 9 );

		if ( (string) $worksheet_id === (string) $sheet_id || intval( '-1' ) === intval( $worksheet_id ) ) {
			$worksheet_id = 0;
		}

		$response = $this->api_get_rows( $gs_spreadsheet_id, $worksheet_id );

		echo wp_json_encode( $response );
		die();
	}