Skip to content

Instantly share code, notes, and snippets.

View Richzendy's full-sized avatar
🎯
Focusing

Edwind Contreras Richzendy

🎯
Focusing
View GitHub Profile
@Skatox
Skatox / class-my-class.php
Created August 23, 2017 14:07
A WordPress plugin class
<?php
/**
* Class description
*
* @package Plugin name
*/
/**
* Class My_Class
*
@Richzendy
Richzendy / Add CSS class to children menu item on WordPress
Created August 27, 2014 23:59
Add CSS class to children menu item on WordPress
// Add CSS class to children menu item on WordPress
add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );
function add_menu_parent_class( $items ) {
foreach ( $items as $item ) {
if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
$item->classes[] = 'menu-children-item';
}
}
@dsebao
dsebao / functions.php
Last active February 26, 2021 15:00
Create OptGroups for select dropdown (categories) in WordPress using selectize plugin
<?php
class Top_level_Optgroup extends Walker_CategoryDropdown {
var $optgroup = false;
function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
$pad = str_repeat('&nbsp;', $depth * 3);
@danriti
danriti / hipchat-v2.sh
Last active July 19, 2021 10:49
HipChat API v2 - Send a message to a room using cURL
#!/bin/bash
# Set the ROOM_ID & AUTH_TOKEN variables below.
# Further instructions at https://www.hipchat.com/docs/apiv2/auth
ROOM_ID=XXX
AUTH_TOKEN=XXX
MESSAGE="Hello world!"
curl -H "Content-Type: application/json" \
@thomseddon
thomseddon / gist:3511330
Last active March 8, 2023 03:39
AngularJS byte format filter
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});