PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.5
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.5
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / freemius / templates / tabs.php

tabs.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.5, at freemius/templates/tabs.php

178 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $tabs = array();
24 foreach ( $menu_items as $priority => $items ) {
25 foreach ( $items as $item ) {
26 if ( ! $item['show_submenu'] ) {
27 continue;
28 }
29
30 $url = $fs->_get_admin_page_url( $item['menu_slug'] );
31 $title = $item['menu_title'];
32
33 $tab = array(
34 'label' => $title,
35 'href' => $url,
36 'slug' => $item['menu_slug'],
37 );
38
39 if ( 'pricing' === $item['menu_slug'] && $fs->is_in_trial_promotion() ) {
40 $tab['href'] .= '&trial=true';
41 }
42
43 $tabs[] = $tab;
44 }
45 }
46 ?>
47 <script type="text/javascript">
48 (function ($) {
49 $(document).ready(function () {
50 var $wrap = $('.wrap');
51 if (0 === $wrap.length) {
52 $wrap = $('<div class="wrap">');
53 $wrap.insertBefore($('#wpbody-content .clear'));
54 }
55
56 var
57 $tabsWrapper = $('.nav-tab-wrapper'),
58 $tabs = $tabsWrapper.find('.nav-tab'),
59 $tab = null;
60
61 if (0 < $tabs.length) {
62 // Tries to set $tab to the first inactive tab.
63 for (var i = 0; i < $tabs.length; i++) {
64 $tab = $($tabs[i]);
65
66 if (!$tab.hasClass('nav-tab-active')) {
67 break;
68 }
69 }
70 }
71
72 <?php if (0 < count( $tabs )) : ?>
73 if (null == $tab) {
74 // No tabs found, therefore, create new tabs section if required.
75 var $h1 = $wrap.find('h1');
76
77 $tabsWrapper = $('<h2 class="nav-tab-wrapper"></h2>');
78
79 if (0 < $h1.length) {
80 $tabsWrapper.insertAfter($h1);
81 } else if (0 < $wrap.length) {
82 $wrap.prepend($tabsWrapper);
83 }
84
85 $tab = $('<a href="#" class="nav-tab"></a>');
86 }
87
88 // Create a clone.
89 $tab = $tab.clone();
90 // Open in current page.
91 $tab.removeAttr('target');
92 $tab.removeClass('nav-tab-active');
93 $tab.addClass('fs-tab');
94 $tab.addClass('<?php echo $fs->get_unique_affix() ?>');
95
96 var $tabClone = null;
97
98 <?php $freemius_context_page = null ?>
99
100 <?php foreach ($tabs as $tab) : ?>
101 <?php $is_support_tab = ( 'wp-support-forum' == $tab['slug'] ) ?>
102 // Add the Freemius tabs.
103 $tabClone = $tab.clone();
104 $tabClone.html(<?php echo json_encode( $tab['label'] ) ?>)
105 .attr('href', '<?php echo $is_support_tab ? $fs->get_support_forum_url() : $tab['href'] ?>')
106 .appendTo($tabsWrapper)
107 // Remove any custom click events.
108 .off('click', '**')
109 .addClass('<?php echo $tab['slug'] ?>')
110 // Avoid tab click triggering parent events.
111 .click(function (e) {
112 e.stopPropagation();
113 });
114
115 <?php if ($is_support_tab) : ?>
116 // Open support in a new tab/page.
117 $tabClone.attr('target', '_blank');
118 <?php endif ?>
119
120 <?php if ($fs->is_admin_page( $tab['slug'] )) : ?>
121 <?php $freemius_context_page = $tab['slug'] ?>
122 // Select the relevant Freemius tab.
123 $tabs.removeClass('nav-tab-active');
124 $tabClone.addClass('nav-tab-active');
125
126 <?php if (in_array( $freemius_context_page, array( 'pricing', 'contact', 'checkout' ) )) : ?>
127 // Add AJAX loader.
128 $tabClone.prepend('<i class="fs-ajax-spinner"></i>');
129 // Hide loader after content fully loaded.
130 $('.wrap i' + 'frame').load(function () {
131 $(".fs-ajax-spinner").hide();
132 });
133 <?php endif ?>
134
135 // Fix URLs that are starting with a hashtag.
136 $tabs.each(function (j, tab) {
137 if (0 === $(tab).attr('href').indexOf('#')) {
138 $(tab).attr('href', '<?php echo esc_js( $fs->main_menu_url() ) ?>' + $(tab).attr('href'));
139 }
140 });
141 <?php endif ?>
142 <?php endforeach ?>
143
144 var selectTab = function ($tab) {
145 $(window).load(function () {
146 $tab.click();
147
148 // Scroll to the top since the browser will auto scroll to the anchor.
149 document.body.scrollTop = 0;
150 document.body.scrollLeft = 0;
151 // window.scrollTo(0,0);
152 });
153 };
154
155 // If the URL is loaded with a hashtag, find the context tab and select it.
156 if (window.location.hash) {
157 for (var j = 0; j < $tabs.length; j++) {
158 if (window.location.hash === $($tabs[j]).attr('href')) {
159 selectTab($($tabs[j]));
160 break;
161 }
162 }
163 }
164
165 <?php if (is_string( $freemius_context_page ) && in_array( $freemius_context_page, array(
166 'pricing',
167 'contact',
168 'checkout'
169 ) )) : ?>
170 // Add margin to the upper section of the tabs to give extra space for the HTTPS header.
171 // @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.
172 var $tabsWrap = $tabsWrapper.parents('.wrap');
173 $tabsWrap.css('marginTop', (parseInt($tabsWrap.css('marginTop'), 10) + 30) + 'px');
174 <?php endif ?>
175 <?php endif ?>
176 });
177 })(jQuery);
178 </script>