PluginProbe
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs / 2.6.2
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs v2.6.2
5.0.1 4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 All 39 releases
← All changes | freemius/templates/tabs.php +189 -189 1.3.3 → 2.6.2 View file →
@@ -1,190 +1,190 @@
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.2.2.7
7 - */
8 -
9 - if ( ! defined( 'ABSPATH' ) ) {
10 - exit;
11 - }
12 -
13 - /**
14 - * @var array $VARS
15 - * @var Freemius $fs
16 - */
17 - $fs = freemius( $VARS['id'] );
18 -
19 - $slug = $fs->get_slug();
20 -
21 - $menu_items = $fs->get_menu_items();
22 -
23 - $show_settings_with_tabs = $fs->show_settings_with_tabs();
24 -
25 - $tabs = array();
26 - foreach ( $menu_items as $priority => $items ) {
27 - foreach ( $items as $item ) {
28 - if ( ! $item['show_submenu'] ) {
29 - $submenu_name = ('wp-support-forum' === $item['menu_slug']) ?
30 - 'support' :
31 - $item['menu_slug'];
32 -
33 - if ( 'pricing' === $submenu_name && ! $fs->is_pricing_page_visible() ) {
34 - continue;
35 - }
36 -
37 - if ( ! $show_settings_with_tabs || ! $fs->is_submenu_item_visible( $submenu_name, true ) ) {
38 - continue;
39 - }
40 - }
41 -
42 - $url = $fs->_get_admin_page_url( $item['menu_slug'] );
43 - $title = $item['menu_title'];
44 -
45 - $tab = array(
46 - 'label' => $title,
47 - 'href' => $url,
48 - 'slug' => $item['menu_slug'],
49 - );
50 -
51 - if ( 'pricing' === $item['menu_slug'] && $fs->is_in_trial_promotion() ) {
52 - $tab['href'] .= '&trial=true';
53 - }
54 -
55 - $tabs[] = $tab;
56 - }
57 - }
58 -?>
59 -<script type="text/javascript">
60 - (function ($) {
61 - $(document).ready(function () {
62 - var $wrap = $('.wrap');
63 - if (0 === $wrap.length) {
64 - $wrap = $('<div class="wrap">');
65 - $wrap.insertBefore($('#wpbody-content .clear'));
66 - }
67 -
68 - var
69 - $tabsWrapper = $('.nav-tab-wrapper'),
70 - $tabs = $tabsWrapper.find('.nav-tab'),
71 - $tab = null;
72 -
73 - if (0 < $tabs.length) {
74 - // Tries to set $tab to the first inactive tab.
75 - for (var i = 0; i < $tabs.length; i++) {
76 - $tab = $($tabs[i]);
77 -
78 - if (!$tab.hasClass('nav-tab-active')) {
79 - break;
80 - }
81 - }
82 - }
83 -
84 - <?php if (0 < count( $tabs )) : ?>
85 - if (null == $tab) {
86 - // No tabs found, therefore, create new tabs section if required.
87 - var $h1 = $wrap.find('h1');
88 -
89 - $tabsWrapper = $('<h2 class="nav-tab-wrapper"></h2>');
90 -
91 - if (0 < $h1.length) {
92 - $tabsWrapper.insertAfter($h1);
93 - } else if (0 < $wrap.length) {
94 - $wrap.prepend($tabsWrapper);
95 - }
96 -
97 - $tab = $('<a href="#" class="nav-tab"></a>');
98 - }
99 -
100 - // Create a clone.
101 - $tab = $tab.clone();
102 - // Open in current page.
103 - $tab.removeAttr('target');
104 - $tab.removeClass('nav-tab-active');
105 - $tab.addClass('fs-tab');
106 - $tab.addClass('<?php echo $fs->get_unique_affix() ?>');
107 -
108 - var $tabClone = null;
109 -
110 - <?php $freemius_context_page = null ?>
111 -
112 - <?php foreach ($tabs as $tab) : ?>
113 - <?php $is_support_tab = ( 'wp-support-forum' == $tab['slug'] ) ?>
114 - // Add the Freemius tabs.
115 - $tabClone = $tab.clone();
116 - $tabClone.html(<?php echo json_encode( $tab['label'] ) ?>)
117 - .attr('href', '<?php echo $is_support_tab ? $fs->get_support_forum_url() : $tab['href'] ?>')
118 - .appendTo($tabsWrapper)
119 - // Remove any custom click events.
120 - .off('click', '**')
121 - .addClass('<?php echo $tab['slug'] ?>')
122 - // Avoid tab click triggering parent events.
123 - .click(function (e) {
124 - e.stopPropagation();
125 - });
126 -
127 - <?php if ($is_support_tab) : ?>
128 - // Open support in a new tab/page.
129 - $tabClone.attr('target', '_blank');
130 - <?php endif ?>
131 -
132 - <?php if ($fs->is_admin_page( $tab['slug'] )) : ?>
133 - <?php $freemius_context_page = $tab['slug'] ?>
134 - // Select the relevant Freemius tab.
135 - $tabs.removeClass('nav-tab-active');
136 - $tabClone.addClass('nav-tab-active');
137 -
138 - <?php if (in_array( $freemius_context_page, array( 'pricing', 'contact', 'checkout' ) )) : ?>
139 - // Add AJAX loader.
140 - $tabClone.prepend('<i class="fs-ajax-spinner"></i>');
141 - // Hide loader after content fully loaded.
142 - $('.wrap i' + 'frame').load(function () {
143 - $(".fs-ajax-spinner").hide();
144 - });
145 - <?php endif ?>
146 -
147 - // Fix URLs that are starting with a hashtag.
148 - $tabs.each(function (j, tab) {
149 - if (0 === $(tab).attr('href').indexOf('#')) {
150 - $(tab).attr('href', '<?php echo esc_js( $fs->main_menu_url() ) ?>' + $(tab).attr('href'));
151 - }
152 - });
153 - <?php endif ?>
154 - <?php endforeach ?>
155 -
156 - var selectTab = function ($tab) {
157 - $(window).load(function () {
158 - $tab.click();
159 -
160 - // Scroll to the top since the browser will auto scroll to the anchor.
161 - document.body.scrollTop = 0;
162 - document.body.scrollLeft = 0;
163 -// window.scrollTo(0,0);
164 - });
165 - };
166 -
167 - // If the URL is loaded with a hashtag, find the context tab and select it.
168 - if (window.location.hash) {
169 - for (var j = 0; j < $tabs.length; j++) {
170 - if (window.location.hash === $($tabs[j]).attr('href')) {
171 - selectTab($($tabs[j]));
172 - break;
173 - }
174 - }
175 - }
176 -
177 - <?php if (is_string( $freemius_context_page ) && in_array( $freemius_context_page, array(
178 - 'pricing',
179 - 'contact',
180 - 'checkout'
181 - ) )) : ?>
182 - // Add margin to the upper section of the tabs to give extra space for the HTTPS header.
183 - // @todo This code assumes that the wrapper style is fully loaded, if there's a stylesheet that is not loaded via the HTML head, it may cause unpredicted margin-top.
184 - var $tabsWrap = $tabsWrapper.parents('.wrap');
185 - $tabsWrap.css('marginTop', (parseInt($tabsWrap.css('marginTop'), 10) + 30) + 'px');
186 - <?php endif ?>
187 - <?php endif ?>
188 - });
189 - })(jQuery);
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.2.2.7
7 + */
8 +
9 + if ( ! defined( 'ABSPATH' ) ) {
10 + exit;
11 + }
12 +
13 + /**
14 + * @var array $VARS
15 + * @var Freemius $fs
16 + */
17 + $fs = freemius( $VARS['id'] );
18 +
19 + $slug = $fs->get_slug();
20 +
21 + $menu_items = $fs->get_menu_items();
22 +
23 + $show_settings_with_tabs = $fs->show_settings_with_tabs();
24 +
25 + $tabs = array();
26 + foreach ( $menu_items as $priority => $items ) {
27 + foreach ( $items as $item ) {
28 + if ( ! $item['show_submenu'] ) {
29 + $submenu_name = ('wp-support-forum' === $item['menu_slug']) ?
30 + 'support' :
31 + $item['menu_slug'];
32 +
33 + if ( 'pricing' === $submenu_name && ! $fs->is_pricing_page_visible() ) {
34 + continue;
35 + }
36 +
37 + if ( ! $show_settings_with_tabs || ! $fs->is_submenu_item_visible( $submenu_name, true ) ) {
38 + continue;
39 + }
40 + }
41 +
42 + $url = $fs->_get_admin_page_url( $item['menu_slug'] );
43 + $title = $item['menu_title'];
44 +
45 + $tab = array(
46 + 'label' => $title,
47 + 'href' => $url,
48 + 'slug' => $item['menu_slug'],
49 + );
50 +
51 + if ( 'pricing' === $item['menu_slug'] && $fs->is_in_trial_promotion() ) {
52 + $tab['href'] .= '&trial=true';
53 + }
54 +
55 + $tabs[] = $tab;
56 + }
57 + }
58 +?>
59 +<script type="text/javascript">
60 + (function ($) {
61 + $(document).ready(function () {
62 + var $wrap = $('.wrap');
63 + if (0 === $wrap.length) {
64 + $wrap = $('<div class="wrap">');
65 + $wrap.insertBefore($('#wpbody-content .clear'));
66 + }
67 +
68 + var
69 + $tabsWrapper = $('.nav-tab-wrapper'),
70 + $tabs = $tabsWrapper.find('.nav-tab'),
71 + $tab = null;
72 +
73 + if (0 < $tabs.length) {
74 + // Tries to set $tab to the first inactive tab.
75 + for (var i = 0; i < $tabs.length; i++) {
76 + $tab = $($tabs[i]);
77 +
78 + if (!$tab.hasClass('nav-tab-active')) {
79 + break;
80 + }
81 + }
82 + }
83 +
84 + <?php if (0 < count( $tabs )) : ?>
85 + if (null == $tab) {
86 + // No tabs found, therefore, create new tabs section if required.
87 + var $h1 = $wrap.find('h1');
88 +
89 + $tabsWrapper = $('<h2 class="nav-tab-wrapper"></h2>');
90 +
91 + if (0 < $h1.length) {
92 + $tabsWrapper.insertAfter($h1);
93 + } else if (0 < $wrap.length) {
94 + $wrap.prepend($tabsWrapper);
95 + }
96 +
97 + $tab = $('<a href="#" class="nav-tab"></a>');
98 + }
99 +
100 + // Create a clone.
101 + $tab = $tab.clone();
102 + // Open in current page.
103 + $tab.removeAttr('target');
104 + $tab.removeClass('nav-tab-active');
105 + $tab.addClass('fs-tab');
106 + $tab.addClass('<?php echo $fs->get_unique_affix() ?>');
107 +
108 + var $tabClone = null;
109 +
110 + <?php $freemius_context_page = null ?>
111 +
112 + <?php foreach ($tabs as $tab) : ?>
113 + <?php $is_support_tab = ( 'wp-support-forum' == $tab['slug'] ) ?>
114 + // Add the Freemius tabs.
115 + $tabClone = $tab.clone();
116 + $tabClone.html(<?php echo json_encode( $tab['label'] ) ?>)
117 + .attr('href', '<?php echo $is_support_tab ? $fs->get_support_forum_url() : $tab['href'] ?>')
118 + .appendTo($tabsWrapper)
119 + // Remove any custom click events.
120 + .off('click', '**')
121 + .addClass('<?php echo $tab['slug'] ?>')
122 + // Avoid tab click triggering parent events.
123 + .click(function (e) {
124 + e.stopPropagation();
125 + });
126 +
127 + <?php if ($is_support_tab) : ?>
128 + // Open support in a new tab/page.
129 + $tabClone.attr('target', '_blank');
130 + <?php endif ?>
131 +
132 + <?php if ($fs->is_admin_page( $tab['slug'] )) : ?>
133 + <?php $freemius_context_page = $tab['slug'] ?>
134 + // Select the relevant Freemius tab.
135 + $tabs.removeClass('nav-tab-active');
136 + $tabClone.addClass('nav-tab-active');
137 +
138 + <?php if (in_array( $freemius_context_page, array( 'pricing', 'contact', 'checkout' ) )) : ?>
139 + // Add AJAX loader.
140 + $tabClone.prepend('<i class="fs-ajax-spinner"></i>');
141 + // Hide loader after content fully loaded.
142 + $('.wrap i' + 'frame').load(function () {
143 + $(".fs-ajax-spinner").hide();
144 + });
145 + <?php endif ?>
146 +
147 + // Fix URLs that are starting with a hashtag.
148 + $tabs.each(function (j, tab) {
149 + if (0 === $(tab).attr('href').indexOf('#')) {
150 + $(tab).attr('href', '<?php echo esc_js( $fs->main_menu_url() ) ?>' + $(tab).attr('href'));
151 + }
152 + });
153 + <?php endif ?>
154 + <?php endforeach ?>
155 +
156 + var selectTab = function ($tab) {
157 + $(window).load(function () {
158 + $tab.click();
159 +
160 + // Scroll to the top since the browser will auto scroll to the anchor.
161 + document.body.scrollTop = 0;
162 + document.body.scrollLeft = 0;
163 +// window.scrollTo(0,0);
164 + });
165 + };
166 +
167 + // If the URL is loaded with a hashtag, find the context tab and select it.
168 + if (window.location.hash) {
169 + for (var j = 0; j < $tabs.length; j++) {
170 + if (window.location.hash === $($tabs[j]).attr('href')) {
171 + selectTab($($tabs[j]));
172 + break;
173 + }
174 + }
175 + }
176 +
177 + <?php if (is_string( $freemius_context_page ) && in_array( $freemius_context_page, array(
178 + 'pricing',
179 + 'contact',
180 + 'checkout'
181 + ) )) : ?>
182 + // Add margin to the upper section of the tabs to give extra space for the HTTPS header.
183 + // @todo This code assumes that the wrapper style is fully loaded, if there's a stylesheet that is not loaded via the HTML head, it may cause unpredicted margin-top.
184 + var $tabsWrap = $tabsWrapper.parents('.wrap');
185 + $tabsWrap.css('marginTop', (parseInt($tabsWrap.css('marginTop'), 10) + 30) + 'px');
186 + <?php endif ?>
187 + <?php endif ?>
188 + });
189 + })(jQuery);
190 190 </script>