-
-
Save anonymous/5ab95c40fb5e65048296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: My Custom Functions | |
* Plugin URI: http://moneypantry.com | |
* Description: This is an awesome custom plugin with functionality that I'd like to keep when switching things. These are WordPress specific functions. Theme specific functions go to themes own function.php file. | |
* Author: Satrap | |
* Author URI: http://moneypantry.com | |
* Version: 0.1.0 | |
*/ | |
/* ######################### PLACE CUSTOM CODE BELOW THIS LINE ################################ */ | |
// Add new image sizes | |
add_image_size ( 'smallthumb', 72, 72, TRUE ); | |
//* Begin rel="nofollow" for Comment Reply | |
function custom_comment_reply_link_nofollow( $link ) { | |
global $user_ID; | |
# Registration required login link is already nofollowed | |
if ( get_option( 'comment_registration' ) && ! $user_ID ) | |
return $link; | |
# Add nofollow otherwise | |
else | |
return str_replace( '")\'>', '")\' rel=\'nofollow\'>', $link ); | |
} | |
add_filter( 'comment_reply_link', 'custom_comment_reply_link_nofollow' ); | |
//* Begin prevent the category widget from using the category description as the list item title attribute | |
function sjc_disable_cat_desc_widget_list_titles ( $cat_args ) { | |
$cat_args[ 'use_desc_for_title' ] = 0; | |
return $cat_args; | |
} | |
add_filter( 'widget_categories_args', 'sjc_disable_cat_desc_widget_list_titles' ); | |
//* Begin Customize The Comment Form | |
add_filter( 'comment_form_defaults', 'moneypantry_custom_comment_form' ); | |
function moneypantry_custom_comment_form($fields) { | |
$fields['comment_notes_before'] = ''; //Removes Email Privacy Notice | |
$fields['title_reply'] = __( 'Comment:', 'customtheme' ); //Changes The Form Headline | |
$fields['label_submit'] = __( 'Share My Comment', 'customtheme' ); //Changes The Submit Button Text | |
$fields['comment_notes_after'] = ''; //Removes Form Allowed Tags Box | |
return $fields; | |
} | |
//* Begin Customize the post info function | |
add_filter( 'genesis_post_info', 'post_info_filter' ); | |
function post_info_filter($post_info) { | |
if (!is_page()) { | |
$post_info = '<span style="font-size:12px;">Last updated on: ' .the_modified_date('F j, Y', '', '', false); | |
return $post_info; | |
}} | |
//* Begin Customize the credits | |
add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' ); | |
function sp_footer_creds_text() { | |
echo '<div class="creds"><p>'; | |
echo ' | |
<span style="color:#A9A9A9;"><span style="font-size: 12px;">Copyright © 2013-2014 MoneyPantry.com. All Rights Reserved.</br> | |
<a title="Follow Us On Twitter!" href="https://twitter.com/MoneyPantry" target="_blank">Twitter</a> | <a title="Circle Us On Google+!" href="https://google.com/+Moneypantry" target="_blank" rel="publisher">Google+</a> | <a title="Like Us On Facebook!" href="https://www.facebook.com/MoneyPantry" target="_blank">Facebook</a> | |
</br> | |
All product names, logos, and brands are property of their respective owners, and are in no way associated or affiliated with moneypantry.com.</span></span>'; | |
echo '</p></div>'; | |
} | |
//* Begin Display related posts in Genesis based on Category | |
add_action( 'genesis_after_entry', 'child_related_posts' ); | |
function child_related_posts() { | |
if ( is_single ( ) ) { | |
global $post; | |
$count = 0; | |
$postIDs = array( $post->ID ); | |
$related = ''; | |
$tags = wp_get_post_tags( $post->ID ); | |
$cats = wp_get_post_categories( $post->ID ); | |
if ( $count <= 4 ) { | |
$catIDs = array( ); | |
foreach ( $cats as $cat ) { | |
if ( 3 == $cat ) | |
continue; | |
$catIDs[] = $cat; | |
} | |
$showposts = 4 - $count; | |
$args = array( | |
'category__in' => $catIDs, | |
'post__not_in' => $postIDs, | |
'showposts' => $showposts, | |
'ignore_sticky_posts' => 1, | |
'orderby' => 'rand', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'post_format', | |
'field' => 'slug', | |
'terms' => array( | |
'post-format-link', | |
'post-format-status', | |
'post-format-aside', | |
'post-format-quote' ), | |
'operator' => 'NOT IN' | |
) | |
) | |
); | |
$cat_query = new WP_Query( $args ); | |
if ( $cat_query->have_posts() ) { | |
while ( $cat_query->have_posts() ) { | |
$cat_query->the_post(); | |
$img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />'; | |
$related .= '<li><a href="' . get_permalink() . '" rel="bookmark">' . $img . get_the_title() . '</a></li>'; | |
} | |
} | |
} | |
if ( $related ) { | |
printf( '<div class="related-posts"><h3 class="related-title">Related Resources</h3><ul class="related-list">%s</ul></div>', $related ); | |
} | |
wp_reset_query(); | |
} | |
} | |
// lets hide the cat description from the category admin page | |
function removecategorydescrption($columns) | |
{ | |
// only edit the columns on the current taxonomy | |
if ( !isset($_GET['taxonomy']) || $_GET['taxonomy'] != 'category' ) | |
return $columns; | |
// unset the description columns | |
if ( $posts = $columns['description'] ){ unset($columns['description']); } | |
return $columns; | |
} | |
add_filter('manage_edit-category_columns','removecategorydescrption'); | |
/* ######################### PLACE CUSTOM CODE ABOVE THIS LINE ################################ */ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment