Skip to content

Instantly share code, notes, and snippets.

@galengidman
galengidman / README.md
Last active June 22, 2017 17:50
Quick-and-dirty plugin that allows you to specify custom search results for specific search queries.

GG Custom Results

Quick-and-dirty plugin that allows you to specify custom search results for specific search queries.

Installation

Move gg-custom-results.php into either the /wp-content/plugins/ or /wp-content/mu-plugins/ directory. If you put it in plugins, you'll need to activate from Plugins menu in the WordPress admin. If you put in mu-plugins, it will be automatically active.

Configuration

You can define your custom search results in wp-config.php. Insert the following just above the line that reads /* That's all, stop editing! Happy blogging. */:

<?php
function gg_asset_url( $path = '' ) {
return esc_url( get_template_directory_uri() . '/assets/' . $path );
}
function gg_asset_path( $path = '' ) {
return get_template_directory() . '/assets/' . $path;
}
@galengidman
galengidman / functions.php
Last active June 1, 2016 12:05
Adding WooCommerce cart link to wp_nav_menu()
<?php
function my_nav_wrap() {
$wrap = '<ul id="%1$s" class="%2$s">';
$wrap .= '%3$s';
$wrap .= '<li class="cart">';
$wrap .= '<a href="' . WC()->cart->get_cart_url() . '"> class="cart_totals">';
$wrap .= WC()->cart->get_cart_total();
$wrap .= '</a>';
$wrap .= '</li>';
function classIfOffset(element, class, offset) {
var scroll = $(window).scrollTop();
if (scroll > offset) {
element.addClass(class);
} else {
element.removeClass(class);
}
}
@galengidman
galengidman / functions.php
Created December 26, 2015 19:07
Convert wp_page_menu() to wp_nav_menu() markup
<?php
$html = wp_page_menu( array(
'echo' => false,
'depth' => 2
) );
$html = str_replace( ' page_item_has_children', ' menu-item-has-children', $html );
$html = str_replace( ' current_page_item', ' current-menu-item', $html );
$html = str_replace( ' page-item-', ' menu-item-', $html );
@galengidman
galengidman / gist:7058364
Last active December 25, 2015 23:39
Returns the page title of the blog posts page as set in Settings → Reading.
function get_posts_page_title() {
if (get_option('show_on_front') == 'page') {
return get_the_title(get_option('page_for_posts'));
}
return false;
}
/**
* Add placeholder attributes to Gravity Form inputs.
*/
function my_standard_settings($position, $form_id) {
if ($position == 25) : ?>
<li class="admin_label_setting field_setting" style="display:list-item;">
<label for="field_placeholder">Placeholder Text
<a href="javascript:void(0);" class="tooltip tooltip_form_field_placeholder" tooltip="&lt;h6&gt;Placeholder&lt;/h6&gt;Enter the placeholder/default text for this field.">(?)</a>
</label>
@galengidman
galengidman / data-placeholder.js
Last active December 10, 2015 13:08
Snippet for data-placeholder powered input and textarea placeholders.
$('[data-placeholder]').focus(function() {
if ($(this).val() == $(this).attr('data-placeholder')) {
$(this).removeClass('inactive');
$(this).val('');
}
});
$('[data-placeholder]').blur(function() {
if ($(this).val() == '') {
$(this).addClass('inactive');
@galengidman
galengidman / .htaccess
Created March 27, 2015 20:27
http → https
# http to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
@galengidman
galengidman / mcd.less
Last active August 29, 2015 14:15
Material Design Color Varaibles
@mdc-red-50: #ffebee;
@mdc-red-100: #ffcdd2;
@mdc-red-200: #ef9a9a;
@mdc-red-300: #e57373;
@mdc-red-400: #ef5350;
@mdc-red-500: #f44336;
@mdc-red-600: #e53935;
@mdc-red-700: #d32f2f;
@mdc-red-800: #c62828;
@mdc-red-900: #b71c1c;