Skip to content

Instantly share code, notes, and snippets.

View szbl's full-sized avatar

Sizeable, Inc. szbl

View GitHub Profile
@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>
@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 / wp-reverse-comments.php
Created January 31, 2013 01:31
One line of code that will allow you to reverse the order of comment output from ascending to descending post date.
<?php
// you can do this in your functions.php file, a plugin file
// or even in your theme before comments are displayed:
add_filter( 'comments_array', 'array_reverse' );
?>
@szbl
szbl / wp-alt-text.php
Last active January 4, 2019 17:21
Get WP Attachment Image Alternate Text (alt text attribute)
<?php
echo esc_attr( get_post_meta( $att_id, '_wp_attachment_image_alt', true ) );
@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 / permissions.sh
Last active July 22, 2018 20:42
Liquid Web / Storm Permissions
# for directories
find . -type d -exec chmod 755 {} \;
# for files
find . -type f -exec chmod 644 {} \;
{
"legend": {
"title": "Primary Care (PCMH) Sites",
"labels": ["1-20 Sites", "21-60 Sites", "61-200 Sites", "201+ Sites"],
"ranges": [
{
"min": 1,
"max": 20,
"color": "#9ecae1"
},
<?php
/*
Plugin Name: Sizeable Whitelist Login
Author: Sizeable Interactive
Author URI: https://www.sizeableinteractive.com
Version: 0.1
Description: Server agnostic plugin to white list WordPress login screen to IP addresses using a self-authenticating secret URL.
**** NOTE ***
You must define the SZBL_SECRET_LOGIN_URL or set a login URL in the settings page for this plugin to take affect.
@szbl
szbl / login-restart.sh
Created May 30, 2018 19:06
Restart CentOS login daemon after updates - SSH hangs
systemctl restart systemd-logind
// psuedo-code
{
"query" : "some event",
"results" :
"events" : [
{
"event_name": "Some Event Name 123",
"event_id" : 123
},
{