This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
class My_Widget extends WP_Widget { | |
function __construct() { | |
parent::__construct( | |
'my-widget', // Base ID | |
'My Widget', // Name | |
array( 'description' => 'My Widget description.' ) // Args | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function circlecube_comment_form( $args ) { | |
$args['class_submit'] = 'button'; // since WP 4.1 | |
return $args; | |
} | |
add_filter( 'comment_form_defaults', 'circlecube_comment_form' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function theme_enqueue_styles() { | |
$parent_style = 'parent-style'; | |
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); | |
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add custom fields query to WP REST API v2 | |
// https://1fix.io/blog/2015/07/20/query-vars-wp-api/ | |
function my_allow_meta_query( $valid_vars ) { | |
$valid_vars = array_merge( $valid_vars, array( 'meta_key', 'meta_value' ) ); | |
return $valid_vars; | |
} | |
add_filter( 'rest_query_vars', 'my_allow_meta_query' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* normalize takes a value within a given range | |
* and converts it to a number between 0 and 1 | |
* (actually it can be outside that range | |
* if the original value is outside its range). | |
* | |
* @param {*} value number to be normalized | |
* @param {*} minimum low end of range - mapped to 0 | |
* @param {*} maximum high end of range - mapped to 1 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Fun with functions | |
* | |
* Function exercieses from Douglas Crockford | |
* in his The Good Parts of JavaScript and the Web | |
* course on Frontendmasters | |
* https://frontendmasters.com/courses/good-parts-javascript-web/ | |
*/ | |
// function that takes two numbers and return their sum |