Skip to content

Instantly share code, notes, and snippets.

@miziomon
miziomon / gist:4467983
Created January 6, 2013 15:41
My WordPress robot.txt
User-agent: *
Disallow:
Disallow: /blackhole/*
Disallow: /cgi-bin/
Disallow: /bin/
Disallow: /wp-includes/
Disallow: /wp-content/
Disallow: /wp-admin/
Disallow: /app/
@miziomon
miziomon / the_filters
Created January 29, 2014 08:13
Get WordPress filters attach to specific hook
/**
* get filters attach to specific hook
* eg. the_filters("the_title");
*/
function the_filters($hook = '') {
global $wp_filter;
if (empty($hook) || !isset($wp_filter[$hook]))
return;
echo '<pre>';
@miziomon
miziomon / functions.php
Created March 26, 2014 16:26
WordPress Lazy Pagination
<?php
add_action('wp_ajax_morepage', 'morepage');
add_action('wp_ajax_nopriv_morepage', 'morepage');
/**
*
* posts_per_page have to set with your pagination value
**/
@miziomon
miziomon / qtranlsate-comment
Created April 18, 2014 07:06
WordPress qTranslate comment form error
/**
* first relase
* fix to get and translate comment error message
*
*/
add_action("pre_comment_on_post", function( $comment_post_ID) {
$comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null;
$comment_author_email = ( isset($_POST['email']) ) ? trim($_POST['email']) : null;
@miziomon
miziomon / Restricted access
Last active August 29, 2015 14:20
WordPress Template scaffolding for restricted are
<?php
/**
*
* Template Name: Restricted Area
*
*/
if( !is_user_logged_in() ) {
wp_redirect( WP_HOME ); // redirect to home
@miziomon
miziomon / admin-redirect
Created May 15, 2015 12:55
WordPress user admin redirect
/**
*
* redirect to homepage if has non "edit_posts" capabilities
*/
add_filter("admin_init", function () {
if (!current_user_can('edit_posts')) {
wp_redirect(WP_HOME);
exit;
@miziomon
miziomon / .htaccess
Last active August 29, 2015 14:21
WordPress - hide default login url and prevent brute force attack
# START Security settings
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^[custom-login-path]$ wp-login.php?loginkey=[key]&redirect_to=http://%{SERVER_NAME}/wp-admin/index.php [L]
RewriteCond %{HTTP_REFERER} !^http://%{SERVER_NAME}/wp-admin
RewriteCond %{HTTP_REFERER} !^http://%{SERVER_NAME}/wp-login\.php
RewriteCond %{HTTP_REFERER} !^http://%{SERVER_NAME}/[custom-login-path]
@miziomon
miziomon / .htacess
Last active August 29, 2015 14:21
blackhole implementation
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(phpinfo|wp-signup|phpmyadmin|database|usage|cgi|signup|admin|register|timthumb|function|system|test|t|jsp|asp|aspx)$ blackhole/ [L]
</ifModule>
@miziomon
miziomon / current-user-filter.php
Last active August 29, 2015 14:21
WordPress - Filter content by current user
/*
* @miziomon
* Filter content by current user
*
*/
add_filter('pre_get_posts', function ($query) {
global $pagenow, $user_ID;
if( !current_user_can('administrator') && $query->is_admin && 'upload.php' != $pagenow ){
$query->set('author', $user_ID);
@miziomon
miziomon / remove-emoji.php
Created July 28, 2015 12:19
Howto remve emoji rendering from WordPress
/*
* http://www.denisbouquet.com/remove-wordpress-emoji-code/
*
*/
add_action( 'init', function(){
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');