Skip to content

Instantly share code, notes, and snippets.

@ramseyp
ramseyp / naked-css-wp.php
Last active Apr 9, 2020
WP snippets for CSS Naked Day
View naked-css-wp.php
<?php
function bk_is_naked_day($d) {
$start = date('U', mktime(-12, 0, 0, 04, $d, date('Y')));
$end = date('U', mktime(36, 0, 0, 04, $d, date('Y')));
$z = date('Z') * -1;
$now = time() + $z;
if ( $now >= $start && $now <= $end ) {
return true;
}
@ramseyp
ramseyp / filter-shared-data.php
Created Feb 12, 2019
filter shared counts data
View filter-shared-data.php
function shared_counts_flipboard_data_properties( $attr, $link ) {
if ( 'flipboard' === $link['type'] ) {
$attr['flip-widget'] = 'shareflip';
}
return $attr;
}
add_filter( 'shared_counts_link_data', 'shared_counts_flipboard_data_properties', 5, 2 );
View test_post_meta.php
<?php
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'custom_loop');
function custom_loop() {
echo '<h1 class="entry-title" itemprop="headline">'.get_the_title().'</h1>';
echo '<div class="clear"></div>';
echo '<div class="singlebio">';
@ramseyp
ramseyp / tmpl_child-pages.php
Created Aug 20, 2014
Genesis child theme custom page template that shows child pages of the current page. Heavily based on: https://gist.github.com/billerickson/3218052
View tmpl_child-pages.php
<?php
/*
Template Name: Custom Loop
*/
remove_action( 'genesis_loop','genesis_do_loop' );
add_action( 'genesis_loop','my_custom_loop' );
function my_custom_loop() {
@ramseyp
ramseyp / rsync command with multiple exclusions
Created May 12, 2014
rsync while excluding multiple directories
View rsync command with multiple exclusions
rsync -arv --exclude="*.git" --exclude=".svn" source/ /destination/
View QandD.css
@media only screen and (max-width: 1139px) {
.site-header .widget-area {
width: 600px;
}
.genesis-nav-menu a {
padding: 40px 7px 20px;
}
View mangled-htaccess
# # BEGIN WordPres<I<IfModule mod_rewrite.cReRewriteEngine OReRewriteBase ReRewriteRule ^index\.php$ - [LReRewriteCond %{REQUEST_FILENAME} !-ReRewriteCond %{REQUEST_FILENAME} !-RewriteRule . /index.php [L]
</IfModule>
# END WordPress
s
@ramseyp
ramseyp / custom_comments.php
Last active Sep 6, 2019
Different ways of customizing the WordPress comment form
View custom_comments.php
<?php
// Customized the comment form fields ( not the comment text area )
add_filter('comment_form_default_fields', 'my_comment_form_args');
// Customizes the text area - you have to do this here, rather than in comment_form_default_fields
add_filter('comment_form_field_comment', 'my_comment_form_field_comment');
// Customized the comment notes above the form fields
add_filter( 'comment_form_defaults', 'my_comment_form_defaults' );
@ramseyp
ramseyp / if_exists.php
Last active Aug 29, 2015
Check to see if something exists before you call some function / class / method in your WordPress functions.php
View if_exists.php
<?php
if ( function_exists( 'function_name' ) ) {
//... do something ...
}
if ( class_exists( 'Class_Name' ) ) {
@ramseyp
ramseyp / custom-jetpack-share.php
Last active Aug 29, 2015
Empty the Jetpack Sharing Label input; localize a script to feed it a custom value, wrapped in a p tag.
View custom-jetpack-share.php
<?php
/**
* If the Jetpack Sharing label setting has a value, remove it.
* If that field is empty, Jetpack Sharing will not output a set of H3 tags with the label.
*
*/
function sharing_label_clear() {
if ( class_exists( 'Sharing_Service' ) ) :