edit_url = get_edit_post_link($page->ID); } $domain = "https://formfacade.com"; $url = $domain . "/wordpress/onboard.html"; $preview_url = ''; $admin_url = admin_url('admin.php?page=formfacade_dashboard'); $user = wp_get_current_user(); $user_details = array( 'email' => $user->user_email, 'displayName' => $user->display_name, 'siteName' => get_bloginfo('name'), 'siteDesc' => get_bloginfo('description'), 'siteURL' => get_site_url(), 'homeURL' => get_home_url(), 'emailHash' => md5($user->user_email), 'siteHash' => md5(get_site_url()) ); // Sanitize and validate the input $page_id = isset($_GET['pageId']) ? intval(sanitize_text_field(wp_unslash($_GET['pageId']))) : 0; $user_id = isset($_GET['userId']) ? sanitize_text_field(wp_unslash($_GET['userId'])) : ''; $publish_id = isset($_GET['publishId']) ? sanitize_text_field(wp_unslash($_GET['publishId'])) : ''; $page_name = isset($_GET['pageName']) ? sanitize_text_field(wp_unslash($_GET['pageName'])) : ''; // Validate that the IDs are numeric or alphanumeric as appropriate if ($page_id > 0 && $user_id && $publish_id) { $url = $url . "?pageId=" . esc_attr($page_id) . "&userId=" . esc_attr($user_id) . "&publishId=" . esc_attr($publish_id); $preview_url = get_permalink($page_id) . '?preview=true'; emebd_wordpress_script($page_id, $user_id, $publish_id); } else if($page_name){ $page_id = formfacade_new_page($page_name, $user_id, $publish_id); $url = $url . "?pageId=" . esc_attr($page_id) . "&userId=" . esc_attr($user_id) . "&publishId=" . esc_attr($publish_id); $preview_url = get_permalink($page_id) . '?preview=true'; } formfacade_fullscreen_iframe_css(); ?>
-1) { var data = JSON.parse(formData); var url = window.location.href; var separator = url.indexOf('?') !== -1 ? '&' : '?'; url += separator + 'pageId=' + data.pageId + '&userId=' + data.userId + '&publishId=' + data.publishId; window.location.href = url; } else if(formData && formData.indexOf('pageName') > -1) { var data = JSON.parse(formData); var url = window.location.href; var separator = url.indexOf('?') !== -1 ? '&' : '?'; url += separator + 'pageName=' + data.pageName + '&userId=' + data.userId + '&publishId=' + data.publishId; window.location.href = url; } if (formData && formData.indexOf('redirectURL') > -1) { var data = JSON.parse(formData); url = admin_url + '&redirectURL=' + data.redirectURL; window.location.href = url; } }); }); "; wp_add_inline_script('formfacade_script', $inline_script); } function emebd_wordpress_script($pageId, $userId, $publishId) { $page = get_post($pageId); if ($page) { // Get the current post content $existing_content = $page->post_content; $embedUrl = 'https://formfacade.com/include/' . $userId . '/form/' . $publishId . '/wordpress.js?div=ff-compose'; if (strpos($existing_content, $publishId) === false) { $block_content = ''; $block_content .= ''; wp_register_script('formfacade_embed_script', $embedUrl, [], time(), true); wp_enqueue_script('formfacade_embed_script'); $script_tag = wp_get_inline_script_tag('', ['src' => $embedUrl, 'async' => true, 'defer' => true]); $block_content .= '
' . $script_tag; $block_content .= ''; $block_content .= ''; $updated_content = $existing_content . "\n\n" . $block_content; wp_update_post([ 'ID' => $pageId, 'post_content' => $updated_content, ]); } } } function formfacade_new_page($pageName, $userId, $publishId) { $page = array( 'post_title' => $pageName, 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'page' ); $embedUrl = 'https://formfacade.com/include/' . $userId . '/form/' . $publishId . '/wordpress.js?div=ff-compose'; $pageId = wp_insert_post($page); if ($pageId) { $block_content = ''; $block_content .= ''; wp_register_script('formfacade_embed_script', $embedUrl, [], time(), true); wp_enqueue_script('formfacade_embed_script'); $script_tag = wp_get_inline_script_tag('', ['src' => $embedUrl, 'async' => true, 'defer' => true]); $block_content .= '
' . $script_tag; $block_content .= ''; $block_content .= ''; // New page starts empty, so the embed block is the entire content. $updated_content = $block_content; wp_update_post([ 'ID' => $pageId, 'post_content' => $updated_content, ]); } return $pageId; } class FormFacade { function activate() { } function deactivate() { echo 'FormFacade plugin deactivated'; } function renderFacade($atts = []) { $id = sanitize_text_field($atts['id']); $appearance = 'wordpress'; // Check for appearance attributes if (array_key_exists('appearance', $atts)) { $appearance = sanitize_text_field($atts['appearance']); } if (array_key_exists('owner', $atts)) { $owner = sanitize_text_field($atts['owner']); $script_url = 'https://formfacade.com/include/' . esc_attr($owner) . '/form/' . esc_attr($id) . '/' . esc_attr($appearance) . '.js?div=ff-' . esc_attr($id); $script_tag = wp_get_inline_script_tag('', ['src' => $script_url, 'async' => true, 'defer' => true]); return '
' . $script_tag; } else if ($id) { $embedUrl = 'https://formfacade.com/forms/d/e/' . esc_attr($id) . '/' . esc_attr($appearance) . '.js?div=ff-' . esc_attr($id); wp_register_script('formfacade_render_script', $embedUrl, [], null, true); wp_enqueue_script('formfacade_render_script'); $script_tag = wp_get_inline_script_tag('', ['src' => $embedUrl, 'async' => true, 'defer' => true]); return '
' . $script_tag; } else { return '
Invalid form id.
- For example, if the public url of your Google Form is: https://docs.google.com/forms/d/e/1FAIpQLSdN-M-uIQN8FfjAZul_BQi0MKYARV_vqNKFejV0QFomAjtdGg/viewform
- Your public id issssssssssss: 1FAIpQLSdN-M-uIQN8FfjAZul_BQi0MKYARV_vqNKFejV0QFomAjtdGg
- So, the short code that you need to add to your page will be:
[formfacade id=1FAIpQLSdN-M-uIQN8FfjAZul_BQi0MKYARV_vqNKFejV0QFomAjtdGg]

For Support Contact: support@formfacade.com
'; } } } $formfacade = new FormFacade(); add_shortcode('formfacade', array($formfacade, 'renderFacade')); ?>