Have something to say?

Tell us how we could make the product more useful to you.

Backslashes are stripped from snippet content when pulling from a GitHub-synced repo.

Concrete example from my own snippet: Before (GitHub source): $routes = ["/wp/v2/users", "/wp/v2/users/(?P [\d]+)"]; After (pulled into SnipVault / deployed): $routes = ["/wp/v2/users", "/wp/v2/users/(?P [d]+)"]; The \d became d — the backslash was silently dropped, breaking the regex. Steps to reproduce: Push a snippet containing a literal backslash (e.g. a regex like \d) to the linked GitHub repo. Pull that snippet into SnipVault. Compare: the GitHub source still has \d, but the pulled/deployed snippet now has d — the backslash is gone. Impact: Any snippet content containing backslash escapes (regex patterns, \n, Windows paths, etc.) is silently corrupted on pull, with no error or warning. In my case this broke a regex-based permission check that was meant to restrict access to a REST API endpoint — it deployed "successfully" but the protection silently didn't work, and there was no indication anything was wrong. Suspected cause: Looks like stripslashes() (or wp_unslash()) is being applied somewhere in the GitHub pull path — its documented behavior is exactly this: \d → d, backslash dropped whenever it precedes a character with no special meaning. Thank you.

pearlknowledge about 21 hours ago

💡

Feature Request

Completed

Bug report: false positive "function already exists" for class methods

Hello team. I’d like to report a potential bug I recently found as below. SnipVault's pre-save validation reports a function-name collision and disables the snippet when a class method happens to share its name with an existing global function. In my case a PHP class containing a get_categories() method is rejected with an error along the lines of function get_categories already exists, because WordPress core defines a global get_categories() in wp-includes/category.php. The snippet does not declare any function at global scope. get_categories appears only as a method inside a class body, so there is no actual conflict — PHP resolves class methods in the class scope, entirely separate from the global function namespace. The validation appears to match function declarations textually rather than by parsing the code, so it cannot distinguish a method declaration from a global function declaration. Environment Please fill in before sending: SnipVault version: 1.3.2 WordPress version: 7.1 PHP version: 8.2 Steps to reproduce Create a new PHP snippet. Paste the following (6 lines, no global functions declared): Save the snippet. Expected: the snippet saves and runs. SnipVault_Repro::get_categories() does not conflict with the global get_categories() and PHP loads it without error. Actual: validation reports that get_categories already exists and the snippet is disabled / blocked from running. Substituting any other method name that matches a core function reproduces the same result — get_option, get_posts, get_terms, get_users, get_comments are all extremely common method names in ordinary WordPress class design. Why this matters beyond my snippet This blocks a whole category of legitimate code rather than one unlucky name. Elementor custom widgets cannot be written at all. Elementor's widget API requires subclasses of \Elementor\Widget_Base to implement get_categories() — it is how a widget declares which panel category it belongs to. Every custom Elementor widget therefore contains a method with that exact name, so every one of them trips this check. Given Elementor's install base, this is likely to affect a meaningful number of users, and the failure mode is confusing: the error names a function the user never wrote at global scope. Ordinary class-based snippets are affected too. A settings class with a get_option() method, a query helper with get_posts(), a taxonomy helper with get_terms() — all are idiomatic PHP and all would be rejected. Suggested fix Replace textual matching with token-based analysis. PHP's built-in token_get_all() is sufficient and needs no dependencies. The rule is: a T_FUNCTION token declares a global function only when it appears at brace depth zero and is not inside a class / interface / trait / enum body. Sketch: function snipvault_find_global_functions( $code ) { $tokens = token_get_all( $code ); $names = []; $depth = 0; // current brace nesting depth $scopes = []; // brace depth at which each class-like body started foreach ( $tokens as $i => $token ) { if ( is_array( $token ) ) { // Entering a class-like body: remember its

pearlknowledge 14 days ago

💡

Feature Request