Skip to content

Instantly share code, notes, and snippets.

View polevaultweb's full-sized avatar

Iain Poulson polevaultweb

View GitHub Profile
<?php
add_filter( 'ninja_forms_i18n_front_end', 'my_custom_ninja_forms_i18n_front_end' );
function my_custom_ninja_forms_i18n_front_end( $strings ) {
$strings['validateRequiredField'] = 'this is my required field text';
return $strings;
}
<?php
add_filter( 'igp_post_title', 'my_igp_post_title' );
function my_igp_post_title( $title ) {
return $title . '...';
}
@polevaultweb
polevaultweb / deploy.sh
Last active March 31, 2020 02:51
Deploy script for Travis CI to deploy a WordPress plugin to the repository
#!/usr/bin/env bash
if [[ -z "$TRAVIS" ]]; then
echo "Script is only to be run by Travis CI" 1>&2
exit 1
fi
if [[ -z "$WP_ORG_PASSWORD" ]]; then
echo "WordPress.org password not set" 1>&2
exit 1
@polevaultweb
polevaultweb / local_travis.sh
Last active November 28, 2016 20:03
Recreate Travis build in local docker container
#!/bin/bash
docker run -it quay.io/travisci/travis-php /bin/bash
su - travis
git clone https://github.com/deliciousbrains/mergebot-plugin.git
npm install -g grunt-cli
gem update --system && gem install compass
export WP_ORG_PASSWORD=1234
composer self-update
cd mergebot-plugin
<?php
add_filter( 'mergebot_excluded_queries', 'my_excluded_queries');
function my_excluded_queries( $queries ) {
$my_queries = array(
'WHERE `option_name` = \'duplicate_post_version',
'VALUES \(\'duplicate_post_version',
);
return array_merge( $queries, $my_queries );
<?php
add_filter( 'igp_post_title', 'my_igp_post_title' );
function my_igp_post_title( $title ) {
$delimiter = '||';
$title_parts = explode( $delimiter , $title );
return $title_parts[0;
}
<?php
class Custom_NF_FU_Integrations_NinjaForms_MergeTags {
/**
* Custom_NF_FU_Integrations_NinjaForms_MergeTags constructor.
*/
public function __construct() {
add_filter( 'ninja_forms_merge_tag_value_' . NF_FU_File_Uploads::TYPE, array( $this, 'merge_tag_value' ), 10, 2 );
}
@polevaultweb
polevaultweb / first_tag.php
Created January 21, 2017 14:48
Add this template tag to your content where you want to output the first hashtag %%caption-no-usernames%%
<?php
add_filter( 'igp_template_caption_no_usernames', 'my_igp_template_first_hashtag' );
function my_igp_template_first_hashtag( $caption ) {
if ( empty( $caption ) ) {
return $caption;
}
$parts = explode( "#", $caption );
<?php
$form_data = false;
if( isset( $_POST['formData'] ) ) {
$form_data = json_decode( $_POST['formData'], TRUE );
if( ! $form_data ) {
$this->_form_data = json_decode( stripslashes( $_POST['formData'] ), TRUE );
}
}
<?php
add_filter( 'ninja_forms_uploads_dir', 'my_ninja_forms_uploads_dir' );
function my_ninja_forms_uploads_dir( $path ) {
if ( substr( $path, -3) === 'tmp' ) {
return $path;
}
return str_replace( '/ninja-forms', '/', $path );
}