Skip to content

Instantly share code, notes, and snippets.

View kamirbarron's full-sized avatar
👠
yes

Korronka kamirbarron

👠
yes
View GitHub Profile
<?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 );
@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
/**
* 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() );
@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
@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';
<?php
add_filter( 'caldera_forms_render_get_field', function( $field ) {
if( 'fld123456' == $field[ 'ID' ] ){
$field[ 'config' ][ 'default' ] = esc_url_raw( caldera_forms_get_current_url() );
}
return $field;
});
@Shelob9
Shelob9 / caldera-forms-entry-viewer-and-form-in-content
Last active September 18, 2020 08:23
Examples of how to show the Caldera Forms entry viewer in the front end of your WordPress site. See: https://calderaforms.com/doc/caldera-forms-wordpress-form-entry-viewer/
<?php
add_filter( 'the_content', function( $content ){
$post = get_post();
if( 42 ===$post->ID ){
$form = 'cf1234567';
$content .= Caldera_Forms::render_form( $form );
$content .= Caldera_Forms_Entry_Viewer::form_entry_viewer_2( $form );
}
});
<?php
namespace App;
class WpApi {
protected static $url = 'https://calderaforms.com/wp-json/wp/v2/';
public static function getPost(int $id )
@Shelob9
Shelob9 / cdn-jquery.php
Last active April 6, 2023 10:52
Replace WordPress' jQuery with CDN jQuery of the right version
add_action( 'init', function(){
if ( ! is_admin()) {
if( is_ssl() ){
$protocol = 'https';
}else {
$protocol = 'http';
}
/** @var WP_Scripts $wp_scripts */
global $wp_scripts;
@Shelob9
Shelob9 / functions.php
Created June 28, 2016 18:13 — forked from mathetos/functions.php
Custom Autopopulate Dropdown for CalderaForms
add_filter( 'caldera_forms_autopopulate_options_post_value_field', 'givewp_customer_addon_purchases', 24, 2 );
function givewp_customer_addon_purchases()
{
$current_user = wp_get_current_user();
$purchases = edd_get_users_purchases($current_user->user_email, 100, false, 'any');
if ( $purchases ) {
foreach ($purchases as $purchase) {
$licenses = edd_software_licensing()->get_licenses_of_purchase( $purchase->ID );