Forum Replies Created

  • The error comes from wpai-acf-add-on and not from acf itself, but check and watch this topic to see if any solutions posted there will work for you. It might be related to one of issues posted there.

  • @pacuk4386 @voala @edward-bernstein Turn on debug log and check what’s the error. Probably you will get something different than:
    “PHP Fatal error: Can’t use function return value in write context in /public_html/wp-content/plugins/advanced-custom-fields-pro/includes/local-fields.php on line 304”.

    I got the same error as @pshay92 so that is why it worked for her. None of you posted any error messages. Please turn WP_DEBUG_LOG if you don’t have it enabled to see what error you get. Since it’s not a php issue for you, any logs will help resolve the problem.

    @voala I’ve tested this on our hosting on 5.6 its working ok with 5.7.11 but crashes on 5.4, so you must have different issue

  • I can now confirm that it’s a version PHP 5.4 that cause this issue. Which is old anyway.

    Solution, update your PHP to version 7. Version 5.6 works just fine if you can’t use any of the 7ish, but I highly recommend use most recent available on your server.

  • Check your PHP version on server. The only site that crashed for us after update (and I’ve updated ~20 sites) have php 5.4. Waiting for access to hosting panel right now to change it and test it, but if I would take a guess it would be it. So can anyone of you check php version on crashed sites and if changing to some 7ish will solve the issue?

    Reversing to 5.7.10 helped for now on that one site for us.

  • It might not work because you have set “ID” or object as a returned value, and not URL.

    I had similar issue and this is what I used (note that I restricted this to wp-content/uploads only and it’s for images and files):

    function my_acf_format_value( $value, $post_id, $field ) {
            $value['url'] = str_replace('your-domain/wp-content/uploads', 'cdn/wp-content/uploads', $value['url']);
            if(isset($value['sizes']) && !empty($value['sizes'])){
                foreach($value['sizes'] as $key=>$size){
                    $value['sizes'][$key] = str_replace('your-domain/wp-content/uploads', 'cdn/wp-content/uploads', $size);
            $value = str_replace('your-domain/wp-content/uploads', 'cdn/wp-content/uploads', $value);    
    	return $value;
    add_filter('acf/format_value/type=image', 'my_acf_format_value',10,3);
    add_filter('acf/format_value/type=file', 'my_acf_format_value',10,3);

    And bonus for changing default wordpress URLs for attachments.

    function cdn_attachments_urls($url, $post_id) {
      return str_replace('your-domain/wp-content/uploads', 'cdn/wp-content/uploads', $url);
    add_filter('wp_get_attachment_url', 'cdn_attachments_urls', 10, 2);
  • Yep, tested this few times myself now, and it’s working ok.

    So $wpdb->remove_placeholder_escape() to the rescue!

  • You can follow comments on WP update post to find possible solutions. There are already few people that have issue with this new escaping.

  • Ok thanks John. I thought that Bug reports, are a place where I can post “bug reports” ;o) I’ve submitted a new ticket. Thanks again.

  • If anyone is interested I’ve modified a file /wp-content/plugins/advanced-custom-fields-pro/admin/views/settings-export-generate.php

    By adding this:

    //textdomain and i18n for label
    $code = preg_replace('/\'label\' => \'(.*)\'/', '\'label\' => _x(\'$1\',\'ACF - '.$field_groups[0]['title'].'\',\''.$current_textdomain.'\')',$code);
    //textdomain and i18n for label
    $code = preg_replace('/\'instructions\' => \'(.*)\'/', '\'instructions\' => _x(\'$1\',\'ACF - '.$field_groups[0]['title'].'\',\''.$current_textdomain.'\')',$code);

    just before echo. There is only one thing I can’t figure out – as I genuinely hate regex – how to skip empty strings as this is also changed
    'instructions'=>'' to _x('','ACF','textdomain')

    This doesn’t work for choices in checkbox/select/radio etc and by looking at structure of the var_export it would be almost impossible to make “choice” translatable.

    So I am thinking that maybe a way out would be in label/instructions/choices adding lang:My label name, and later search and replace everything that starts with lang: and make it as __() or_x() depending on preferences. It would have to be striped in the frontend tho, or maybe even changed in frontend to __(). That way it could work even without export.

    What you think?

  • I know it’s a bit old topic, but I have an idea. Not sure if it’s doable in the ACF but I did something similar in the past (not in wordpress). In order to fetch all images I created field media[] that was simply an array of all images/files used in the page. So when a user added an image I also added new field that stored the id to it:
    <input name="media[]" value="image_id">
    I then stored this field in database – which hold all the media connected to this particular page, and then just query images with the IN() in the frontend. This way I had only one query and not 20-30 depending on the amount of images/files connected to that page.

    In the backend I also used to remove all duplicates in media array.

    I am not sure is this possible in ACF as I’m not very familiar with the ACF source code, but it could be a really good solution. Let me know your thoughts about it.

    I use this tool to see where I can have performance problems, and I have now 158 queries where 98 are ACF. And by looking what is it, it’s mostly images, as I have repeater for “partners”. Because there needs to be added URL I can’t use gallery for that.

  • This is something I dream about ;o) Please, please make translatable strings in PHP export.

    Although I think it should add currently active textdomain and you can always use the “updateDomains” option in that grunt plugin.

    It would be awesome to have an option for the use of _x() function similar to this:

    _x('This is my label','ACF - Field group name','textdomain')

  • +1 I would love to see something like that in ACF where you define “global” layouts that can be used in “Flexible layouts” and then you can decide which one should be available. Something similar to that:

    I usualy replace wordpress “content” field with flexible layouts where almost everytime there is “single column”, “two columns”, “column with image” etc which now I have to recreate for every template as there are some additional layouts that must be available depending on page template.

    That would help a lot.

Viewing 12 posts - 1 through 12 (of 12 total)

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.