PluginProbe
Code Engine – PHP Snippets, AI Functions & Automation for WordPress / trunk
Code Engine – PHP Snippets, AI Functions & Automation for WordPress vtrunk
0.5.7 0.5.6 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 0.4.9 0.4.8 0.4.7 0.4.6 trunk 0.0.1 0.0.2 0.2.8 0.2.9 0.3.0 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 All 33 releases
← All changes | classes/rest.php +15 -0 0.3.7trunk View file →
@@ -162,9 +162,15 @@
162 162 'callback' => array($this, 'rest_replace'),
163 163 'permission_callback' => array($this->core, 'can_access_settings')
164 164 ));
165 165
166 + register_rest_route($this->namespace, '/snippets/delete_duplicates', array(
167 + 'methods' => 'POST',
168 + 'callback' => array($this, 'rest_delete_duplicates'),
169 + 'permission_callback' => array($this->core, 'can_access_settings')
170 + ));
166 171
172 +
167 173 // SNIPPETS ENDPOINTS
168 174 $snippets = $this->snippet->select(
169 175 null, // offset
170 176 -1, // limit
@@ -802,8 +808,17 @@
802 808 $result[] = $this->snippet->insert( $snippet );
803 809 }
804 810
805 811 return new WP_REST_Response([ 'success' => true, 'data' => $result ], 200);
812 + } catch (Exception $e) {
813 + return new WP_REST_Response( ['success' => false, 'message' => $e->getMessage() ], 500 );
814 + }
815 + }
816 +
817 + public function rest_delete_duplicates() {
818 + try {
819 + $result = $this->snippet->delete_duplicates();
820 + return new WP_REST_Response([ 'success' => true, 'data' => [ 'deleted' => $result ] ], 200);
806 821 } catch (Exception $e) {
807 822 return new WP_REST_Response( ['success' => false, 'message' => $e->getMessage() ], 500 );
808 823 }
809 824 }