PhpStorm now bundles WordPress coding style natively, starting from version 8.
- Go to
Project Settings>Code Style>PHP. - Select
Set From...(top right of window) >Predefined Style>WordPress.
No longer need to muck with this import! :)
| <?php | |
| /* | |
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| <?php # -*- coding: utf-8 -*- | |
| /** | |
| * Plugin Name: Plugin Class Demo | |
| * Description: How I am using the base class in plugins. | |
| * Plugin URI: | |
| * Version: 2012.09.29 | |
| * Author: Fuxia Scholz | |
| * License: GPL | |
| * Text Domain: plugin_unique_name | |
| * Domain Path: /languages |
| <?php | |
| if ( ! class_exists( 'Autoload_WP' ) ) { | |
| /** | |
| * Generic autoloader for classes named in WordPress coding style. | |
| */ | |
| class Autoload_WP { | |
| public $dir = __DIR__; |
This is simple approach to work-around the missing --global option in Composer. See composer/composer#55
It reads the dependencies from a local composer.json file and installs them
into a global location (e.g. /usr/local/lib/composer) and creates a light-weight
local Composer installation providing the necessary autoload magic.
| <?php | |
| // Reduced to the minimum | |
| class ThumbnailFilter extends FilterIterator | |
| { | |
| private $wp_query; | |
| public function __construct( Iterator $iterator, WP_Query $wp_query ) | |
| { | |
| NULL === $this->wp_query AND $this->wp_query = $wp_query; | |
| parent::__construct( $iterator ); |
This is an example of how to scaffold API endpoints to list / get / create / update / delete Posts in a Keystone website.
It's a modification of the default project created with the yo keystone generator (see https://github.com/JedWatson/generator-keystone)
Gists don't let you specify full paths, so in the project structure the files would be:
routes-index.js --> /routes/index.js // modified to add the api endpoints
routes-api-posts.js --> /routes/api/posts.js // new file containing the Post API route controllers
To implement API authentication in KeystoneJS, you need the following:
For key based authentication
For session based authentication
| <?php | |
| add_filter('gettext',fn($t)=> | |
| @$t[4]&&@$GLOBALS['wp_locale'] | |
| ?["Such $t","Very $t",'Wow'][rand(0,2)] | |
| :$t); |
| <?php namespace GM; | |
| /** | |
| * Angie. Very simple, and quite powerful, plain PHP template engine. | |
| * | |
| * @author Giuseppe Mazzapica <[email protected]> | |
| * @license http://opensource.org/licenses/MIT MIT | |
| */ | |
| class Angie | |
| { |