Skip to content

Instantly share code, notes, and snippets.

View imelgrat's full-sized avatar

Iván Melgrati imelgrat

View GitHub Profile
@imelgrat
imelgrat / "Rotate-on-Hover" 3D Gallery using CSS3 transforms.markdown
Created September 27, 2015 13:38
"Rotate-on-Hover" 3D Gallery using CSS3 transforms
@imelgrat
imelgrat / Disable PUT and DELETE Apache requests and disable Server signature display
Last active September 27, 2015 13:39
Disable PUT and DELETE Apache requests and disable Server signature display
Disable PUT and DELETE Apache requests and disable Server signature display
@imelgrat
imelgrat / products-post-type.php
Last active August 23, 2017 18:06
Declare and configure a new custom post type (Product) in WordPress. Full article at: http://imelgrat.me/wordpress/bulk-upload-custom-posts-wordpress/
<?php
// Only declare the function if it doesn't exist (prevents PHP fatal error)
if (!function_exists('product_post_type'))
{
function product_post_type() // Function to register new custom post type
{
// Labels used inside the WordPress CMS
$labels = array(
'name' => _x('Products', 'Post Type General Name', 'text_domain'),
'singular_name' => _x('Product', 'Post Type Singular Name', 'text_domain'),
@imelgrat
imelgrat / wordcount.php
Last active August 23, 2017 18:11
Calculate the number of words in a Wordpress post. Full article at: http://imelgrat.me/wordpress/customize-wordpress-post-management-page/
function post_word_count($post_id) {
$content = get_post_field( 'post_content', $post_id );
$word_count = str_word_count( strip_tags( strip_shortcodes($content) ) );
return $word_count;
}
@imelgrat
imelgrat / add-column-middle.php
Last active August 23, 2017 18:11
Add a custom column to Wordpress Post management page after title column: Full article at: http://imelgrat.me/wordpress/customize-wordpress-post-management-page/
add_filter('manage_posts_columns', 'add_column_middle'); // Register filter
function add_column_middle($defaults)
{
$new_columns = array(); // Create empty array to store new column order
foreach ($defaults as $key => $value)
{
$new_columns[$key] = $value; // Add columns to new array
if ($key == 'title')
@imelgrat
imelgrat / .htaccess
Last active August 23, 2017 19:31
Deny access to WordPress wp-config.php file using .htaccess. Full article at: http://imelgrat.me/security/wordpress-htaccess-file-protect/
# Deny access to wp-config.php file
<files wp-config.php>
order allow,deny
deny from all
</files>
@imelgrat
imelgrat / .htaccess
Last active August 23, 2017 19:42
Protect .htaccess and .htpasswd files (current and child folders). Full article at: http://imelgrat.me/security/wordpress-htaccess-file-protect/
# Deny access to all .htaccess files
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>
@imelgrat
imelgrat / .htaccess
Last active August 23, 2017 19:42
Use .htaccess to disable execution (and send files to the browser) of CGI-based files. Full article at: http://imelgrat.me/security/wordpress-htaccess-file-protect/
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
Options -ExecCGI
@imelgrat
imelgrat / .htaccess
Last active August 23, 2017 19:42
Disable directory browsing using .htaccess. Full article at: http://imelgrat.me/security/wordpress-htaccess-file-protect/
# Disable directory browsing
Options All -Indexes
@imelgrat
imelgrat / .htaccess
Last active August 23, 2017 19:42
Disable access to all file types except the following (to be placed inside a Wordpress wp-content directory). Full article at: http://imelgrat.me/security/wordpress-htaccess-file-protect/
# Disable access to all file types except the following
Order deny,allow
Deny from all
<Files ~ ".(xml|css|js|jpe?g|png|gif|pdf|docx|rtf|odf|zip|rar)$">
Allow from all
</Files>