Skip to content

Instantly share code, notes, and snippets.

leepettijohn

Block or report user

Report or block leepettijohn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@leepettijohn
leepettijohn / functions.php
Created Oct 26, 2019
Admin View of Post Type - Add ACF field to column
View functions.php
<?php
/* *** add fields from ACF to columns in admin view ****
https://pluginrepublic.com/add-acf-fields-to-admin-columns/
CHANGE
- manage_model_posts_columns (replace "model" with post type slug)
- manage_model_posts_custom_column (replace "model" with post type slug)
- model_order (replace with ACF slug)
*/
function add_acf_columns ( $columns ) {
return array_merge ( $columns, array (
@leepettijohn
leepettijohn / functions.php
Last active Oct 25, 2019
ACF - Populate Dropdown in Repeater Field - with Post Name and ID
View functions.php
<?php
/*
https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/#example-2
*** CHANGE ***
- child_field (this is the dropdown inside the repeater field)
- post_slug
*/
function acf_pre_populate_repeater_dropdown ( $field ) {
$field['choices'] = array();
$args = array('post_type' => 'post_slug');
@leepettijohn
leepettijohn / functions.php
Last active Oct 19, 2019
Gravity Forms - get value from field in previous page
View functions.php
<?php
// https://docs.gravityforms.com/gform_pre_render/#3-populate-field-with-values-from-earlier-page
add_filter( 'gform_pre_render_8', 'populate_user_dropdown_info' );
add_filter( 'gform_pre_validation_8', 'populate_user_dropdown_info' );
add_filter( 'gform_pre_submission_filter_8', 'populate_user_dropdown_info' );
//add_filter( 'gform_admin_pre_render_8', 'populate_user_dropdown_info' );
function populate_user_dropdown_info( $form ) {
$current_page = GFFormDisplay::get_current_page( $form['id'] );
@leepettijohn
leepettijohn / functions.php
Created Jun 22, 2019
Gravity Forms - Update User Info Meta and Password
View functions.php
add_action( 'gform_post_submission_6', 'update_user_info', 10, 2 );
function update_user_info( $entry, $form ) {
$userid = rgar($entry,'6');
$email = rgar($entry,'5');
$first_name = rgar($entry,'1.3');
$last_name = rgar($entry,'1.6');
$company = rgar($entry,'4');
$address = rgar($entry,'3');
$password = rgar($entry,'7');
$user_id = wp_update_user( array(
@leepettijohn
leepettijohn / functions.php
Created Jun 21, 2019
Gravity Forms - Populate the Name Field from a GET variable which is the user ID
View functions.php
add_filter( 'gform_pre_render_6', 'populate_user_info' );
add_filter( 'gform_pre_validation_6', 'populate_user_info' );
add_filter( 'gform_pre_submission_filter_6', 'populate_user_info' );
add_filter( 'gform_admin_pre_render_6', 'populate_user_info' );
function populate_user_info( $form ) {
$userid = sanitize_text_field($_GET['userid']);
foreach ( $form['fields'] as &$field ) {
if ($field->type == 'name'){
$field->inputs[1]['defaultValue'] = get_first_name($userid);
@leepettijohn
leepettijohn / functions.php
Last active Jun 11, 2019
Gravity Forms - Dropdown populated with posts
View functions.php
// https://docs.gravityforms.com/dynamically-populating-drop-down-fields/
/* Instructions
- Create a form
- Add a "Dropdown" field
- Add "populate-posts" as the CSS class
*/
add_filter( 'gform_pre_render_51', 'populate_posts' );
add_filter( 'gform_pre_validation_51', 'populate_posts' );
@leepettijohn
leepettijohn / functions.php
Created May 19, 2018
Add Widget Area to Non-Genesis Theme
View functions.php
/*** add widget area *** */
register_sidebar( array(
'name' => __( 'New Widget Area'),
'id' => 'new-widget-area',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>'
));
@leepettijohn
leepettijohn / functions.php
Created Apr 6, 2018
Gravity Forms - dynamically populate fields
View functions.php
<?php
/* *** replace "your_parameter" with the parameter in the advanced tab
https://docs.gravityforms.com/using-dynamic-population/ */
add_filter( 'gform_field_value_your_parameter', 'my_custom_population_function' );
function my_custom_population_function( $value ) {
return 'boom!';
}
@leepettijohn
leepettijohn / custom-button-class.php
Created Mar 30, 2018
Add button to tinyMCE editor
View custom-button-class.php
<?php
/**
* Plugin Name: TinyMCE Custom Link Class
* Plugin URI: http://wpbeginner.com
* Version: 1.0
* Author: WPBeginner
* Author URI: http://www.wpbeginner.com
* Resource: http://www.wpbeginner.com/wp-tutorials/how-to-create-a-wordpress-tinymce-plugin/
* Description: A simple TinyMCE Plugin to add a custom link class in the Visual Editor
* License: GPL2
@leepettijohn
leepettijohn / functions.php
Created Jan 9, 2018
Create a zip folder from media
View functions.php
<?
function create_zip_file(){
$zip = new ZipArchive();
$filename = "test114.zip";
if ($zip->open($filename, ZipArchive::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
$zip->addFile($_SERVER['DOCUMENT_ROOT']."/wp-content/uploads/2018/01/Bus-Card-ABC-Domestic-Live-Kelly-Ryan.jpg");
$zip->close();
}
You can’t perform that action at this time.