* Search in standalone forms.
private function search_in_standalone_forms(): array {
foreach ( Locator::STANDALONE_LOCATION_TYPES as $location_type ) {
$location_types[] = '"' . $location_type . '_enable":"1"';
$regexp = implode( '|', $location_types );
$post_statuses = wpforms_wpdb_prepare_in( $this->locator->get_post_statuses() );
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$standalone_forms = $wpdb->get_results(
"SELECT ID, post_content, post_status
WHERE post_status IN ( $post_statuses ) AND
post_type = 'wpforms' AND
post_content REGEXP '$regexp';"
// phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
foreach ( $standalone_forms as $standalone_form ) {
$form_data = json_decode( $standalone_form->post_content, true );
$locations[] = $this->locator->build_standalone_location(
(int) $standalone_form->ID,
$standalone_form->post_status
* Get form location metas.
* @param array $locations Locations.
private function get_form_location_metas( $locations ) {
foreach ( $locations as $location ) {
if ( empty( $location['form_id'] ) ) {
$metas[ $location['form_id'] ][] = $location;