PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 3.6.0
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v3.6.0
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 / app / Legacy / Utils / Maintain.php

Maintain.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 3.6.0, at app/Legacy/Utils/Maintain.php

140 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * SOFTWARE LICENSE INFORMATION
5 *
6 * Copyright (c) 2017 Buttonizer, all rights reserved.
7 *
8 * This file is part of Buttonizer
9 *
10 * For detailed information regarding to the licensing of
11 * this software, please review the license.txt or visit:
12 * https://buttonizer.pro/license/
13 */
14 namespace Buttonizer\Legacy\Utils;
15
16 use Buttonizer\Core\Utils\PermissionCheck;
17 use Buttonizer\Core\Utils\Settings;
18 # No script kiddies
19 defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
20 class Maintain {
21 // Construct
22 public function __construct( $ready = false ) {
23 if ( !$ready ) {
24 return;
25 }
26 register_activation_hook( 'buttonizer', array(&$this, 'pluginActivate') );
27 register_deactivation_hook( 'buttonizer', array(&$this, 'pluginDeactivate') );
28 add_action(
29 'upgrader_process_complete',
30 array(&$this, 'pluginUpdated'),
31 10,
32 2
33 );
34 add_action( 'admin_bar_menu', array(&$this, 'wordpress_admin_bar'), 100 );
35 }
36
37 /**
38 * Activate Buttonizer, AWESOMAAH!
39 */
40 public function pluginActivate() {
41 // Check updated data
42 $this->pluginUpdated();
43 }
44
45 /**
46 * Deactivate plugin, SEE YOU SOON!
47 */
48 public function pluginDeactivate() {
49 // Nothing to handle right now. Maybe later
50 }
51
52 /**
53 * Updated?
54 */
55 public function pluginUpdated() {
56 if ( !Settings::isset( "migration_version" ) ) {
57 ( new Update() )->run();
58 } else {
59 if ( Settings::getSetting( 'migration_version', BUTTONIZER_LAST_MIGRATION ) !== BUTTONIZER_LAST_MIGRATION ) {
60 ( new Update() )->selfMigrate( Settings::getSetting( 'migration_version' ) );
61 }
62 }
63 }
64
65 /**
66 * Add Buttonizer to the admin bar
67 * @param $admin_bar
68 */
69 public function wordpress_admin_bar( $admin_bar ) {
70 // Only show to admins and when enabled
71 if ( PermissionCheck::hasPermission() ) {
72 $showTopBar = Settings::getSetting( 'admin_top_bar_show_button', true );
73 if ( $showTopBar && filter_var( $showTopBar, FILTER_VALIDATE_BOOLEAN, [
74 'options' => [
75 'default' => false,
76 ],
77 ] ) === true ) {
78 $admin_bar->add_menu( array(
79 'id' => 'buttonizer',
80 'title' => '<img src="' . plugins_url( '/assets/images/wp-icon.png', BUTTONIZER_PLUGIN_DIR ) . '" style="vertical-align: text-bottom; opacity: 0.7; display: inline-block;" />',
81 'href' => admin_url() . 'admin.php?page=Buttonizer',
82 'meta' => [],
83 ) );
84 // Buttonizer buttons
85 $admin_bar->add_menu( array(
86 'id' => 'buttonizer_buttons',
87 'parent' => 'buttonizer',
88 'title' => __( 'Manage buttons', 'buttonizer-multifunctional-button' ),
89 'href' => admin_url() . 'admin.php?page=Buttonizer',
90 'meta' => array(),
91 ) );
92 // Settings
93 $admin_bar->add_menu( array(
94 'id' => 'buttonizer_knowledgebase',
95 'parent' => 'buttonizer',
96 'title' => __( 'Knowledge base', 'buttonizer-multifunctional-button' ),
97 'href' => "https://community.buttonizer.pro/knowledgebase",
98 'meta' => [
99 "target" => "_blank",
100 "title" => __( 'Find out everything you need to know about Buttonizer', 'buttonizer-multifunctional-button' ),
101 ],
102 ) );
103 }
104 }
105 }
106
107 /**
108 * Get WordPress timezone
109 */
110 public static function getTimezone() {
111 $timezone_string = get_option( 'timezone_string' );
112 if ( !empty( $timezone_string ) ) {
113 return $timezone_string;
114 }
115 $offset = get_option( 'gmt_offset' );
116 $hours = (int) $offset;
117 $minutes = ($offset - floor( $offset )) * 60;
118 $offset = sprintf( '%+03d:%02d', $hours, $minutes );
119 return $offset;
120 }
121
122 /**
123 * Generate a uuid unique id
124 */
125 public static function GenerateUniqueId() {
126 return sprintf(
127 '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
128 mt_rand( 0, 0xffff ),
129 mt_rand( 0, 0xffff ),
130 mt_rand( 0, 0xffff ),
131 mt_rand( 0, 0xfff ) | 0x4000,
132 mt_rand( 0, 0x3fff ) | 0x8000,
133 mt_rand( 0, 0xffff ),
134 mt_rand( 0, 0xffff ),
135 mt_rand( 0, 0xffff )
136 );
137 }
138
139 }
140