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 / 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 {
@tareq1988
tareq1988 / etc-hosts-on-win.md
Created September 12, 2018 06:47 — forked from zenorocha/etc-hosts-on-win.md
/etc/hosts on Windows

1. Get your IP Address

echo `ifconfig $(netstat -nr | grep -e default -e "^0\.0\.0\.0" | head -1 | awk '{print $NF}') | grep -e "inet " | sed -e 's/.*inet //' -e 's/ .*//' -e 's/.*\://'`

2. Modify your hosts file

notepad

@tareq1988
tareq1988 / fb-group.php
Last active February 25, 2018 08:44
Facebook Group to WP - Post Type Changer
<?php
/**
* Plugin Name: Facebook Group to WP - Post Type Changer
* Description: Changes the default Facebook Group post type to Post
* Plugin URI: https://wordpress.org/plugins/fb-group-to-wp/
* Author: Tareq Hasan
* Author URI: https://tareq.co
* Version: 1.0
* License: GPL2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
@tareq1988
tareq1988 / email-log.php
Created September 12, 2017 14:37
WordPress Email Log to File
<?php
/**
* Plugin Name: Email Log
* Plugin URI: https://tareq.co
* Description: Log all outgoing emails to <code>wp-content/uploads/emails/DATE.log</code> file
* Author: Tareq Hasan
* Author URI: https://tareq.co
* Version: 1.0
*/
@tareq1988
tareq1988 / prli-override.php
Created July 7, 2017 08:05
Override pretty link admin area access role
<?php
/*
Plugin Name: Pretty Link Role Override
Description: Override pretty link admin area access role
Plugin URI: http://tareq.co
Author: Tareq Hasan
Author URI: http://tareq.co
Version: 1.0
License: GPL2
*/
@tareq1988
tareq1988 / hook-taxonomy.php
Last active January 7, 2017 00:06
WPUF Action Hook Taxonomy
<?php
/**
* Register a custom taxonomy
*
* @return void
*/
function prefix_register_genere_taxonomy() {
register_taxonomy( 'genere', 'post', array(
'label' => __( 'Genre' ),
@tareq1988
tareq1988 / wpuf-woo-price.php
Created January 6, 2016 12:59
WooCommerce price adjustment for WPUF
<?php
/**
* WooCommerce price adjustment for WPUF
*
* @param int $post_id
*
* @return void
*/
function wpufe_update_post_price( $post_id ) {
@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() ) {