Giter Club home page Giter Club logo

acf's Introduction

Advanced Custom Fields

Welcome to the official Advanced Custom Fields repository on GitHub. ACF is a WordPress plugin used to take full control of your edit screens & custom field data.

Documentation

Do you need help getting started with ACF, or do you have questions about one of the ACF features? You can search through our documentation here. If you don't find the answers you're looking for, you can start a new forum thread in the support forum or contact our support team

If you've got feedback or a feature suggestion for ACF, please use our feedback board

Support

This repository is not suitable for support. Please don't use our issue tracker for support requests, but for core issues only. Support can take place in the appropriate channels:

  • Community forum
  • Email based ticket system

These channels can be accessed from our support website.

Contributing

If you have a patch, or stumbled upon an issue with ACF core, you can contribute this back to the code. Please create a new github issue with as much information as possible, and a PR if appropriate.

Translations

If you're looking to translate ACF, you can submit new PRO translations via a PR on this repo. Any strings from the free version are imported from translate.wordpress.org. For more information, please view our translation guide

acf's People

Contributors

anthonyburchell avatar cfoellmann avatar elliotcondon avatar lgladdy avatar mattgrshaw avatar moritzjacobs avatar polevaultweb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acf's Issues

Conflict with other plugins / themes that use Walker_Nav_Menu_Edit

This is a known limitation in WordPress, admin menu items are a bit tricky to work with.

At the moment, ACF_Walker_Nav_Menu_Edit breaks the menu items functionality added by other plugins and themes. There's no support for multiple walkers, so if ACF walker is loaded after other plugins, it overwrites those other plugins custom's code (can happen other way around, and ACF menu item code is rendered useless as well).

Theme and plugin developers took a shared approach and now add a hook named wp_nav_menu_item_custom_fields, so others can extend the menu items, even without their specific Walker being used. Examples:

Can that hook be added in ACF_Walker_Nav_Menu_Edit? It would be helpful for everyone, as it makes cross-plugin compatibility easier to implement.

Cheers

Custom buttons not visible in TinyMCE

Buttons created with custom plugin are not visible in a repeater field inside WYSIWYG editor.
No errors thrown.

When using v5.6.10, custom buttons are visible:

With

In v5.7.0-RC1 same buttons are not visible:

With

No other plugins are used except acf pro and our custom plugin.

How to add fields to the default settings pages?

Hey. Can I use ACF to add fields to the settings pages created by WordPress itself, for example here /wp-admin/options-reading.php? By default, ACF does not know this, but can there be methods to overcome this constraint?

Load Images with Selected Field

Dear Coders,
Tried many times to register into your web site but there is no activation mail, tried with different mail providers but no mail !

There is question,
I've tried to make some hierarchical fields, Everything is OK
but my question is, Is it possible to load an image with selected field ? or attach image to every field by default ?

capture

acf-json + fields' translation

I would like to use fields (defined, versioned and deployed using ACF-JSON) for various sites having different languages.
Is there a plan to handle ACF JSON when it comes to i18n fields?

A couple of hooks (are available at load-time/save-time to load/write translations (acf/prepare_field_group_for_export, NB: acf_import_field_group is missing a similar hook, only acf/update_field_group is provided) but formalize it (and why not, implement it), would be appreciated for forward-compatibility.

w3c issued a couple of guideline and draft on this topic some months ago:

Cloning all fields from field group that has repeater. Won't save repeater values.

I seem to have found an issue with the Clone field.

Steps to recreate:
1 - Create a Field Group named Layouts, for sake of reference.
2 - Then create a Repeater in that Layouts group.
3 - Populate that Repeater with some dummy fields. ( image, text, etc. )
4 - Create a new Field Group, named Home Page, for sake of reference and assign it to Home template.
5 - In the Home Page field group, create a Clone field and set it to "All fields from Layouts field group".
6 - Go to Home template, upload repeater subfields with content then update the page. The fields reset to blank.

Way I got it to work for now: On step 5, set Clone field to clone just the "Layouts (repeater)". Now it will save subfields just fine.

Side note: ACF is the greatest thing to ever happen to WordPress. Fantastic work!

Loading symbol on front end forms oddly placed.

When displaying a Field Group on the front end via acf_form() the loading symbol that appears on submit often appears in something random - or seemingly random. Seems like it should be moved inside the submit button so it's consistent. I'm happy to submit a patch for this but would like to know if such a patch would be accepted.

Flexible Content field resets itself

Issue

After creating layout sub fields and hit update on the custom field form everything is OK. After a few page updates with this custom fields, the custom fields reset itself. It sets all the the layout sub field to the first layout subfield.

I can temporary solve it by dragging all the layout subfields back to their original position, but after a while it resets again

Cause

This issue happens at random and I wasn't able to reproduce it for this issue, I did manage to take a screenshot after it happened.

issue

ACF Field JavaScript API

Dear ACF and JS developers,

Work on our upcoming version 5.7 is now entering it's final stages! If you are not yet up to speed on the new changes, please read our ACF PRO 5.7.0 – New Architecture for New Features blog post.

Whilst we tidy up the remaining bugs, testing, beta releases and documentation, we would love to get your opinions, feedback and help in reviewing our JS library.

At the center of this library is the acf.Field class. This is what will be used the most by conditional logic, 3rd party developers and other core logic when interacting with a field.

Example

For example, you can find a field on the screen like so:
var field = acf.getField('field_123456');

You can then get it's value like so:
var val = field.val();

This is all pretty basic stuff, but each field type requires different logic due to it's unique Markup and functionality. What we have tried to do is break down these actions into easy to customize functions allowing for rapid development.

Breaking down .val()

For example, the val() function is broken down into getValue() and setValue() depending on if a value parameter is defined.

These functions call getInput() to find the field's "jQuery input element" and return it's jQuery .val().

This means that when creating the Select field type, all we needed to do for all conditional logic support was define the getInput() function to look like this:

var Field = acf.Field.extend({
	type: 'select',
	getInput: function(){
		return this.$('select');
	},
	// ...
});

acf.registerFieldType( Field );

The BIG question

We are quite happy with the acf.Field class in terms of its usability and functionality, but are still not 100% sure we nailed the naming conventions.

For now, lets focus on the getInput() function, but keep in mind that each field has other elements too which need to be 'standardized'. This includes the:

  • Label wrap: "> .acf-label"
  • Input wrap: "> .acf-input"
  • input control: ".acf-repeater:first" or ".acf-date-picker"

To help decide, we have put together some choices. Each have their own pros and cons. We have tested them all, and the performance between them are almost the same, so we are more interested in "what is the current standard" or "what is best for our developers".

Idea 1. Store on initialization

Each field is initialized once (either on page load or when the HTML is newly appended). This is used to initialize field specific functionality such as .sortable() or .datepicker().

During initialization, we currently set the field jQuery object to the field.$el property. It would be easy enough to also set the $input, $control and any other $elements.

The field object would then look like so:

var field = {
	$el: jQueryElement,
	$input: jQueryElement,
	$control: jQueryElement,
	// ...
}

The upside to this, is that all jQuery elements are distinctly found with the prefix '$' which would help "console log debugging". For example, field.search = function(){}; and field.$search = jQueryElement;

The downside is this will add unnecessary "jQuery searching" during initialization to find elements.

Idea 2. Stick with getElement

As we currently have it, elements are found using get prefixed functions.

The field object looks like so:

var field = {
	$el: jQueryElement,
	getInput: function(){ return jQueryElement;  },
	getControl: function(){ return jQueryElement;  },
	// ...
}

The upside of this is that during initialization, there is no unnecessary "jQuery searching".
The downside is that without documentation, it is not clear these functions return jQuery elements.
For example, field.getValue() returns the field's value, but and field.getInput() returns a jQuery element.

Idea 3. A mixture of both

We have also tried a version that mixes both ideas together and looks like so:

var field = {
	$el: jQueryElement,
	$input: function( return jQueryElement; ),
	$control: function( return jQueryElement; ),
	// ...
}

The upside of this is that these functions are easy to identify as jQuery element functions. You would use them like so:
field.$control().addClass('has-value');

Idea 4. Find

Throughout the new JS library, we have used the prefix "find" when returning jQuery elements, and "get" when returning native JS types. For example:

// returns a collection of jQuery field elements
var $fields = acf.findFields();

// returns an array of `acf.Field` instances.
var fields = acf.getFields();

Following in these footsteps we could use the same principles like so:

var field = {
   $el: jQueryElement,
   findInput: function(){ return jQueryElement;  },
   findControl: function(){ return jQueryElement; },
   // ...
}

The upside to this is a much more coherent JS library.

How to contribute

Please leave your comments below, we would love to hear from you. Please remember to be diplomatic and helpful in our conversation. Everyone is entitled to their own opinion, and we are looking for positive ideas, suggestions and feedback.

Thanks
Elliot

Taxonomy field ignores accented characters when checking if a term exists

Steps to reproduce

  1. Using the ACF taxonomy term, insert a new term without using characters: e.g. Commes des Garcons
  2. Then try and insert a new term with accented characters: e.g. Comme des Garçons. ACF considers them identical and won't add it.
  3. The default WP taxonomy admin pages does treat the two names as different, and will let you add them both.

Admittedly, a bit of an edge case, but client ran into this issue on a site that handles a lot of accented characters. They had incorrectly spelt a term, but when they tried to correct it by adding a new term with the correct accented characters, the ACF field refused to insert it. I'm guessing it compares against the slug rather than the term name itself. While you can edit the terms using WP's default taxonomy menus, I prefer to not show those in the admin to simplify things for the end client.

clarify how ACF save_post is triggered by programmatic methods (eg: post import)

When using wp_insert_post() like does wxr-importer we save posts from an export file.
Such a file may (or may not) contains the field_<uniqid>() meta (eg: if meta does not come from WordPress or fields unique ids changed)
But they do contain the actual meta-key/meta-value registered with ACF:

This is a sample (shortened) WXR file:

<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="WordPress/4.9.1" created="2018-04-24 18:40" -->
<rss version="2.0" xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/1.2/">
  <channel>
    <description/>
    <pubDate>Tue, 24 Apr 18 18:40:31 +0100</pubDate>
    <language>en-US</language>
    <wp:wxr_version>1.2</wp:wxr_version>
    <item>
      <title>foo</title>
      <pubDate>Wed, 07 Mar 12 20:17:20 +0000</pubDate>
      <dc:creator>me</dc:creator>
      <guid isPermaLink="false">https://localhost/368</guid>
      <description></description>
      <content:encoded><![CDATA[body]]></content:encoded>
      <excerpt:encoded><![CDATA[excerpt]]></excerpt:encoded>
      <wp:post_id>368</wp:post_id>
      <wp:post_date>2012-03-07 20:17:20</wp:post_date>
      <wp:post_date_gmt>2012-03-07 20:17:20</wp:post_date_gmt>
      <wp:comment_status>closed</wp:comment_status>
      <wp:ping_status>closed</wp:ping_status>
      <wp:post_name></wp:post_name>
      <wp:status>publish</wp:status>
      <wp:post_parent></wp:post_parent>
      <wp:menu_order></wp:menu_order>
      <wp:post_type>news</wp:post_type>
      <wp:is_sticky>0</wp:is_sticky>
      <wp:postmeta>
	<wp:meta_key>sources</wp:meta_key>
	<wp:meta_value><![CDATA[1]]></wp:meta_value>
      </wp:postmeta>
      <wp:postmeta>
	<wp:meta_key>sources_0_url</wp:meta_key>
	<wp:meta_value><![CDATA[a:2:{s:5:"title";s:15:"BBC NATURE";s:3:"url";s:36:"http://www.bbc.co.uk/nature/foo";}]]></wp:meta_value>
      </wp:postmeta>
    </item>
  </channel>
</rss>

The file get imported correctly and the backend UI correctly shows the custom fields value's (since these fields must have been registered beforehand).
The issue is that fields won't work in the frontend (get_field() is NULL) because field_ab546aff meta keys are missing although the post was processed using wp_insert_post() on the ACF-enabled WP instance.
(These are repeater fields. The issue does not arise with plain text fields)

  • Saving the post manually from the backoffice creates the needed meta.
  • Saving the post using wp_insert_post(get_post(368))); will not work (!)

I'd likely attempt to resave each imported post, so that meta get created, but I'd like to know which ACF function to call for each of them. I could not find such a helper so far.

  1. why ACF "save" hook(s) reserved to admin backend (and not working otherwise)?
  2. which ACF function could serve as a resave-to-recreate-internal-meta-key helper?

NB: this is a long-standing "issue", simply google +acf +wp_insert_post

thank you

Subplugin with WPML and ACF detects wrong language

Hello,

currently I found a little bug in my Plugin, which output my german fields on my france page.
I'm using th newest WPML und ACF Plugin versions.

I could fix this behavior with following snippet in my theme function:

add_action('wp', function() {
    global $sitepress;

    acf_update_setting('current_language', $sitepress->get_current_language());
});

Solution found here: https://github.com/AdvancedCustomFields/acf/blob/master/includes/wpml.php#L33

PS: I think it is not save to use ICL_LANGUAGE_CODE as the Identifier. Because a theme/plugin can easily switch the language programmatically with $sitepress->switch_lang('en');.

Fatal error: Cannot use object of type WP_Error as array

Fatal error: Cannot use object of type WP_Error as array in /public_html/wp-content/plugins/advanced-custom-fields/includes/early-access.php on line 272

I ptrint this array
pinrt_r($info);

WP_Error Object ( [errors] => Array ( [http_request_failed] => Array ( [0] => cURL error 28: connect() timed out! ) ) [error_data] => Array ( ) )

Version: 5.6.10

2 ways to upload pictures

2 ways to upload pictures
1、Fill in the picture address through the input box
2、Through the upload button
20180526152931

WHY?
Because...
Many people need to use CDN ...

ACF Technical Support Position

Overview

The Advanced Custom Fields plugin is continuing to grow and needs a skilled support team that reflects the quality of our product.

We offer various portals for help, all of which require attention:

  • Support Tickets: On average, we receive an average of 25 new or updated (a reply is sent to the customer) conversations which require a reply. This is the primary support channel and it is expected that each ticket is replied to (and solved) promptly. We currently hire a single company who handle all support via their own team, however, the quality of support given is not at the level that we require.

  • Support Forum: We also have a public support forum which allows developers and users to post topics, reply to others and collaborate together to discuss ideas, problems and such. We currently hire a single freelance web developer to help the community solve tickets. Anything bug related or complex is directed to a new support ticket.

  • Documentation: Last but not least are our documentation articles. Without these, our customers would be lost. A major gripe I have with the current support team is that the documentation is never improved. I believe a large part of providing help via support tickets should also be the debrief afterwards and improvements made to existing / new documentation.

Job brief

We are looking for WordPress Developers to join the Support ticket helpdesk and provide assistance to our customers. You will diagnose and troubleshoot incoming issues, help direct our customers to relevant documentation/solutions and work together to keep the helpdesk at "inbox zero".

Through our Helpdesk, you will be the first point of contact with our customers. Here, you will have the chance to view the available tickets, continue conversations and assign them. Tickets that require "sales" or "admin" should be assigned to the lead developer, all others are available for your assistance.

Ultimately, you will be a person our customers trust. They will rely on you to provide timely and accurate solutions to their technical problems.

Responsibilities

  • Taking ownership of customer issues reported and seeing problems through to resolution
  • Researching, diagnosing, troubleshooting and identifying solutions to resolve issues
  • Identifying and escalating priority tickets to the lead developer
  • Ask customers targeted questions to quickly understand the root of the problem
  • Talk clients through a series of actions until they’ve solved a technical issue
  • Properly escalate unresolved issues to the lead developer
  • Provide prompt and accurate feedback to customers
  • Refer to internal or external resources to provide information, solutions, context
  • Ensure all issues are properly tagged
  • Prioritize and manage several open issues at one time
  • Maintain jovial relationships with clients

Code Standards

As you may be aware, WordPress core now mostly conforms to WPCS (with an ongoing project to address the remaining violations), so getting prominent plugins to adhere to them as well not only helps the authors and contributors of those plugins, but ensures that the community as a whole benefits from code following the same code style conventions and best practices.

Would there be any interest in adding code standards checking for this repo? PHP_CodeSniffer plus WordPress Coding Standards?

I'd propose to add:

  • an .editorconfig file (example) so supporting IDEs follow the basics code style consistently.
  • a basic composer.json so that dependencies are explicitly declared and isolated via the require-dev section (example, though this includes extra dependencies not needed for this repo); PHPCS, WPCS, PHPCompatibility and VariableAnalysis packages.
  • a .phpcs.xml.dist file (example though this would be customised for ACF) so that checks are run consistently and easily.

Initially, there will be lots of CS violations (warnings and errors), and these can be addressed over time, or through a concerted effort to fix groups of files. Later, exclusions could be added to the config file, or at the per-line level, though adding exclusions typically means not conforming in the long term.

The benefit of fixing the low-level stuff (typically whitespace or optional braces, missing periods in documentation and comments, etc.), is that more important issues are easier to see (output not escaped, deprecated functions being used, syntax used that doesn't match up with lowest supported version of PHP etc.)

If there is interest, then I'm happy to do the PR for the above proposed items (not the actual CS fixes, initially).

PHP Warning: A non-numeric value encountered in /wp-content/plugins/acf-repeater/4/views/field.php on line 184

Hi there,

I'm getting the following error in the error_log. Is it something that could be prevented for the next version?

Thanks,
Sam

[Mon Jun 04 10:32:40.951740 2018] [php7:warn] [pid 20644] [client 127.0.0.1:58406] PHP Warning:  A non-numeric value encountered in /wp-content/plugins/acf-repeater/4/views/field.php on line 184, referer: http://mysite.co.uk/wp-admin/post-new.php
[Mon Jun 04 10:32:40.952305 2018] [php7:warn] [pid 20644] [client 127.0.0.1:58406] PHP Warning:  A non-numeric value encountered in /wp-content/plugins/acf-repeater/4/views/field.php on line 184, referer: http://mysite.co.uk/wp-admin/post-new.php
[Mon Jun 04 10:32:40.953228 2018] [php7:warn] [pid 20644] [client 127.0.0.1:58406] PHP Warning:  A non-numeric value encountered in /wp-content/plugins/acf-repeater/4/views/field.php on line 184, referer: http://mysite.co.uk/wp-admin/post-new.php
[Mon Jun 04 10:36:57.624452 2018] [php7:warn] [pid 20662] [client 127.0.0.1:58512] PHP Warning:  A non-numeric value encountered in /wp-content/plugins/acf-repeater/4/views/field.php on line 184, referer: http://mysite.co.uk/wp-admin/
[Mon Jun 04 10:36:57.624815 2018] [php7:warn] [pid 20662] [client 127.0.0.1:58512] PHP Warning:  A non-numeric value encountered in /wp-content/plugins/acf-repeater/4/views/field.php on line 184, referer: http://mysite.co.uk/wp-admin/
[Mon Jun 04 10:36:57.625784 2018] [php7:warn] [pid 20662] [client 127.0.0.1:58512] PHP Warning:  A non-numeric value encountered in /wp-content/plugins/acf-repeater/4/views/field.php on line 184, referer: http://mysite.co.uk/wp-admin/

Revert PHP export

Hi!
I trusted your advice and moved my acf configuration to a functions.php file.
I still agree that it's a good idea, but I miss a way to edit them again without going through the craziness of manual editing that array.
Have you think of any way to solve this problem?

Thanks

Call to a member function register_field_type() on null on line 204 in advanced-custom-fields/includes/fields.php

Version: ACF Free 5.6.10
PHP: 7.1
WP: 4.9.6

While trying to preview or update a page in the WordPress admin I get an error that looks like this one:

Call to a member function register_field_type() on null on line 204 in TRUNCATED/wp-content/plugins/advanced-custom-fields/includes/fields.php
#0 TRUNCATED/wp-content/plugins/advanced-custom-fields/includes/fields/class-acf-field-text.php(167): acf_register_field_type('acf_field_text')
#1 TRUNCATED/wp-content/plugins/advanced-custom-fields/includes/api/api-helpers.php(397): include_once('TRUNCATED')
#2 TRUNCATED/wp-content/plugins/advanced-custom-fields/acf.php(261): acf_include('includes/fields...')
#3 TRUNCATED/wp/wp-includes/class-wp-hook.php(286): ACF->init('')
#4 TRUNCATED/wp/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#5 TRUNCATED/wp/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#6 TRUNCATED/wp/wp-settings.php(450): do_action('init')
#7 TRUNCATED/wp-config.php(27): require_once('TRUNCATED')
#8 TRUNCATED/wp/wp-load.php(42): require_once('TRUNCATED')
#9 TRUNCATED/wp/wp-admin/admin.php(31): require_once('TRUNCATED')
#10 TRUNCATED/wp/wp-admin/post.php(12): require_once('TRUNCATED')
#11 {main}

Relevant version information:

    "wpackagist-plugin/advanced-custom-fields": "5.6.10",
    "wpackagist-plugin/acf-content-analysis-for-yoast-seo": "2.0.1",

Let me know if I missed anything here. Would love to help getting rid of this error.

Layout - Unable to access parent fields after checking `have_rows()`

Here's some simplified code:

<?php the_sub_field( 'tools_section_title' ); // Works Here ?>
<?php if( have_rows( 'tool_cards' ) ): ?>
    <h2><?php the_sub_field( 'tools_section_title' ); // Stops working ?></h2>
    <?php while ( have_rows( 'tool_cards' ) ) : the_row(); ?>
        <h3><?php the_sub_field( 'tool_title' ); ?></h3>
        <p><?php the_sub_field( 'tool_text' ); ?></p>
    <?php endwhile; ?>
<?php endif; ?>

When this appears inside a flexible layout, after checking have_rows() I can no longer access data from the 'parent' context. When not in a flexible layout, you would normally just use the_field(), but here we have a special case... perhaps we need a function like the_parent_field() for this special case?

Kinda hoping I've got something wrong here. Thanks for the great code Elliot! 🎊

Cannot disable a datepicker field manipulating $field

Hello everyone!

I was trying to disable some fields according the clean way suggested by the documentation:

function my_acf_prepare_field( $field ) {
	if( $field['value'] ) {
		$field['disabled'] = true;
	}
    return $field;
}

But I noticed that this code doesn't work (it's still possible to interact with the field) on the datepicker field (the same is true also datetime picker). I dug a bit into the code and I realized that, simply, the disabled attribute is not honored because there's not code that makes use of it.

Since it's quite trivial to solve, I'm about to submit a small pull request. :)

Have a nice day!

Add .DS_Store to .gitignore

Looks like your local .gitignore file doesn't exclude macOS created .DS_Store files. You'll probably want these in your global gitignore since it looks like you're using macOS:

.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes

ACF Pro 5.7.0 beta – Media Modal not working with Gutenberg editor

Just tested the new ACF Pro 5.7.0 beta version for a couple of days, and the Media Modal won't open on image fields in Gutenberg editor. Nothing happens if you click the "Add media"-button. Also not able do edit images already saved on posts created with previous version of ACF. This was working fine with ACF Pro 5.6.10, and same Gutenberg version (2.7.0)

WordPress 4.9.5
ACF PRO 5.7.0 (beta 2 & 3)
Gutenberg 2.7.0

Add limit characters on Wysiwyg

Hi,

Is it possible to add a limit characters on Wysiwyg same as on the text area ?

So very nice job for this plugin ;)

Peace

Excluding ACF JS/CSS files from certain admin pages

ACF includes large JS files such as tinymc and thickbox, they add about 1.5MB of code, which slows down admin pages.

I'm trying to find a way to exclude them on certain admin pages. I'm afraid that if I just do wp_dequeue_script('thickbox') and wp_dequeue_script('editor') it'll break your other code that depends on it and cause blocking JS error.

Do you have a recommendation on how to exclude ACF JS and CSS files from certain admin pages? Or disable ACF entirely on certain admin pages? Something like:

if ($_GET['no_acf'] ) {
  disable_acf();
}

Many thanks!

Components with two or more Clone fields will overwrite with the last field

Summary

When we create a component with two or more Clone type components, the data from the first components get overwritten with the data from the last component.

Example

For this example, we created a Content Box (1), which is a WYSIWYG, and a Write In component (2), which is essentially a text field with a text area:
(1)
image

(2)
image

Now, here is the component with two Clone fields:
image

Here is the Two Column Container component created in a new page with the two clone fields using the initially mentioned components:
image

And here is the same Two Column Container component after it is published/updated in the same page:
image

Note

This example uses only two Clone field components for simplicity, but the same happens if you have more than two Clone field components. There are other components in this project, but none of them share the same name as any of the components mentioned in the example section.

Widget Select2 Fields Broken

As of version 5.7.0, ACF fields on widgets that use Select2 js will initialize twice when the widget is first added to the widget location. This causes the field to break entirely until reload.

ACF 5.7.3 issue with WPML: editing taxonomy makes UI disappear

When trying to add or edit taxonomy fields all fields disappear from the interface.
I believe this happens with translated taxonomies. I deactivated WPML and the issue didn't occur.
The issue started after updating ACF to version 5.7.3

Tried with the previous version and it worked fine.

[Feedback] Adding a new results filter for AJAX choices

Hi all,

I'm looking for some feedback on a new filter. Please be sure to post your comments bellow and 'thumbs up' other comments you like!

Overview

I'm looking to add a new filter to customize the 'AJAX results' for choice based fields. The aim of this filter is to allow the select field (and others) to be used with 'Remote Data Sources' or simply to be customized with PHP.

The fields currently using AJAX to load choices are: Select, Relationship, Post Object, Page Link, Taxonomy and User. These fields use Select2 to handle the AJAX functionality which expects a JSON response like:

array(
	'results' => array(
		'red' => 'Red',
		'green' => 'Green',
	),
	'more' => true
);

Existing Filters

ACF contains some existing filters used in AJAX queries, and it is important to keep a similar naming convention. Existing filters look like:

'acf/fields/post_object/query' - modify the get_posts() query $args
'acf/fields/post_object/result' - modify each result $title

New filter name

Here are some suggested names for the filter:

'acf/fields/select/results' - implies modifying the array of results
'acf/fields/select/response' - implies modifying the AJAX response

* note that the above is in context of the select field type. This would change for each different field type such as post_object, relationship, etc.

What do you think of this filter name? Please let me know in the comments below.

New filter paramters

This filter will only be as useful as the parameters it is given. The obvious ones are:

  1. $results - (array) the data to be modified by this filter (format to be discussed)
  2. $field - (array) the field array containing all attributes & settings
  3. $post_id - (int|string) the current post ID being edited
  4. $paged - (int) the current page being queried (used for paginating results)
  5. $search - (string) the search term if entered

What do you think of these parameters? Please let me know in the comments below.

New filter functionality

This filter allows us to modify the $results, but what does $results look like?
As shown previously, Select2 expects and array containing:

  1. results: This is the array of returned 'key => value' pairs
  2. more: This boolean value tells Select2 if there is 'more data' to load (allows pagination loading via scroll)

I'm happy to keep things consistent between the filtered PHP $response to the returned JSON, however, it is possible for us to use a different 'data format'.

Here is an example showing 2 different ways the $response could look. This is only an example returning 2 results at a time (more is true):

1. Select2 friendly.

  • Allows you to edit both 'results' and 'more' independently, and provides a future proof way of adding more data to the returned response.
  • Makes sense for the naming to be 'response'
array(
	'results' => array(
		'red' => 'Red',
		'green' => 'Green',
	),
	'more' => true
);

2. Simple

  • Allows you to edit both 'results' and 'more' together in the same array
  • May cause issues if an actual choice has a value of '_more' (unlikely)
  • Makes sense for the naming to be 'results'
array(
	'red' => 'Red',
	'green' => 'Green',
	'_more' => true
);

Thanks

Thanks in advance for your comments, thoughts, advice and votes. Please keep your comments as short and precise as possible. I'm only looking for general feedback at the moment, we can have more in depth discussions afterwards. πŸ˜„πŸ‘

[ACF PRO 5.7.0-beta1] "acf.get_fields is not a function"

While running acf_form on the frontend:

VM2581 input.js:484 Uncaught TypeError: acf.get_fields is not a function at VM2581 input.js:484 at _runHook (VM2576 acf-input.js:2299) at Object.doAction (VM2576 acf-input.js:2125) at Object.acf.doAction (VM2576 acf-input.js:819) at HTMLDocument.<anonymous> (VM2576 acf-input.js:2045) at i (VM2555 jquery-1.12.4.min.js:2) at Object.fireWith [as resolveWith] (VM2555 jquery-1.12.4.min.js:2) at Function.ready (VM2555 jquery-1.12.4.min.js:2) at HTMLDocument.K (VM2555 jquery-1.12.4.min.js:2)

[ACF PRO 5.7.0-beta1] Can't add field (JS error)

Hi all.

Trying to use the beta but I'm not able to add a field to a Field Group.

Description: Just installed the ACF beta (ACF PRO 5.7.0-beta1) on a new install using LOCAL by Flywheel. I created a new Field Group called 'Post' and left the default location to Post Type is Post. When I tried to add a field clicking the 'Add Field+' button, nothing happens. There is the following js error in the console:

Uncaught TypeError: Cannot read property 'field_object' of undefined
at acf-pro-field-group.min.js:1
at acf-pro-field-group.min.js:1

Expected behavior: ability to add a field.

Steps to reproduce:

  1. Install ACF Pro 5.7.1 beta1
  2. Create Field Group
  3. Try to add a field

I also tried deactivating and reactivating the plugin but that had no effect.

There are no other plugins installed.

Wrong language in backend

Hi!

First of all, thanks for the great plugin! I've noticed an issue with the language that ACF is using in the backend, though. My site's language is German, but in my profile I've selected that the WordPress backend language should be English. However, ACF ignores the language I selected in my profile and displays everything in German. If I change the site language to English ACF displays its whole UI in English. Please adjust?

Thanks!
Ed

acf/settings/load_json filter not parsing JSON

Hi there,
First, i want to tell you that ACF is an amazing Plugin which helps me a lot..
Now i'm making a plugin which uses ACF
This plugin is supposed to use it's own JSON fields
I added current filter
$this->loader->add_filter('acf/settings/load_json', $this, 'acf_json_load_point');
The JSON file is loaded, and the Sync functionality works great !
BUT
The default exported JSON is found, but not parsed
When i remove the begining array chars "[" and at end "]" it works

This does not works :

[
    {
        "key": "group_5a3c0e1b7d21f",
        "title": "my title",
        "fields": [
            {
                "key"....
   ....
    }
]

But this works :

{
        "key": "group_5a3c0e1b7d21f",
        "title": "my title",
        "fields": [
            {
                "key"....
   ....
}

It will be good if you take a look on how the JSON is parsed using the filter...

Group Field Color Picker z-index Problems

Using ACF 5.6.2 and WP 4.8.2, I'm seeing the following with the Color Picker in a Group Field:

image
Using the Block layout, the popup is underneath the sidebar elements

image
When in the group field, a color picker with a set width may have the group field dividers appear over the popup.

I haven't done enough testing to determine if this is a universal color picker issue or just one with the group field.

Regardless, the popup picker should obviously appear above all other page elements.

allow relative urls & those which contain anchors

Can you please make the changes in this file acf/includes/fields/class-acf-field-url.php

To allow relative URLS:
/a/b/c
/a/b/c#some-anchor

I have tried using a custom validation and doesn't work!
I've even tried defining

// https://www.advancedcustomfields.com/resources/acf-validate_value/
add_filter('acf/validate_value', 'wbs_network_acf_validate_value', 10, 4);
//add_filter('acf/validate_value/type=url', 'wbs_network_acf_validate_value', 10, 4);

function wbs_network_acf_validate_value( $valid, $value, $field, $input ) {
    // allow relative links to be used which could contain an anchor
    if( 1 || !$valid && preg_match('!^[\/\w\-\#]+$!si', $value)) {
        $valid = true;
    }

    return $valid;
}

I've even tried defining the class ... still nothing.

add_action('acf/init', 'wbs_acf_init', 0);

function wbs_acf_init() {
    if ( ! class_exists('acf_field_url') ) {
        class acf_field_url extends acf_field {
            /*
            *  initialize
            *
            *  This function will setup the field type data
            *
            *  @type	function
            *  @date	5/03/2014
            *  @since	5.0.0
            *
            *  @param	n/a
            *  @return	n/a
            */

            function initialize()
            {

                // vars
                $this->name = 'url';
                $this->label = __("Url", 'acf');
                $this->defaults = array(
                    'default_value' => '',
                    'placeholder' => '',
                );

            }


            /*
            *  render_field()
            *
            *  Create the HTML interface for your field
            *
            *  @param	$field - an array holding all the field's data
            *
            *  @type	action
            *  @since	3.6
            *  @date	23/01/13
            */

            function render_field($field)
            {

                // vars
                $atts = array();
                $keys = array('type', 'id', 'class', 'name', 'value', 'placeholder', 'pattern');
                $keys2 = array('readonly', 'disabled', 'required');
                $html = '';


                // atts (value="123")
                foreach ($keys as $k) {
                    if (isset($field[$k])) $atts[$k] = $field[$k];
                }


                // atts2 (disabled="disabled")
                foreach ($keys2 as $k) {
                    if (!empty($field[$k])) $atts[$k] = $k;
                }


                // remove empty atts
                $atts = acf_clean_atts($atts);


                // render
                $html .= '<div class="acf-input-wrap acf-url">';
                $html .= '<i class="acf-icon -globe -small"></i>' . acf_get_text_input($atts);
                $html .= '</div>';


                // return
                echo $html;

            }


            /*
            *  render_field_settings()
            *
            *  Create extra options for your field. This is rendered when editing a field.
            *  The value of $field['name'] can be used (like bellow) to save extra data to the $field
            *
            *  @type	action
            *  @since	3.6
            *  @date	23/01/13
            *
            *  @param	$field	- an array holding all the field's data
            */

            function render_field_settings($field)
            {

                // default_value
                acf_render_field_setting($field, array(
                    'label' => __('Default Value', 'acf'),
                    'instructions' => __('Appears when creating a new post', 'acf'),
                    'type' => 'text',
                    'name' => 'default_value',
                ));


                // placeholder
                acf_render_field_setting($field, array(
                    'label' => __('Placeholder Text', 'acf'),
                    'instructions' => __('Appears within the input', 'acf'),
                    'type' => 'text',
                    'name' => 'placeholder',
                ));

            }


            /*
            *  validate_value
            *
            *  description
            *
            *  @type	function
            *  @date	11/02/2014
            *  @since	5.0.0
            *
            *  @param	$post_id (int)
            *  @return	$post_id (int)
            */

            function validate_value($valid, $value, $field, $input)
            {
                return true;

                // bail early if empty
                if (empty($value)) {

                    return $valid;

                }


                if (strpos($value, '://') !== false) {

                    // url

                } elseif (strpos($value, '//') === 0) {

                    // protocol relative url

                } else {

                    $valid = __('Value must be a valid URL', 'acf');

                }


                // return
                return $valid;

            }

        }

// initialize
        acf_register_field_type('acf_field_url');
    }
}

Options retrieval issues in get_field_objects()

Looks like get_field_objects() generates non optimal sql query, when as $post_id is provided option name with '_' character or ending with a digit.

For example, this call:
get_fields('option1');

generates query:

SELECT option_name, option_value
FROM wp_options
WHERE option_name LIKE 'option1_%'
OR option_name LIKE '_option1_%';

and could match some records, which belongs to 'option11', 'option12' and so on.

If I understand correctly, query should have every '_' char in params escaped here

$rows = $wpdb->get_results($wpdb->prepare(
"SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s",
$post_id . '_%' ,
'_' . $post_id . '_%'
), ARRAY_A);

to create query like this:

SELECT option_name, option_value
FROM wp_options
WHERE option_name LIKE 'option1\_%'
OR option_name LIKE '\_option1\_%';

For some cases I have several times more rows retrieved from database than it's necessary.

Propose an updated composer.json for PRO version

Hi,

I am currently using the project https://github.com/PhilippBaschke/acf-pro-installer to get ACF PRO installed through composer.

While it works great, I need to manually set the version of each ACF version to get the update installed.

That would be great if you could maintain a repository with a simple composer.json file that could be used to enable updates through composer.

Something like https://github.com/johnpbloch/wordpress but with the package format used in https://github.com/PhilippBaschke/acf-pro-installer.

Even if I am a PRO user, a composer.json in this repository should help installation / upgrade through composer also for free version.

What to do you think about that?

Thanks,

`wp.hooks` implementation overridden by AFC PRO

I was able to reproduce the bug filed in the Gutenberg repository WordPress/gutenberg#5860 by installing ACF Pro (v5.6.9).

This issue is caused by the ACF implementation in assets/js/acf-input.js file, lines 8-250:

var EventManager = function() {
    ...
};

window.wp = window.wp || {};
window.wp.hooks = new EventManager();

Putting this into words, ACF reimplements wp.hooks instead of using the already present module registered under wp-hooks name. My understanding is that it removes some of the filters registered previously causing the issue.

Hooks library which is developed under https://github.com/WordPress/packages/tree/master/packages/hooks and published to npm as https://www.npmjs.com/package/@wordpress/hooks is planned to be included under wp.hooks namespace in WordPress core in the 5.0 release. To avoid that kind of conflicts it might be a good idea to detect if wp.hooks is already defined and provide your implementation only when it is missing.

Firefox validation bug

A bug in Firefox 59 and below prevents the form from submitting after ACF validation has been performed. Please find updated .js files below to place into the 'assets/js' folder
Archive.zip

Radio Input `other` value is not valid when other_choice is disabled

Running ACF PRO 5.7.1 -

I have a radio field with other_choice set to 0 / off. One of the custom choice values we present is
other which triggers conditional logic on other fields.
If other_choice is set to 0, we'd expect a value of other to be valid or accept a null value. However, this now triggers an error in acf-input.js line 6868.

{Chrome}
Uncaught TypeError: this.inputText is not a function at Child.getValue (acf-input.js?ver=5.7.1:6868) at Child.val (acf-input.js?ver=5.7.1:4090) at Child.match (acf-input.js?ver=5.7.1:9416) at Child.calculate (acf-input.js?ver=5.7.1:8637) at acf-input.js?ver=5.7.1:9047 at Array.filter (<anonymous>) at acf-input.js?ver=5.7.1:9046 at Array.map (<anonymous>) at Child.calculate (acf-input.js?ver=5.7.1:9040) at Child.render (acf-input.js?ver=5.7.1:9023)

If the value of the field is set to other, there is an assumption that there is inputText() on the field, although in this case because other_choice is off, there is no inputText.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.