Last active
December 14, 2017 02:28
-
-
Save spivurno/cfb2c76282fdc7c04e60 to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Exclude Forms from Form List
This file contains hidden or 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 | |
/** | |
* Gravity Wiz // Gravity Forms // Exclude Forms from Form List | |
* http://gravitywiz.com | |
*/ | |
add_filter( 'query', function( $query ) { | |
if( rgget( 'page' ) != 'gf_edit_forms' ) { | |
return $query; | |
} | |
if( strpos( $query, 'SELECT f.id, f.title, f.date_created, f.is_active, 0 as lead_count, 0 view_count' ) === 0 ) { | |
$search = 'ORDER BY'; | |
$replace = sprintf( "AND f.id NOT IN( %s )\nORDER BY", implode( ', ', range( 0, 870 ) ) ); | |
$query = str_replace( $search, $replace, $query ); | |
} | |
$form_table_name = GFFormsModel::get_form_table_name(); | |
$sql = "SELECT(SELECTcount(0)FROMwp_rg_formWHEREis_trash=0)astotal,(SELECTcount(0)FROMwp_rg_formWHEREis_active=1ANDis_trash=0)asactive,(SELECTcount(0)FROMwp_rg_formWHEREis_active=0ANDis_trash=0)asinactive,(SELECTcount(0)FROMwp_rg_formWHEREis_trash=1)astrash"; | |
if( strpos( preg_replace( '/\s+/', '', $query ), $sql ) === 0 ) { | |
$replace = sprintf( "\nAND id NOT IN( %s )", implode( ', ', range( 0, 870 ) ) ); | |
$searches = array( | |
'WHERE is_trash = 0', | |
'WHERE is_active=1 AND is_trash = 0', | |
'WHERE is_active=0 AND is_trash = 0', | |
'WHERE is_trash=1' | |
); | |
foreach( $searches as $search ) { | |
$query = str_replace( $search, $search . $replace, $query ); | |
} | |
} | |
return $query; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment