| @@ -62,20 +62,15 @@ | ||
| 62 | 62 | if (!isset($request['security']) || !wp_verify_nonce($request['security'], WOWP_Plugin::PREFIX . '_settings')) { |
| 63 | 63 | wp_send_json_error(['message' => 'Invalid nonce'], 400); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 67 | - wp_send_json_error( [ 'message' => 'Permission denied' ], 403 ); | |
| 68 | - } | |
| 66 | + $info = $request['info']; | |
| 69 | 67 | |
| 70 | - $info = ( isset( $request['info'] ) && is_array( $request['info'] ) ) ? $request['info'] : []; | |
| 71 | 68 | |
| 72 | 69 | $id = isset( $info['tool_id'] ) ? absint( $info['tool_id'] ) : 0; |
| 73 | 70 | |
| 74 | - $param = ( isset( $info['param'] ) && is_array( $info['param'] ) ) ? $info['param'] : []; | |
| 71 | + $settings = apply_filters( WOWP_Plugin::PREFIX . '_save_settings', $info['param'] ); | |
| 75 | 72 | |
| 76 | - $settings = apply_filters( WOWP_Plugin::PREFIX . '_save_settings', $param ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound | |
| 77 | - | |
| 78 | 73 | $data = [ |
| 79 | 74 | 'title' => isset( $info['title'] ) ? sanitize_text_field( wp_unslash( $info['title'] ) ) : '', |
| 80 | 75 | 'status' => isset( $info['status'] ) ? 1 : 0, |
| 81 | 76 | 'mode' => isset( $info['mode'] ) ? 1 : 0, |
| @@ -109,9 +104,9 @@ | ||
| 109 | 104 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 110 | 105 | $id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : $id; |
| 111 | 106 | |
| 112 | 107 | if ( ! empty( $id ) ) { |
| 113 | - DBManager::update( [ 'status' => '1' ], [ 'id' => $id ], [ '%d' ] ); | |
| 108 | + DBManager::update( [ 'status' => '1' ], [ 'ID' => $id ], [ '%d' ] ); | |
| 114 | 109 | } |
| 115 | 110 | |
| 116 | 111 | } |
| 117 | 112 | |
| @@ -119,9 +114,9 @@ | ||
| 119 | 114 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 120 | 115 | $id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : $id; |
| 121 | 116 | |
| 122 | 117 | if ( ! empty( $id ) ) { |
| 123 | - DBManager::update( [ 'status' => '' ], [ 'id' => $id ], [ '%d' ] ); | |
| 118 | + DBManager::update( [ 'status' => '' ], [ 'ID' => $id ], [ '%d' ] ); | |
| 124 | 119 | } |
| 125 | 120 | |
| 126 | 121 | } |
| 127 | 122 | |
| @@ -129,9 +124,9 @@ | ||
| 129 | 124 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 130 | 125 | $id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : $id; |
| 131 | 126 | |
| 132 | 127 | if ( ! empty( $id ) ) { |
| 133 | - DBManager::update( [ 'mode' => '' ], [ 'id' => $id ], [ '%d' ] ); | |
| 128 | + DBManager::update( [ 'mode' => '' ], [ 'ID' => $id ], [ '%d' ] ); | |
| 134 | 129 | } |
| 135 | 130 | |
| 136 | 131 | } |
| 137 | 132 | |
| @@ -139,9 +134,9 @@ | ||
| 139 | 134 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 140 | 135 | $id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : $id; |
| 141 | 136 | |
| 142 | 137 | if ( ! empty( $id ) ) { |
| 143 | - DBManager::update( [ 'mode' => '1' ], [ 'id' => $id ], [ '%d' ] ); | |
| 138 | + DBManager::update( [ 'mode' => '1' ], [ 'ID' => $id ], [ '%d' ] ); | |
| 144 | 139 | } |
| 145 | 140 | } |
| 146 | 141 | |
| 147 | 142 | public static function get_options() { |
| @@ -176,9 +171,9 @@ | ||
| 176 | 171 | |
| 177 | 172 | return $param; |
| 178 | 173 | } |
| 179 | 174 | |
| 180 | - public static function option( $name, $options ) { | |
| 175 | + public static function option( $name, $option ) { | |
| 181 | 176 | return $options[ $name ] ?? ''; |
| 182 | 177 | } |
| 183 | 178 | |
| 184 | 179 | } |