Skip to content

Commit

Permalink
Merge pull request #30 from BeAPI/fix/field-registration
Browse files Browse the repository at this point in the history
update field registration for ACF 5.6 or greater
  • Loading branch information
petitphp authored Jul 17, 2023
2 parents c75e162 + 723e012 commit 6b0f0a2
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions acf-svg-icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,20 @@ public static function load_translation() {
* @since 1.0.0
*/
public static function register_field_v5() {
$version = version_compare( acf_get_setting( 'version' ), '5.6.O', '>=' ) ? 56 : 5;

// Include the corresponding files
include_once sprintf( '%sfields/acf-base.php', ACF_SVG_ICON_DIR );
include_once sprintf( '%sfields/acf-%s.php', ACF_SVG_ICON_DIR, $version );

/**
* Instantiate the corresponding class
* @see acf_field_svg_icon_56
* @see acf_field_svg_icon_5
*/
$klass = sprintf( 'acf_field_svg_icon_%s', $version );
new $klass();
if ( version_compare( acf_get_setting( 'version' ), '5.6.O', '>=' ) ) {
// Register field for ACF 5.6 or greater
include_once sprintf( '%sfields/acf-base.php', ACF_SVG_ICON_DIR );
include_once sprintf( '%sfields/acf-56.php', ACF_SVG_ICON_DIR );

acf_register_field_type( 'acf_field_svg_icon_56' );
} else {
// Register field for ACF 5
include_once sprintf( '%sfields/acf-base.php', ACF_SVG_ICON_DIR );
include_once sprintf( '%sfields/acf-5.php', ACF_SVG_ICON_DIR );

$klass = 'acf_field_svg_icon_5';
new $klass();
}
}
}

Expand Down

0 comments on commit 6b0f0a2

Please sign in to comment.