@@ -205,6 +205,40 @@ public static function get_carbon_plugin_option( $key, $cache = true ) {
205205
206206 }
207207
208+ /**
209+ * Get Carbon Fields network container option (if multisite enabled)
210+ *
211+ * @param string $key The name of the option key
212+ * @param string $container The name of the Carbon Fields network container
213+ * @param bool $cache Whether or not to attempt to get cached value
214+ * @param int $site_id The network site ID to use - default: SITE_ID_CURRENT_SITE
215+ * @return mixed The value of specified Carbon Fields option key
216+ * @link https://carbonfields.net/docs/containers-usage/ Carbon Fields containers
217+ * @since 0.4.1
218+ *
219+ */
220+ public static function get_carbon_network_option ( $ key , $ container = null , $ cache = true , $ site_id = null ) {
221+
222+ if ( !$ site_id ) {
223+ if ( !defined ( 'SITE_ID_CURRENT_SITE ' ) ) return null ;
224+ $ site_id = SITE_ID_CURRENT_SITE ;
225+ }
226+
227+ if ( !$ container ) $ container = self ::$ config ->get ( 'network/default_options_container ' );
228+ $ key = self ::prefix ( $ key );
229+
230+ if ( $ cache ) {
231+ // Attempt to get value from cache, else fetch value from database
232+ return self ::$ cache ->get_object ( $ key , function () use ( &$ key ) {
233+ return carbon_get_network_option ( $ site_id , $ key , $ container );
234+ });
235+ } else {
236+ // Return uncached value
237+ return carbon_get_network_option ( $ site_id , $ key , $ container );
238+ }
239+
240+ }
241+
208242 /**
209243 * Get plugin option from WordPress Settings API Class, with object caching
210244 * (if available).
0 commit comments