Skip to content

Instantly share code, notes, and snippets.

Avatar

Rodolfo Buaiz brasofilo

View GitHub Profile
@brasofilo
brasofilo / download.php
Created Jun 3, 2012
Force File Download with PHP
View download.php
<?php
/*
* Foce File Download
* Usage: http://example.com/download.php?file=./uploads/image.jpg
*
* There are a couple of *ninja* exit() as security guarantee, adapt as necessary
*
*/
// grab the requested file's name
@brasofilo
brasofilo / gist:3302470
Created Aug 9, 2012
5G Blacklist 2012 - Adapted to work with WordPress
View gist:3302470
# 5G BLACKLIST/FIREWALL
# @ http://perishablepress.com/5g-blacklist/
# 5G:[QUERY STRINGS]
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (localhost|mosconfig|scanner) [NC,OR]
# RewriteCond %{QUERY_STRING} (environ|localhost|mosconfig|scanner) [NC,OR]
# too many pieces of legitimate content with the word "environment" in the URL
@brasofilo
brasofilo / wpse_70758.php
Created Nov 19, 2012
WordPress plugin : Prevent Categories Deletion
View wpse_70758.php
<?php
/*
Plugin Name: Prevent Category Deletion
Plugin URI: http://wordpress.stackexchange.com/q/70758/12615
Description: Prevent deletion of categories. Modify the $undeletable array to suit your setup. Use Category SLUGS.
Author: brasofilo
Version: 1.0
Author URI: http://wordpress.stackexchange.com/users/12615/brasofilo
*/
@brasofilo
brasofilo / authorized-acf-access.php
Created Dec 8, 2012
Hide ACF Menu from Clients
View authorized-acf-access.php
/**
* A method to really block access to ACF menu
* http://www.advancedcustomfields.com/docs/tutorials/hide-acf-menu-from-clients/
*/
/**
* Remove ACF menu item from the admin menu
*/
add_action( 'admin_menu', 'acf_remove_menu_page', 15 );
@brasofilo
brasofilo / install.php
Last active Aug 11, 2020
WP Install Defaults - Dropin Plugin
View install.php
<?php
!defined( 'ABSPATH' ) AND exit;
/*
Plugin Name: Custom Installation Script
Plugin URI: http://wordpress.stackexchange.com/q/75420/12615
Description: Create our own content on WP install
License: GPL
*/
@brasofilo
brasofilo / so_13646200.php
Created Dec 11, 2012
Repeatable upload field
View so_13646200.php
add_action('admin_init', 'so_13646200_add_post_gallery');
add_action('save_post' , 'so_13646200_update_post_gallery');
function so_13646200_add_post_gallery() {
add_meta_box(
'post_gallery',
'Clients Logo Options',
'so_13646200_post_gallery_options',
'post',
'normal',
@brasofilo
brasofilo / wpse_76593.php
Last active Aug 17, 2017
Hide wp-content/themes path
View wpse_76593.php
<?php
// REMOVE WP-CONTENT
// Rewrites DO NOT happen for child themes
// Add .htaccess rewrite rules to convert urls
// like "http://example.com/wp-content/themes/theme-name/path" into "http://example.com/path"
/*
in case your wordpress is in a folder,
and you change the site_url to the root of the domain,
add the folder name in lines 29 to 34,
@brasofilo
brasofilo / gist:4367116
Last active Dec 10, 2015
Values in $wp_admin_bar
View gist:4367116
/**
* Value of $nodes in the following:
* global $wp_admin_bar;
* $nodes = $wp_admin_bar->get_nodes();
*/
Array
(
[user-actions] => stdClass Object
(
[id] => user-actions
@brasofilo
brasofilo / press-this-thickbox.php
Last active Dec 10, 2015
Dealing with PressThis inside an administrative thickbox
View press-this-thickbox.php
<?php
/**
Auxiliary menu and page with a button to open the thickbox
*/
add_action('admin_menu', 'add_auxiliary_menu');
function add_auxiliary_menu()
{
add_menu_page(
'TB',
@brasofilo
brasofilo / old-upload-method.php
Last active Oct 5, 2018
Replace the New WP 3.5 Uploader with the Old Thickbox
View old-upload-method.php
<?php
/**
* Plugin Name: Old Upload Method
* Plugin URI: http://wordpress.org/support/topic/is-there-a-way-to-disable-the-new-media-manager
* Description: Replace the new media upload with the old thickbox
* Author: A.Morita, brasofilo
* Version: 1.2
* License: GPLv2 or later
*
You can’t perform that action at this time.