Skip to content

Instantly share code, notes, and snippets.

@linuslundahl
linuslundahl / Ignore .DS_Store forever
Created September 13, 2010 09:55
Make git always ignore .DS_Store
$ git config --global core.excludesfile ~/.gitignore
$ echo .DS_Store >> ~/.gitignore
@scottsweb
scottsweb / gravity-forms-validation.php
Last active March 11, 2024 10:22
Using a Gravity Forms filter to create a custom validation and check for existing UID in already saved entries.
<?php
/***************************************************************
* Function media_custom_validation
* Check the media form for duplicate inputs on the same day
***************************************************************/
add_filter('gform_validation', 'media_custom_validation');
function media_custom_validation($validation_result) {
@jo-snips
jo-snips / custom-date-time-display.php
Created August 22, 2012 02:36
The Events Calendar: Custom Date/Time Display
<?php if (tribe_get_start_date() !== tribe_get_end_date() ) { ?>
<dt class="event-label event-label-start"><?php _e('Starts:', 'tribe-events-calendar') ?></dt>
<dd class="event-meta event-meta-start"><meta itemprop="startDate" content="<?php echo tribe_get_start_date( null, false, 'Y-m-d' ); ?>"/><?php echo tribe_get_start_date( null, false, 'F j, Y' ); ?></dd>
<dt class="event-label event-label-from"><?php _e('From:', 'tribe-events-calendar') ?></dt>
<dd class="event-meta event-meta-from"><meta itemprop="fromTime" content="<?php echo tribe_get_start_date( null, false, 'g:ia' ); ?>"/><?php echo tribe_get_start_date( null, false, 'g:ia' ); ?> to <?php echo tribe_get_end_date( null, false, 'g:ia'); ?></dd>
<?php } else { ?>
<dt class="event-label event-label-date"><?php _e('Date:', 'tribe-events-calendar') ?></dt>
<dd class="event-meta event-meta-date"><meta itemprop="startDate" content="<?php echo tribe_get_start_date( null, false, 'Y-m-d' ); ?>"/><?php echo tribe_get_start_date(); ?></d
@dziudek
dziudek / new_gist_file
Created August 13, 2013 10:35
Change ordering of the sale price and original price in WooCommerce
/**
*
* Code used to change the price order in WooCommerce
*
**/
function PREFIX_woocommerce_price_html( $price, $product ){
return preg_replace('@(<del>.*?</del>).*?(<ins>.*?</ins>)@misx', '$2 $1', $price);
}
@shawnrgrimes
shawnrgrimes / Localhost Wordpress Permissions
Created September 14, 2013 14:33
Enable updating WordPress in a local environment on OS X (Updates, Themes and Plugins)
On Mac OS X (Leopard+), the Apache HTTP Server runs under the user account, _www which belongs to the group _www. To allow WordPress to configure wp-config.php during installation, update files during upgrades, and update the .htaccess file for pretty permalinks, give the server write permission on the files.
One way to do this is to change the owner of the wordpress directory and its contents to _www. Keep the group as staff, a group to which your user account belongs and give write permissions to the group.
$ cd /<wherever>/Sites/<thesite>
$ sudo chown -R _www wordpress
$ sudo chmod -R g+w wordpress
This way, the WordPress directories have a permission level of 775 and files have a permission level of 664. No file nor directory is world-writeable.
@bryanwillis
bryanwillis / debug-atts.php
Last active July 29, 2019 23:52
This allows you to debug all of the known genesis attributes available for filtering. Genesis attributes are used for adding classes, schema.org markup, id's, and any other html attributes to elements. Drop this in your functions.php
<?php
/**
* Debug Genesis Attributes
* @author Bryan Willis
*/
add_action( 'wp_footer', 'debug_genesis_attr_filters' );
function debug_genesis_attr_filters()
{
global $wp_filter; // current_filter() might be a better way to do this
$genesis_attr_filters = array ();
@cartpauj
cartpauj / mepr-plus-invisible-recaptcha.php
Created April 4, 2017 16:19
MemberPress + Invisible Recaptcha plugin integration (untested)
<?php
//Integrates MemberPress with https://wordpress.org/plugins/invisible-recaptcha/
//This is untested code ATM
function add_invisible_recaptcha_mepr_signup($membership_ID) {
?>
<div class="mp-form-row mepr_invisible_recaptcha">
<?php do_action('google_invre_render_widget_action'); ?>
</div>
<?php
}
@FranciscoG
FranciscoG / acf_repeater_shortcode.php
Last active April 18, 2024 00:00
An Advanced Custom Fields shortcode that allows to loop through a field with a repeater. This only handles simple cases, it can't handle nested repeater fields
<?php
/**
* ACF Pro repeater field shortcode
*
* I created this shortcode function because it didn't exist and it was being requested by others
* I originally posted it here: https://support.advancedcustomfields.com/forums/topic/repeater-field-shortcode/
*
* @attr {string} field - (Required) the name of the field that contains a repeater sub group
* @attr {string} sub_fields - (Required) a comma separated list of sub field names that are part of the field repeater group
* @attr {string} post_id - (Optional) Specific post ID where your value was entered. Defaults to current post ID (not required). This can also be options / taxonomies / users / etc