HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: /volume1/web1//wp-content/plugins/polylang/include/db-tools.php
<?php
/**
 * @package Polylang
 */

defined( 'ABSPATH' ) || exit; // @phpstan-ignore-line

/**
 * Small set of tools to work with the database.
 *
 * @since 3.2
 */
class PLL_Db_Tools {

	/**
	 * Changes an array of values into a comma separated list, ready to be used in a `IN ()` clause.
	 * Only string and integers and supported for now.
	 *
	 * @since 3.2
	 *
	 * @param  array<int|string> $values An array of values.
	 * @return string                    A comma separated list of values.
	 */
	public static function prepare_values_list( $values ) {
		$values = array_map( array( __CLASS__, 'prepare_value' ), (array) $values );

		return implode( ',', $values );
	}

	/**
	 * Wraps a value in escaped double quotes or casts as an integer.
	 * Only string and integers and supported for now.
	 *
	 * @since  3.2
	 * @global wpdb $wpdb
	 *
	 * @param  int|string $value A value.
	 * @return int|string
	 */
	public static function prepare_value( $value ) {
		if ( ! is_numeric( $value ) ) {
			return $GLOBALS['wpdb']->prepare( '%s', $value );
		}

		return (int) $value;
	}
}