Skip to content

Instantly share code, notes, and snippets.

View abouolia's full-sized avatar
🤠

Ahmed Bouhuolia abouolia

🤠
View GitHub Profile
@mjangda
mjangda / get_current_post_type.php
Created July 15, 2010 13:55
Get the current post_type context in the WordPress admin.
<?php
/**
* Gets the current global post type if one is set
*/
function x_get_current_post_type() {
global $post, $typenow, $current_screen;
if( $post && $post->post_type )
$post_type = $post->post_type;
elseif( $typenow )
@wesbos
wesbos / is_blog.php
Created September 2, 2011 19:32
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@danny-englander
danny-englander / jquery.responsive-classes.js
Created September 13, 2012 00:16
JQuery Responsive Classes
/*
* Inspired by:
* http://designedbythomas.co.uk/blog/how-detect-width-web-browser-using-jquery
*
* This script is ideal for getting specific class depending on device width
* for enhanced theming. Media queries are fine in most cases but sometimes
* you want to target a specific JQuery call based on width. This will work
* for that. Be sure to put it first in your script file. Note that you could
* also target the body class instead of 'html' as well.
* Modify as needed
@westonruter
westonruter / nav-menu-item-custom-fields.php
Created September 28, 2012 22:47
Proof of concept for how to add new fields to nav_menu_item posts in the WordPress menu editor.
<?php
/**
* Proof of concept for how to add new fields to nav_menu_item posts in the WordPress menu editor.
* @author Weston Ruter (@westonruter), X-Team
*/
add_action( 'init', array( 'XTeam_Nav_Menu_Item_Custom_Fields', 'setup' ) );
class XTeam_Nav_Menu_Item_Custom_Fields {
static $options = array(
@elclanrs
elclanrs / v2p.html
Created December 19, 2012 22:10
Use CSS viewport units with jQuery
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="v2p.js"></script>
<style type="text/css" media="all">
body { margin: 0; }
div {
background: #fa7098;
}
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
<?php
add_action( 'init', function () {
global $shortcode_tags;
foreach ( $shortcode_tags as $tag => $function ) {
$shortcode_tags[$tag] = function ( $attr, $content = null ) use ( $tag, $function ) {
$expires = 60;
$expires = apply_filters( 'shortcode_cache_expires', $expires, $tag );
$cache_key = $tag . md5( serialize( $attr ) ) . get_the_ID();
$cached = wp_cache_get( $cache_key );
@staltz
staltz / introrx.md
Last active May 2, 2024 12:31
The introduction to Reactive Programming you've been missing
anonymous
anonymous / index.html
Created November 12, 2014 18:42
// source http://jsbin.com/fezigapava
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.pricing-table {
margin: 0 0 rem-calc(20) 0;
border: 0;
background-color: #f0f0f0;
@jhamrick
jhamrick / genkeys.sh
Last active January 17, 2024 07:33
Generate SSL certificates with IP SAN
#!/usr/bin/env bash
#
# Generate a set of TLS credentials that can be used to run development mode.
#
# Based on script by Ash Wilson (@smashwilson)
# https://github.com/cloudpipe/cloudpipe/pull/45/files#diff-15
#
# usage: sh ./genkeys.sh NAME HOSTNAME IP
set -o errexit