| @@ -7,37 +7,37 @@ | ||
| 7 | 7 | use WPCoder\WPCoder; |
| 8 | 8 | |
| 9 | 9 | class Link { |
| 10 | 10 | |
| 11 | - public static function create( $arg = [] ): string { | |
| 11 | + public static function create($arg = []): string { | |
| 12 | 12 | return add_query_arg( $arg, self::link() ); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public static function activate_mode( $id = 0 ): string { | |
| 16 | - return wp_nonce_url( add_query_arg( [ | |
| 15 | + public static function activate_mode($id = 0): string { | |
| 16 | + return wp_nonce_url (add_query_arg( [ | |
| 17 | 17 | 'id' => $id, |
| 18 | - ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_activate_mode' ); | |
| 18 | + ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_activate_mode'); | |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public static function deactivate_mode( $id = 0 ) { | |
| 22 | - return wp_nonce_url( add_query_arg( [ | |
| 21 | + public static function deactivate_mode($id = 0) { | |
| 22 | + return wp_nonce_url (add_query_arg( [ | |
| 23 | 23 | 'id' => $id, |
| 24 | - ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_deactivate_mode' ); | |
| 24 | + ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_deactivate_mode'); | |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | |
| 28 | - public static function activate_url( $id = 0 ) { | |
| 29 | - return wp_nonce_url( add_query_arg( [ | |
| 30 | - 'id' => $id, | |
| 28 | + public static function activate_url($id = 0) { | |
| 29 | + return wp_nonce_url (add_query_arg( [ | |
| 30 | + 'id' => $id, | |
| 31 | 31 | 'action' => 'activate', |
| 32 | - ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_activate_item' ); | |
| 32 | + ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_activate_item'); | |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public static function deactivate_url( $id = 0 ) { | |
| 36 | - return wp_nonce_url( add_query_arg( [ | |
| 37 | - 'id' => $id, | |
| 35 | + public static function deactivate_url($id = 0) { | |
| 36 | + return wp_nonce_url (add_query_arg( [ | |
| 37 | + 'id' => $id, | |
| 38 | 38 | 'action' => 'deactivate', |
| 39 | - ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_deactivate_item' ); | |
| 39 | + ], self::link() ), WPCoder::PREFIX . '_nonce', WPCoder::PREFIX . '_deactivate_item'); | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public static function remove_item() { |
| 43 | 43 | return add_query_arg( [ |
| @@ -42,32 +42,24 @@ | ||
| 42 | 42 | public static function remove_item() { |
| 43 | 43 | return add_query_arg( [ |
| 44 | 44 | 'notice' => 'remove_item', |
| 45 | 45 | ], self::link() ); |
| 46 | + | |
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | public static function save_item( $id ) { |
| 49 | - | |
| 50 | - $paged = $_GET['wpcoder-page'] ?? ''; | |
| 51 | - | |
| 52 | - $arg = [ | |
| 53 | - 'page' => WPCoder::SLUG . '-settings', | |
| 50 | + return add_query_arg( [ | |
| 51 | + 'page' => WPCoder::SLUG . '-settings', | |
| 54 | 52 | 'action' => 'update', |
| 55 | 53 | 'id' => $id, |
| 56 | 54 | 'notice' => 'save_item', |
| 57 | - ]; | |
| 58 | - | |
| 59 | - if(!empty($paged)) { | |
| 60 | - $arg['wpcoder-page'] = absint($paged); | |
| 61 | - } | |
| 62 | - | |
| 63 | - return add_query_arg( $arg, admin_url( 'admin.php' ) ); | |
| 55 | + ], admin_url( 'admin.php' ) ); | |
| 64 | 56 | } |
| 65 | 57 | |
| 66 | 58 | public static function menu( $page, $action, $id ): string { |
| 67 | 59 | if ( ! empty( $id ) && $action === 'update' ) { |
| 68 | 60 | return add_query_arg( [ |
| 69 | - 'page' => WPCoder::SLUG . '-settings', | |
| 61 | + 'page' => WPCoder::SLUG . '-settings', | |
| 70 | 62 | 'action' => 'update', |
| 71 | 63 | 'id' => $id, |
| 72 | 64 | ], admin_url( 'admin.php' ) ); |
| 73 | 65 | } |
| @@ -80,31 +72,16 @@ | ||
| 80 | 72 | public static function edit( $id ) { |
| 81 | 73 | if ( ! $id ) { |
| 82 | 74 | return false; |
| 83 | 75 | } |
| 84 | - $paged = $_GET['paged'] ?? ''; | |
| 76 | + | |
| 85 | 77 | return add_query_arg( [ |
| 86 | - 'page' => WPCoder::SLUG . '-settings', | |
| 87 | - 'action' => 'update', | |
| 88 | - 'id' => $id, | |
| 89 | - 'wpcoder-page' => absint( $paged ), | |
| 78 | + 'page' => WPCoder::SLUG . '-settings', | |
| 79 | + 'action' => 'update', | |
| 80 | + 'id' => $id | |
| 90 | 81 | ], admin_url( 'admin.php' ) ); |
| 91 | 82 | } |
| 92 | 83 | |
| 93 | - public static function all_codes() { | |
| 94 | - $paged = $_GET['wpcoder-page'] ?? ''; | |
| 95 | - | |
| 96 | - $arg = [ | |
| 97 | - 'page' => WPCoder::SLUG , | |
| 98 | - ]; | |
| 99 | - | |
| 100 | - if(!empty($paged)) { | |
| 101 | - $arg['paged'] = absint($paged); | |
| 102 | - } | |
| 103 | - | |
| 104 | - return add_query_arg( $arg, admin_url( 'admin.php' ) ); | |
| 105 | - } | |
| 106 | - | |
| 107 | 84 | public static function duplicate( $id ) { |
| 108 | 85 | if ( ! $id ) { |
| 109 | 86 | return false; |
| 110 | 87 | } |
| @@ -109,9 +86,9 @@ | ||
| 109 | 86 | return false; |
| 110 | 87 | } |
| 111 | 88 | |
| 112 | 89 | return add_query_arg( [ |
| 113 | - 'page' => WPCoder::SLUG . '-settings', | |
| 90 | + 'page' => WPCoder::SLUG . '-settings', | |
| 114 | 91 | 'action' => 'duplicate', |
| 115 | 92 | 'id' => $id |
| 116 | 93 | ], admin_url( 'admin.php' ) ); |
| 117 | 94 | } |