get_forms_detected_in_posts(); } // Fetch AWeber account, using OAuth1 or OAuth2. // This is how the AWeber Plugin fetches the account data, as nothing is cached in their Plugin or the database. $response = $aweber_webform_plugin->getAWeberAccount( get_option( $aweber_webform_plugin->adminOptionsName ), // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase get_option( $aweber_webform_plugin->oauth2TokensOptions ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ); // If no account is returned, fall back to showing the AWeber Form IDs found in the posts, if any. if ( ! isset( $response['account'] ) ) { return $this->get_forms_detected_in_posts(); } // Get account, which contains forms and form split tests. $account = $response['account']; $web_forms = $account->getWebForms(); $web_form_split_tests = $account->getWebFormSplitTests(); // Build array of forms. $forms = array(); foreach ( $web_forms as $form ) { $forms[ $form->id ] = sprintf( '%s: %s', __( 'Sign Up Form', 'convertkit' ), $form->name ); } foreach ( $web_form_split_tests as $form ) { $forms[ $form->id ] = sprintf( '%s: %s', __( 'Split Tests', 'convertkit' ), $form->name ); } // Return forms. return $forms; } /** * Returns whether the given block ID attribute value matches the AWeber form ID. * * AWeber's block stores the list ID, form ID and form type e.g. 6924484-289586845-webform. * * @since 3.4.5 * * @param mixed $value Block ID attribute value. * @param string|int $third_party_form_id Third Party Form ID. * @return bool */ protected function block_id_attribute_matches( $value, $third_party_form_id ) { $parts = explode( '-', (string) $value ); return isset( $parts[1] ) && $parts[1] === (string) $third_party_form_id; } /** * Returns an array of AWeber form IDs and titles found in the posts. * * @since 3.1.5 * * @return array */ private function get_forms_detected_in_posts() { $forms = array(); foreach ( $this->get_form_ids_in_posts() as $form_id ) { $forms[ $form_id ] = sprintf( 'AWeber Form ID #%s', $form_id ); } return $forms; } }