Skip to content

Instantly share code, notes, and snippets.

View aprakasa's full-sized avatar
🎯
Focusing

Arya Prakasa aprakasa

🎯
Focusing
View GitHub Profile
@aprakasa
aprakasa / gist:5082956
Last active December 14, 2015 11:58
Remove price display at homepage
add_action( 'get_header', 'remove_price_at_homepage' );
/**
* Remove price display and add to chart button at homepage
*
* @see http://docs.woothemes.com/document/hooks/
*/
function remove_price_at_homepage() {
if ( is_home() || is_front_page() ) {
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
@aprakasa
aprakasa / gist:5069221
Last active December 14, 2015 09:59
Block Header
/* block header */
function before_block( $instance ) {
extract( $instance );
$column_class = $first ? 'aq-first' : '';
$template_title = sanitize_title_with_dashes( get_the_title( $template_id ) );
echo '<div id="aq-block-'.$template_title.'-'.$number.'" class="aq-block aq-block-'.$id_base.' aq_'.$size.' '.$column_class.' cf">';
}
@aprakasa
aprakasa / gist:4618624
Last active December 11, 2015 15:08
Add Additional Links To The WordPress Plugin Admin
add_filter('plugin_row_meta', 'register_plugins_links', 10, 2);
/**
* Add Additional Links To The WordPress Plugin Admin
*
* @see http://www.paulund.co.uk/add-additional-links-to-the-wordpress-plugin-admin
*/
function register_plugins_links ($links, $file) {
$base = plugin_basename(__FILE__);
if ($file == $base) {
$links[] = '<a href="admin.php?page=settings_plugin">' . __('Settings') . '</a>';
/**
* Aqua Page Builder block API
*
* @link https://github.com/sy4mil/Aqua-Page-Builder/wiki/Block-API
*/
class My_Custom_Block extends AQ_Block {
function __construct() {
// block actual processes
}
<?php
function sharelinks( $atts ){
$links = get_transient('share_links' . get_the_ID() );
if($links === false){
// add the links you want
$links = "<a href='https://www.facebook.com/sharer.php?u=" . urlencode( get_permalink() ) . "&t=" . get_the_title(). "'></a>";
@aprakasa
aprakasa / gist:4264393
Created December 12, 2012 02:40
automatically echo to the screen
<?php
/**
* automatically echo to the screen using transient
*
* @link http://speckyboy.com/2011/12/14/website-speed-part-3-caching-wordpress/
* /
$loop_output = get_transient( 'loopOutput' );
if ( false === $loop_output ) {
<?php
/**
* Using caching for theme options
* @link http://speckyboy.com/2011/12/14/website-speed-part-3-caching-wordpress/
* /
function my_get_cache_option($option_name = 'ThemeAdminOptions' ){
// get wanted transient
$value = get_transient( $option_name );
// check if it has any content
if(false === $value){
<?php
/**
* Caching Widgets with transients
*
* @link http://speckyboy.com/2011/12/14/website-speed-part-3-caching-wordpress/
* /
class show_ak_events_Widget extends WP_Widget {
function show_ak_events_Widget() {
/* Widget settings. */
@aprakasa
aprakasa / gist:4264372
Created December 12, 2012 02:34
Using transients on a single loop inside WordPress
<?php
/**
* Using transients on a single loop inside WordPress
*
* @link http://speckyboy.com/2011/12/14/website-speed-part-3-caching-wordpress/
* /
$loop = get_transient( 'loop' );
if ( false === $loop ) {
// Show the last 100 tweets from the custom post type tweets.
@aprakasa
aprakasa / gist:4242702
Created December 9, 2012 00:23
Redirect theme/plugin after activation
<?php
add_action( 'init', 'ayo_redirect_plugin_activation' );
function ayo_redirect_plugin_activation(){
global $pagenow;
if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'plugins.php' )
wp_redirect( admin_url( 'options-general.php?page=plugin-page-slug' ) );
exit;
}