Skip to content

Instantly share code, notes, and snippets.

View tareq1988's full-sized avatar
🎯
Focusing

Tareq Hasan tareq1988

🎯
Focusing
View GitHub Profile
@tareq1988
tareq1988 / functions.php
Created July 10, 2013 15:15
I have a user level in a site. It allows people to post to two Custom Post Types (say Type A and Type B). I need to allow users to be able to Publish to Post Type A but only save drafts to Post Type B.
<?php
add_action( 'save_post', function( $post_id ) {
if ( !wp_is_post_revision( $post_id ) ) {
$post_type = get_post_type( $post_id );
// apply on specific post type and for specific user role
if ( $post_type == 'product' && current_user_can( 'subscriber' ) ) {
wp_update_post( array(
<?php
if ( is_multisite() ) {
global $wpdb;
$all_sites = $wpdb->get_results( "SELECT * FROM $wpdb->blogs" );
if ( $all_sites ) {
foreach ($all_sites as $site) {
$wpdb->set_blog_id( $site->blog_id );
<?php
/**
* Map display shortcode
*
* @param string $meta_key
* @param int $post_id
* @param array $args
*/
function wpuf_shortcode_map( $location, $post_id = null, $args = array() ) {
<?php
function wpuf_show_custom_fields( $content ) {
global $post;
$form_id = get_post_meta( $post->ID, '_wpuf_form_id', true );
if ( !$form_id ) {
return $content;
}
@tareq1988
tareq1988 / settings-api-class-demo.php
Created March 8, 2013 13:46
A simple theme options page created with WordPress Settings API PHP class https://github.com/tareq1988/wordpress-settings-api-class
<?php
require_once dirname( __FILE__ ) . '/class.settings-api.php';
/**
* Theme Admin panel for Tareq's Planet
*
* @author Tareq Hasan
*/
class Tareqs_Planet_Admin {
<?php
/**
* Entry Views - for counting single post views.
*
* Borrowed from Hybrid Core framework and adapted for weDevs Framework
* @package WeDevs Framework
*/
class WeDevs_Entry_Views {
public function __construct() {
<?php
if ( !function_exists( 'wp_log' ) ) {
/**
* A file based logging utility.
*
* Made for WordPress, but can be used anywhere with a single change.
*
* @author Tareq Hasan <tareq@wedevs.com>
*
@tareq1988
tareq1988 / menu.less
Created December 7, 2012 11:02
Navigation menu with LESS
@borderColor: #eee;
.main-navigation {
clear: both;
display: block;
float: left;
width: 100%;
border-top: 1px solid @borderColor;
border-left: 1px solid @borderColor;
border-right: 1px solid @borderColor;
@tareq1988
tareq1988 / wp_print_r.php
Created June 25, 2012 13:14
a debugging function for php
<?php
if ( !function_exists( 'wp_print_r' ) ) {
/**
* Debugging function
*
* @param mixed $var the variable name
* @param string $title title of the variable
* @param bool $die if to die or not
*/
function wp_print_r( $var, $title = '', $die = false ) {
@tareq1988
tareq1988 / bug-hunt-one.php
Created January 9, 2012 13:32 — forked from EnvatoWP/bug-hunt-one.php
Bug Hunt One
<?php
/*
* Plugin Name: EnvatoWP Bug Hunt One
* Plugin URI: https://gist.github.com/
* Description: Bug Hunt One - Find all the bugs in this basic plugin
* Version: 0.1
* Author: EnvatoWP
* Author URI: http://envatowp.github.com/
* License: GPL2
*/