PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 6.0.7
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v6.0.7
trunk 2.0.2 3.0 4.0 4.1.2 4.3 5.0 5.0.1 5.1 5.1.1 5.2 5.3 5.3.1 6.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 All 31 releases
floating-button / classes / Dashboard / Settings.php

Settings.php in Floating Button – Easily Create Sticky, Fixed & Floating Buttons 6.0.7, at classes/Dashboard/Settings.php

94 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FloatingButton\Dashboard;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use FloatingButton\WOW_Plugin;
8
9 class Settings {
10
11 public static function init(): void {
12 $pages = DashboardHelper::get_files( 'settings' );
13
14 $i = 0;
15 echo '<h3 class="nav-tab-wrapper wowp-tab" id="settings-tab">';
16 foreach ( $pages as $key => $page ) {
17 $current = ( $i === 0 ) ? 'nav-tab nav-tab-active' : 'nav-tab';
18 echo '<a class="' . esc_attr( $current ) . '" data-tab="' . esc_attr( $page['file'] ) . '">' . esc_html( $page['name'] ) . '</a>';
19 $i ++;
20 }
21 echo '</h3>';
22
23 $i = 0;
24
25 echo '<div class="tab-content-wrapper wowp-tab-content" id="settings-content">';
26 foreach ( $pages as $key => $page ) {
27 $current = ( $i === 0 ) ? 'tab-content tab-content-active' : 'tab-content';
28 $file = DashboardHelper::get_folder_path( 'settings' ) . '/' . $key . '.' . $page['file'] . '.php';
29
30 if ( file_exists( $file ) ) {
31 echo '<div class="' . esc_attr( $current ) . '" data-content="' . esc_attr( $page['file'] ) . '">';
32 require_once $file;
33 echo '</div>';
34 }
35 $i ++;
36 }
37 echo '</div>';
38 }
39
40 public static function save_item() {
41 if ( empty( $_POST['submit_settings'] ) ) {
42 return false;
43 }
44
45 $id = isset( $_POST['tool_id'] ) ? absint( wp_unslash( $_POST['tool_id'] ) ) : '';
46 $settings = apply_filters( WOW_Plugin::PREFIX . '_save_settings', [ 'data' => [], 'formats' => [] ], $_POST );
47
48 if ( empty( $id ) ) {
49 $id_item = DBManager::insert( $settings['data'], $settings['formats'] );
50 } else {
51 $where = [
52 'id' => absint( $id ),
53 ];
54 DBManager::update( $settings['data'], $where, $settings['formats'] );
55 $id_item = $id;
56 }
57
58 wp_safe_redirect( Link::save_item( $id_item ) );
59 exit;
60 }
61
62 public static function deactivate_item( $id = 0 ): void {
63 $id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : $id;
64
65 if ( ! empty( $id ) ) {
66 DBManager::update( [ 'status' => '1' ], [ 'ID' => $id ], [ '%d' ] );
67 }
68 }
69
70 public static function activate_item( $id = 0 ): void {
71 $id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : $id;
72
73 if ( ! empty( $id ) ) {
74 DBManager::update( [ 'status' => '' ], [ 'ID' => $id ], [ '%d' ] );
75 }
76 }
77
78 public static function deactivate_mode( $id = 0 ): void {
79 $id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : $id;
80
81 if ( ! empty( $id ) ) {
82 DBManager::update( [ 'mode' => '' ], [ 'ID' => $id ], [ '%d' ] );
83 }
84 }
85
86 public static function activate_mode( $id = 0 ): void {
87 $id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : $id;
88
89 if ( ! empty( $id ) ) {
90 DBManager::update( [ 'mode' => '1' ], [ 'ID' => $id ], [ '%d' ] );
91 }
92 }
93
94 }