Skip to content

Instantly share code, notes, and snippets.

View vanbernaert's full-sized avatar

Kristof Bernaert vanbernaert

  • VAN BERNAERT
  • Europe
View GitHub Profile
@vanbernaert
vanbernaert / gist:7385376
Created November 9, 2013 13:22
wp custom nav. this is also outputting every menu item found in wp, and not only a specific custom menu 'test'. registering or not doesn't make a difference.
<? php
$menu_name = 'test';
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menu_list = '<a>test</a><nav id="bt-menu" class="bt-menu"><ul id="menu-' . $menu_name . '">';
<?php
/**
* Filters the next, previous and submit buttons.
* Replaces the forms <input> buttons with <button> while maintaining attributes from original <input>.
* @param string $button Contains the <input> tag to be filtered.
* @param object $form Contains all the properties of the current form.
* @return string The filtered button.
*/
add_filter( 'gform_next_button', 'input_to_button', 10, 2 );
add_filter( 'gform_previous_button', 'input_to_button', 10, 2 );
<?php
/**
* Filters the next, previous and submit buttons.
* Replaces the forms <input> buttons with <button> while maintaining attributes from original <input>.
* @param string $button Contains the <input> tag to be filtered.
* @param object $form Contains all the properties of the current form.
* @return string The filtered button.
*/
add_filter( 'gform_next_button', 'input_to_button', 10, 2 );
add_filter( 'gform_previous_button', 'input_to_button', 10, 2 );
@vanbernaert
vanbernaert / gist:cfc80b5d702c5d290658
Last active August 29, 2015 14:17
Gravity forms, replace <input type="submit> element with a <button> element
// credits: https://github.com/CFXd
function gf_make_submit_input_into_a_button_element($button_input, $form) {
//save attribute string to $button_match[1]
preg_match("/<input([^\/>]*)(\s\/)*>/", $button_input, $button_match);
//remove value attribute
$button_atts = str_replace("value='".$form['button']['text']."' ", "", $button_match[1]);
return '<button '.$button_atts.'>'.$form['button']['text'].'<i class="fa fa-refresh"></i></button>';
@vanbernaert
vanbernaert / gist:284982c517e54b4a9ef1
Last active August 29, 2015 14:20
Wordpress: do only if page has ancestor
<?php
function has_ancestor($pid)
{
global $post;
$ancestors = get_post_ancestors($post->$pid);
$root = count($ancestors);
if ( $root < 1) { return false; } // set to false in case of no ancestors
$parent = $ancestors[$root];
if(is_page() && (is_page($pid) || $post->post_parent == $pid || in_array($pid, $ancestors)))
{
<div id="selected-filters" class="selected-filters">
<h4><?php _e('Selected filters','rc'); ?>:</h4>
<?php echo facetwp_display('selections'); ?>
<span class="facetwp-reset" onclick="FWP.reset()"><?php _e('reset all filters','rc'); ?></span>
</div>
<html>
<head>
<title>Welcome to Public WiFi</title>
</head>
<body>
<h1>Welcome to Public WiFi</h1>
<?php
$base_grant_url = urldecode($_GET['base_grant_url']);
$user_continue_url = urldecode($_GET['user_continue_url']);
@vanbernaert
vanbernaert / gist:4dd1557abda08e7be90a
Last active November 3, 2015 11:31
Gravity Forms: restrict days on datepicker
jQuery(function () {
// 0 = monday, 1 = tuesday, 2 = wednesday, 3 = thursday,
// 4=friday, 5 = saturday, 6=sunday
var daysToDisable = [2, 4, 5];
jQuery("#input_id_id").datepicker({
beforeShowDay: disableSpecificWeekDays
});
@vanbernaert
vanbernaert / functions.php
Created November 12, 2015 22:07 — forked from wpspeak/functions.php
Add Estimated Post Reading Time in Genesis Framework
<?php
//* Add Estimated Post Reading Time in Genesis Framework using Estimated Post Reading Time plugin
add_filter( 'genesis_post_info', 'afn_post_info_filter' );
function afn_post_info_filter($post_info) {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit] Estimated reading time: [est_time]';
return $post_info;
}