Skip to content

Instantly share code, notes, and snippets.

@codearachnid
Created March 10, 2023 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codearachnid/f0f8671c62a9ce5a1bee62926e28e848 to your computer and use it in GitHub Desktop.
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.
<?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