Skip to content

Instantly share code, notes, and snippets.

View cdsalmons's full-sized avatar

Dustin Salmons cdsalmons

View GitHub Profile
#!/usr/bin/perl
use cPanel::PublicAPI;
use Getopt::Long;
&Getopt::Long::config('bundling');
# Options args
my $conf = GetOptions(
"H|hostname=s" => \$conf_host,
"P|port=i" => \$conf_port,
@cdsalmons
cdsalmons / override_plugin_stylesheet.php
Last active August 29, 2015 14:25 — forked from strangerstudios/override_plugin_stylesheet.php
Look for a stylesheet in a WP child theme or theme before loading a default plugin stylesheet.
//figure out which css to load
if(file_exists(get_stylesheet_directory() . "/pluginname/frontend.css"))
$css_url = get_stylesheet_directory_uri() . "/pluginname/frontend.css";
elseif(file_exists(get_template_directory() . "/pluginname/frontend.css"))
$css_url = get_template_directory_uri() . "/pluginname/frontend.css";
else
$css_url = plugins_url('css/frontend.css',dirname(__FILE__) );
//load it
wp_enqueue_style('pluginname-frontend', $css_url);
@cdsalmons
cdsalmons / GhettoPress.php
Last active August 29, 2015 14:26 — forked from wycks/GhettoPress.php
WordPress Ghetto Loader - stop doing this, you
<?php
//Load WorsPress quick and dirty into something not WordPress. This is horrible I know,
//But the database queries they are so low, and it's just so dirty
//install WordPress in a dir like /lib or something and stick classPageLoader.php in there, ha!
//Example use for a index.php or whatever, no autoloading here!
#######################################################
require('lib/classPageLoader.php');
$content = new LoadWpContent();
WordPress block botnet brute force with Mod_security
SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000134
<Locationmatch "/wp-login.php">
# Setup brute force detection.
# React if block flag has been set.
SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000135,msg:'ip address blocked for 5 minutes, more than 10 login attempts in 3 minutes.'"
# Setup Tracking. On a successful login, a 302 redirect is performed, a 200 indicates login failed.
SecRule RESPONSE_STATUS "^302" "phase:5,t:none,nolog,pass,setvar:ip.bf_counter=0,id:5000136"
SecRule RESPONSE_STATUS "^200" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000137"
@cdsalmons
cdsalmons / image_optimize-wordpress.php
Last active August 29, 2015 14:26 — forked from wycks/image_optimize-wordpress.php
Remove WordPress full size images from being inserted into a post + option to and add max size to to prevent users from inserting massive images.
<?php
/**
*
* This removes the ability to add the FULL image size into a post, it does not alter or delete the image
* Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
*
* For now we have to do it this way to make the labels translatable, see trac ref below.
*
* If your theme has $content_width GLOBAL make sure and remove it
@cdsalmons
cdsalmons / htaccess cache and stuff
Last active August 29, 2015 14:26 — forked from wycks/htaccess cache and stuff
Boilerplate .htaccess from Paul Irish with WordPress added
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@cdsalmons
cdsalmons / gist:1884ff877b6d831a5e66
Last active August 29, 2015 14:26 — forked from wycks/gist:2377285
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@cdsalmons
cdsalmons / wp-config.php
Last active August 29, 2015 14:26 — forked from wycks/wp-config.php
Multi Environment wp-config.php
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
@cdsalmons
cdsalmons / gist:c7f0f9ef5e68506a374d
Last active August 29, 2015 14:26 — forked from wycks/gist:2315279
Relative URLs in WordPress (hide wordpress)
<?php
function roots_root_relative_url($input) {
$output = preg_replace_callback(
'!(https?://[^/|"]+)([^"]+)?!',
create_function(
'$matches',
// if full URL is site_url, return a slash for relative root
'if (isset($matches[0]) && $matches[0] === site_url()) { return "/";' .
// if domain is equal to site_url, then make URL relative
@cdsalmons
cdsalmons / gist:43abb8284e2a010b56b6
Last active August 29, 2015 14:26 — forked from wycks/gist:2315295
Rewrite static theme assets and plugins directory (WordPress)
<?php
// rewrite /wp-content/themes/theme-name/css/ to /css/
// rewrite /wp-content/themes/theme-name/js/ to /js/
// rewrite /wp-content/themes/theme-name/img/ to /img/
// rewrite /wp-content/plugins/ to /plugins/
function roots_flush_rewrites() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}