Skip to content

Instantly share code, notes, and snippets.

@ScottDeLuzio
ScottDeLuzio / functions.php
Created October 13, 2017 23:16
Create a task in WP-CRM System programatically
<?php
/*
Plugin Name: WP-CRM System Create Task
Plugin URI: https://www.wp-crm.com
Description: Create a task in WP-CRM System.
Version: 1.0
Author: Scott DeLuzio
Author URI: https://www.wp-crm.com
*/
function wpcrm_system_programmatically_create_task() {
@ScottDeLuzio
ScottDeLuzio / functions.php
Created September 6, 2017 20:16
wpcrm_system_add_calendar_entry
function wpcrm_system_new_calendar_entry( $calendar, $month, $list_day, $year ){
// Display an entry on the calender on December 25th every year.
if ( $month == 12 && $list_day == 25 ){
$calendar .= '<li>Christmas</li>';
}
// Display an entry on the calendar on September 5th 2017
if ( $month == 9 && $list_day == 5 && $year == 2017 ){
$calendar .= '<li>This is a date specific entry</li>';
}
// Display an entry on the calendar on the 15th of every month
@ScottDeLuzio
ScottDeLuzio / functions.php
Last active December 29, 2017 15:13
Add content before your conditional checkout fields for WooCommerce
<?php
function show_before_field_group( $content, $repeat, $field_number ){
return 'This is some <strong>test</strong> info that will show up before each group of fields';
if( $repeat == 1 && $field_number == 2 ){
return 'This is some <strong>test</strong> info will show up only before the first instance of the field with ID 2';
}
}
add_filter( 'cwcfp_before_conditional_field_grouping', 'show_before_field_group', 10, 3 );
function show_before_each_field_id_one( $content, $repeat, $field_number ){
@ScottDeLuzio
ScottDeLuzio / functions.php
Last active June 6, 2017 21:25
Add multiple volume discounts to EDD
<?php
/*
* Our discounts are going to be applied to two products. In this case product IDs 54 & 55. Add/modify the $product_ids array as applicable.
* Both products will get the same tiered discounts but we don't want someone to buy 10 of product 54 and 1 of product 55 and get the discount for product 55.
* So, we need to create separate discounts only if the criteria is met for each product.
* The tiered discount will look like this:
* 10-24 of any single product = 25% discount
* 25-99 of any single product = 33% discount
* 100-249 of any single product = 40% discount
* 250-499 of any single product = 45% discount
@ScottDeLuzio
ScottDeLuzio / functions.php
Last active May 31, 2017 16:51
Add text before input
<?php
function show_content_before_fields(){
$contents = '<h1>Teilnehmer-Daten</h1>';
$contents .= 'Conditional fields here:<br>';
echo $contents;
}
add_action( 'cwcfp_before_checkout_fields', 'show_content_before_fields' );
@ScottDeLuzio
ScottDeLuzio / functions.php
Last active December 29, 2017 15:13
Move Conditional Checkout Fields With WooCommerce Hooks
<?php
/*
* This has not been tested, but should work in theory. Use with care.
*/
/*
* Remove the default WooCommerce Action
* Valid actions include:
* woocommerce_before_checkout_billing_form
* woocommerce_after_checkout_billing_form
@ScottDeLuzio
ScottDeLuzio / mainwp.php
Created January 25, 2017 22:55
mainwp_addsite and mainwp_editsite
// for add child site
$params = array(
'url' => 'http://childsite.com', // child site url
'name' => 'my child site', // set name
'wpadmin' => 'admin-user-name',
'unique_id' => '', // set value if needed
'groupids' => array( ... ), // array of group ids
'ssl_verify' => 0, // or 1, 2
'ssl_version' => 'auto',
'http_user' => '', // set value if needed
@ScottDeLuzio
ScottDeLuzio / stripe.php
Last active January 25, 2024 18:13
Add card to customer account in Stripe
<?php
// Function to add a new card for your customer.
function sd_process_add_customer_card(){
$redirect = false;
if ( isset( $_POST['action'] ) && $_POST['action'] == 'add_customer_card' && wp_verify_nonce( $_POST['stripe_nonce'], 'stripe-nonce' ) ){
if ( !isset( $_POST['card_number'] ) || !isset( $_POST['card_cvc'] ) || !isset( $_POST['card_exp_month'] ) || !isset( $_POST['card_exp_year'] ) ){
$redirect = add_query_arg( array(
'card' => 'not-created',
), $_POST['redirect'] );
// Replace this
function wp_jv_prg_add_rg_meta_box_head() {
add_meta_box('wp_jv_prg_sectionid','WP JV Reading Groups','wp_jv_prg_add_rg_meta_box', 'post','side','high');
add_meta_box('wp_jv_prg_sectionid','WP JV Reading Groups','wp_jv_prg_add_rg_meta_box', 'page','side','high');
}
// With this
function wp_jv_prg_add_rg_meta_box_head() {
$post_types = wp_jv_prg_get_post_types();
@ScottDeLuzio
ScottDeLuzio / wordpress-plugin-svn-to-git.md
Last active September 3, 2016 22:40 — forked from kasparsd/wordpress-plugin-svn-to-git.md
Using Git with Subversion Mirroring for WordPress Plugin Development