PluginProbe ʕ •ᴥ•ʔ
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel / trunk
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel vtrunk
trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / freemius / templates / tabs.php
foogallery / freemius / templates Last commit date
account 7 months ago checkout 7 months ago connect 3 years ago debug 7 months ago forms 7 months ago js 7 months ago partials 2 years ago plugin-info 7 months ago .DS_Store 7 months ago account.php 7 months ago add-ons.php 7 months ago add-trial-to-pricing.php 3 years ago admin-notice.php 2 years ago ajax-loader.php 3 years ago api-connectivity-message-js.php 3 years ago auto-installation.php 3 years ago checkout.php 7 months ago clone-resolution-js.php 7 months ago connect.php 7 months ago contact.php 7 months ago debug.php 7 months ago email.php 3 years ago gdpr-optin-js.php 2 years ago index.php 3 years ago plugin-icon.php 3 years ago pricing.php 7 months ago secure-https-header.php 3 years ago sticky-admin-notice-js.php 3 years ago tabs-capture-js.php 2 years ago tabs.php 6 years ago
tabs.php
190 lines
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 </script>