Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Shelob9 / billing-details-translation.php
Last active April 12, 2022 18:06 — forked from helgatheviking/billing-details-translation.php
Change Billing Details text on free checkout
<?php
add_filter( 'gettext', function( $translated_text, $untranslated_text, $domain ) {
if ( function_exists( 'wc' ) && 'woocommerce' === $domain ) {
//make the changes to the text
switch( $untranslated_text ) {
case 'Billing details':
if ( ! WC()->cart->needs_shipping() && 0.0 === floatval( WC()->cart->get_total( 'edit' ) ) ) {
@Shelob9
Shelob9 / track-entry-id-by-user.php
Created September 13, 2018 14:31 — forked from New0/track-entry-id-by-user.php
Track Caldera Forms entry ID in user meta so form can be used as editor for previous submission https://calderaforms.com/doc/edit-caldera-forms-entries/
<?php
/**
* On form load, check for a saved entry for current user
*/
add_filter( 'caldera_forms_render_entry_id', function ( $entry_id, $form ){
//change form ID to match your form
if( 'CF1234567' == $form[ 'ID' ] && get_current_user_id() ){
$saved_entry_id = get_user_meta( get_current_user_id(), 'form_entry_id', true );
if( 0 < absint( $saved_entry_id ) ){
$entry_id = $saved_entry_id;
@Shelob9
Shelob9 / Hoverable.js
Created September 11, 2018 20:19 — forked from MoOx/Hoverable.js
Hoverable HoC for React components
// @flow
import React, { Component } from "react"
type Props = {
onMouseEnter?: Function | boolean,
onMouseLeave?: Function | boolean,
}
type State = {
@Shelob9
Shelob9 / setup-phpunit.sh
Last active February 28, 2018 17:15 — forked from DevinWalker/setup-phpunit.sh
Setup PHPUnit for use in the Local by Flywheel app
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, git, subversion, composer, curl and wget
#
# WordPress and the WP_UnitTestCase are installed in the /tmp directory
# The $WP_CORE_DIR and $WP_TESTS_DIR variables are added to the .bashrc file
@Shelob9
Shelob9 / setup-phpunit.sh
Last active April 14, 2018 17:03 — forked from DevinWalker/setup-phpunit.sh
Setup PHPUnit for use in the Local by Flywheel app
#!/usr/bin/env bash
# ===============================================================================
# Script to install PHPUnit in the Local by Flywheel Mac app
# These packages are installed
#
# PHPUnit, git, subversion, composer, curl and wget
#
# WordPress and the WP_UnitTestCase are installed in the /tmp directory
# The $WP_CORE_DIR and $WP_TESTS_DIR variables are added to the .bashrc file
@Shelob9
Shelob9 / addon.js
Created February 16, 2018 16:34 — forked from JasonHoffmann/addon.js
Sample filterable block
/**
* This is an example of a script that would hook into the filter or
* subscribe to some sort of data. I want to make the assumption that
* this could be non-ES6 code with no access to the spread operator, so
* something like push would be used instead.
*/
function rkvAddPython( codeList ) {
codeList.push( {
title: 'Python',
codemirror: 'python',
<?php
/**
* Delete one field's value after Caldera Forms sends main mailer
*/
add_action( 'caldera_forms_submit_complete',
function( $form, $referrer, $process_id, $entry_id ){
//IMPORTANT: Change form ID here
$form_id = 'CF123456';
//IMPORTANT: Change field ID here
@Shelob9
Shelob9 / Select.js
Last active December 18, 2019 22:57 — forked from royboy789/Select.react.js
Gutenberg React state example
const { __ } = wp.i18n;
const { Component } = wp.element;
const el = wp.element.createElement;
export default class Select extends Component {
constructor( props ) {
super( ...props );
this.selectCallback = this.selectCallback.bind(this);
this.state = {
@Shelob9
Shelob9 / Input-es5.js
Last active January 24, 2018 22:06 — forked from royboy789/Input.es6.js
Gutenberg React Component
var __ = wp.i18n;
var el = wp.element.createElement;
function Input( className, id, value, label, changeHandler ) {
return el(
'div',
{
className: className
},
[
@Shelob9
Shelob9 / add_caldera_form_to_edit_post.php
Last active December 2, 2017 18:55 — forked from andrewlimaza/add_caldera_form_to_edit_post
Caldera Form example for frontend post creation to show only for admins.
<?php
/**
* Example for front end post edit with Caldera Forms. Use code to show a Caldera Form at the bottom of a single post if user is an Administrator for WordPress.
*/
add_filter( 'the_content', 'show_cf_form_for_admins' );
function show_cf_form_for_admins( $content ) {
if( is_single() && current_user_can( 'edit_posts' ) ){
//change to your form ID you would like to display.
$content .= Caldera_Forms::render_form( 'CF58e4c8ae55fa2' );