Skip to content

Instantly share code, notes, and snippets.

View kamirbarron's full-sized avatar
👠
yes

Korronka kamirbarron

👠
yes
View GitHub Profile
@Shelob9
Shelob9 / caldera_forms_render_field_structure-change-default.php
Created December 22, 2016 17:23
Examples of using the Caldera Forms filter caldera_forms_render_field_structure to modify field display when rednering forms, see: https://calderaforms.com/doc/caldera_forms_render_field_structure/
<?php
/**
* Change the default for a dropdown to "red" if a specific user meta key is set for current user
*/
add_filter( 'caldera_forms_render_field_structure', function( $field_structure, $form ){
//make sure to change field ID to your field's ID here!
//not that $field_structure is not the same as field config, but that is stored in $field_structure[ 'field' ]
if( 0 != get_current_user_id() && 'fld_1234' == $field_structure[ 'field' ][ 'ID' ] ) {
if( 'red' == get_user_meta( get_current_user_id(), 'color', true ) ){
$field_structure[ 'default' ] = 'red';
@simonas-dev
simonas-dev / .adb
Created December 30, 2016 12:02
Android Debug Bridge(adb) alias
function adbc () {
IP=`adb shell ifconfig wlan0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'`
adb tcpip 5555
adb connect $IP
adb devices
}
function adbscr () {
echo "Shoot"
adb shell screencap -p /sdcard/screen.png
<?php
/**
* UI for Example Caldera Forms Processor
*
* Using the UI generator is way simpler than reverse engineering UI markup and provides for better forward-compatibility
*/
echo Caldera_Forms_Processor_UI::config_fields( my_processor_extra_meta_processor_fields() );
@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' );
<?php
/**
* Define the directory with the font via fontDir configuration key.
*/
add_filter( 'dkpdf_mpdf_font_dir', function ( $font_dir ) {
// path to wp-content directory
$wp_content_dir = trailingslashit( WP_CONTENT_DIR );