Skip to content

Instantly share code, notes, and snippets.

View syamilmj's full-sized avatar

Syamil MJ syamilmj

View GitHub Profile
@syamilmj
syamilmj / generate_options_css.php
Created November 3, 2012 22:53
generate_options_css()
function generate_options_css($newdata) {
/** Define some vars **/
$data = $newdata;
$uploads = wp_upload_dir();
$css_dir = get_template_directory() . '/css/'; // Shorten code, save 1 call
/** Save on different directory if on multisite **/
if(is_multisite()) {
$aq_uploads_dir = trailingslashit($uploads['basedir']);
@syamilmj
syamilmj / gist:3993470
Created November 1, 2012 12:57
replace attachment with dummy image
function dummy_wp_get_attachment_url( $url, $post_id ){
return 'http://dummy/image/URL';
}
add_filter( 'wp_get_attachment_url' , 'dummy_wp_get_attachment_url' , 10 , 2 );
class My_Custom_Block extends AQ_Block {
function __construct() {
// block actual processes
}
function form( $instance ) {
// outputs the options form on admin
}
@syamilmj
syamilmj / functions.php
Created July 19, 2012 14:34
fix pagination on search
function aq_fix_query( $query ) {
global $paged;
if( $query->is_main_query() && $query->is_home() ) {
$query->set( 'post_type', array( 'post', 'listings' ) );
}
}
add_action( 'pre_get_posts', 'aq_fix_query' );
@syamilmj
syamilmj / functions.php
Created June 21, 2012 19:08
Fix "Cheatin' uh?" error on custom media upload buttons
/**
* Get rid of "Cheatin' uh?" error
* note: this will create a persistent "Hello World" post
*/
function aq_cheatin_uh(){
$id = 1;
$check = get_post($id);
if(! $check ) {
$post = array(
@syamilmj
syamilmj / gist:2952342
Created June 19, 2012 04:51
Fix pagination error on homepage WP3.4
//Fix for home page navigation error on WP 3.4
function aq_query_for_homepage( $query ) {
global $paged;
if(get_option('lp_include_reviews') == "true") { $include_reviews = "reviews"; }
if(get_option('lp_include_videos') == "true") { $include_videos = "videos"; }
if(get_option('lp_include_screenshots') == "true") { $include_screenshots = "screenshots"; }
if( $query->is_main_query() && $query->is_home() ) {
$query->set( 'post_type', array( 'post', $include_reviews, $include_videos, $include_screenshots ) );
@syamilmj
syamilmj / index.php
Created June 13, 2012 19:37
smof index.php file
<?php
/*
Title : SMOF
Description : Slightly Modified Options Framework
Version : 1.4.0
Author : Syamil MJ
Author URI : http://aquagraphite.com
License : WTFPL - http://sam.zoy.org/wtfpl/
Credits : Thematic Options Panel - http://wptheming.com/2010/11/thematic-options-panel-v2/
KIA Thematic Options Panel - https://github.com/helgatheviking/thematic-options-KIA