Skip to content

Instantly share code, notes, and snippets.

View mbootsman's full-sized avatar

Marcel Bootsman mbootsman

View GitHub Profile
@vxnick
vxnick / gist:380904
Created April 27, 2010 15:52
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@billerickson
billerickson / functions.js
Created August 3, 2012 20:23
Gravity Forms labels used as placeholders
jQuery(document).ready(function($){
// gravity forms custom placeholders
$('#inner li.gfield .gfield_label').click(function(){
$(this).next('.ginput_container').find('input[type="text"], textarea').focus();
})
$('#inner .ginput_container input[type="text"], #inner .ginput_container textarea')
.focus(function(){
$(this).closest('.ginput_container').prev('.gfield_label').hide();
@kingkool68
kingkool68 / rh-get-widget-data-for-all-sidebars.php
Last active February 15, 2021 03:51
WordPress function to get raw widget data for all of the widgets in a given sidebar
<?php
function rh_get_widget_data_for_all_sidebars() {
global $wp_registered_sidebars;
$output = array();
foreach ( $wp_registered_sidebars as $sidebar ) {
if ( empty( $sidebar['name'] ) ) {
continue;
}
$sidebar_name = $sidebar['name'];
@grtaylor2
grtaylor2 / Change Read More Text Genesis WordPress
Last active August 11, 2021 19:53
Change the [Read More] Text in Genesis WordPress Child Theme
/** Customize Read More Text */
add_filter( 'excerpt_more', 'child_read_more_link' );
add_filter( 'get_the_content_more_link', 'child_read_more_link' );
add_filter( 'the_content_more_link', 'child_read_more_link' );
function child_read_more_link() {
return '<a href="' . get_permalink() . '" rel="nofollow">CUSTOMIZE YOUR TEXT HERE</a>';
}
@murdaugh
murdaugh / copy post to blog function
Created October 3, 2013 20:11
Copies a post (as well as its associated meta data) from one wordpress blog to another on the same network.
<?php
function copy_post_to_blog($post_id, $target_blog_id) {
$post = get_post($post_id, ARRAY_A); // get the original post
$meta = get_post_meta($post_id);
$post['ID'] = ''; // empty id field, to tell wordpress that this will be a new post
switch_to_blog($target_blog_id); // switch to target blog
$inserted_post_id = wp_insert_post($post); // insert the post
foreach($meta as $key=>$value) {
update_post_meta($inserted_post_id,$key,$value[0]);
}
@mannieschumpert
mannieschumpert / gist:8334811
Last active August 20, 2023 14:58
Filter the submit button in Gravity Forms to change the <input type="submit> element to a <button> element. There's an example in the Gravity Forms documentation, but it lacks the proper code to show your custom button text, AND removes important attributes like the onclick that prevents multiple clicks. I was trying to solve that.
<?php
// filter the Gravity Forms button type
add_filter("gform_submit_button", "form_submit_button", 10, 2);
function form_submit_button($button, $form){
// The following line is from the Gravity Forms documentation - it doesn't include your custom button text
// return "<button class='button' id='gform_submit_button_{$form["id"]}'>'Submit'</button>";
// This includes your custom button text:
return "<button class='button' id='gform_submit_button_{$form["id"]}'>{$form['button']['text']}</button>";
}
// Oops this strips important stuff
@spivurno
spivurno / gw-gravity-forms-unrequire-required-fields-usage.php
Last active June 13, 2022 20:04
Gravity Wiz // Gravity Forms Unrequire Required Fields for Speedy Testing
<?php
# Basic Usage
# requires that the user be logged in as an administrator and that a 'gwunrequire' parameter be added to the query string
# http://youurl.com/your-form-page/?gwunrequire=1
new GWUnrequire();
# Enable for All Users (Including Visitors)
# still requires the 'gwunrequire' parameter be added to the query string
new GWUnrequire( array(
@nielsvr
nielsvr / posts.php
Created October 14, 2014 18:35
Get posts starting with a letter
<?php
add_filter( 'posts_where', 'start_with_letter', 10, 2 );
function start_with_letter( $where, &$wp_query )
{
global $wpdb;
if ( $start_with_letter = $wp_query->get( 'start_with_letter' ) ) {
$where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'' . esc_sql( like_escape( $start_with_letter ) ) . '%\'';
}
@eteubert
eteubert / wordpress-passwort-reset-unmultisite.php
Last active April 15, 2024 20:45
Multisite: Passwort Reset on Local Blog
<?php
/**
* Plugin Name: Multisite: Passwort Reset on Local Blog
* Plugin URI: https://gist.github.com/eteubert/293e07a49f56f300ddbb
* Description: By default, WordPress Multisite uses the main blog for passwort resets. This plugin enables users to stay in their blog during the whole reset process.
* Version: 1.0.0
* Author: Eric Teubert
* Author URI: http://ericteubert.de
* License: MIT
*/
@BjornW
BjornW / canned-linkedin-connection-request-response.txt
Last active February 3, 2024 05:54
Canned LinkedIn Connection Request reponse
Hi,
Thanks for your interest on connecting via LinkedIn.
Sadly your LinkedIn Connection Request contains just the plain default LinkedIn Connection request text without any context, personal touch or proper introduction. Therefore I assume this LinkedIn Connection Request was written by an automated algorithm and thus has been declined.
Bye!
PS: For any humans reading this, please communicate in a human-friendly way and I will respond accordingly.