Skip to content

Commit b650b71

Browse files
author
Miika Arponen
committed
Check for if Gravity Forms is activated
1 parent c646d24 commit b650b71

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Field/GravityForms.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ class GravityForms extends \Geniem\ACF\Field\Select {
2121
public function __construct( string $label, string $key = null, string $name = null ) {
2222
parent::__construct( $label, $key, $name );
2323

24+
if ( ! class_exists( '\GFFormsModel' ) ) {
25+
$this->disable();
26+
$this->add_choice( 'Gravity Forms is not activated.' );
27+
return;
28+
}
29+
2430
if ( is_admin() ) {
2531
$this->populate_options();
2632
}
@@ -34,10 +40,10 @@ public function __construct( string $label, string $key = null, string $name = n
3440
protected function populate_options() {
3541
global $wpdb;
3642

37-
$table_name = GFFormsModel::get_form_table_name();
43+
$table_name = \GFFormsModel::get_form_table_name();
3844

39-
$sql = "SELECT id, title from $table_name where is_active = %d and is_trash = %d";
40-
$query = $wpdb->prepare( $sql, 1, 0 ); // phpcs:ignore
45+
$sql = "SELECT id, title from $table_name where is_active = %d and is_trash = %d";
46+
$query = $wpdb->prepare( $sql, 1, 0 ); // phpcs:ignore
4147

4248
$gf_form_results = $wpdb->get_results( $query ); // phpcs:ignore
4349

0 commit comments

Comments
 (0)