Skip to content

Instantly share code, notes, and snippets.

View ronalfy's full-sized avatar
🏠
Working from home

Ronald Huereca ronalfy

🏠
Working from home
View GitHub Profile
@ronalfy
ronalfy / wp-options-framework-page-selector.php
Last active August 29, 2015 14:08
WordPress Options Framework - Page Selector Option
<?php
/*
Place in functions.php or custom plugin
example usage
$options[] = array(
'name' => __('Bid Text Page', 'options_framework_theme'),
'desc' => __('The bid page', 'options_framework_theme'),
'id' => 'header-bid-cta-page',
'type' => 'page_select');
?>
@ronalfy
ronalfy / wp-add-edit-link-reading-pages.php
Created November 4, 2014 01:48
WordPress - Add Edit Link to Options-Reading Pages
@ronalfy
ronalfy / wp-youtube-embed-lightbox-overlay.php
Created November 13, 2014 21:07
WordPress YouTube Embed Overlay Into Lightbox
<?php
/*Place in functions.php or in custom plugin
Creates an overlay over the YouTube iFrame and allows you to pop-up the YouTube URL into a lightbox
*/
add_filter( 'embed_oembed_html', 'opubco_youtube_parse', 10, 4 );
function opubco_youtube_parse( $html, $url, $attr, $post_ID ) {
//Works well with: http://www.wonderplugin.com/wordpress-lightbox/
if ( strstr( $url, 'youtu' ) ) {
if ( preg_match( '/src="([^"]+)"/', $html, $matches ) ) {
$embed_url = $matches[ 1 ];
@ronalfy
ronalfy / ai1ec_override_avatar.php
Created January 7, 2015 04:18
WordPress All in One Event Calendar - Override Avatar
<?php
//Place in mu-plugins folder
//Custom Twig Template Functions
function opubco_add_twig_functions_and_filters( $registry ) {
$loader = $registry->get('theme.loader');
$twig = $loader->get_twig_instance(false, true);
$twig->addFunction( new Twig_SimpleFunction('opubco_get_event_avatar', 'opubco_get_event_avatar') );
}
add_action( 'ai1ec_loaded', 'opubco_add_twig_functions_and_filters');
@ronalfy
ronalfy / wp-page-widget-is-home.php
Created January 12, 2015 22:58
WordPress - WP Page Widget working on is_home
<?php
add_action( 'init', 'opubco_filter_sidebar_widgets_init' );
function opubco_filter_sidebar_widgets_init() {
add_filter('widget_display_callback', 'opubco_filter_widget_display_instance', 12, 3);
add_filter( 'sidebars_widgets', 'opubco_filter_sidebar_widgets', 15, 1 );
}
function opubco_filter_widget_display_instance( $instance, $widget, $args ) {
if ( is_home() ) {
@ronalfy
ronalfy / woocommerce-remarketing.php
Last active August 29, 2015 14:13
WooCommerce Google Product Feed Remarketing Footer Code
if ( function_exists( 'is_product' ) && is_product() ) :
global $post;
$product = get_product( $post->ID );
if ( $product->is_in_stock() ) {
$price = $product->get_price();
}
?>
<script type="text/javascript">
var google_tag_params = {
@ronalfy
ronalfy / wp-limit-actions.php
Created July 11, 2015 16:08
WordPress - Limit Actions
<?php
class I_Am_Evil {
private $times = 0;
private $callbacks = array();
private $accepted_args = array();
public function __construct() {
}
public function load() {
global $wp_filter;
@ronalfy
ronalfy / wp-featured-image-post-types.php
Created July 13, 2015 15:55
WordPress Featured Images in Post List - Post Types
<?php
//Run in init action
//Replace apartments with your post type name
//Must use PHP >= 5.3
add_filter( 'manage_apartments_posts_columns', function( $columns ) {
$columns['apt_thumb'] = __('Thumb');
return $columns;
} );
add_action( 'manage_apartments_posts_custom_column', function( $column_name, $post_id ) {
@ronalfy
ronalfy / sce-logged-in-only.php
Created July 14, 2015 01:59
Simple Comment Editing - Logged In Users Only
<?php
//Requires PHP >= 5.3
add_filter( 'sce_can_edit', function( $can_edit, $comment_obj, $comment_id, $post_id ) {
//Make sure user is logged in
if ( !is_user_logged_in() ) {
return false;
}
//Get current user id
$user = wp_get_current_user();
@ronalfy
ronalfy / wp-fa-social.php
Last active August 29, 2015 14:25
Get Social Icons - Font Awesome
<?php
class APTL_Social {
private $social_networks = array();
public function __construct() {
}
private function init() {
$this->social_networks = array(