| | 2062 | |
| | 2063 | /** |
| | 2064 | * Retrieve a network meta field for a user from the sitemeta table |
| | 2065 | * |
| | 2066 | * @since 3.7.0 |
| | 2067 | * |
| | 2068 | * @uses get_metadata() |
| | 2069 | * |
| | 2070 | * @param int $network_id Network ID. Corresponds to site_id in the sitemeta table. |
| | 2071 | * @param string $key Optional. The meta key to retrieve. By default, returns data for all keys. |
| | 2072 | * @param bool $single Whether to return a single value. |
| | 2073 | * |
| | 2074 | * @return array|string Array if $single is false. Value of the meta data field if $single is true. |
| | 2075 | */ |
| | 2076 | function get_network_meta( $network_id, $key = '', $single = false ) { |
| | 2077 | return get_metadata( 'site', $network_id, $key, $single ); |
| | 2078 | } |
| | 2079 | |
| | 2080 | /** Add a metadata field to a network. |
| | 2081 | * |
| | 2082 | * $since 3.7.0 |
| | 2083 | * |
| | 2084 | * @uses add_metadata() |
| | 2085 | * |
| | 2086 | * @param int $network_id Network ID. Corresponds to site_id in the sitemeta table. |
| | 2087 | * @param string $key Metadata name. |
| | 2088 | * @param mixed $value Metadata value. Must be serializable if non-scalar. |
| | 2089 | * @param bool $unique Optional. Default is false. Whether the same key should be added. |
| | 2090 | * |
| | 2091 | * @return bool|int Meta ID on success. False on failure. |
| | 2092 | */ |
| | 2093 | function add_network_meta( $network_id, $key, $value, $unique = false ) { |
| | 2094 | return add_metadata( 'site', $network_id, $key, $value, $unique ); |
| | 2095 | } |
| | 2096 | |
| | 2097 | /** |
| | 2098 | * Update network meta field based on network ID. |
| | 2099 | * |
| | 2100 | * Use the $prev_value parameter to differentiate between meta fields with the |
| | 2101 | * same key and network ID. |
| | 2102 | * |
| | 2103 | * @since 3.7.0 |
| | 2104 | * |
| | 2105 | * @uses update_metadata() |
| | 2106 | * |
| | 2107 | * @param int $network_id Network ID. Corresponds to site_id in the sitemeta table. |
| | 2108 | * @param string $key Key of metadata to be updated. |
| | 2109 | * @param mixed $value Metadata value. Must be serializable if non-scalar. |
| | 2110 | * @param mixed $prev_value Optional. Previous value to check before removing. |
| | 2111 | * |
| | 2112 | * @return bool True on success. False on failure. |
| | 2113 | */ |
| | 2114 | function update_network_meta( $network_id, $key, $value, $prev_value = '' ) { |
| | 2115 | return update_metadata( 'site', $network_id, $key, $value, $prev_value ); |
| | 2116 | } |
| | 2117 | |
| | 2118 | /** |
| | 2119 | * Remove specified metadata from a network. |
| | 2120 | * |
| | 2121 | * @since 3.7.0 |
| | 2122 | * |
| | 2123 | * @uses delete_metadata() |
| | 2124 | * |
| | 2125 | * @param int $network_id Network ID. Corresponds to site_id in the sitemeta table. |
| | 2126 | * @param string $key Key of metadata to be deleted. |
| | 2127 | * @param mixed $value Optional. Metadata value. Must be serializable if non-scalar. |
| | 2128 | * |
| | 2129 | * @return bool True on success. False on failure. |
| | 2130 | */ |
| | 2131 | function delete_network_meta( $network_id, $key, $value = '' ) { |
| | 2132 | return delete_metadata( 'site', $network_id, $key, $value ); |
| | 2133 | } |