Skip to content

Instantly share code, notes, and snippets.

View dingo-d's full-sized avatar
🏠
Working from home

Denis Žoljom dingo-d

🏠
Working from home
View GitHub Profile
@dingo-d
dingo-d / renameTests.php
Created May 25, 2020 12:24
Append Test to test file name script
#!/usr/bin/env php
<?php
function getDirs( $currentDir ) {
return array_filter( $currentDir, function ( $dir ) {
return is_dir( $dir ) && $dir !== '..' && $dir !== '.';
} );
}
@dingo-d
dingo-d / rename.php
Last active May 25, 2020 12:22
Simple php script to rename folder names to PascalCase from split-name. Doesn't go recursively in subfolders.
#!/usr/bin/env php
<?php
function getDirs( $currentDir ) {
return array_filter( $currentDir, function ( $dir ) {
return is_dir( $dir ) && $dir !== '..' && $dir !== '.';
} );
}
@dingo-d
dingo-d / ajax.js
Created April 17, 2020 14:50
Download users from WordPress admin
export const ajaxFetch = (options, resolve, reject) => $.ajax(options)
.done(resolve)
.fail(reject);
@dingo-d
dingo-d / PHP Class
Last active August 5, 2020 07:56
PHPStorm PHP class file templates (class, trait and interfaces). To modify go to Settings > Editor > File and Code Templates
<?php
/**
* File holding ${NAME} class
*
#if (${NAMESPACE}) * @package ${NAMESPACE}
#end
* @since
*/
@dingo-d
dingo-d / extract-versions.sh
Created April 7, 2020 12:01
A simple shell command script to extract packages and their versions from Gutenberg WP editor. Once in the 'packages' directory you can run this script
for package in $(ls -1); do echo $package; jq -r .version $package/package.json; done
@dingo-d
dingo-d / phpcs-results.txt
Created February 16, 2020 17:07
The result of vendor/bin/phpcs --sniffs=WordPress.WP.i18n ../WordPress-Themes/themes/ --report-file=../phpcs-result.txt --error-severity=0 --extensions=php --report=code
FILE: mnt/d/WordPress-Themes/themes/lightning/comments.php
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LINE 28: WARNING Mismatched placeholders is probably an error (WordPress.WP.I18n.MismatchedPlaceholders)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
26: » » <h2·class="comments-title">
27: » <?php
>> 28: » printf(·_nx(·'One·thought·on·&ldquo;%2$s&rdquo;',·'%1$s·thoughts·on·&ldquo;%2$s&rdquo;',·get_comments_number(),·'comments·title',·'lightning'·),
@dingo-d
dingo-d / test-api-doc-response.php
Created January 3, 2020 09:54
A test for API response
<?php
/**
* Class Api_Docs_Page
*
* @package My_Plugin\Routes\Endpoints
*/
namespace My_Plugin\Tests\Routes\Endpoints;
use WP_REST_Request;
FILE: ...wp-graphql/src/Connection/Themes.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
1 | ERROR | Missing file doc comment
| | (Squiz.Commenting.FileComment.Missing)
----------------------------------------------------------------------
FILE: ...wp-graphql/src/Connection/Comments.php
----------------------------------------------------------------------
version: '3.3'
services:
app:
image: wordpress:5.2.0-php7.2-fpm
container_name: wptest-app
depends_on:
- db
- redis
@dingo-d
dingo-d / composer.json
Created July 8, 2019 08:26
PHPCS Security scan (for WordPress). This setup can check your project for some possible security issues. It will also check it against the PHPCompatibility standard, WPCS-Extra standard (includes Core), and uses a security audit standard from Pheromone.
{
"require-dev": {
"pheromone/phpcs-security-audit": "^2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"roave/security-advisories": "dev-master",
"phpcompatibility/php-compatibility": "^9.2",
"wp-coding-standards/wpcs": "^2.1"
},
"scripts": {
"phpcs-i": "@php vendor/bin/phpcs -i",