Skip to content

Instantly share code, notes, and snippets.

View logichub's full-sized avatar

Kashif Rafique logichub

View GitHub Profile
@khromov
khromov / gist:10502980
Created April 11, 2014 21:27
Adding custom shortcodes to Contact Form 7
<?php
/*
Plugin Name: Contact Form 7 Post Title shortcode
Plugin URI:
Description: Use in form: [post_title thetitle] - use in email (to get value): [thetitle]
Version: 2014.04.07
Author: khromov
Author URI: http://profiles.wordpress.org/khromov/
License: GPL2
*/
@khromov
khromov / wp-users-media.php
Created May 16, 2014 09:44
wp-users-media.php Plugin
<?php
/**
* Plugin Name: WP Users Media
* Plugin URI: http://www.wknet.com/wp-users-media/
* Description: WP Users Media is a WordPress plugin that displays only the current users media files and attachments in WP Admin.
* Version: 1.0.3
* Author: Damir Calusic
* Author URI: http://www.damircalusic.com/
* License: GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
@mor10
mor10 / advanced-featured-image.php
Last active August 29, 2015 14:01
Advanced responsive featured image function utilizing transients for caching.
@khromov
khromov / limit-author-view-scope.php
Created May 28, 2014 15:22
Limit author view scope WordPress
<?php
/*
Plugin Name: Limit Author View scope
Plugin URI:
Description: Limits non-admins to only see their own media and comments.
Version: 2014.05.28
Author: khromov
Author URI: https://profiles.wordpress.org/khromov
License: GPL2
*/
#!/bin/bash
# Adds WordPress zipped up:
wget http://wordpress.org/latest.tar.gz
# Unzip WordPress:
tar xfz latest.tar.gz
# Move the contents of WordPress back a folder:
mv wordpress/* ./
@mathetos
mathetos / gist:4d80d5c7bf2d23fd2a7e
Created June 19, 2014 21:35
Targeting Mobile Devices
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
// Small script to detect mobile browsers and toggle the visibility of specified elements.
(function($){
var isMobile = function(_, ua){
_.Android = ua.match(/Android/i);
@khromov
khromov / bootstrap-3-grid.css
Last active June 12, 2017 16:05
Bootstrap 3 Grid (Without the rest of the framework).
/*!
* Grid portion of Bootstrap under sc- namespace.
* Classes:
* sc-container-fluid, sc-row, sc-col-X-Y (like regular B3)
*
* For more info, see:
* http://snippets.khromov.se/decoupled-bootstrap-3-grid/
*
* Bootstrap v3.2.0 (http://getbootstrap.com)
* Copyright 2011-2014 Twitter, Inc.
@strangerstudios
strangerstudios / coming_soon.php
Created August 13, 2014 15:02
Various options for redirecting to a "Coming Soon" page with WordPress.
/*
1. Create a page called "Coming Soon" with the slug "coming-soon".
If you use something different, be sure to update the code below.
2. Copy just one of the blocks of code below to a custom plugin or your active theme's functions.php.
*/
//redirect non-users to the coming soon page
function coming_soon_redirect()
{
@mathetos
mathetos / custom_the_content.php
Last active July 17, 2017 09:53
Adding Custom Class to the_content
<?php
//Adding custom class to posts is easy with the post_class filter
add_filter('post_class', 'custom_content_class');
function custom_content_class($classes) {
$classes[] = 'custom_class';
return $classes;
}
@khromov
khromov / file.php
Last active January 29, 2019 21:24
Advanced Custom Fields get_field() sanitization
<?php
/**
* Helper function to get sanitized field
* and also normalize values.
*
* @param $field_key
* @param bool $post_id
* @param bool $format_value
* @param string $sanitization_method esc_html / esc_attr or NULL for none
* @return array|bool|string