Skip to content

Instantly share code, notes, and snippets.

@miziomon
miziomon / virtualmin_sf_symlink.sh
Created August 26, 2015 14:36
Post Domain modification script for Virtualmin. (create a symlink from /home/public_html to virtualbox shared folder)
@miziomon
miziomon / gulfile.js
Created August 26, 2015 09:55
my gulp config
/*
* https://github.com/gulpjs/gulp
* http://code.tutsplus.com/tutorials/using-gulp-for-wordpress-automation--cms-23081
* https://markgoodyear.com/2014/01/getting-started-with-gulp/
* http://mattbanks.me/gulp-wordpress-development/
*
*/
var gulp = require('gulp'),
through = require('gulp-through'),
@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');
@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 / .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 / .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 / 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 / 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 / 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 / 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
**/