get_api_domain() ); $valid_hosts[] = $api_domain_parse_url['host']; // Validate host. if ( in_array( $parse_url['host'], $valid_hosts, true ) ) { return true; } return false; } /** * Get all the posts to be reset. * * @since 3.0.3 * @return array */ function astra_sites_get_reset_post_data() { global $wpdb; $post_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_astra_sites_imported_post'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need this to get all the posts and pages. Traditional WP_Query would have been expensive here. return $post_ids; } /** * Get all the forms to be reset. * * @since 3.0.3 * @return array */ function astra_sites_get_reset_form_data() { global $wpdb; $form_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_astra_sites_imported_wp_forms'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need this to get all the WP forms. Traditional WP_Query would have been expensive here. return $form_ids; } /** * Get all the terms to be reset. * * @since 3.0.3 * @return array */ function astra_sites_get_reset_term_data() { global $wpdb; $term_ids = $wpdb->get_col( "SELECT term_id FROM {$wpdb->termmeta} WHERE meta_key='_astra_sites_imported_term'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need this to get all the terms and taxonomy. Traditional WP_Query would have been expensive here. return $term_ids; } /** * Get API params * * @since 2.7.3 * @return array */ function astra_sites_get_api_params() { return apply_filters( 'astra_sites_api_params', array( 'purchase_key' => '', 'site_url' => get_site_url(), 'per-page' => 15, 'template_status' => '', 'version' => ASTRA_SITES_VER, ) ); } /** * Check if Import for Astra Site is in progress * * @since 3.0.21 * @return array */ function astra_sites_has_import_started() { $has_import_started = get_transient( 'astra_sites_import_started' ); if ( 'yes' === $has_import_started ) { return true; } return false; } /** * Remove the post excerpt * * @param int $post_id The post ID. * @since 3.1.0 */ function astra_sites_empty_post_excerpt( $post_id = 0 ) { if ( ! $post_id ) { return; } wp_update_post( array( 'ID' => $post_id, 'post_excerpt' => '', ) ); } /** * Get the WP Forms URL. * * @since 3.2.4 * @param int $id The template ID. * @return string */ function astra_sites_get_wp_forms_url( $id ) { $demo_data = get_option( 'astra_sites_import_elementor_data_' . $id, array() ); if ( empty( $demo_data ) ) { return ''; } if ( isset( $demo_data['type'] ) ) { $type = $demo_data['type']; if ( 'site-pages' === $type && isset( $demo_data['astra-site-wpforms-path'] ) ) { return $demo_data['astra-site-wpforms-path']; } if ( 'astra-blocks' === $type && isset( $demo_data['post-meta'] ) ) { return $demo_data['post-meta']['astra-site-wpforms-path']; } } return ''; }