PluginProbe
MaxButtons – Create buttons / 7.13.2
MaxButtons – Create buttons v7.13.2
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / classes / maxbuttons-admin-helper.php

maxbuttons-admin-helper.php in MaxButtons – Create buttons 7.13.2, at classes/maxbuttons-admin-helper.php

315 lines 11.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MaxButtons;
3 defined('ABSPATH') or die('No direct access permitted');
4
5 /* Helper class for uniform elements in admin pages */
6
7 class maxAdmin
8 {
9 protected static $tabs = null;
10
11 public static function init()
12 {
13 add_action('mb-display-logo', array(maxUtils::namespaceit('maxAdmin'),'logo'));
14 add_action('mb-display-title', array(maxUtils::namespaceit("maxAdmin"),'rate_us'), 20);
15 add_action('mb-display-tabs', array(maxUtils::namespaceit('maxAdmin'),'tab_menu'));
16 add_action('mb-display-ads', array(maxUtils::namespaceit('maxAdmin'), 'display_ads'));
17 add_action('mb-display-pagination', array(maxUtils::namespaceit('maxAdmin'), 'display_pagination'), 10, 2);
18 add_action('mb-display-collection-welcome', array(maxUtils::namespaceit('maxAdmin'), 'displayCollectionWelcome'));
19 }
20
21 public static function logo()
22 {
23 $version = self::getAdVersion();
24 $url = self::getCheckoutURL();
25 ?>
26
27 <?php printf(__('Upgrade to MaxButtons Pro today! %sClick Here%s', 'maxbuttons'), '<a class="simple-btn" href="' . $url . '&utm_source=mbf-dash' . $version . '&utm_medium=mbf-plugin&utm_content=click-here&utm_campaign=cart' . $version . '" target="_blank">', '</a>' ) ?>
28
29
30 <?php
31 }
32
33 static function tab_items_init()
34 {
35 self::$tabs = array(
36 "list" => array("name" => __('Buttons', 'maxbuttons'),
37 "link" => "page=maxbuttons-list",
38 "active" => "maxbuttons-list", ),
39 "pro" => array( "name" => __('Upgrade to Pro', 'maxbuttons'),
40 "link" => "page=maxbuttons-pro",
41 "active" => "maxbuttons-pro",
42 ),
43 "settings" => array("name" => __('Settings', 'maxbuttons'),
44 "link" => "page=maxbuttons-settings",
45 "active" => "maxbuttons-settings",
46 "userlevel" => 'manage_options' ),
47 "support" => array("name" => __('Support', 'maxbuttons'),
48 "link" => "page=maxbuttons-support",
49 "active" => "maxbuttons-support",
50 "userlevel" => 'manage_options'
51 )
52 );
53
54 if ( maxInstall::hasAddOn('socialshare'))
55 {
56 unset(self::$tabs['collection']);
57 }
58 }
59
60 public static function tab_menu()
61 {
62 self::tab_items_init();
63 ?>
64 <h2 class="tabs">
65 <span class="spacer"></span>
66 <?php foreach (self::$tabs as $tab => $tabdata) {
67 if (isset($tabdata["userlevel"]) && ! current_user_can($tabdata["userlevel"]))
68 continue;
69
70 $link = admin_url() . "admin.php?" . $tabdata["link"];
71 $name = $tabdata["name"];
72 $active = '';
73 if ($tabdata["active"] == $_GET["page"])
74 $active = "nav-tab-active";
75
76 echo "<a class='nav-tab $active' href='$link'>$name</a>";
77
78 }
79 echo "</h2>";
80 }
81
82 public static function getAdversion()
83 {
84 $version = MAXBUTTONS_VERSION_NUM;
85 $version = str_replace('.','',$version);
86 return $version;
87
88 }
89
90 public static function getCheckoutURL()
91 {
92 return $url = 'https://maxbuttons.com/checkout/?edd_action=add_to_cart&download_id=24035';
93 }
94
95
96 public static function do_review_notice () {
97
98 $current_user_id = get_current_user_id();
99 $version = MAXBUTTONS_VERSION_NUM;
100
101 $review = get_user_meta( $current_user_id, 'maxbuttons_review_notice' , true );
102
103 if ($review == '')
104 {
105 //$created = get_option("MBFREE_CREATED");
106 $show = time() + (7* DAY_IN_SECONDS);
107 update_user_meta($current_user_id, 'maxbuttons_review_notice', $show);
108 return;
109 }
110
111 $display_review = false;
112
113 if ($review == 'off')
114 { return; // no show
115
116 }
117 elseif (is_numeric($review))
118 {
119 $now = time();
120
121 if ($now > $review)
122 {
123 $display_review = true;
124
125 }
126 }
127
128 // load style / script. It's seperated since it should show everywhere in admin.
129 if ($display_review)
130 {
131 add_action( 'admin_notices', array( maxUtils::namespaceit('maxAdmin'), 'mb_review_notice'));
132 // registered in admin scripts
133 MB()->load_library('review_notice');
134 }
135
136 }
137
138 public static function setReviewNoticeStatus()
139 {
140 $status = isset($_POST["status"]) ? sanitize_text_field($_POST["status"]) : '';
141 $current_user_id = get_current_user_id();
142
143 $updated = false;
144
145 if ($status == 'off')
146 {
147 $updated = true;
148 update_user_meta($current_user_id, 'maxbuttons_review_notice', 'off');
149
150 }
151 if ($status == 'later')
152 {
153 $updated = true;
154 $later = time() + (14 * DAY_IN_SECONDS );
155
156 update_user_meta($current_user_id, 'maxbuttons_review_notice', $later);
157 }
158 if ($status == 'reviewoffer-dismiss') // different ad!
159 {
160 $updated = true;
161 update_user_meta($current_user_id, 'maxbuttons_review_offer', 'off');
162
163 }
164
165 echo json_encode(array("updated" => $updated)) ;
166
167 exit();
168 }
169
170 public static function display_ads()
171 {
172 $plugin_url = MB()->get_plugin_url();
173 $ad_url = $plugin_url . '/images/ads/';
174 $version = self::getAdVersion();
175 $url = self::getCheckoutURL();
176 ?>
177
178 <div class="ads image-ad">
179 <a href="<?php echo $url ?>&utm_source=mbf-dash<?php echo $version ?>&utm_medium=mbf-plugin&utm_content=MBF-sidebar&utm_campaign=cart<?php echo $version ?>" target="_blank" >
180 <img src="<?php echo $plugin_url ?>/images/max_ad.png" width="300">
181 </a>
182 </div>
183
184 <div class="ads image-ad">
185 <a href="http://www.maxbuttons.com/pricing/?utm_source=mbf-dash<?php echo $version ?>&utm_medium=mbf-plugin&utm_content=EBWG-sidebar-22&utm_campaign=inthecart<?php echo $version ?>" target="_blank"><img src="<?php echo $plugin_url ?>/images/ebwg_ad.png" /></a>
186
187 </div>
188
189 <div class="ads image-ad">
190 <a href="https://wordpress.org/plugins/maxgalleria/?utm_source=mbf-dash<?php echo $version ?>&utm_medium=mbf_plugin&utm_content=MG_sidebar&utm_campaign=MG_promote" target="_blank">
191 <img src="<?php echo $plugin_url ?>/images/mg_ad.png" /></a>
192 </div>
193
194 <?php
195 }
196
197 /** Display Rating Links
198 *
199 * Displays rating links via mb-display-title hook.
200 */
201 public static function rate_us()
202 {
203 $output = '';
204
205 $output .= "<div>";
206 $output .= sprintf("Enjoying MaxButtons? Please %s rate us ! %s",
207 "<a href='https://wordpress.org/support/view/plugin-reviews/maxbuttons#postform'>",
208 "</a>"
209 );
210 $output .= "</div>";
211 echo $output;
212 }
213
214
215 public static function display_pagination($page_args, $location = 'top')
216 {
217
218 $mbadmin = MB()->getClass("admin");
219 $pag = $mbadmin->getButtonPages($page_args);
220 if ($pag["first"] == $pag["last"])
221 { return; }
222
223
224 extract($pag);
225
226 ?>
227 <div class='tablenav <?php echo $location ?>'>
228 <div class="tablenav-pages">
229 <span class="displaying-num"><?php echo $pag["total"] ?> items</span>
230 <span class="pagination-links">
231
232 <?php if (! $first_url): ?>
233 <a class="tablenav-pages-navspan button first-page disabled" href='#'>«</a>
234 <?php else: ?>
235 <a href="<?php echo $first_url ?>" data-page="1" title="<?php _e("Go to the first page","maxbuttons") ?>" class="tablenav-pages-navspan button first-page <?php if (!$first_url) echo "disabled"; ?>">«</a>
236 <?php endif; ?>
237
238 <?php if (! $prev_url): ?>
239 <a class="tablenav-pages-navspan button prev-page disabled" href='#'></a>
240 <?php else : ?>
241 <a href="<?php echo $prev_url ?>" data-page="<?php echo $prev_page ?>" title="<?php _e("Go to the previous page","maxbuttons"); ?>" class="tablenav-pages-navspan button prev-page <?php if (!$prev_url) echo "disabled"; ?>"></a>
242 <?php endif; ?>
243
244 <span class="paging-input"><input data-url="<?php echo $base ?>" class='input-paging' min="1" max="<?php echo $last ?>" type="number" name='paging-number' size="1" value="<?php echo $current ?>"> <?php _e("of","maxbuttons") ?> <span class="total-pages"><?php echo $last ?>
245 </span></span>
246
247 <?php if (! $next_url): ?>
248 <a class="tablenav-pages-navspan button next-page disabled" href='#'></a>
249 <?php else: ?>
250 <a href="<?php echo $next_url ?>" data-page="<?php echo $next_page ?>" title="<?php _e("Go to the next page","maxbuttons") ?>" class=" tablenav-pages-navspan button next-page <?php if (!$next_url) echo "disabled"; ?>"></a>
251 <?php endif; ?>
252
253 <?php if (! $last_url): ?>
254 <a class="tablenav-pages-navspan button last-page disabled" href='#'>»</a></span>
255 <?php else: ?>
256 <a href="<?php echo $last_url ?>" data-page="<?php echo $last ?>" title="<?php _e("Go to the last page","maxbuttons") ?>" class="tablenav-pages-navspan button last-page <?php if (!$last_url) echo "disabled"; ?>">»</a></span>
257 <?php endif; ?>
258
259 </div> <!-- tablenav-pages -->
260 </div> <!-- tablenav -->
261
262 <?php
263 }
264
265 public static function mb_review_notice() {
266 if( current_user_can( 'manage_options' ) ) { ?>
267 <div class="updated notice maxbuttons-notice">
268 <div class='review-logo'></div>
269 <div class='mb-notice'>
270 <p class='title'><?php _e("Rate us Please!","maxbuttons"); ?></p>
271 <p><?php _e("Your rating is the simplest way to support MaxButtons. We really appreciate it!","maxbuttons"); ?></p>
272
273 <ul class="review-notice-links">
274 <li> <span class="dashicons dashicons-smiley"></span><a data-action='off' href="javascript:void(0)"><?php _e("I've already left a review","maxbuttons"); ?></a></li>
275 <li><span class="dashicons dashicons-calendar-alt"></span><a data-action='later' href="javascript:void(0)"><?php _e("Maybe Later","maxbuttons"); ?></a></li>
276 <li><span class="dashicons dashicons-external"></span><a target="_blank" href="https://wordpress.org/support/view/plugin-reviews/maxbuttons?filter=5#postform"><?php _e("Sure! I'd love to!","maxbuttons"); ?></a></li>
277 </ul>
278 </div>
279 <a class="dashicons dashicons-dismiss close-mb-notice" href="javascript:void(0)" data-action='off'></a>
280
281 </div>
282 <?php
283 }
284 }
285
286
287
288 public static function displayCollectionWelcome()
289 {
290 ?>
291 <div class="collection welcome">
292 <h2><?php _e("Welcome to MaxButtons Social Sharing", "maxbuttons"); ?></h2>
293 <p><?php _e("Social Sharing sets are collections of buttons that are primarily used to promote your social media profiles on your site.","maxbuttons"); ?></p>
294 <p><?php _e("MaxButtons comes with 5 terrific free sets of Social Sharing buttons for you to use: Notched Box Social Share, Modern Social Share, Round White Social Share, Social Share Squares, Minimalistic Share Buttons. You can also add any other button you have made to a collection of Social Sharing buttons.","maxbuttons"); ?></p>
295
296 <p><?php _e("After clicking the Get Started link below you’ll come to the ‘Select your buttons’ page. Here you will see the listing of free Social Sharing sets plus all of the buttons that you have on your site can be used in the collection that you are putting together.","maxbuttons"); ?></p>
297
298 <p><?php _e("You build your Social Sharing set by selecting the buttons you want in your collection. Then click the Add selected buttons button in the lower right. Aside from being included in your collection your selected buttons are now included with all of the other buttons on your site. You can edit those buttons by going to the Buttons section in the Nav bar on the left.","maxbuttons"); ?></p>
299
300 <p><?php printf(__("By upgrading to %sMaxButtons Pro%s you get an 13 additional Social Sharing button sets along with the ability to build your own Social Sharing sets using your own icons, using Google Fonts in your Social Sharing buttons along with all of the features that come with our premium product.","maxbuttons"), "<a href='https://www.maxbuttons.com' target='_blank'>", "</a>"); ?></p>
301
302 <p><strong><?php _e("Click Get Started and we will have your social media icons up and running on your site super quick!","maxbuttons"); ?></strong></p>
303
304 <p><?php _e("The Max Foundry Team", "maxbuttons"); ?></p>
305
306 <p><a class="page-title-action " href="<?php echo admin_url() ?>admin.php?page=maxbuttons-collections&action=edit&collection=social">
307 <?php _e("Get Started","maxbuttons"); ?></a></p>
308
309 </div>
310
311 <?php
312 }
313
314 } // class
315