Skip to content

Instantly share code, notes, and snippets.

View eugenoprea's full-sized avatar

Eugen Oprea eugenoprea

View GitHub Profile
@eugenoprea
eugenoprea / functions.php
Created February 3, 2013 01:42
Genesis - How to Display Custom Taxonomy Terms - Helper Function
/**
* Returns the given number of terms from the specified taxonomies (for the current post).
*
* @param (string|array) $taxonomies The taxonomy(es) to retrieve terms from
* @param (int) $term_number Limit the number of terms returned (-1 for no limit)
* @param (bool) $term_links Whether to return links to term archives or not
* @param (string) $separator String that will be used as the terms separarator
* @return (string) The list of taxonomy terms for the current post or empty string
*/
function eo_get_tax_terms($taxonomies, $term_number = -1, $term_links = true, $separator = ', ')
@eugenoprea
eugenoprea / functions.php
Created February 3, 2013 01:44
Genesis - How to Display Custom Taxonomy Terms - Display Taxonomy Terms
// taxonomy terms will be displayed after the post content (notice the priority of 50)
add_action ('genesis_post_content', 'eo_display_taxonomy_terms', 50);
function eo_display_taxonomy_terms()
{
// replace with the slugs of your custom taxonomies
$taxonomy1 = 'taxonomy1';
$taxonomy2 = 'taxonomy2';
$other_taxonomies = array('taxonomy3', 'taxonomy4');
// display all terms from the first taxonomy separated by commas, with each term linking to that term's archive page
@eugenoprea
eugenoprea / .htaccess
Created February 3, 2013 01:46
Default WordPress .htaccess for "Pretty" permalinks
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
@eugenoprea
eugenoprea / functions.php
Last active December 8, 2022 11:37
Gravity Forms - Checkbox Dynamic Population
// When true, the form will be saved to DB after dynamic population
define('EO_SAVE_FORM_ON_PRE_RENDER', true);
// Adds a filter to form id 7. Replace 26 with your actual form id
add_filter('gform_pre_render_7', 'eo_populate_checkbox');
add_filter('gform_admin_pre_render_7', 'eo_populate_checkbox');
function eo_populate_checkbox($form) {
if (EO_SAVE_FORM_ON_PRE_RENDER)
@eugenoprea
eugenoprea / functions.php
Last active December 12, 2015 02:38
Genesis - Custom Post Class
// Add custom post class to posts in the "Featured" category
add_filter('post_class', 'eo_custom_post_class');
function eo_custom_post_class($classes)
{
$new_class = 'featured-post';
if (in_category('Featured'))
$classes[] = esc_attr(sanitize_html_class($new_class));
return $classes;
}
@eugenoprea
eugenoprea / functions.php
Created February 3, 2013 01:57
Genesis - How to Change Text Shown When No Posts Are Found
/** Change Text Shown When No Posts Are Found */
add_filter('genesis_noposts_text', 'eo_noposts_text');
function eo_noposts_text($text)
{
$text = '<span class="noposts-text">' . __('Your request did not return any results, please check back later.', 'eo') . '</span>';
return $text;
}
@eugenoprea
eugenoprea / functions.php
Created February 3, 2013 02:00
Genesis - How to Change Header Link/URL
/** Modify the header URL */
add_filter('genesis_seo_title', 'eo_set_header_url');
function eo_set_header_url($title, $inside, $wrap)
{
$blog_name = get_bloginfo('name');
$header_url = user_trailingslashit('http://www.eugenoprea.com');
$inside = sprintf('<a title="%s" href="%s">%s</a>', $header_url, esc_attr($blog_name), $blog_name);
$title = sprintf('<%1$s id="title">%2$s</%1$s>', $wrap, $inside);
return $title;
(function(a){a.isScrollToFixed=function(b){return a(b).data("ScrollToFixed")!==undefined};a.ScrollToFixed=function(d,h){var k=this;k.$el=a(d);k.el=d;k.$el.data("ScrollToFixed",k);var c=false;var F=k.$el;var G;var D;var p;var C=0;var q=0;var i=-1;var e=-1;var t=null;var y;var f;function u(){F.trigger("preUnfixed.ScrollToFixed");j();F.trigger("unfixed.ScrollToFixed");e=-1;C=F.offset().top;q=F.offset().left;if(k.options.offsets){q+=(F.offset().left-F.position().left)}if(i==-1){i=q}G=F.css("position");c=true;if(k.options.bottom!=-1){F.trigger("preFixed.ScrollToFixed");w();F.trigger("fixed.ScrollToFixed")}}function m(){var H=k.options.limit;if(!H){return 0}if(typeof(H)==="function"){return H.apply(F)}return H}function o(){return G==="fixed"}function x(){return G==="absolute"}function g(){return !(o()||x())}function w(){if(!o()){t.css({display:F.css("display"),width:F.outerWidth(true),height:F.outerHeight(true),"float":F.css("float")});F.css({width:F.width(),position:"fixed",top:k.options.bottom==-1?s():"",bottom:k
@eugenoprea
eugenoprea / functions.php
Last active December 12, 2015 03:28
Add Cloud Box scripts to footer
/** Add Cloud Box scripts to footer */
function eo_add_scripts_to_footer() {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-scrolltofixed', get_stylesheet_directory_uri() . '/js/jquery-scrolltofixed-min.js', array('jquery'), '', true);
}
add_action('wp_enqueue_scripts', 'eo_add_scripts_to_footer');
function eo_add_extra_script_to_footer() {
?>
<script>
@eugenoprea
eugenoprea / sidebar-widget
Created February 4, 2013 13:55
Sample code for your Cloud Box text widget
<div id="sidebar-cloud-box">
<a href="http://www.getelevatr.com/" target="_blank"><img src="http://www.eugenoprea.com/wp-content/uploads/2012/12/270x250.png" title="Elevatr - Start Building your Email List Today"/></a>
</div>