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