diff --git a/admin/partials/menu/manage-forms.php b/admin/partials/menu/manage-forms.php index 9d777387..0082b45f 100644 --- a/admin/partials/menu/manage-forms.php +++ b/admin/partials/menu/manage-forms.php @@ -128,7 +128,7 @@ 0 ) { + if ( $all_forms && count( $all_forms ) > 0 ) { $i = 1; foreach( $all_forms as $id => $form ) { ?> diff --git a/includes/class-yikes-inc-easy-mailchimp-extender-option-forms.php b/includes/class-yikes-inc-easy-mailchimp-extender-option-forms.php index cbe3c186..8fc266da 100644 --- a/includes/class-yikes-inc-easy-mailchimp-extender-option-forms.php +++ b/includes/class-yikes-inc-easy-mailchimp-extender-option-forms.php @@ -31,10 +31,14 @@ public function get_form( $form_id ) { * Get the IDs of all registered forms. * * @author Jeremy Pry - * @return array All form IDs. + * @return array|bool All form IDs. */ public function get_form_ids() { - return array_keys( $this->get_all_forms() ); + if ( is_array( $this->get_all_forms() ) ) { + return array_keys( $this->get_all_forms() ); + } + + return false; } /** @@ -77,7 +81,12 @@ public function create_form( $form_data ) { // Grab our existing IDs and determine what the next one should be. $all_ids = $this->get_form_ids(); - $last_id = end( $all_ids ); + $last_id = 0; + + if ( is_array( $all_ids ) ) { + $last_id = end( $all_ids ); + } + $new_id = false === $last_id ? 1 : $last_id + 1; $form_data['id'] = $new_id;