ellm
7/11/2018 - 2:19 PM

WordPress Development Notes

WordPress Development Notes Notes

WordPress Development

Translation

A BAD example of adding translation to a string w/ variables.

There is no need to translate HTML <a href="%1$s" rel="tag">%2$s</a>.

<?php
printf(
  __( '<a href="%1$s" rel="tag">%2$s</a>', 'text-domain' ),
  esc_url( wpcom_vip_get_term_link( $tag->term_id, $tag->taxonomy ) ),
  esc_html( $tag->name )
);
?>

An example of using sprintf for translating variables.

sprintf( __( '%1$s', 'text-domain' ), esc_html( $tag ) )

PHPCS and WordPress Coding Standards Setup

Install brew

Install composer

WordPress Coding Standards

Installation Guide

  • cd ~
  • composer create-project wp-coding-standards/wpcs --no-dev

Add to your .bash_profile or bash replacement (.zshrc)

  • export PATH="$PATH:$HOME/wpcs/vendor/bin"

Config phpcs

  • phpcs --config-set installed_paths ~/wpcs
  • phpcs --config-set default_standard WordPress-VIP

Gutenberg

Plugin Development

REST API Reesources

Plugins

Links

Community