Skip to content

Instantly share code, notes, and snippets.

View ahmadawais's full-sized avatar
Building the easiest way for developers to build AI products BaseAI.dev

Ahmad Awais ⌘ ahmadawais

Building the easiest way for developers to build AI products BaseAI.dev
View GitHub Profile
@ahmadawais
ahmadawais / github-brand-colors-aug-2015.css
Created June 28, 2016 03:06 — forked from christopheranderton/github-brand-colors-aug-2015.css
Official Github Brand Colors (August 20, 2015) from the GitHub internal CSS framework (Primer) version 2.3.3 at: http://primercss.io/colors/
/* # OFFICIAL GITHUB BRAND COLORS
--------------------------------------------------------------------
Official Github Brand Colors (August 20, 2015) from the
GitHub internal CSS framework (Primer) version 2.3.3
Source URI: http://primercss.io/colors/
1.a = Github Branding Color Swatches
-------------------------------------------------------------------- */
.swatch-github-blue {
background-color:#4078c0;
@ahmadawais
ahmadawais / filters-in-the-wp-rest-api-v2
Created June 27, 2016 14:56 — forked from BraadMartin/filters-in-the-wp-rest-api-v2
A list of all of the filters available in the WP REST API v2
rest_avatar_sizes
rest_prepare_attachment
rest_pre_insert_comment
rest_comment_type_trashable
comment_text
@ahmadawais
ahmadawais / like-actions.js
Created June 8, 2016 15:45 — forked from lukecav/like-actions.js
Simple Likes
jQuery( document ).ready( function ( $ ) {
$( document ).on( 'click', '.simple-like-btn', function( e ) {
e.preventDefault();
var like = {
'action' : $( this ).data( 'action' ),
'pid' : $( this ).data( 'pid' )
}
var likebtn = this;
$.post( ajax_object.ajax_url, like ).done( function( response ) {
response = JSON.parse( response );
@ahmadawais
ahmadawais / customize-validate-entitled-settings.js
Last active May 11, 2016 13:49 — forked from westonruter/customize-validate-entitled-settings.js
Notify on Save only! Plugin demonstration of Customize Setting Validation: validates Customizer settings that contain titles to ensure they are not empty, and then blocks saving the Customizer until they are populated. See https://github.com/xwp/wp-customize-setting-validation
/* global wp, _customizeValidateEntitledSettingsExports */
/* exported customizeValidateEntitledSettings */
var customizeValidateEntitledSettings = ( function( $, api, exports ) {
var self = {
l10n: {
invalid_value: ''
}
};
@ahmadawais
ahmadawais / customizer.php
Last active May 10, 2016 15:17 — forked from grappler/customizer.php
Theme Check Customizer Issue File and Setting Name https://github.com/Otto42/theme-check/issues/155
<?php
/**
* Checks for the Customizer.
*/
class CustomizerCheck implements themecheck {
protected $error = array();
function check( $php_files, $css_files, $other_files) {
@ahmadawais
ahmadawais / wp-i18n-cheatsheet.md
Created May 7, 2016 09:49 — forked from bueltge/wp-i18n-cheatsheet.md
WordPress i18n Cheatsheet

WordPress i18n CheatSheet

Whenever I write plugins or themes, there is one thing that needs a little extra attention and is quite frankly hard to get right: Translatable text. This list should helps me to find the right way fast.

Props to Alex Kirk, there list it inside a quiz.

You want to output the username in a sentence.

Assume that the $username has been escaped using esc_html().

Regular Expression Cheat Sheet - PCRE

Kudos/Source: https://github.com/niklongstone/regular-expression-cheat-sheet

Anchor Description Example Valid match Invalid
^ start of string or line ^foam foam bath foam
\A start of string in any match mode \Afoam foam bath foam
$ end of string or line finish$ finish finnish
\Z end of string, or char before last new line in any match mode finish\Z finish finnish
@ahmadawais
ahmadawais / register-post-type.php
Created May 7, 2016 09:47 — forked from justintadlock/register-post-type.php
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@ahmadawais
ahmadawais / wp-singleton-namespace-example.php
Created March 4, 2016 16:17 — forked from szbl/wp-singleton-namespace-example.php
Quick Singleton class to be included in WordPress plugin (or theme functions.php file) that will create a simple Person post type and shows some methods of encapsulating functionality in a class as a "namespace," as well as applying filters to things, allowing other users to extend your code.
<?php
class Sizeable_Person
{
const POST_TYPE_SLUG = 'szbl-person';
public static $instance;
public static function init()
{
if ( is_null( self::$instance ) )
@ahmadawais
ahmadawais / gist:4715b693d0432b09a9f6
Created February 21, 2016 16:56 — forked from thegdshop/gist:3171026
WooCommerce - Add checkbox field to the checkout
<?php
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my-new-field"><h3>'.__('My Checkbox: ').'</h3>';