Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ronald Huereca ronalfy

🏠
Working from home
View GitHub Profile
@ronalfy
ronalfy / has_post_thumbnail_fail.php
Last active Jul 31, 2022
Use Auto-Generate-Thumbnail plugin to generate thumbnail images when has_post_thumbnail is erroring out. This assumes you are inside of the WordPress loop.
View has_post_thumbnail_fail.php
<?php
//Assumes within the WordPress Loop
$args = array ('title' => $post->post_title);
if ( strlen( $img = get_the_post_thumbnail( get_the_ID() ) ) ) {
/* display thumbnail */
the_post_thumbnail( 'thumbnail', $args );
} else {
delete_post_meta( $post->ID, '_thumbnail_id' );
//Requires Auto Post Thumbnails plugin - http://wordpress.org/extend/plugins/auto-post-thumbnail/
if ( function_exists( 'apt_publish_post' ) ) {
@ronalfy
ronalfy / locale_in_multisite.php
Created Jan 21, 2013
Having trouble getting a language to set across a network? Try running this as a mu-plugin.
View locale_in_multisite.php
<?php
//For setting the multisite language
function sp_modify_locale(){
return 'ja_JP'; //change this
}
add_filter('locale','sp_modify_locale');
add_filter( 'bbpress_locale', 'sp_modify_locale' );
?>
@ronalfy
ronalfy / gravity-forms-disable-autocomplete.php
Last active Mar 28, 2022
Disable autocomplete on the front-end for Gravity Forms
View gravity-forms-disable-autocomplete.php
<?php
add_filter( 'gform_form_tag', 'gform_form_tag_autocomplete', 11, 2 );
function gform_form_tag_autocomplete( $form_tag, $form ) {
if ( is_admin() ) return $form_tag;
if ( GFFormsModel::is_html5_enabled() ) {
$form_tag = str_replace( '>', ' autocomplete="off">', $form_tag );
}
return $form_tag;
}
add_filter( 'gform_field_content', 'gform_form_input_autocomplete', 11, 5 );
@ronalfy
ronalfy / tango_fix_38.php
Created Dec 13, 2013
Tango Smilies Fix for WordPress 3.8
View tango_fix_38.php
function tango_smilies_fixurl($text) {
$siteurl = get_option('siteurl');
$plugurl = plugin_dir_url(__FILE__);
$search = sprintf( '#<img src="%s/wp-includes/images/smilies/#', $siteurl );
$replace = sprintf( '<img src="%stango/', $plugurl );
return preg_replace( $search, $replace, $text );
}
@ronalfy
ronalfy / slash_edit_override_endpoint
Last active Mar 12, 2016
Override Endpoint for Slash Edit WordPress Plugin
View slash_edit_override_endpoint
add_filter( 'slash_edit_endpoint', 'rjh_slash_edit_endpoint' );
function rjh_slash_edit_endpoint( $endpoint ) {
return 'edición'; //ends up as edicion since accents are removed
}
@ronalfy
ronalfy / frizzly-woocommerce-product-feeds.php
Last active Aug 29, 2015
WordPress Frizzly Plugin and WooCommerce Product Feeds
View frizzly-woocommerce-product-feeds.php
<?php
add_action( 'template_redirect', 'rjh_remove_frizzly_content' );
function rjh_remove_frizzly_content() {
if ( isset( $_GET[ 'woocommerce_gpf' ] ) ) {
remove_filter( 'the_content', 'frizzly_the_content_filter' );
remove_filter( 'the_excerpt', 'frizzly_the_excerpt_filter' );
}
}
?>
@ronalfy
ronalfy / minit-jetpack-sharing.php
Last active May 31, 2016
Minit and Jetpack Sharing
View minit-jetpack-sharing.php
<?php
/*
Place code in custom plugin
Get awesome minify plugin (Minit) by Kaspars D. - https://github.com/kasparsd/minit
to work with crazy, but often necessary, Jetpack Sharing - https://wordpress.org/plugins/jetpack/
Written by Ronald Huereca (@ronalfy). Powered by lack of Sleep(TM) and Vodka(R).
*/
@ronalfy
ronalfy / opubco-opt-in-editor-and-updates.php
Created Oct 28, 2014
WordPress - Disable Plugin/Theme Editors and WordPress Updates with Manual Opt-In's by Administrators
View opubco-opt-in-editor-and-updates.php
<?php
//Tested in a theme's functions.php, but not in a plugin
//Allow overriding of editor
class opubco_user_optin {
public function __construct() {
add_action( 'personal_options', array( &$this, 'add_interface' ) );
//User update action
add_action( 'edit_user_profile_update', array( &$this, 'save_user_profile' ) );
@ronalfy
ronalfy / wp-localhost-config.debug.php
Created Oct 29, 2014
WordPress localhost wp-config debug
View wp-localhost-config.debug.php
<?php
//Place in wp-config.php
if ( isset( $_SERVER[ 'REMOTE_ADDR' ] ) && ( '127.0.0.1' == $_SERVER['REMOTE_ADDR'] || '::1' == $_SERVER['REMOTE_ADDR'] ) ) {
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', true );
define( 'SCRIPT_DEBUG', true );
define( 'CONCATENATE_SCRIPTS', false );
}
?>
@ronalfy
ronalfy / localhost.wordpress.php
Created Oct 30, 2014
Know When You're On Localhost - WordPress
View localhost.wordpress.php
<?php
function opubco_localhost() {
// Do check for localhost IP (remove this if you want to ALWAYS display it)
if ( '127.0.0.1' != $_SERVER['REMOTE_ADDR'] && '::1' != $_SERVER['REMOTE_ADDR'] ) {
return;
}
if ( defined( 'WP_DEBUG' ) && WP_DEBUG == true ) {
$debug = 'WP_DEBUG=ON';
} else {
$debug = 'WP_DEBUG=OFF';