本文整理汇总了PHP中acf函数的典型用法代码示例。如果您正苦于以下问题:PHP acf函数的具体用法?PHP acf怎么用?PHP acf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_dependency_satisfied
/**
* Check if plugin dependencies are satisfied and add an admin notice if not
*
* @return bool
*/
public static function is_dependency_satisfied()
{
if (class_exists('acf') && version_compare(acf()->settings['version'], self::PLUGIN_MIN_VERSION, '>=')) {
return true;
}
return false;
}
示例2: is_version_compatible
/**
* Check if the installed version of ACF is compatible with this version of Layotter
*
* @return bool
*/
public static function is_version_compatible()
{
if (self::is_pro_installed()) {
return version_compare(acf_get_setting('version'), self::REQUIRED_PRO_VERSION) >= 0;
} else {
return version_compare(acf()->get_info('version'), self::REQUIRED_VERSION) >= 0;
}
}
示例3: acf_append_setting
function acf_append_setting($name, $value)
{
// createa array if needed
if (!isset(acf()->settings[$name])) {
acf()->settings[$name] = array();
}
// append to array
acf()->settings[$name][] = $value;
}
示例4: __construct
function __construct()
{
$this->acf_version = acf()->settings['version'];
if (version_compare($this->acf_version, '4.0', '>=')) {
add_filter('facetwp_facet_sources', array($this, 'facet_sources'));
add_filter('facetwp_indexer_post_facet', array($this, 'indexer_post_facet'), 1, 2);
add_filter('facetwp_acf_display_value', array($this, 'index_source_other'), 1, 2);
}
}
示例5: acf_repeater_collapser_acf5_compat
function acf_repeater_collapser_acf5_compat()
{
if (!class_exists('acf')) {
return;
}
$acf_version = acf()->settings['version'];
if (version_compare($acf_version, '5.0', '>=')) {
add_filter('acf/compatibility/field_wrapper_class', '__return_true');
}
}
示例6: acf_check_404
function acf_check_404()
{
if (function_exists('acf')) {
$acf = acf();
}
// not set or < v5 of ACF
if (!isset($acf) || version_compare($acf->settings['version'], '5.0', '<')) {
add_action('admin_notices', 'acf_404');
add_action('network_admin_notices', 'acf_404');
}
}
示例7: is_dependency_satisfied
/**
* Check if plugin dependencies are satisfied and add an admin notice if not
*
* @return bool
*/
public function is_dependency_satisfied()
{
if (class_exists('acf')) {
//TODO: Should this be function_exists?
$acf = \acf();
if (version_compare($acf->settings['version'], self::PLUGIN_MIN_VERSION, '>=')) {
return true;
}
}
return false;
}
示例8: acf_repeater_collapser_assets
function acf_repeater_collapser_assets()
{
$acf_version = acf()->settings['version'];
if (version_compare($acf_version, '4.0', '>=') && version_compare($acf_version, '5.0', '<')) {
// version 4.X
wp_enqueue_script('acf_repeater_collapser_admin_js', esc_url(plugins_url('js/acf4_repeater_collapser_admin.js', __FILE__)), array('jquery'), ACF_REPEATER_COLLAPSER_VERSION);
wp_enqueue_style('acf_repeater_collapser_admin_css', esc_url(plugins_url('css/acf4_repeater_collapser_admin.css', __FILE__)), false, ACF_REPEATER_COLLAPSER_VERSION);
} elseif (version_compare($acf_version, '5.0', '>=')) {
// version 5.X
wp_enqueue_script('acf_repeater_collapser_admin_js', esc_url(plugins_url('js/acf5_repeater_collapser_admin.js', __FILE__)), array('jquery'), ACF_REPEATER_COLLAPSER_VERSION);
wp_enqueue_style('acf_repeater_collapser_admin_css', esc_url(plugins_url('css/acf5_repeater_collapser_admin.css', __FILE__)), false, ACF_REPEATER_COLLAPSER_VERSION);
}
}
示例9: get_field_object
function get_field_object($selector, $post_id = false, $format_value = true, $load_value = true)
{
// complete loading
acf()->complete();
// compatibilty
if (is_array($format_value)) {
extract($format_value);
}
// vars
$field_name = false;
// get valid post_id
$post_id = acf_get_valid_post_id($post_id);
// load field reference if not a field_key
if (!acf_is_field_key($selector)) {
// save selector as field_name (could be sub field name)
$field_name = $selector;
// get reference
$selector = acf_get_field_reference($selector, $post_id);
// bail early if no reference for this field
if (!$selector) {
return false;
}
}
// get field key
$field = acf_get_field($selector);
// bail early if no field found
if (!$field) {
return false;
}
// Override name - allows the $selector to be a sub field (images_0_image)
if ($field_name) {
$field['name'] = $field_name;
}
// load value
if ($load_value) {
$field['value'] = acf_get_value($post_id, $field);
}
// format value
if ($format_value) {
// get value for field
$field['value'] = acf_format_value($field['value'], $post_id, $field);
}
// return
return $field;
}
示例10: acf_set_form_data
function acf_set_form_data($data = array())
{
return acf()->input->set_data($data);
}
示例11: acf_update_setting
function acf_update_setting($name, $value)
{
return acf()->update_setting($name, $value);
}
示例12: get_field_object
function get_field_object($selector, $post_id = false, $format_value = true, $load_value = true)
{
// complete loading
acf()->complete();
// compatibilty
if (is_array($format_value)) {
$format_value = acf_parse_args($format_value, array('format_value' => true, 'load_value' => true));
extract($format_value);
}
// vars
$override_name = false;
// filter post_id
$post_id = acf_get_valid_post_id($post_id);
// load field reference if not a field_key
if (!acf_is_field_key($selector)) {
$override_name = $selector;
$reference = acf_get_field_reference($selector, $post_id);
if ($reference) {
$selector = $reference;
}
}
// get field key
$field = acf_get_field($selector);
// bail early if no field found
if (!$field) {
return false;
}
// override name?
// This allows the $selector to be a sub field (images_0_image)
if ($override_name) {
$field['name'] = $override_name;
}
// load value
if ($load_value) {
$field['value'] = acf_get_value($post_id, $field);
}
// format value
if ($format_value) {
// get value for field
$field['value'] = acf_format_value($field['value'], $post_id, $field);
}
// return
return $field;
}
示例13: acf_local
function acf_local()
{
return acf()->local;
}
示例14: acf_remove_loop
function acf_remove_loop($i = 'active')
{
return acf()->loop->remove_loop($i);
}
示例15: acf_get_db_updates
function acf_get_db_updates()
{
// vars
$available = array();
$db_updates = acf()->admin->install->db_updates;
$acf_version = acf_get_setting('version');
$db_version = acf_get_db_version();
// bail early if is fresh install
if (!$db_version) {
acf_update_db_version($acf_version);
return false;
}
// bail early if is up to date
if (acf_version_compare($db_version, '>=', $acf_version)) {
return false;
}
// loop
foreach ($db_updates as $version => $callback) {
// ignore if update is for a future version (may exist for testing)
if (acf_version_compare($version, '>', $acf_version)) {
continue;
}
// ignore if update has already been run
if (acf_version_compare($version, '<=', $db_version)) {
continue;
}
// append
$available[$version] = $callback;
}
// bail early if no updates available
// - also update DB to current version
if (empty($available)) {
acf_update_db_version($acf_version);
return false;
}
// return
return $available;
}