pluginUpdated(); } /** * Deactivate plugin, SEE YOU SOON! */ public function pluginDeactivate() { // Nothing to handle right now. Maybe later } /** * Updated? */ public function pluginUpdated() { if ( !Settings::isset( "migration_version" ) ) { ( new Update() )->run(); } else { if ( Settings::getSetting( 'migration_version', BUTTONIZER_LAST_MIGRATION ) !== BUTTONIZER_LAST_MIGRATION ) { ( new Update() )->selfMigrate( Settings::getSetting( 'migration_version' ) ); } } } /** * Add Buttonizer to the admin bar * @param $admin_bar */ public function wordpress_admin_bar( $admin_bar ) { // Only show to admins and when enabled if ( PermissionCheck::hasPermission() ) { $showTopBar = Settings::getSetting( 'admin_top_bar_show_button', true ); if ( $showTopBar && filter_var( $showTopBar, FILTER_VALIDATE_BOOLEAN, [ 'options' => [ 'default' => false, ], ] ) === true ) { $admin_bar->add_menu( array( 'id' => 'buttonizer', 'title' => '', 'href' => admin_url() . 'admin.php?page=Buttonizer', 'meta' => [], ) ); // Buttonizer buttons $admin_bar->add_menu( array( 'id' => 'buttonizer_buttons', 'parent' => 'buttonizer', 'title' => __( 'Manage buttons', 'buttonizer-multifunctional-button' ), 'href' => admin_url() . 'admin.php?page=Buttonizer', 'meta' => array(), ) ); // Settings $admin_bar->add_menu( array( 'id' => 'buttonizer_knowledgebase', 'parent' => 'buttonizer', 'title' => __( 'Knowledge base', 'buttonizer-multifunctional-button' ), 'href' => "https://community.buttonizer.pro/knowledgebase", 'meta' => [ "target" => "_blank", "title" => __( 'Find out everything you need to know about Buttonizer', 'buttonizer-multifunctional-button' ), ], ) ); } } } /** * Get WordPress timezone */ public static function getTimezone() { $timezone_string = get_option( 'timezone_string' ); if ( !empty( $timezone_string ) ) { return $timezone_string; } $offset = get_option( 'gmt_offset' ); $hours = (int) $offset; $minutes = ($offset - floor( $offset )) * 60; $offset = sprintf( '%+03d:%02d', $hours, $minutes ); return $offset; } /** * Generate a uuid unique id */ public static function GenerateUniqueId() { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xfff ) | 0x4000, mt_rand( 0, 0x3fff ) | 0x8000, mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) ); } }