(´/"v€4A°JAă4A`´/"v8AAři A(]A°JA˜´/"vĐ´/"včA°JA€Ą/"vľ/"vA°JAh•IA@ľ/"v@ćA°JAxľ/"v°ľ/"vđ×A°JAŔĄ/"včľ/"v ś/"v°JAœ!"vXś/"v2AAŔ/"vś/"vR#A°JA ă4AČś/"v€4A°JAă4Aˇ/"v8AAři A(]A°JA˘/"v8ˇ/"včA°JA@˘/"vpˇ/"vA°JAh•IA¨ˇ/"v@ćA°JA€˘/"vŕˇ/"vđ×A°JAŔ˘/"v¸/"vP¸/"v°JA€œ!"vˆ¸/"v2AA`Ŕ/"vŔ¸/"vR#A°JA ă4Ař¸/"v€4A°JAă4A0š/"v8AAři A áęDŮUey should be cast to float to avoid further multi-time currency conversion. $payment->subtotal_amount = $payment->subtotal_amount ? (float) $payment->subtotal_amount : 0; $payment->discount_amount = $payment->discount_amount ? (float) $payment->discount_amount : 0; $payment->total_amount = $payment->total_amount ? (float) $payment->total_amount : 0; return $payment; } /** * Update an existing payment in the database. * * @since 1.8.2 * * @param string $payment_id Payment ID. * @param array $data Array of columns and associated data to update. * @param string $where Column to match against in the WHERE clause. If empty, $primary_key will be used. * @param string $type Data type context. * @param array $args Additional arguments. * * @return bool */ public function update( $payment_id, $data = [], $where = '', $type = '', $args = [] ) { if ( ! $this->current_user_can( $payment_id, $args ) ) { return false; } // TODO: consider validating other properties as well or get rid of it. if ( isset( $data['status'] ) && ! ValueValidator::is_valid( $data['status'], 'status' ) ) { return false; } // Use database type identifier if a context is empty. $type = empty( $type ) ? $this->type : $type; return parent::update( $payment_id, $data, $where, $type ); } /** * Delete a payment from the database, also removes payment meta. * * @since 1.8.2 * * @param int $payment_id Payment ID. * @param array $args Additional arguments. * * @return bool False if the payment and meta could not be deleted, true otherwise. */ public function delete( $payment_id = 0, $args = [] ): bool { if ( ! $this->current_user_can( $payment_id, $args ) ) { return false; } $is_payment_deleted = parent::delete( $payment_id ); $is_meta_deleted = wpforms()->obj( 'payment_meta' )->delete_by( 'payment_id', $payment_id ); return $is_payment_deleted && $is_meta_deleted; } /** * Retrieve a list of payments. * * @since 1.8.2 * * @param array $args Arguments. * * @return array */ public function get_payments( $args = [] ) { global $wpdb; $args = $this->sanitize_get_payments_args( $args ); if ( ! $this->current_user_can( 0, $args ) ) { return []; } // Prepare query. $query[] = "SELECT p.* FROM {$this->table_name} as p"; /** * Filter the query for get_payments method before the WHERE clause. * * @since 1.8.2 * * @param string $where Before the WHERE clause in DB query. * @param array $args Query arguments. * * @return string */ $query[] = apply_filters( 'wpforms_db_payments_payment_get_payments_query_before_where', '', $args ); $query[] = 'WHERE 1=1'; $query[] = $this->add_columns_where_conditions( $args ); $query[] = $this->add_secondary_where_conditions( $args ); /** * Extend the query for the get_payments method after the WHERE clause. * * This hook provides the flexibility to modify the SQL query by appending custom conditions * right after the WHERE clause. * * @since 1.8.4 * * @param string $where After the WHERE clause in the database query. * @param array $args Query arguments. * * @return string */ $query[] = apply_filters( 'wpforms_db_payments_payment_get_payments_query_after_where', '', $args ); // Order. $query[] = sprintf( 'ORDER BY %s', sanitize_sql_orderby( "{$args['orderby']} {$args['order']}" ) ); // Limit. $query[] = $wpdb->prepare( 'LIMIT %d, %d', $args['offset'], $args['number'] ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared $result = $wpdb->get_results( implode( ' ', $query ), ARRAY_A ); // Get results. return ! $result ? [] : $result; } /** * Create the table. * * @since 1.8.2 */ public function create_table() { global $wpdb; $charset_collate = $wpdb->get_charset_collate(); /** * To avoid any possible issues during migration from entries to payments' table, * all data types are preserved. * * Note: there must be two spaces between the words PRIMARY KEY and the definition of primary key. * * @link https://codex.wordpress.org/Creating_Tables_with_Plugins#Creating_or_Updating_the_Table */ $query = "CREATE TABLE $this->table_name ( id bigint(20) NOT NULL AUTO_INCREMENT, form_id bigint(20) NOT NULL, status varchar(10) NOT NULL DEFAULT '', subtotal_amount decimal(26,8) NOT NULL DEFAULT 0, discount_amount decimal(26,8) NOT NULL DEFAULT 0, total_amount decimal(26,8) NOT NULL DEFAULT 0, currency varchar(3) NOT NULL DEFAULT '', entry_id bigint(20) NOT NULL DEFAULT 0, gateway varchar(20) NOT NULL DEFAULT '', type varchar(12) NOT NULL DEFAULT '', mode varchar(4) NOT NULL DEFAULT '', transaction_id varchar(40) NOT NULL DEFAULT '', customer_id varchar(40) NOT NULL DEFAULT '', subscription_id varchar(40) NOT NULL DEFAULT '', subscription_status varchar(10) NOT NULL DEFAULT '', title varchar(255) NOT NULL DEFAULT '', date_created_gmt datetime NOT NULL, date_updated_gmt datetime NOT NULL, is_published tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (id), KEY form_id (form_id), KEY status (status(8)), KEY total_amount (total_amount), KEY type (type(8)), KEY transaction_id (transaction_id(32)), KEY customer_id (customer_id(32)), KEY subscription_id (subscription_id(32)), KEY subscription_status (subscription_status(8)), KEY title (title(64)) ) $charset_collate;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $query ); } /** * Check if the current user has capabilities to manage payments. * * @since 1.8.2 * * @param int $payment_id Payment ID. * @param array $args Additional arguments. * * @return bool * @noinspection IfReturnReturnSimplificationInspection */ private function current_user_can( $payment_id, $args = [] ) { $manage_cap = wpforms_get_capability_manage_options(); if ( ! isset( $args['cap'] ) ) { $args['cap'] = $manage_cap; } if ( ! empty( $args['cap'] ) && ! wpforms_current_user_can( $args['cap'], $payment_id ) ) { return false; } return true; } /** * Construct where clauses for selected columns. * * @since 1.8.4 * * @param array $args Query arguments. * * @return string */ public function add_columns_where_conditions( $args = [] ) { // Allowed columns for filtering. $allowed_cols = [ 'form_id', 'entry_id', 'status', 'subscription_status', 'type', 'gateway', ]; $where = ''; // Determine if this is a table query. $is_table_query = ! empty( $args['table_query'] ); $keys_to_validate = [ 'status', 'subscription_status', 'type', 'gateway' ]; foreach ( $args as $key => $value ) { if ( empty( $value ) || ! in_array( $key, $allowed_cols, true ) ) { continue; } // Explode values if needed. $values = explode( '|', $value ); // Run some keys through the "ValueValidator" class to make sure they are valid. if ( in_array( $key, $keys_to_validate, true ) ) { $values = array_filter( $values, static function ( $v ) use ( $key ) { return ValueValidator::is_valid( $v, $key ); } ); } // Skip if no valid values found. if ( empty( $values ) ) { continue; } // Merge "Partially Refunded" status with "Refunded" status. if ( $is_table_query && $key === 'status' && in_array( 'refunded', $values, true ) ) { $values[] = 'partrefund'; } $placeholders = wpforms_wpdb_prepare_in( $values ); // Prepare and add to WHERE clause. $where .= " AND {$key} IN ({$placeholders})"; } return $where; } /** * Construct secondary where clauses. * * @since 1.8.2 * * @param array $args Query arguments. * * @return string */ public function add_secondary_where_conditions( $args = [] ) { global $wpdb; /** * Filter arguments needed for all query. * * @since 1.8.2 * * @param array $args Query arguments. */ $args = (array) apply_filters( 'wpforms_db_payments_payment_add_secondary_where_conditions_args', $args ); $args = wp_parse_args( (array) $args, [ 'currency' => wpforms_get_currency(), 'mode' => 'live', 'is_published' => 1, ] ); $where = ''; // If it's a valid mode, add it to a WHERE clause. if ( ValueValidator::is_valid( $args['mode'], 'mode' ) ) { $where .= $wpdb->prepare( ' AND mode = %s', $args['mode'] ); } $where .= $wpdb->prepare( ' AND currency = %s', $args['currency'] ); $where .= $wpdb->prepare( ' AND is_published = %d', $args['is_published'] ); return $where; } /** * Sanitize query arguments for get_payments() method. * * @since 1.8.2 * * @param array $args Query arguments. * * @return array */ private function sanitize_get_payments_args( $args ) { $defaults = [ 'number' => 20, 'offset' => 0, 'orderby' => 'id', 'order' => 'DESC', ]; $args = wp_parse_args( (array) $args, $defaults ); // Sanitize. $args['number'] = absint( $args['number'] ); $args['offset'] = absint( $args['offset'] ); if ( $args['number'] === 0 ) { $args['number'] = $defaults['number']; } return $args; } } …ň5™!V ŕP|."!6™!V€Š°|=56™!Vđ¨P|Aa6™!Vđ`|u•ô5™!Vp|C&6™!V˙˙˙˙˙˙˙˙`|ő6™!V`˙˙˙˙P|4G6™!VP ˙˙˙˙|+|đ5™!V@¨p}Q}6™!Vp0¨€}G6™!V€Ŕ ˙˙˙˙}+ď5™!V ¨˙˙˙˙~î5™!Vđ§ €s%6™!V € €.|đ5™!VŔ§°€Q=6™!V°˙˙˙˙Ŕ€ő6™!VŔ˙˙˙˙ €4%6™!V € €."!6™!V P§¸€=@ 6™!V˙˙˙˙˙˙˙˙Đ€<ő6™!VĐ˙˙˙˙ €4G6™!V ŕ˙˙˙˙€+"!6™!V€ŕŚŔ†=56™!VĐŚP†A56™!VŔŚ`†A@ 6™!V˙˙˙˙˙˙˙˙đ†<•6™!V𐌆"!6™!V€€ŚČ†=56™!VpŚP†A56™!V`Ś`†A@ 6™!V˙˙˙˙˙˙˙˙†<6™!V †•6™!V Ś0†"!6™!V€ŚĐ†=56™!VđĽP†A56™!VŕĽ`†A@ 6™!V˙˙˙˙˙˙˙˙@†<6™!V0@P†•6™!VPĽ`†Ĺô5™!V ™ď-™˙˙˙˙†ůO™!V`˙˙˙˙˙˙˙˙†‰"!6™!V`@ĽŘ‰=56™!V0ĽP‰A&6™!V˙˙˙˙˙˙˙˙p‰=6™!Vp˙˙˙˙€‰6™!V€Ŕ€‰/"!6™!V`Ŕ¤ŕ‰=56™!V°¤P‰A&6™!V˙˙˙˙˙˙˙˙‰=6™!V˙˙˙˙ ‰ő6™!V ˙˙˙˙€‰4G6™!V€˙˙˙˙‰+"!6™!Vp ¤čŠ="!6™!V€¤đŠ=56™!V¤PŠA56™!VđŁ`ŠA@ 6™!V˙˙˙˙˙˙˙˙ŔŠ<q46™!VŔPŠu"!6™!Vp ŁřŠ="!6™!V€ŁŠ=56™!V€ŁPŠA56™!VpŁ`ŠA@ 6™!V˙˙˙˙˙˙˙˙ĐŠ<q46™!VĐPŠu56™!V Ł`ŠA&6™!V˙˙˙˙˙˙˙˙ੁq46™!Vŕ`Šu&6™!V˙˙˙˙˙˙˙˙𩁹ô5™!V°pCHš˙˙˙˙ŠůO™!Vđ˙˙˙˙˙˙˙˙Љqô5™!V˙˙˙˙‹G}ô5™!V ˙˙˙˙‹H}ô5™!V°˙˙˙˙‹H}ô5™!VŔ˙˙˙˙‹HH˙5™!V˙˙˙˙˙˙˙˙‹>Ţ6™!V€˙˙˙˙˙˙˙˙€*î5™!V°Ąs%6™!V`.|đ5™!V€Ą Qő6™!V ˙˙˙˙4%6™!V ."!6™!V 0Ą=@ 6™!V˙˙˙˙˙˙˙˙0<=6™!V0˙˙˙˙@ő6™!V@˙˙˙˙4G6™!V@˙˙˙˙+"!6™!V€  Ž=56™!V PŽA56™!V€ `ŽA@ 6™!V˙˙˙˙˙˙˙˙`Ž<•6™!V`P pŽ"!6™!V€@ Ž=56™!V0 PŽA56™!V  `ŽA@ 6™!V˙˙˙˙˙˙˙˙€Ž<6™!Vp€Ž•6™!VП Ž"!6™!V€ŔŸ Ž=56™!V°ŸPŽA56™!V Ÿ`ŽA@ 6™!V˙˙˙˙˙˙˙˙°Ž<6™!V °ŔŽ•6™!VŔPŸĐŽ"!6™!V€@Ÿ(Ž=56™!V0ŸPŽA56™!V Ÿ`ŽA@ 6™!V˙˙˙˙˙˙˙˙ŕŽ<6™!VĐŕđŽ•6™!VđО ŽĹô5™!V @i`ş˙˙˙˙ŽůO™!V ˙˙˙˙˙˙˙˙މŢ6™!V˙˙˙˙˙˙˙˙}*"!6™!V€`ž0=56™!VPžPA|đ5™!V@ž Qb%6™!V `A•ô5™!VppC&6™!V˙˙˙˙˙˙˙˙ G6™!V ˙˙˙˙+|đ5™!Vp°0 ‘QŠő5™!V€0 ˙˙˙˙‘|đ5™!Vp€P ’QŠő5™!VP ˙˙˙˙’ ń5™!V€Pp “G6™!Vp ˙˙˙˙“+ü46™!V`˙˙˙˙”+đ6™!V˙˙˙˙ ”Ţ6™!V@˙˙˙˙˙˙˙˙”*bal $wpdb; $column = esc_sql( $column ); if ( ! empty( $where ) ) { return $wpdb->get_col( "SELECT $column FROM $this->table_name WHERE $where" ); } else { return $wpdb->get_col( "SELECT $column FROM $this->table_name" ); } } /** * Select few columns based on condition * * @since 1.0.0 * * @param string $where * * @param array $columns * * @return array|object|null * */ public function get_columns_by_condition( $columns = [], $where = '', $output = ARRAY_A ) { global $wpdb; if ( ! is_array( $columns ) ) { return []; } $columns = esc_sql( $columns ); $columns = implode( ', ', $columns ); $query = "SELECT $columns FROM $this->table_name"; if ( ! empty( $where ) ) { $query .= " WHERE $where"; } return $wpdb->get_results( $query, $output ); } /** * Insert a new row * * @since 1.0.0 * * @param string $type * * @param $data * * @return int * */ public function insert( $data, $type = '' ) { global $wpdb; // Set default values $data = wp_parse_args( $data, $this->get_column_defaults() ); do_action( 'kc_us_pre_insert_' . $type, $data ); // Initialise column format array $column_formats = $this->get_columns(); // Force fields to lower case $data = array_change_key_case( $data ); // White list columns $data = array_intersect_key( $data, $column_formats ); // Reorder $column_formats to match the order of columns given in $data $data_keys = array_keys( $data ); $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); $wpdb->insert( $this->table_name, $data, $column_formats ); $wpdb_insert_id = $wpdb->insert_id; do_action( 'kc_us_post_insert_' . $type, $wpdb_insert_id, $data ); return $wpdb_insert_id; } /** * Update a specific row * * @since 1.0.0 * * @param array $data * @param string $where * * @param $row_id * * @return bool * */ public function update( $row_id, $data = [], $where = '' ) { global $wpdb; // Row ID must be positive integer $row_id = absint( $row_id ); if ( empty( $row_id ) ) { return false; } if ( empty( $where ) ) { $where = $this->primary_key; } // Initialise column format array $column_formats = $this->get_columns(); // Force fields to lower case $data = array_change_key_case( $data ); // White list columns $data = array_intersect_key( $data, $column_formats ); // Reorder $column_formats to match the order of columns given in $data $data_keys = array_keys( $data ); $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); if ( false === $wpdb->update( $this->table_name, $data, [ $where => $row_id ], $column_formats ) ) { return false; } return true; } /** * Delete a row by primary key * * @since 1.0.0 * * @param int $row_id * * @return bool * */ public function delete( $row_id = 0 ) { global $wpdb; // Row ID must be positive integer $row_id = absint( $row_id ); if ( empty( $row_id ) ) { return false; } $where = $wpdb->prepare( "$this->primary_key = %d", $row_id ); if ( false === $this->delete_by_condition( $where ) ) { return false; } return true; } /** * Delete all rows. * * @since 1.8.0 * @return bool */ public function delete_all() { global $wpdb; if ( false === $wpdb->query( "DELETE FROM $this->table_name" ) ) { return false; } return true; } /** * Delete by column * * @since 1.1.0 * * @param $value * * @param $column * * @return bool * */ public function delete_by( $column, $value ) { global $wpdb; if ( empty( $column ) ) { return false; } $where = $wpdb->prepare( "$column = %s", $value ); if ( false === $this->delete_by_condition( $where ) ) { return false; } return true; } /** * Delete rows by primary key * * @since 1.0.0 * * @param array $row_ids * * @return bool * */ public function bulk_delete( $row_ids = [] ) { if ( ! is_array( $row_ids ) && empty( $row_ids ) ) { return false; } $row_ids_str = $this->prepare_for_in_query( $row_ids ); $where = "$this->primary_key IN( $row_ids_str )"; if ( false === $this->delete_by_condition( $where ) ) { return false; } return true; } /** * Delete records based on $where * * @since 1.0.0 * * @param string $where * * @return bool * */ public function delete_by_condition( $where = '' ) { global $wpdb; if ( empty( $where ) ) { return false; } if ( false === $wpdb->query( "DELETE FROM $this->table_name WHERE $where" ) ) { return false; } return true; } /** * Update specific column by condition. * * @since 1.8.7 * * @param $column * @param $value * @param $where * * @return bool */ public function update_by_condition( $column, $value, $where ) { global $wpdb; if ( empty( $where ) ) { return false; } $query = $wpdb->prepare( "UPDATE $this->table_name SET $column = %s WHERE $where", $value ); if ( false === $wpdb->query( $query ) ) { return false; } return true; } /** * Check whether table exists or not * * @since 1.0.0 * * @param $table * * @return bool * */ public function table_exists( $table ) { global $wpdb; $table = sanitize_text_field( $table ); return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; } /** * Check whether table installed * * @since 1.0.0 * @return bool * */ public function installed() { return $this->table_exists( $this->table_name ); } /** * Get total count * * @since 1.0.0 * @return string|null * */ public function count( $where = '' ) { global $wpdb; $query = "SELECT count(*) FROM $this->table_name"; if ( ! empty( $where ) ) { $query .= " WHERE $where"; } return $wpdb->get_var( $query ); } /** * Insert data into bulk * * @since 1.0.0 * * @param int $length * @param string $type * * @param $values */ public function bulk_insert( $values, $length = 100 ) { global $wpdb; if ( ! is_array( $values ) ) { return false; } // Get the first value from an array to check data structure $first_value = array_slice( $values, 0, 1 ); $data = array_shift( $first_value ); // Set default values $data = wp_parse_args( $data, $this->get_column_defaults() ); // Initialise column format array $column_formats = $this->get_columns(); // Remove primary key as we don't require while inserting data unset( $column_formats[ $this->primary_key ] ); // Force fields to lower case $data = array_change_key_case( $data ); // White list columns $data = array_intersect_key( $data, $column_formats ); // Reorder $column_formats to match the order of columns given in $data $data = wp_parse_args( $data, $this->get_column_defaults() ); $data_keys = array_keys( $data ); $fields = array_keys( array_merge( array_flip( $data_keys ), $column_formats ) ); // Convert Batches into smaller chunk $batches = array_chunk( $values, $length ); foreach ( $batches as $key => $batch ) { $place_holders = $final_values = []; foreach ( $batch as $value ) { $formats = []; foreach ( $column_formats as $column => $format ) { $final_values[] = isset( $value[ $column ] ) ? $value[ $column ] : $data[ $column ]; // set default if we don't have $formats[] = $format; } $place_holders[] = '( ' . implode( ', ', $formats ) . ' )'; $fields_str = '`' . implode( '`, `', array_keys( $column_formats ) ) . '`'; } $query = "INSERT INTO $this->table_name ({$fields_str}) VALUES "; $query .= implode( ', ', $place_holders ); $sql = $wpdb->prepare( $query, $final_values ); if ( ! $wpdb->query( $sql ) ) { return false; } } return true; } /** * @param $table_name * @param $fields * @param $place_holders * @param $values * * @return bool * * @sicne 1.0.0 */ public static function do_insert( $table_name, $fields, $place_holders, $values ) { global $wpdb; $fields_str = '`' . implode( '`, `', $fields ) . '`'; $query = "INSERT INTO $table_name ({$fields_str}) VALUES "; $query .= implode( ', ', $place_holders ); $sql = $wpdb->prepare( $query, $values ); if ( $wpdb->query( $sql ) ) { return true; } else { return false; } } /** * Get ID, Name Map * * @since 1.0.0 * * @param string $where * * @return array * */ public function get_id_name_map( $where = '' ) { return $this->get_columns_map( $this->primary_key, 'name', $where ); } /** * Get map of two columns * * e.g array($column_1 => $column_2) * * @since 1.0.0 * * @param string $column_2 * @param string $where * * @param string $column_1 * * @return array * */ public function get_columns_map( $column_1 = '', $column_2 = '', $where = '' ) { if ( empty( $column_1 ) || empty( $column_2 ) ) { return []; } $columns = [ $column_1, $column_2 ]; $results = $this->get_columns_by_condition( $columns, $where ); $map = []; if ( count( $results ) > 0 ) { foreach ( $results as $result ) { $map[ $result[ $column_1 ] ] = $result[ $column_2 ]; } } return $map; } public static function prepare_data( $data, $column_formats, $column_defaults, $insert = true ) { // Set default values if ( $insert ) { $data = wp_parse_args( $data, $column_defaults ); } // Force fields to lower case $data = array_change_key_case( $data ); // White list columns $data = array_intersect_key( $data, $column_formats ); // Reorder $column_formats to match the order of columns given in $data $data_keys = array_keys( $data ); $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); return [ 'data' => $data, 'column_formats' => $column_formats, ]; } /** * Prepare string for SQL IN query * * @since 1.0.0 * * @param array $array * * @return string * */ public function prepare_for_in_query( $array = [] ) { $array = esc_sql( $array ); if ( is_array( $array ) && count( $array ) > 0 ) { return "'" . implode( "', '", $array ) . "'"; } return ''; } /** * Save Data * * @since 1.0.2 * * @param null $id * * @param array $data * * @return bool|int * */ public function save( $data = [], $id = null ) { if ( is_null( $id ) ) { return $this->insert( $data ); } else { return $this->update( $id, $data ); } } /** * Concert To Associative Array * * @since 1.2.1 * * @param $key * @param $value * @param string $null_label * * @param $results * * @return array * */ public function convert_to_associative_array( $results, $key, $value, $null_label = 'unknown' ) { if ( empty( $results ) ) { return []; } $final_array = []; foreach ( $results as $result ) { if ( ! empty( $result[ $key ] ) ) { $final_array[ $result[ $key ] ] = $result[ $value ]; } else { $final_array[ $null_label ] = $result[ $value ]; } } return $final_array; } /** * Get data from cache * * @since 1.4.7 * * @param $found * * @param $key * * @return false|mixed * */ public function get_cache( $key, &$found ) { return Cache::get( $key, 'query', false, $found ); } /** * Set data into cache * * @since 1.4.7 * * @param string $value * * @param string $key */ public function set_cache( $key = '', $value = '' ) { if ( ! empty( $key ) ) { Cache::set( $key, $value, 'query' ); } } /** * Check if cache exists? * * @since 1.4.7 * * @param string $key * * @return bool * */ public function cache_exists( $key = '' ) { return Cache::exists( $key, 'query' ); } /** * Generate cache key * * @since 1.4.7 * * @param string $str * * @return string * */ public function generate_cache_key( $str = '' ) { return Cache::generate_key( $str ); } }