PluginProbe
Code Engine – PHP Snippets, AI Functions & Automation for WordPress / 0.3.9
Code Engine – PHP Snippets, AI Functions & Automation for WordPress v0.3.9
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/modules/snippet.php +4 -34 0.4.90.3.9 View file →
@@ -390,9 +390,8 @@
390 390 $scopes = [
391 391 "global" => "persistent",
392 392 "front-end" => "frontend",
393 393 "admin" => "backend",
394 - "content" => "content_php",
395 394 ];
396 395
397 396 if ( array_key_exists( $params['scope'], $scopes ) ) {
398 397 $params['scope'] = $scopes[$params['scope']];
@@ -537,9 +536,9 @@
537 536 return $tag !== '';
538 537 } );
539 538 }
540 539 $params['tags'] = $tags ? implode( ',', $tags ) : '';
541 - //$params['code'] = $this->sanitize_code( $params['code'] );
540 + $params['code'] = $this->sanitize_code( $params['code'] );
542 541 return $params;
543 542 }
544 543
545 544 /**
@@ -586,12 +585,9 @@
586 585 $stats[$scope] = $this->wpdb->get_var( $this->wpdb->prepare( "SELECT COUNT( * ) FROM $this->table_name WHERE scope = %s", $scope ) );
587 586 }
588 587 $stats['all'] += $stats[$scope];
589 588 }
590 -
591 - // Combined count for the "Content" filter (PHP + JS). Not added to 'all', already counted above.
592 - $stats['content'] = (int) $stats['content_php'] + (int) $stats['content_js'];
593 -
589 +
594 590 return $stats;
595 591 }
596 592
597 593 public function import( )
@@ -614,34 +610,15 @@
614 610
615 611 return count( $snippets );
616 612 }
617 613
618 - public function sanitize_code( $code )
614 + private function sanitize_code( $code )
619 615 {
616 + $code = preg_replace( '/<\?php/', '', $code, 1 );
620 617 $code = ltrim( $code );
621 -
622 - $first_chats = substr( $code, 0, 5 );
623 - if( $first_chats === '<?php' ) {
624 - $code = substr( $code, 5 );
625 - $code = ltrim( $code );
626 - }
627 -
628 618 return $code;
629 619 }
630 620
631 - public function delete_duplicates() {
632 - // Delete snippets that have the same code and scope, keeping only the most recent one ( based on the updated column )
633 - $query = "DELETE t1 FROM $this->table_name t1
634 - INNER JOIN $this->table_name t2
635 - WHERE t1.id < t2.id
636 - AND t1.code = t2.code
637 - AND t1.scope = t2.scope";
638 -
639 - $this->wpdb->query( $query );
640 -
641 - return $this->wpdb->rows_affected;
642 - }
643 -
644 621 #endregion
645 622
646 623 #region Snippet CRUD
647 624
@@ -672,11 +649,8 @@
672 649 }
673 650 else if ( $filter['accessor'] === 'scope' && $filter['value'] === 'global' ) {
674 651 $freshFilters[] = [ 'accessor' => 'scope', 'value' => ['backend', 'frontend', 'persistent'] ];
675 652 }
676 - else if ( $filter['accessor'] === 'scope' && $filter['value'] === 'content' ) {
677 - $freshFilters[] = [ 'accessor' => 'scope', 'value' => ['content_php', 'content_js'] ];
678 - }
679 653 else {
680 654 $freshFilters[] = $filter;
681 655 }
682 656 }
@@ -900,12 +874,8 @@
900 874 }
901 875
902 876 function check_db( )
903 877 {
904 - if ( $this->db_check ) {
905 - return true;
906 - }
907 -
908 878 if ( $this->does_table_exist( $this->table_name ) ) {
909 879 $this->check_columns( );
910 880 $this->db_check = true;
911 881 } else {