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 / has_post_thumbnail_fail.php
Last active July 31, 2022 10:11
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.
<?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 January 21, 2013 14:33
Having trouble getting a language to set across a network? Try running this as a mu-plugin.
<?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 March 28, 2022 19:41
Disable autocomplete on the front-end for Gravity Forms
<?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 December 13, 2013 18:13
Tango Smilies Fix for WordPress 3.8
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 March 12, 2016 14:40
Override Endpoint for Slash Edit WordPress Plugin
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 August 29, 2015 14:08
WordPress Frizzly Plugin and WooCommerce Product Feeds
<?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 13:20
Minit and Jetpack Sharing
<?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 October 28, 2014 21:20
WordPress - Disable Plugin/Theme Editors and WordPress Updates with Manual Opt-In's by Administrators
<?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 October 29, 2014 20:40
WordPress localhost wp-config debug
<?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 October 30, 2014 15:00
Know When You're On Localhost - WordPress
<?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';