| @@ -142,15 +142,15 @@ | ||
| 142 | 142 | foreach ( $functions_snippet as $function_snippet ) { |
| 143 | 143 | if ( $function_snippet['snippetId'] == $snippetId ) { |
| 144 | 144 | |
| 145 | 145 | $snippet['functionName'] = $function_snippet['name']; |
| 146 | - if ( !isset( $snippet['functionBehavior'] ) || empty( $snippet['functionBehavior'] ) ) { | |
| 146 | + if ( !isset( $function_snippet['behavior'] ) || empty( $function_snippet['behavior'] ) ) { | |
| 147 | 147 | $snippet['functionBehavior'] = 'dynamic'; |
| 148 | 148 | } |
| 149 | 149 | else { |
| 150 | 150 | $snippet['functionBehavior'] = $function_snippet['behavior']; |
| 151 | 151 | } |
| 152 | - if ( !isset( $snippet['functionTarget'] ) || empty( $snippet['functionTarget'] ) ) { | |
| 152 | + if ( !isset( $function_snippet['target'] ) || empty( $function_snippet['target'] ) ) { | |
| 153 | 153 | $snippet['functionTarget'] = 'PHP'; |
| 154 | 154 | } |
| 155 | 155 | else { |
| 156 | 156 | $snippet['functionTarget'] = $function_snippet['target']; |
| @@ -536,9 +536,9 @@ | ||
| 536 | 536 | return $tag !== ''; |
| 537 | 537 | } ); |
| 538 | 538 | } |
| 539 | 539 | $params['tags'] = $tags ? implode( ',', $tags ) : ''; |
| 540 | - $params['code'] = $this->sanitize_code( $params['code'] ); | |
| 540 | + //$params['code'] = $this->sanitize_code( $params['code'] ); | |
| 541 | 541 | return $params; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
| @@ -549,9 +549,9 @@ | ||
| 549 | 549 | */ |
| 550 | 550 | private function formatParamsForFront( $params ) |
| 551 | 551 | { |
| 552 | 552 | // Separate the scope tags from the tags |
| 553 | - $scopes = ['backend', 'frontend', 'function', 'persistent', 'scheduled']; | |
| 553 | + $scopes = ['backend', 'frontend', 'function', 'persistent', 'scheduled', 'content_php', 'content_js']; | |
| 554 | 554 | |
| 555 | 555 | if ( isset( $params['tags'] ) && !empty( $params['tags'] ) ) { |
| 556 | 556 | |
| 557 | 557 | $tags = array_map( function ( $tag ) use ( $scopes ) { |
| @@ -610,12 +610,18 @@ | ||
| 610 | 610 | |
| 611 | 611 | return count( $snippets ); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - private function sanitize_code( $code ) | |
| 614 | + public function sanitize_code( $code ) | |
| 615 | 615 | { |
| 616 | - $code = preg_replace( '/<\?php/', '', $code, 1 ); | |
| 617 | 616 | $code = ltrim( $code ); |
| 617 | + | |
| 618 | + $first_chats = substr( $code, 0, 5 ); | |
| 619 | + if( $first_chats === '<?php' ) { | |
| 620 | + $code = substr( $code, 5 ); | |
| 621 | + $code = ltrim( $code ); | |
| 622 | + } | |
| 623 | + | |
| 618 | 624 | return $code; |
| 619 | 625 | } |
| 620 | 626 | |
| 621 | 627 | #endregion |
| @@ -687,9 +693,9 @@ | ||
| 687 | 693 | $scopes = array_map( function( $scope ) { |
| 688 | 694 | return esc_sql( $scope ); |
| 689 | 695 | }, $filter['value'] ); |
| 690 | 696 | $where[] = "scope IN ('" . implode( "', '", $scopes ) . "')"; |
| 691 | - } else { | |
| 697 | + } else if ( !empty( $filter['value'] ) ) { | |
| 692 | 698 | $value = esc_sql( $filter['value'] ); |
| 693 | 699 | $where[] = $this->wpdb->prepare( "scope = %s", $value ); |
| 694 | 700 | } |
| 695 | 701 | } |