PluginProbe
Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress / trunk
Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress vtrunk
2.0.14 trunk 1.0 1.2 1.2.1 1.2.2 1.2.3 1.2.4 2.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
counter-box / classes / Admin / Link.php

Link.php in Counter Box – Add Countdowns, Timers & Dynamic Counters to WordPress trunk, at classes/Admin/Link.php

147 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class Link
5 *
6 * Handles generating various URLs within the admin area.
7 */
8
9 namespace CounterBox\Admin;
10
11 defined( 'ABSPATH' ) || exit;
12
13 use /**
14 * The CounterBox\WOWP_Plugin class represents a WordPress plugin that adds custom buttons to the post editor.
15 *
16 * @package CounterBox
17 */
18 CounterBox\WOWP_Plugin;
19
20 /**
21 * The Link class provides methods for generating URLs with query arguments.
22 */
23 class Link {
24
25 public static function add_new_item() {
26
27 return add_query_arg( [
28 'page' => WOWP_Plugin::SLUG,
29 'tab' => 'settings',
30 'action' => 'new'
31 ], admin_url( 'admin.php' ) );
32
33 }
34
35 public static function create( $arg = [] ): string {
36 return add_query_arg( $arg, self::link() );
37 }
38
39 public static function activate_mode( $id = 0 ): string {
40 return wp_nonce_url( add_query_arg( [
41 'id' => $id,
42 ], self::link() ), WOWP_Plugin::PREFIX . '_nonce', WOWP_Plugin::PREFIX . '_activate_mode' );
43 }
44
45 public static function deactivate_mode( $id = 0 ) {
46 return wp_nonce_url( add_query_arg( [
47 'id' => $id,
48 ], self::link() ), WOWP_Plugin::PREFIX . '_nonce', WOWP_Plugin::PREFIX . '_deactivate_mode' );
49 }
50
51
52 public static function activate_url( $id = 0 ) {
53 return wp_nonce_url( add_query_arg( [
54 'id' => $id,
55 'action' => 'activate',
56 ], self::link() ), WOWP_Plugin::PREFIX . '_nonce', WOWP_Plugin::PREFIX . '_activate_item' );
57 }
58
59 public static function deactivate_url( $id = 0 ) {
60 return wp_nonce_url( add_query_arg( [
61 'id' => $id,
62 'action' => 'deactivate',
63 ], self::link() ), WOWP_Plugin::PREFIX . '_nonce', WOWP_Plugin::PREFIX . '_deactivate_item' );
64 }
65
66 public static function remove_item() {
67 return add_query_arg( [
68 'notice' => 'remove_item',
69 ], self::link() );
70
71 }
72
73 public static function save_item( $id ) {
74 return add_query_arg( [
75 'tab' => 'settings',
76 'action' => 'update',
77 'id' => $id,
78 'notice' => 'save_item',
79 'nonce' => wp_create_nonce( 'save-item')
80 ], self::link() );
81 }
82
83 public static function menu( $page, $action, $id ): string {
84 if ( ! empty( $id ) && $action === 'update' ) {
85 return add_query_arg( [
86 'tab' => $page,
87 'action' => 'update',
88 'id' => $id,
89 ], self::link() );
90 }
91
92 return add_query_arg( [
93 'tab' => $page,
94 ], self::link() );
95 }
96
97 public static function edit( $id ) {
98 if ( ! $id ) {
99 return false;
100 }
101
102 return add_query_arg( [
103 'action' => 'update',
104 'tab' => 'settings',
105 'id' => $id
106 ], self::link() );
107 }
108
109 public static function duplicate( $id ) {
110 if ( ! $id ) {
111 return false;
112 }
113
114 return add_query_arg( [
115 'action' => 'duplicate',
116 'tab' => 'settings',
117 'id' => $id
118 ], self::link() );
119 }
120
121 public static function export( $id ) {
122 if ( ! $id ) {
123 return false;
124 }
125
126 return wp_nonce_url( add_query_arg( [
127 'action' => 'export',
128 'id' => $id
129 ], self::link() ), WOWP_Plugin::PREFIX . '_nonce', WOWP_Plugin::PREFIX . '_export_item' );
130 }
131
132 public static function remove( $id ) {
133 if ( ! $id ) {
134 return false;
135 }
136
137 return wp_nonce_url( add_query_arg( [
138 'action' => 'delete',
139 'id' => $id
140 ], self::link() ), WOWP_Plugin::PREFIX . '_nonce', WOWP_Plugin::PREFIX . '_remove_item' );
141 }
142
143 private static function link(): string {
144 return add_query_arg( [ 'page' => WOWP_Plugin::SLUG ], admin_url( 'admin.php' ) );
145 }
146
147 }