Skip to content

Commit

Permalink
Fix consistency + new debug options
Browse files Browse the repository at this point in the history
  • Loading branch information
bahiirwa committed Jan 29, 2023
1 parent b68cdd5 commit 513b991
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

### [0.5.2]
- Fix: Add consistency in the child theme snippets.
- Add: New snippets for JS logs.
- Add: Snippets for detailed error logs

### [0.5.1]
- Fix: Folder structure.
- Fix: Better Documentation flow and links.
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"bugs": {
"url": "https://github.com/bahiirwa/classicpress-snippets/issues"
},
"version": "0.5.1",
"version": "0.5.2",
"engines": {
"vscode": "^1.18.0"
},
Expand All @@ -39,6 +39,10 @@
"language": "css",
"path": "./snippets/css/theme.json"
},
{
"language": "javascript",
"path": "./snippets/php/general.json"
},
{
"language": "php",
"path": "./snippets/php/general.json"
Expand Down
4 changes: 2 additions & 2 deletions snippets/css/theme.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme_start": {
"start_theme": {
"prefix": "start_theme",
"body": [
"/**",
Expand All @@ -21,7 +21,7 @@
],
"description": "Theme start up details bootstrap"
},
"child_theme_start": {
"start_theme_child": {
"prefix": "start_theme_child",
"body": [
"/**",
Expand Down
9 changes: 9 additions & 0 deletions snippets/js/general.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"clog": {
"prefix": "clog",
"body": [
"console.log( ${1:variable} )"
],
"description": "Log the variable in browser console."
}
}
34 changes: 33 additions & 1 deletion snippets/php/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,40 @@
"print_error_log": {
"prefix": "print_error_log",
"body": [
"error_log( print_r( ${1:\\$log}, true ) );"
"error_log( print_r( ${1:$log}, true ) );"
],
"description": "Log PHP errors in the debug.php file."
},
"dd": {
"prefix": "dd",
"body": [
"// @param string $message Error needed for print",
"// @param string $pre Context text string for where logging happens / expected data should be",
"dd( ${1:$message}, ${2:$pre} );"
],
"description": "Uses clog_detailed in helpers to Log PHP errors with context in the debug.php file."
},
"clog_detailed": {
"prefix": "clog_detailed",
"body": [
"/**",
"* @param mixed $message Error needed for print",
"* @param string $pre Context text string for where logging happens / expected data should be",
"* @return void",
"*/",
"function dd( ${1:$message}, $pre = '' ) {",
"if ( true === WP_DEBUG && ! defined( 'DOING_CRON' ) && ! defined( 'DOING_AJAX' ) ) {",
"if ( $pre ) {",
"error_log( $pre );",
"}",
"if ( is_array( ${1:$message} ) || is_object( ${1:$message} ) ) {",
"error_log( print_r( ${1:$message}, true ) );",
"} else {",
"error_log( ${1:$message} );",
"}",
"}",
"}"
],
"description": "Log PHP errors with context in the debug.php file."
}
}

0 comments on commit 513b991

Please sign in to comment.