Skip to content

Instantly share code, notes, and snippets.

View espiat's full-sized avatar
🎯
Focusing

DER SPANIER espiat

🎯
Focusing
View GitHub Profile
@espiat
espiat / .gitignore
Created June 23, 2021 12:17 — forked from salcode/.gitignore
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@espiat
espiat / gist:cf1a115229b3f09523f300d62c317eef
Created January 23, 2021 17:56 — forked from woogist/gist:5692886
Sample WooCommerce Points & Rewards 3rd Party Plugin Integration
<?php
// Add the action setting
add_filter( 'wc_points_rewards_action_settings', 'points_rewards_newsletter_action_settings' );
function points_rewards_newsletter_action_settings( $settings ) {
$settings[] = array(
'title' => __( 'Points earned for newsletter signup' ),
'desc_tip' => __( 'Enter the amount of points earned when a customer signs up for a newsletter via MailChimp.' ),
@espiat
espiat / pdo.php
Last active October 14, 2020 20:01 — forked from cp6/pdo_examples.php
PHP PDO MySQL / Maria DB cheat sheet
<?php
//Create connection
try{
$db = new PDO('mysql:host=localhost;dbname=DATABASENAME;charset=utf8mb4', 'USERNAME', 'PASSWORD');
}
catch (PDOException $e) {
echo $e->getMessage();
die('PDO Fehler!');
}
@espiat
espiat / random-repeater.php
Created April 3, 2019 15:22 — forked from wesrice/random-repeater.php
Return a random row of data from an ACF repeater field
<?php
// Get the repeater field
$repeater = get_field( 'repeater_field_name' );
// Get a random rows. Change the second parameter in array_rand() to how many rows you want.
$random_rows = array_rand( $repeater, 2 );
// Loop through the random rows if more than one is returned
if( is_array( $random_rows ) ){
<?php
/**
* Set a max length attribute for all paragraph fields in Caldera Forms
*/
add_filter( 'caldera_forms_field_attributes-paragraph', function( $attrs ){
$attrs[ 'maxlength' ] = 255;
return $attrs;
});