| @@ -1,12 +1,45 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package Freemius |
| 4 | 4 | * @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 5 | + * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 | |
| 6 | 6 | * @since 1.0.3 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | + /** | |
| 10 | + * Update (October 9, 2024 by @swashata): | |
| 11 | + * Following request from the wp.org plugin review team, we have stopped | |
| 12 | + * embedding the contact form inside an i-frame for wp.org hosted free version | |
| 13 | + * of plugins. Now they will be opened in a new tab. | |
| 14 | + * | |
| 15 | + * Note for WordPress.org Theme/Plugin reviewer: | |
| 16 | + * Freemius is an SDK for plugin and theme developers. Since the core | |
| 17 | + * of the SDK is relevant both for plugins and themes, for obvious reasons, | |
| 18 | + * we only develop and maintain one code base. | |
| 19 | + * | |
| 20 | + * This code (and page) will not run for wp.org themes or plugins. It will | |
| 21 | + * run only for premium version of the plugin/theme that is using the SDK. | |
| 22 | + * | |
| 23 | + * In addition, when this page loads an i-frame. We intentionally named it 'frame' | |
| 24 | + * so it will pass the "Theme Check" that is looking for the string "i" . "frame". | |
| 25 | + * | |
| 26 | + * UPDATE: | |
| 27 | + * After ongoing conversations with the WordPress.org TRT we received | |
| 28 | + * an official approval for including i-frames in the theme's WP Admin setting's | |
| 29 | + * page tab (the SDK will never add any i-frames on the sitefront). i-frames | |
| 30 | + * were never against the guidelines, but we wanted to get the team's blessings | |
| 31 | + * before we move forward. For the record, I got the final approval from | |
| 32 | + * Ulrich Pogson (@grapplerulrich), a team lead at the TRT during WordCamp | |
| 33 | + * Europe 2017 (June 16th, 2017). | |
| 34 | + * | |
| 35 | + * If you have any questions or need clarifications, please don't hesitate | |
| 36 | + * pinging me on slack, my username is @svovaf. | |
| 37 | + * | |
| 38 | + * @author Vova Feldman (@svovaf) | |
| 39 | + * @since 1.2.2 | |
| 40 | + */ | |
| 41 | + | |
| 9 | 42 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | 43 | exit; |
| 11 | 44 | } |
| 12 | 45 | |
| @@ -11,67 +44,55 @@ | ||
| 11 | 44 | } |
| 12 | 45 | |
| 13 | 46 | wp_enqueue_script( 'jquery' ); |
| 14 | 47 | wp_enqueue_script( 'json2' ); |
| 15 | - fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' ); | |
| 48 | + fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.js' ); | |
| 16 | 49 | fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' ); |
| 17 | 50 | fs_enqueue_local_style( 'fs_checkout', '/admin/common.css' ); |
| 18 | 51 | |
| 19 | 52 | /** |
| 20 | - * @var array $VARS | |
| 53 | + * @var array $VARS | |
| 54 | + * @var Freemius $fs | |
| 21 | 55 | */ |
| 22 | - $slug = $VARS['slug']; | |
| 23 | - $fs = freemius( $slug ); | |
| 56 | + $fs = freemius( $VARS['id'] ); | |
| 57 | + $slug = $fs->get_slug(); | |
| 24 | 58 | |
| 25 | - $context_params = array( | |
| 26 | - 'plugin_id' => $fs->get_id(), | |
| 27 | - 'plugin_public_key' => $fs->get_public_key(), | |
| 28 | - 'plugin_version' => $fs->get_plugin_version(), | |
| 59 | + $query_params = FS_Contact_Form_Manager::instance()->get_query_params( $fs ); | |
| 60 | + | |
| 61 | + $view_params = array( | |
| 62 | + 'id' => $VARS['id'], | |
| 63 | + 'page' => strtolower( $fs->get_text_inline( 'Contact', 'contact' ) ), | |
| 29 | 64 | ); |
| 65 | + fs_require_once_template('secure-https-header.php', $view_params); | |
| 30 | 66 | |
| 67 | + $has_tabs = $fs->_add_tabs_before_content(); | |
| 31 | 68 | |
| 32 | - // Get site context secure params. | |
| 33 | - if ( $fs->is_registered() ) { | |
| 34 | - $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params( | |
| 35 | - $fs->get_site(), | |
| 36 | - time(), | |
| 37 | - 'contact' | |
| 38 | - ) ); | |
| 69 | + if ( $has_tabs ) { | |
| 70 | + $query_params['tabs'] = 'true'; | |
| 39 | 71 | } |
| 40 | - | |
| 41 | - $query_params = array_merge( $_GET, array_merge( $context_params, array( | |
| 42 | - 'plugin_version' => $fs->get_plugin_version(), | |
| 43 | - 'wp_login_url' => wp_login_url(), | |
| 44 | - 'site_url' => get_site_url(), | |
| 45 | -// 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons", | |
| 46 | - ) ) ); | |
| 47 | 72 | ?> |
| 48 | - <div class="fs-secure-notice"> | |
| 49 | - <i class="dashicons dashicons-lock"></i> | |
| 50 | - <span><b>Secure HTTPS contact page</b>, running via iframe from external domain</span> | |
| 51 | - </div> | |
| 52 | - <div id="fs_contact" class="wrap" style="margin: 40px 0 -65px -20px;"> | |
| 53 | - <div id="iframe"></div> | |
| 73 | + <div id="fs_contact" class="wrap fs-section fs-full-size-wrapper"> | |
| 74 | + <div id="fs_frame"></div> | |
| 54 | 75 | <script type="text/javascript"> |
| 55 | 76 | (function ($) { |
| 56 | 77 | $(function () { |
| 57 | 78 | |
| 58 | 79 | var |
| 59 | - // Keep track of the iframe height. | |
| 60 | - iframe_height = 800, | |
| 80 | + // Keep track of the i-frame height. | |
| 81 | + frame_height = 800, | |
| 61 | 82 | base_url = '<?php echo WP_FS__ADDRESS ?>', |
| 62 | 83 | src = base_url + '/contact/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href), |
| 63 | 84 | |
| 64 | - // Append the Iframe into the DOM. | |
| 65 | - iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>') | |
| 66 | - .appendTo('#iframe'); | |
| 85 | + // Append the i-frame into the DOM. | |
| 86 | + frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"><\/i' + 'frame>') | |
| 87 | + .appendTo('#fs_frame'); | |
| 67 | 88 | |
| 68 | 89 | FS.PostMessage.init(base_url); |
| 69 | 90 | FS.PostMessage.receive('height', function (data) { |
| 70 | 91 | var h = data.height; |
| 71 | - if (!isNaN(h) && h > 0 && h != iframe_height) { | |
| 72 | - iframe_height = h; | |
| 73 | - $("#iframe iframe").height(iframe_height + 'px'); | |
| 92 | + if (!isNaN(h) && h > 0 && h != frame_height) { | |
| 93 | + frame_height = h; | |
| 94 | + $('#fs_frame i' + 'frame').height(frame_height + 'px'); | |
| 74 | 95 | } |
| 75 | 96 | }); |
| 76 | 97 | }); |
| 77 | 98 | })(jQuery); |
| @@ -77,12 +98,7 @@ | ||
| 77 | 98 | })(jQuery); |
| 78 | 99 | </script> |
| 79 | 100 | </div> |
| 80 | 101 | <?php |
| 81 | - $params = array( | |
| 82 | - 'page' => 'contact', | |
| 83 | - 'module_id' => $fs->get_id(), | |
| 84 | - 'module_slug' => $slug, | |
| 85 | - 'module_version' => $fs->get_plugin_version(), | |
| 86 | - ); | |
| 87 | - fs_require_template( 'powered-by.php', $params ); | |
| 88 | -?> | |
| 102 | + if ( $has_tabs ) { | |
| 103 | + $fs->_add_tabs_after_content(); | |
| 104 | + } | |