123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- global $acf_stores, $acf_instances;
- $acf_stores = array();
- $acf_instances = array();
- function acf_new_instance( $class = '' ) {
- global $acf_instances;
- return $acf_instances[ $class ] = new $class();
- }
- function acf_get_instance( $class = '' ) {
- global $acf_instances;
- if ( ! isset( $acf_instances[ $class ] ) ) {
- $acf_instances[ $class ] = new $class();
- }
- return $acf_instances[ $class ];
- }
- function acf_register_store( $name = '', $data = false ) {
-
- $store = new ACF_Data( $data );
-
- global $acf_stores;
- $acf_stores[ $name ] = $store;
-
- return $store;
- }
- function acf_get_store( $name = '' ) {
- global $acf_stores;
- return isset( $acf_stores[ $name ] ) ? $acf_stores[ $name ] : false;
- }
- function acf_switch_stores( $site_id, $prev_site_id ) {
-
- global $acf_stores;
- foreach ( $acf_stores as $store ) {
- $store->switch_site( $site_id, $prev_site_id );
- }
- }
- add_action( 'switch_blog', 'acf_switch_stores', 10, 2 );
- function acf_get_path( $filename = '' ) {
- return ACF_PATH . ltrim( $filename, '/' );
- }
- function acf_get_url( $filename = '' ) {
- if ( ! defined( 'ACF_URL' ) ) {
- define( 'ACF_URL', acf_get_setting( 'url' ) );
- }
- return ACF_URL . ltrim( $filename, '/' );
- }
- function acf_include( $filename = '' ) {
- $file_path = acf_get_path( $filename );
- if ( file_exists( $file_path ) ) {
- include_once $file_path;
- }
- }
|