Created
March 10, 2023 04:07
-
-
Save codearachnid/f0f8671c62a9ce5a1bee62926e28e848 to your computer and use it in GitHub Desktop.
Improve the Ninja Tables admin experience by hooking into `ninja_table_raw_sql_placeholders` filter to add additional placeholders while in admin to allow queries to run in psuedo-mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* hook into `ninja_table_raw_sql_placeholders` filter to add additional placeholders | |
* while in admin to allow queries to run in psuedo-mode | |
* @param array $filter | |
*/ | |
add_filter('ninja_table_raw_sql_placeholders', function($filter){ | |
if( is_admin() ){ | |
/** | |
* these should already be set passing into this filter | |
{current_user_id} | |
{current_date} | |
{current_date_time} | |
{prefix} | |
**/ | |
$filter['{current_post_id}'] = 1; | |
$filter['{current_post_title}'] = 'Hello World!'; | |
} | |
return $filter; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment