Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Make compatible with older versions of ACF5
Browse files Browse the repository at this point in the history
  • Loading branch information
funkjedi committed Jan 29, 2017
1 parent 69b7751 commit 5745268
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion acf-qtranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Advanced Custom Fields: qTranslate
Plugin URI: http://github.com/funkjedi/acf-qtranslate
Description: Provides multilingual versions of the text, text area, and wysiwyg fields.
Version: 1.7.20
Version: 1.7.21
Author: funkjedi
Author URI: http://funkjedi.com
License: GPLv2 or later
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: funkjedi
Tags: acf, advanced custom fields, qtranslate, add-on, admin
Requires at least: 3.5.0
Tested up to: 4.7.2
Version: 1.7.20
Stable tag: 1.7.20
Version: 1.7.21
Stable tag: 1.7.21
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -54,6 +54,9 @@ The plugin is based on code samples posted to the ACF support forums by taeo bac

== Changelog ==

= 1.7.21 =
* Bug Fix: Make compatible with older versions of ACF5 by checking for `acf_connect_attachment_to_post`

= 1.7.20 =
* Core: Added ability to display LSBs on specific pages

Expand Down
12 changes: 7 additions & 5 deletions src/acf_5/fields/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,16 @@ function update_value($values, $post_id, $field) {
// validate
if ( !is_array($values) ) return false;

foreach ($values as $value) {
if (function_exists('acf_connect_attachment_to_post')) {
foreach ($values as $value) {

// bail early if not attachment ID
if( !$value || !is_numeric($value) ) continue;
// bail early if not attachment ID
if( !$value || !is_numeric($value) ) continue;

// maybe connect attacments to post
acf_connect_attachment_to_post( (int) $value, $post_id );
// maybe connect attacments to post
acf_connect_attachment_to_post( (int) $value, $post_id );

}
}

return qtrans_join($values);
Expand Down

0 comments on commit 5745268

Please sign in to comment.