Skip to content

Instantly share code, notes, and snippets.

View szbl's full-sized avatar

Sizeable, Inc. szbl

View GitHub Profile
@szbl
szbl / szbl-obfuscate-login.php
Last active December 15, 2015 18:49
Obfuscate WordPress login errors.
<?php
add_filter( 'login_errors', 'szbl_login_errors' );
function szbl_login_errors( $error )
{
return 'The information you entered was incorrect.';
}
@szbl
szbl / .htaccess
Created April 17, 2013 14:04
Lock down your /wp-admin/ directory with an .htpasswd file.
#
# Require a password
#
AuthName "Admin Login"
AuthUserFile /home/user/path/to/.htpasswd
AuthType basic
require valid-user
#
# Allow admin-ajax.php to work
@szbl
szbl / .htaccess
Created April 17, 2013 14:06
Stop direct PHP execution via URL in directories like /wp-content/uploads/, certain plugins, etc.
<Files *.php>
deny from all
</Files>
<!doctype html>
<html>
<head>
<!-- meta and such -->
<title>Most important keywords/title content.</title>
</head>
<body>
<nav id="top">
<ul>
<!doctype html>
<html>
<head>
<title>Source Ordering with jQuery</title>
<style type="text/css">
body { font: 14px HelveticaNeue,Helvetica,Arial,Sans-serif; color: #666; text-align: center; }
.wrap { margin: 0 auto; width: 980px; text-align: left; }
#sidebar { float: right; width: 300px;}
#content { width: 650px; }
<nav>
<ul>
<li>
<a href="services.html">Services</a>
<ul>
<li><a href="#">Sub-page A</a></li>
<li>
<a href="#">Sub-page B</a>
<ul>
<li><a href="#">Sub-page i</a></li>
@szbl
szbl / wp-singleton-namespace-example.php
Last active December 21, 2018 05:56
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 ) )
@szbl
szbl / szbl-person-plugin.php
Last active December 19, 2015 08:19
Example of a plugin extending the Sizeable_Person object.
<?php
/*
Plugin Name: Extend Sizeable Person
Description: Adds post thumbnails, excerpts and page attributes to People post type. Also, sets URL slug to /people/ instead of /szbl-person/
Author: theandystratton
Version: 1.0
License: GPL2+
*/
add_filter( 'szbl_people-post_type_args', 'szbl_people_filter_post_type_args' );
function szbl_people_filter_post_type_args( $args )
@szbl
szbl / my-plugin-snippet.php
Last active March 15, 2022 04:17
How I auto-include my library of "controllers" in a theme/plugin.
<?php
// include all PHP files in ./lib/ directory:
foreach ( glob( dirname( __FILE__ ) . '/lib/*.php' ) as $file )
include $file;
@szbl
szbl / add-meta.php
Last active December 19, 2015 08:19
Example of an auto-included plugin "controller" script.
<?php
if ( class_exists( 'Sizeable_Person' ) ) :
add_action( 'add_meta_boxes', 'szbl_mvc_example_add_meta_boxes' );
function szbl_mvc_example_add_meta_boxes()
{
add_meta_box( 'szbl-mvc-person-meta', 'Additional Information', 'szbl_mvc_example_meta_output', Sizeable_Person::POST_TYPE_SLUG, 'normal', 'high' );
}