437 * |
437 * |
438 * @see WP_Site_Query::parse_query() |
438 * @see WP_Site_Query::parse_query() |
439 * |
439 * |
440 * @param string|array $args Optional. Array or string of arguments. See WP_Site_Query::__construct() |
440 * @param string|array $args Optional. Array or string of arguments. See WP_Site_Query::__construct() |
441 * for information on accepted arguments. Default empty array. |
441 * for information on accepted arguments. Default empty array. |
442 * @return array|int List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', |
442 * @return WP_Site[]|int[]|int List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', |
443 * or the number of sites when 'count' is passed as a query var. |
443 * or the number of sites when 'count' is passed as a query var. |
444 */ |
444 */ |
445 function get_sites( $args = array() ) { |
445 function get_sites( $args = array() ) { |
446 $query = new WP_Site_Query(); |
446 $query = new WP_Site_Query(); |
447 |
447 |
448 return $query->query( $args ); |
448 return $query->query( $args ); |
1024 * |
1024 * |
1025 * @since 5.1.0 |
1025 * @since 5.1.0 |
1026 * |
1026 * |
1027 * @param int $site_id Site ID. |
1027 * @param int $site_id Site ID. |
1028 * @param string $meta_key Metadata name. |
1028 * @param string $meta_key Metadata name. |
1029 * @param mixed $meta_value Metadata value. Must be serializable if non-scalar. |
1029 * @param mixed $meta_value Metadata value. Arrays and objects are stored as serialized data and |
|
1030 * will be returned as the same type when retrieved. Other data types will |
|
1031 * be stored as strings in the database: |
|
1032 * - false is stored and retrieved as an empty string ('') |
|
1033 * - true is stored and retrieved as '1' |
|
1034 * - numbers (both integer and float) are stored and retrieved as strings |
|
1035 * Must be serializable if non-scalar. |
1030 * @param bool $unique Optional. Whether the same key should not be added. |
1036 * @param bool $unique Optional. Whether the same key should not be added. |
1031 * Default false. |
1037 * Default false. |
1032 * @return int|false Meta ID on success, false on failure. |
1038 * @return int|false Meta ID on success, false on failure. |
1033 */ |
1039 */ |
1034 function add_site_meta( $site_id, $meta_key, $meta_value, $unique = false ) { |
1040 function add_site_meta( $site_id, $meta_key, $meta_value, $unique = false ) { |
1067 * This parameter has no effect if `$key` is not specified. |
1073 * This parameter has no effect if `$key` is not specified. |
1068 * Default false. |
1074 * Default false. |
1069 * @return mixed An array of values if `$single` is false. |
1075 * @return mixed An array of values if `$single` is false. |
1070 * The value of meta data field if `$single` is true. |
1076 * The value of meta data field if `$single` is true. |
1071 * False for an invalid `$site_id` (non-numeric, zero, or negative value). |
1077 * False for an invalid `$site_id` (non-numeric, zero, or negative value). |
1072 * An empty string if a valid but non-existing site ID is passed. |
1078 * An empty array if a valid but non-existing site ID is passed and `$single` is false. |
|
1079 * An empty string if a valid but non-existing site ID is passed and `$single` is true. |
|
1080 * Note: Non-serialized values are returned as strings: |
|
1081 * - false values are returned as empty strings ('') |
|
1082 * - true values are returned as '1' |
|
1083 * - numbers (both integer and float) are returned as strings |
|
1084 * Arrays and objects retain their original type. |
1073 */ |
1085 */ |
1074 function get_site_meta( $site_id, $key = '', $single = false ) { |
1086 function get_site_meta( $site_id, $key = '', $single = false ) { |
1075 return get_metadata( 'blog', $site_id, $key, $single ); |
1087 return get_metadata( 'blog', $site_id, $key, $single ); |
1076 } |
1088 } |
1077 |
1089 |