Created
March 29, 2024 20:12
-
-
Save daveromsey/4159f64b461912aa59699cf11815d686 to your computer and use it in GitHub Desktop.
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
{ | |
// Place your snippets for php here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", | |
// "$2" | |
// ], | |
// "description": "Log output to console" | |
// } | |
"Log var_export()": { | |
"prefix": "logv", | |
"body": ["error_log( '$1 ' . var_export( $2, true ) );"], | |
"description": "Do a var_export( $variable ) to PHP error log." | |
}, | |
"Exit with var_dump()": { | |
"prefix": "xvd", | |
"body": ["exit( var_dump( $0 ) );"], | |
"description": "Exit with var_dump()" | |
}, | |
"Exit with print_r()": { | |
"prefix": "xpr", | |
"body": ["exit( print_r( $0 ) );"], | |
"description": "Exit with print_r()" | |
}, | |
"Log print_r()": { | |
"prefix": "logp", | |
"body": ["error_log( print_r( $0, true ) );"], | |
"description": "Do a print_r( $variable ) to PHP error log." | |
}, | |
"Detailed Error Log": { | |
"prefix": "logd", | |
"body": [ | |
"error_log( print_r( (object)", | |
"\t[", | |
"\t\t'line' => __LINE__,", | |
"\t\t'file' => __FILE__,", | |
"\t\t'dump' => [", | |
"\t\t\t$0,", | |
"\t\t],", | |
"\t], true ) );" | |
], | |
"description": "Detailed error logging" | |
}, | |
"Log gettype()": { | |
"prefix": "logt", | |
"body": ["error_log( gettype( $0 ) );"], | |
"description": "Do a gettype( $variable ) to PHP error log." | |
}, | |
"PHPCS Fix Escape Output": { | |
"prefix": "phpcseo", | |
"body": ["// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped"], | |
"description": "Ignore PHPCS Escape output error" | |
}, | |
"__()": { | |
"prefix": "__(", | |
"body": ["__( '$0', '' )"], | |
"description": "Basic translatable string." | |
}, | |
"Debug Filters": { | |
"prefix": "logf", | |
"body": ["add_action( 'all', function() { error_log( var_export( current_filter(), true ) ); } );"], | |
"description": "Logs current filter." | |
}, | |
"if …": { | |
"prefix": "if", | |
"body": [ | |
"if ( ${1:condition} ) {", | |
"\t${0:# code...}", | |
"}" | |
], | |
"description": "If block" | |
}, | |
"foreach …": { | |
"prefix": "foreach", | |
"body": [ | |
"foreach ( $${1:variable} as $${2:key} ${3:=> $${4:value}} ) {", | |
"\t${0:# code...}", | |
"}" | |
], | |
"description": "Foreach loop" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solid!