Skip to content

Instantly share code, notes, and snippets.

View logichub's full-sized avatar

Kashif Rafique logichub

View GitHub Profile
@mathetos
mathetos / smart-excerpts
Last active May 17, 2016 19:43
Smart Excerpts
<?php
/*
* This asks first for a Yoast SEO meta description,
* If that's not present, then it asks for the excerpt of the post,
* If that's not present, then it strips the content
* In this case, I have an excerpt length setting in the Customizer
* Both the excerpt and content stripping, also strip shortcodes
* @author Matt Cromwell <[email protected]>
* @copyright Copyright (c) 2014, Matt Cromwell
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
@ericandrewlewis
ericandrewlewis / gist:a1b127aefbd58c210666
Last active January 19, 2019 00:02
Towards a data model for scalable queries against rich WordPress post attribute data

Towards a data model for scalable queries against rich WordPress post attribute data

This document is in draft status, and is being made available for peer review. If you have feedback, comment on this gist or email me.

Let's say you're a web developer. A client of yours is a gemstone dealer in Manhattan. This dealer has an inventory of gemstones that they'd like to put on their website.

Gemstones have a plethora of attributes: type of gemstone (e.g. sapphire or emerald), price, weight, width, height, depth, color, shape, country of origin, treatment (if it's heat treated), who certified these details, whether the stone is a single stone or a pair.

You're offered the task to make a website to display the gemstone inventory, which will include a search interface. So a user can say "I want to see sapphires that are no heavier than 1.33 karats that are oval, between $750 and $1250, between 1.11mm and 1.20mm that weren't heat treated, because heat treatment is cheap."

anonymous
anonymous / my.css
Created December 29, 2014 20:22
CSS Gradient Animation
background: linear-gradient(270deg, #5b318c, #000000);
background-size: 400% 400%;
-webkit-animation: AnimationName 10s ease infinite;
-moz-animation: AnimationName 10s ease infinite;
-o-animation: AnimationName 10s ease infinite;
animation: AnimationName 10s ease infinite;
@-webkit-keyframes AnimationName {
    0%{background-position:0% 50%}
    50%{background-position:100% 50%}
    100%{background-position:0% 50%}
@khromov
khromov / capital_p_dangit_perf.php
Last active August 29, 2015 14:13
capital_P_dangit performance impact tester
<?php
/*
Plugin Name: capital_P_dangit performance test
Plugin URI:
Description: Use shortcode on any page: [capital_P_dangit_performance count="10000"]
Version: 1.0
Author: khromov
Author URI: http://snippets.khromov.se
License: GPL2
*/
<?php
/*
Plugin Name: Your Plugin
Plugin URI: http://snippets.khromov.se/a-nicer-way-to-structure-your-plugin/
Description: Your plugin skeleton
Version: 1.0
Author: you
Author URI: http://your-site.com
License: GPL2
*/
<?php
/*
Plugin Name: PageLines Security Patcher
Description: Blocks the recent exploits for legacy themes in the event you cant update the themes.
Version: 1.0
Author: PageLines
*/
class Fix_Pagelines_Legacy {
function __construct() {
@mathetos
mathetos / functions.php
Created January 23, 2015 06:18
User-Friendly Styled Content in the WordPress Editor
<?php
/*
* Add "Formats" dropdown to TinyMCE Editor
*/
function matt2015_mce_formats($buttons) {
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'matt2015_mce_formats');
@tomazzaman
tomazzaman / functions.php
Created February 18, 2015 23:57
Insert image in WordPress with HTML5 <figure> tag and caption
<?php
// Don't include the opening tag
function html5_insert_image( $html, $id, $caption, $title, $align, $url, $size, $alt ) {
$src = wp_get_attachment_image_src( $id, $size, false );
$html5 = "<figure id=\"post-$id media-$id\" class=\"align-$align\">";
if ( $url ) {
$html5 .= "<a href=\"$url\" class=\"image-link\"><img src=\"$src[0]\" alt=\"$alt\" /></a>";
} else {
@tomazzaman
tomazzaman / README.md
Last active September 17, 2023 20:59
Gulp workflow for WordPress theme development

Gulp workflow for WordPress theme development

Requirements

In order for Livereload to work, you need a Firefox or Chrome extension as Gulp doesn't inset it automatically. Alternatively, you can also manually put the livereload script in footer.php, just make sure to insert it only on development environment:

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
@bearded-avenger
bearded-avenger / mixin.less
Created February 22, 2015 14:49
Grid Layout - CSS - nth child
// this targets 1,5,7,11,13,17,19...
.ale--66 {
&:nth-child(6n+1),
&:nth-child(6n+5){
width:66.666%;
}
}
// this targets - 2,4,8,10,14,16,20....
.ale--33 {