Skip to content

Instantly share code, notes, and snippets.

View gregrickaby's full-sized avatar
:octocat:

Greg Rickaby gregrickaby

:octocat:
View GitHub Profile
@gregrickaby
gregrickaby / recent-post-widget.php
Last active August 29, 2015 14:06
Recent Post Widget
<?php
/*
Plugin Name: Recent Posts Widget
Plugin URI: http://gregrickaby.com
Description: Display recent posts in a widget area.
Version: 1.0.0
Author: Greg Rickaby
Author URI: http://gregrickaby.com
License: GPLv2
Text Domain: textdomain
@gregrickaby
gregrickaby / .htaccess
Created August 31, 2014 14:54
Lock down WordPress Dashboard login with .htaccess
# APACHE .HTACCESS
# This will deny all traffic (except yours) to /wp-admin (including wp-login.php)
# It will also return a 403 forbidden error.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.444$
RewriteRule ^(.*)$ - [R=403,L]
@gregrickaby
gregrickaby / functions.php
Created August 4, 2014 21:07
Auto check the "Open link in a new window/tab" checkbox in WordPress
<?php
// DO NOT INCLUDE THE OPENING PHP TAG AND INSERT INTO FUNCTIONS.PHP
add_action( 'admin_footer', 'custom_new_link_auto_check', 9999 );
/**
* Auto check the "Open link in a new window/tab" modal
*/
function custom_new_link_auto_check() { ?>
<script type="text/javascript">
@gregrickaby
gregrickaby / Custom_Walker_Nav_Menu.php
Created July 31, 2014 13:57
Add HTML Markup to WordPress Nav Menu Editor
<?php
/**
* Create HTML list of nav menu items.
*
* @since 3.0.0
* @uses Walker
*/
class Custom_Walker_Nav_Menu extends Walker_Nav_Menu {
/**
@gregrickaby
gregrickaby / functions.php
Created July 17, 2014 15:39
Prevent Wordpress from inserting an extra 10px of width to image caption shortcodes.
<?php
// DO NOT INCLUDE OPENING PHP TAG
add_filter( 'img_caption_shortcode', 'custom_remove_additional_10px_from_captions', 10, 3 );
/**
* Prevent Wordpress from inserting an extra 10px of width to image caption shortcodes.
*/
function custom_remove_additional_10px_from_captions( $val, $attr, $content = null ) {
extract( shortcode_atts( array(
@gregrickaby
gregrickaby / functions.php
Last active January 24, 2017 07:54
Customize the excerpt length, strip tags, append, and change the "Read More" text
<?php
// DO NOT INCLUDE OPENING PHP TAG
/**
* Customize the excerpt length and strip tags
*/
function custom_excerpt ( $text ) {
global $post;
@gregrickaby
gregrickaby / functions.php
Last active August 29, 2015 14:03
How to create an Author Box using the Gravatar API
<?php
// DO NOT INCLUDE OPENING PHP TAG AND PLACE INTO FUNCTIONS.PHP
/**
* Get Author's Gravatar profile data.
*/
function custom_get_gravatar_profile() {
// Get author data
$author = strtolower( trim( get_the_author_meta( 'email' ) ) );
@gregrickaby
gregrickaby / wp-config.php
Last active January 3, 2024 20:31
WordPress Debugging
<?php
// DO NOT INCLUDE THE OPENING PHP TAG
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
@gregrickaby
gregrickaby / social-icons-widget.php
Last active August 29, 2015 14:03
Social Icons Widget
<?php
/*
Plugin Name: Social Icons Widget
Description: A simple widget to display social icons from Font Awesome.
Version: 1.0.0
Author: Greg Rickaby
Author URI: http://gregrickaby.com
License: GPLv2
Text Domain: textdomain
*/
@gregrickaby
gregrickaby / wordpress-sample-content.txt
Last active August 10, 2016 20:35
Sample content for QA purposes. Just copy/paste into a post or page and hit "publish". Also, here is an Alfred Workflow: http://gregslink.co/1FFTova
<h1>This is an H1</h1>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tu vero, inquam, ducas licet, si sequetur; Haec et tu ita posuisti, et verba vestra sunt. Atque his de rebus et splendida est eorum et illustris oratio. Eam stabilem appellas. Nam Pyrrho, Aristo, Erillus iam diu abiecti. Illa sunt similia: hebes acies est cuipiam oculorum, corpore alius senescit; Est enim effectrix multarum et magnarum voluptatum. Duo Reges: constructio interrete.<!--more-->
Fortasse id optimum, sed ubi illud: Plus semper voluptatis? Nihil enim hoc differt. Hoc enim constituto in philosophia constituta sunt omnia. Dat enim intervalla et relaxat. Aliena dixit in physicis nec ea ipsa, quae tibi probarentur; Tecum optime, deinde etiam cum mediocri amico. Ait enim se, si uratur, Quam hoc suave! dicturum. Respondent extrema primis, media utrisque, omnia omnibus.
<h2>This is an H2</h2>
Ita multo sanguine profuso in laetitia et in victoria est mortuus. Quae duo sunt, unum facit. Expectoque quid ad id, quod quaerebam, re