Skip to content

Instantly share code, notes, and snippets.

@mateusneves
mateusneves / 0_reuse_code.js
Created May 31, 2014 19:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mateusneves
mateusneves / functions.php
Created June 30, 2014 18:32
Mime type extended, for upload files in WordPress
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
// add the file extension to the array
$existing_mimes['cdr'] = 'mime/type';
// call the modified list of extensions
return $existing_mimes;
}
@mateusneves
mateusneves / .htaccess
Created July 10, 2014 13:52
Force download with .htacces
<FilesMatch "\.(jpg|zip|avi|pdf|mp3|mp4|doc|ppt|xls|odt|wav|mov|swf)$" >
ForceType application/octet-stream
Header add Content-Disposition "attachment"
</FilesMatch>
@mateusneves
mateusneves / functions.php
Created July 16, 2014 13:33
Function to return true or false if the current page is the login page
function is_login_page() {
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
}
@mateusneves
mateusneves / functions.php
Created July 16, 2014 21:01
Add custom attributes to images links in the WordPress native gallery
add_filter('wp_get_attachment_link', 'add_gallery_id_rel');
function add_gallery_id_rel($link) {
global $post;
return str_replace('<a href', '<a class="fancybox" rel="gallery" href', $link);
}
@mateusneves
mateusneves / functions.js
Created August 6, 2014 21:06
Simple dropdow list menu
$('#nav-menu li').hover(
function () {
$('ul', this).stop().slideDown(100);
},
function () {
$('ul', this).stop().slideUp(100);
}
);
@mateusneves
mateusneves / functions.php
Created December 11, 2014 19:55
Fix WordPress Upload Error
// ===================================================
// Dont use Years folder for uploads
// ===================================================
add_filter( 'option_uploads_use_yearmonth_folders', '__return_false', 100 );
@mateusneves
mateusneves / .htaccess
Created February 9, 2015 16:10
Increase the Maximum File Upload Size
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
@mateusneves
mateusneves / new_gist_file_0
Created February 9, 2015 16:13
Config for file expires
# Expires
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
#ExpiresDefault "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
@mateusneves
mateusneves / wp-config.php
Created February 10, 2015 14:06
Disable Theme and Plugin Editors from WordPress Admin Panel
define( 'DISALLOW_FILE_EDIT', true );