Last active
July 13, 2022 19:21
-
-
Save mklasen/0c3891d1e91f2d4eb2bf1897e79d0588 to your computer and use it in GitHub Desktop.
Save custom fields to custom plugin folder. All three examples do exactly the same thing in different ways.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Plugin { | |
public function __construct() { | |
add_filter( 'acf/settings/save_json', array( $this, 'acf_location' ) ); | |
add_filter( 'acf/settings/load_json', array( $this, 'acf_locations' ) ); | |
} | |
public function acf_location() { | |
return plugin_dir_path( __FILE__ ) . 'acf-json/'; | |
} | |
public function acf_locations() { | |
return array(plugin_dir_path( __FILE__ ) . 'acf-json/'); | |
} | |
} | |
new Plugin(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'acf/settings/save_json', 'acf_location' ); | |
add_filter( 'acf/settings/load_json', 'acf_locations' ); | |
function acf_location() { | |
return '/var/www/app/www/content/plugins/maatwerk-plugin/acf-json'; | |
} | |
function acf_location() { | |
return array('/var/www/app/www/content/plugins/maatwerk-plugin/acf-json'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'acf/settings/save_json', function() { | |
return '/var/www/app/www/content/plugins/maatwerk-plugin/acf-json'; | |
}); | |
add_filter( 'acf/settings/load_json', function() { | |
return array('/var/www/app/www/content/plugins/maatwerk-plugin/acf-json'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment