Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

fixing version check in case using deprecated functions #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions acf-ninja_forms-v5.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ function render_field_settings( $field ) {

}

/*
* is_ninja_forms_three()
*
* We might be 3.0 but using deprecated version for compatibility!
* Taken straight from NF
*/

function is_ninja_forms_three() {
if ( get_option( 'ninja_forms_load_deprecated', false ) ) {
return false;
}

return version_compare( get_option( 'ninja_forms_version', '0' ), '3', '>=' );
}

/*
* render_field()
Expand All @@ -111,7 +125,7 @@ function render_field( $field ) {
$field = array_merge($this->defaults, $field);
$choices = array();

if ( version_compare( get_option( 'ninja_forms_version', '0.0.0' ), '3', '<' ) ) {
if ( !$this->is_ninja_forms_three() ) {
// Ninja forms 2.x functions
$forms = Ninja_Forms()->forms()->get_all();
if ( $forms ) {
Expand All @@ -135,7 +149,7 @@ function render_field( $field ) {
$field['type'] = 'select';
?>
<select name="<?php echo $field['name'];echo ( true == $field['allow_multiple'] ? '[]' : null );?>" id="<?php echo $field['name'];?>" <?php echo ( true == $field['allow_multiple'] ? 'multiple' : null ); ?>>
<?php;
<?php
if( true == $field['allow_null'] ) { ?>
<option value="">-- <?php _e('None'); ?> --</option>
<?php
Expand Down