Skip to content

Instantly share code, notes, and snippets.

@trepmal
trepmal / gist:1c66dbe97e8f322bc107
Created December 19, 2014 22:42
wp-cli: reset all user passwords
#!/bin/bash
for uid in $(wp user list --field=ID)
do
pass=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32}`
wp user update $uid --user_pass="$pass"
done
# For SCSS-Lint v0.31.0
linters:
BangFormat:
enabled: true
space_before_bang: true
space_after_bang: false
BorderZero:
@norcross
norcross / yoast-ga-menu-move.php
Last active August 29, 2015 14:06
move Yoast Google Analytics top-level nav to a sub menu
/**
* move the main settings page for Yoast Google Analytics
* from it's own parent menu into a submenu page in either
* the Yoast SEO menu or in the general settings
*
* @return null
*/
function rkv_yoast_ga_menu() {
// check for the Yoast GA class in the event the plugin
@Shelob9
Shelob9 / mini-rest-api-get-client.php
Created August 25, 2014 02:08
Example code, packaged as a plugin for my Torque article on getting posts via GET requests using the WordPress REST API. http://torquemag.io/?p=72403
<?php
/*
Plugin Name: JP Mini REST API GET Client
Plugin URI: http://torquemag.io/?p=72403
Description: A min client for making GET requests via the WordPress REST API.
Version: 0.1.1
Author: Josh Pollock
Author URI: http://JoshPress.net
License: GPL v2 or later
*/
@tddewey
tddewey / _mixin-optical-center.scss
Created August 20, 2014 18:44
Optical Centering Mixin
// optical-center
//
// Provide this mixin a padding value that you might normally apply equally to
// top and bottom padding on an element (e.g. so its contents are centered).
//
// It will, instead, give a bit more padding to the bottom and a bit less to the top so
// the element appears optically centered and takes up the same amount of room.
//
// The amount of padding that goes to the bottom vs the top is controlled by a second
// $ratio parameter that defaults to 1.3
<?php
/**
* Dont Update the Theme
*
* If there is a theme in the repo with the same name, this prevents WP from prompting an update.
*
* @since 1.0.0
* @param array $r Existing request arguments
* @param string $url Request URL
* @return array Amended request arguments
@georgiecel
georgiecel / wp-comment-callback
Created March 9, 2014 09:09
Custom callback for HTML5 friendly WordPress comment. Also includes schema.org microdata. To use, insert the following into comments.php: <?php wp_list_comments('callback=better_comment&end-callback=better_comment_close'); ?>
// awesome semantic comment
function better_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'article' == $args['style'] ) {
$tag = 'article';
$add_below = 'comment';
} else {
<?php
/**
* Plugin Name: Static Templates
*
* If most of your site content is in .php template files, and you're tired of
* creating new pages, assigning them page templates, creating page templates
* then doing it all over again on production, this plugin is for you.
*
* Examples:
*
@gitaarik
gitaarik / git_submodules.md
Last active May 4, 2024 11:10
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@gmazzap
gmazzap / CptInMainQueryByMeta.php
Created January 10, 2014 14:42
Simlpe plugin coded to refactor the code posted on a WPSE anwser
<?php
/**
* Plugin Name: Cpt In Main Query By Meta
* Plugin URI: http://wordpress.stackexchange.com/questions/129236/
* Description: Allow mixing a post type with another on main query, only if the second match some meta query args
* Author: Giuseppe Mazzapica
* Author URI: http://wordpress.stackexchange.com/users/35541/g-m
*/