Skip to content

Instantly share code, notes, and snippets.

View senlin's full-sized avatar

Pieter Bos senlin

View GitHub Profile
@senlin
senlin / language-independent-acf-theme-options-output.php
Last active March 13, 2024 16:00
How to get language independent ACF theme options on a WPML site
<?php
/**
* To get this to work, you need to tinker with the acf/settings/ filter and reset the default language
* so that the get_field() function returns the correct results even when not on the default language.
*
* You can add the filter before you call the get_field() function and then call it again with the current
* language to reset it again, so it will affect other pages.
*
* answer courtesy of James of ACF Support
*/
@senlin
senlin / page-testimonials.php
Created November 30, 2012 01:49
Testimonials Page Example
<?php
/** Template Name: Testimonials */
get_header(); ?>
<div class="page-header">
<h1 class="page-title">
<?php _e( 'Testimonials', 'basejump' ); ?>
</h1>
</div><!-- end .page-header -->
<div <?php post_class(); ?>>
@senlin
senlin / classic-editor-addon.php
Last active February 3, 2019 03:13
Classic Editor Addon by SO WP & Greg Schoppe - Classic Editor plugin doesn't remove Gutenberg by default. With this addon function we set the option that controls this from no-replace to replace, we remove the Settings link from the main Plugins page and we hide the Settings from the Settings > Writing screen. We also suppress the Nag screen tha…
<?php
/**
* Plugin Name: Classic Editor Addon
* Plugin Author: Pieter Bos (https://so-wp.com) and Greg Schoppe (https://gschoppe.com)
* Description: The Classic Editor plugin doesn't remove Gutenberg by default. With this function we set the option that controls this from no-replace to replace and we remove the Settings link from the main Plugins page
*/
function classic_editor_addon_hardcode_replace( $value ) {
return 'replace';
@senlin
senlin / highlighting-wp_nav_menu-ancestor-children-custom-post-types.php
Created December 27, 2012 13:08
Highlight the wp_nav_menu menu item when on a Custom Post Type.
<?php
// The code below finds the menu item with the class "[CPT]-menu-item" and adds another “current_page_parent” class to it.
// Furthermore, it removes the “current_page_parent” from the blog menu item, if this is present.
// Via http://vayu.dk/highlighting-wp_nav_menu-ancestor-children-custom-post-types/
add_filter('nav_menu_css_class', 'current_type_nav_class', 10, 2);
function current_type_nav_class($classes, $item) {
// Get post_type for this post
$post_type = get_query_var('post_type');
@senlin
senlin / contribution-svg.rb
Created September 26, 2018 09:32 — forked from jcouyang/contribution-svg.rb
SVG image for your github contributions calendar
require "nokogiri"
require "open-uri"
url = "https://github.com/#{params['username']}"
document = Nokogiri::HTML(open(url))
contrib_boxes = document.css('svg.js-calendar-graph-svg')[0]
contrib_boxes['xmlns']="http://www.w3.org/2000/svg"
width = (params['width']||54*13-2).to_i
height = (params['height']||89).to_i
contrib_boxes.css('text').remove
contrib_boxes['width']=(width+11).to_s+'px'
<?php
/**
* Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
*
* Preview your Gravity forms on the frontend of your website. Adds a "Live Preview" link to the Gravity Forms toolbar.
*
* Usage
*
* 1 - Enable "Allow field to be populated dynamically" option on field which should be populated.
* 2 - In the "Parameter Name" input, enter the merge tag (or merge tags) of the field whose value whould be populated into this field.
@senlin
senlin / Three Wise Monkeys.md
Last active February 6, 2018 11:34 — forked from malarkey/Three Wise Monkeys.md
Three Wise Monkeys (NDA)

Date: [date]

Between us [company name] and you [customer name].

Summary:

In short; neither of us will share any confidential information about each-other, by any means, with anyone else.

What’s confidential information?

@senlin
senlin / controllers--contact.php
Created January 3, 2018 18:05 — forked from bastianallgeier/controllers--contact.php
Plain contactform example for Kirby 2
<?php
return function($site, $pages, $page) {
$alert = null;
if(get('submit')) {
$data = array(
'name' => get('name'),
@senlin
senlin / icons-social.php
Created October 29, 2011 15:21
Add Facebook, Twitter, Google+ and LinkedIn sharing to your template files with this easy to adapt tempate-part
<?php /*
Name: Social Media Icons Template Part
Description: Add Facebook, Twitter, Google+ and LinkedIn sharing to your template files with this easy to adapt tempate-part
Author: Piet Bos
Author URI: http://wpti.ps
Instructions: Step 1. Take the code from line 10-36 of this file, paste them into a blank file, save that file as icons-social.php and upload it to your theme's directory. On lines 19 and 21 you need to fill in your Twitter username and on line 24 you need to upload your favourite tweet-button (or grab it from http://a2.twimg.com/a/1319826270/images/goodies/tweetn.png) to the images folder of your theme. Step 2. Take line 39 of this file and paste it into your template files on the place where you want the icons to show up. Step 3. Take the scripts of line 42-49 and paste them in your footer.php file just above the closing </body> tag. Step 4. Style through CSS. NOTE that with the code below you will get 4 working share buttons. If you however want to make adjustments then visit the following pa
@senlin
senlin / index.php
Created March 6, 2014 00:25
Custom controls in the theme customizer using WP_Query() instead of query_posts(). Article on http://code.tutsplus.com/articles/custom-controls-in-the-theme-customizer
<div id="posts">
<?php
// Get category ID from Theme Customizer
$catID = get_theme_mod( 'tcx_category' );
// Only get Posts that are assigned to the given category ID
$args = array(
'post_type' => 'post',
'cat' => $catID
);