Skip to content

Instantly share code, notes, and snippets.

Phil Banks emirpprime

Block or report user

Report or block emirpprime

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@emirpprime
emirpprime / Pure CSS Offsets
Last active Jun 19, 2019
CSS to add offsets to Pure grids http://purecss.io/
View Pure CSS Offsets
/*
Offsets from https://raw.githubusercontent.com/tilomitra/pure/d7f85e37abec3fdab14a541305ad05783159655c/src/grids/css/grids-offsets.css
Media queries from Pure v0.5.0
Copyright 2014 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
https://github.com/yui/pure/blob/master/LICENSE.md
*/
@media screen and (min-width: 35.5em) {
.offset-sm-0 {
margin-left:0;
View wp.sh
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Do you need to setup new MySQL database? (y/n)"
read -e setupmysql
if [ "$setupmysql" == y ] ; then
echo "MySQL Admin User: "
read -e mysqluser
View RegEx to link Twitter Usernames and Hashtags (e.g. in WordPress)
@emirpprime
emirpprime / functions.php
Last active Feb 1, 2017
Show WordPress "authors" only the comments on their posts
View functions.php
<?php
/**
* Clone of wp_count_comments from WP4.2.
*/
function myblogs_count_comments( $post_id = 0 ) {
global $wpdb;
$post_id = (int) $post_id;
/**
* Filter the comments count for a given post.
@emirpprime
emirpprime / add_flagging_link_comment_crowd-control.php
Created Oct 14, 2015
Only show Crowd Control's "report" link when users logged in if "Users must be registered and logged in to comment" is set.
View add_flagging_link_comment_crowd-control.php
@emirpprime
emirpprime / gform_clamav.php
Created Aug 8, 2016
Scan Gravity Forms uploads with ClamAV - WordPress
View gform_clamav.php
/**
* Scan Gravity Forms uploads with ClamAV
* Based on 'Custom Scan AV function by Kris Chase'
* https://krischase.com/detect-and-prevent-malware-in-gravity-forms-file-upload-with-php-clamav/
* Requires clamav and php-clamav installed and enabled
*/
function myfunc_uploads_clamav( $validation_result ) {
if ( $_FILES ) {
$form = $validation_result['form'];
View mod.php
<?php
echo '<pre>';
for ($j = 1; $j < 10; $j++) {
for ($k = 0; $k < $j; $k++) {
echo "\n\$i % $j == $k: \n";
for ($i = 0; $i < 10; $i++) {
echo "$i : ";
if ($i % $j == $k) {
echo "TRUE";
@emirpprime
emirpprime / mod_rows.php
Last active Sep 7, 2016
Modulus example to create rows in a grid
View mod_rows.php
<div class="row">
<?php
// $posts is some content to loop over and output.
$posts_count = 0;
foreach ( $posts as $post ) :
echo $post;
if ( $posts_count % 3 == 2 ) : // Fires every 3rd item since we are counting from 0. ?>
</div><div class="row>
<?php endif;
@emirpprime
emirpprime / mod_backgrounds.php
Last active Sep 7, 2016
Multiple modulus calculations for looping background colours
View mod_backgrounds.php
<?php
// $posts is some content to loop over and output. Perhaps 28 items.
// We want raindow coloured boxes so loop over 7 possible colours.
$posts_count = 0;
foreach ( $posts as $post ) :
$colour = '';
if ( $posts_count % 7 == 0 ) {
$colour = 'red';
} elseif ( $posts_count % 7 == 1 ) {
$colour = 'orange';
@emirpprime
emirpprime / remove_bws_captcha.php
Created Dec 6, 2016
Remove BWS captcha for whitelisted IPs
View remove_bws_captcha.php
/**
* Check if a given ip is in a network https://gist.github.com/tott/7684443
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
You can’t perform that action at this time.