PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.2
WP Coder – Insert & Manage Code Snippets v3.2
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
wp-coder / classes / Dashboard / Link.php

Link.php in WP Coder – Insert & Manage Code Snippets 3.2, at classes/Dashboard/Link.php

122 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPCoder\Dashboard;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use WPCoder\WPCoder;
8
9 class Link {
10
11 public static function create($arg = []): string {
12 return add_query_arg( $arg, self::link() );
13 }
14
15 public static function activate_mode($id = 0): string {
16 return wp_nonce_url (add_query_arg( [
17 'id' => $id,
18 ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_activate_mode');
19 }
20
21 public static function deactivate_mode($id = 0) {
22 return wp_nonce_url (add_query_arg( [
23 'id' => $id,
24 ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_deactivate_mode');
25 }
26
27
28 public static function activate_url($id = 0) {
29 return wp_nonce_url (add_query_arg( [
30 'id' => $id,
31 'action' => 'activate',
32 ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_activate_item');
33 }
34
35 public static function deactivate_url($id = 0) {
36 return wp_nonce_url (add_query_arg( [
37 'id' => $id,
38 'action' => 'deactivate',
39 ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_deactivate_item');
40 }
41
42 public static function remove_item() {
43 return add_query_arg( [
44 'notice' => 'remove_item',
45 ], self::link() );
46
47 }
48
49 public static function save_item( $id ) {
50 return add_query_arg( [
51 'page' => WPCoder::SLUG . '-settings',
52 'action' => 'update',
53 'id' => $id,
54 'notice' => 'save_item',
55 ], admin_url( 'admin.php' ) );
56 }
57
58 public static function menu( $page, $action, $id ): string {
59 if ( ! empty( $id ) && $action === 'update' ) {
60 return add_query_arg( [
61 'page' => WPCoder::SLUG . '-settings',
62 'action' => 'update',
63 'id' => $id,
64 ], admin_url( 'admin.php' ) );
65 }
66
67 return add_query_arg( [
68 'tab' => $page,
69 ], self::link() );
70 }
71
72 public static function edit( $id ) {
73 if ( ! $id ) {
74 return false;
75 }
76
77 return add_query_arg( [
78 'page' => WPCoder::SLUG . '-settings',
79 'action' => 'update',
80 'id' => $id
81 ], admin_url( 'admin.php' ) );
82 }
83
84 public static function duplicate( $id ) {
85 if ( ! $id ) {
86 return false;
87 }
88
89 return add_query_arg( [
90 'page' => WPCoder::SLUG . '-settings',
91 'action' => 'duplicate',
92 'id' => $id
93 ], admin_url( 'admin.php' ) );
94 }
95
96 public static function export( $id ) {
97 if ( ! $id ) {
98 return false;
99 }
100
101 return wp_nonce_url( add_query_arg( [
102 'action' => 'export',
103 'id' => $id
104 ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_export_item' );
105 }
106
107 public static function remove( $id ) {
108 if ( ! $id ) {
109 return false;
110 }
111
112 return wp_nonce_url( add_query_arg( [
113 'action' => 'delete',
114 'id' => $id
115 ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_remove_item' );
116 }
117
118 private static function link(): string {
119 return add_query_arg( [ 'page' => WPCoder::SLUG ], admin_url( 'admin.php' ) );
120 }
121
122 }