Skip to content

Instantly share code, notes, and snippets.

Avatar

Theuns Coetzee ipokkel

View GitHub Profile
@ipokkel
ipokkel / make-pot.sh
Last active Apr 4, 2021
Create .pot language template file with WP-CLI. Additionally creates text-domain.po and text-domain.mo files. If previous language files exists gives the user the option to update with --merge option as well as to update all per locale language packs. #translations #localization #i18n #l10n #wordpress
View make-pot.sh
#!/bin/bash -e
# ==============================================================
# Plugin Language File Creator
# Author: Theunis Coetzee (ipokkel)
#
# This file must be placed inside the /plugin-folder/language/ folder
#
# Excecute from plugin root folder with ". languages/make-pot.sh"
# Check if executed from root, if not moves up one folder and
@ipokkel
ipokkel / my-pmpro-directory-widget-sql-parts.php
Created May 13, 2020
Custom SQL query for PMPro Directory Widget that also filters field values stored as arrays
View my-pmpro-directory-widget-sql-parts.php
<?php
function my_pmpro_directory_widget_filter_sql_parts( $sql_parts, $levels, $s, $pn, $limit, $start, $end, $order_by, $order ) {
global $wpdb;
// Filter results based on ares of practice is selected.
if ( ! empty( $_REQUEST['areasofpractice'] ) && is_array( $_REQUEST['areasofpractice'] ) ) {
$sql_parts['JOIN'] .= " LEFT JOIN $wpdb->usermeta um_areasofpractice ON um_areasofpractice.meta_key = 'areasofpractice' AND u.ID = um_areasofpractice.user_id ";
$sql_parts['WHERE'] .= ' AND ( ';
$first_areasofpractice = true;
@ipokkel
ipokkel / change-level-cost-text.php
Created Apr 1, 2021
Change or translate text for PMPro Custom Level Cost Text Add On #pmpro-level-cost-text #translate
View change-level-cost-text.php
<?php
/**
* This recipe is an example of how to change or translate
* localized text strings for PMPro Custom Level Cost Text Add On.
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
@ipokkel
ipokkel / change-advanced-levels-shortcode.php
Last active Apr 1, 2021
Change or translate text for PMPro Advanced Levels Shortcode using gettext filter #pmpro-advanced-levels-shortcode #translate
View change-advanced-levels-shortcode.php
<?php
/**
* This recipe is an example of how to change or translate
* localized text strings for PMPro Advanced Levels Shortcode.
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
@ipokkel
ipokkel / my-pmpro-confirmation-message-example.php
Created Apr 1, 2021
Example code recipe to modify the PMPro confirmation message.
View my-pmpro-confirmation-message-example.php
<?php
/**
* This recipe is an example of customizing the confirmation message displayed on
* the PMPro confirmation page after checkout.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@ipokkel
ipokkel / my-pmpro-account-profile-action-links-removal.php
Created Jul 2, 2020
This recipe can be used to remove the profile action links on the account page. #pmpro
View my-pmpro-account-profile-action-links-removal.php
@ipokkel
ipokkel / my-pmpro-account-profile-action-links.php
Last active Apr 1, 2021
This recipe changes the profile action links on the account page. #pmpro
View my-pmpro-account-profile-action-links.php
@ipokkel
ipokkel / terms-and-conditions.css
Created Jul 6, 2020
Stylize the Terms & Conditons checkbox. #pmpro
View terms-and-conditions.css
/*
Based upon the "Checkbox Hack" article by Chris Coyier - https://css-tricks.com/the-checkbox-hack/
CSS inspired by Geoffrey Crofte - https://codepen.io/GeoffreyCrofte/pen/BiHzp
*/
/* Base for label styling */
#pmpro_tos_checked_div [type="checkbox"]:not(:checked),
#pmpro_tos_checked_div [type="checkbox"]:checked {
position: absolute;
left: -9999px;
@ipokkel
ipokkel / terms-of-service-as-a-link-only.php
Created Jul 6, 2020
Create a a text link to a media file (PDF) for a Terms & Conditions checkbox on checkout. #pmpro #pdf
View terms-of-service-as-a-link-only.php
@ipokkel
ipokkel / my-pmprorh-init-must-love-dogs-example-save-function.php
Created Jul 26, 2020
Custom save-function callback example that will capitalize input string value.
View my-pmprorh-init-must-love-dogs-example-save-function.php
<?php
// Create a registration form field with a custom callback
function my_pmprorh_init_must_love_dogs_example_save_function() {
// don't break if Register Helper is not loaded
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
// define the fields
$fields = array();
// Basic Text Field Example