Skip to content

Instantly share code, notes, and snippets.

Avatar

Denis Žoljom dingo-d

View GitHub Profile
@dingo-d
dingo-d / ajax.js
Created Apr 17, 2020
Download users from WordPress admin
View ajax.js
export const ajaxFetch = (options, resolve, reject) => $.ajax(options)
.done(resolve)
.fail(reject);
@dingo-d
dingo-d / PHP Class
Last active Aug 5, 2020
PHPStorm PHP class file templates (class, trait and interfaces). To modify go to Settings > Editor > File and Code Templates
View PHP Class
<?php
/**
* File holding ${NAME} class
*
#if (${NAMESPACE}) * @package ${NAMESPACE}
#end
* @since
*/
@dingo-d
dingo-d / extract-versions.sh
Created Apr 7, 2020
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
View extract-versions.sh
for package in $(ls -1); do echo $package; jq -r .version $package/package.json; done
@dingo-d
dingo-d / phpcs-results.txt
Created Feb 16, 2020
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
View phpcs-results.txt
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'·),
View test-api-doc-response.php
<?php
/**
* Class Api_Docs_Page
*
* @package My_Plugin\Routes\Endpoints
*/
namespace My_Plugin\Tests\Routes\Endpoints;
use WP_REST_Request;
View wpgraphql-after-phpcbf.txt
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
----------------------------------------------------------------------
View docker-compose.yaml
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 Jul 8, 2019
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.
View composer.json
{
"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",
View pointers.js
/* global pointerLocalization */
export default class Pointers {
constructor() {
this.pointersList = {};
this.openedPointers = JSON.parse(localStorage.getItem('openedPointers')) || [];
this.openPointer = this.openPointer.bind(this);
this.setLabel = this.setLabel.bind(this);
this.initPointers = this.initPointers.bind(this);
}
@dingo-d
dingo-d / pointer-init.js
Created Dec 13, 2018
Init file for the pointers. Pointers script is located here: https://gist.github.com/dingo-d/a83092146c1660383cb5c3483d71cdab
View pointer-init.js
/* global pointerLocalization */
import Pointers from './pointers';
$(function() {
const pointers = new Pointers();
// Filter the current context pointers
const pointersInContext = Object.values(pointerLocalization.pointers)
.filter((pointer) => pointer.context === pointerLocalization.currentScreen);