Skip to content

Instantly share code, notes, and snippets.

View gravityforms-date-selection-alt.php
<?php
/**
* Filters radio choices to include the next 14 days
*
* Place in the theme's functions.php file
* @link https://docs.gravityforms.com/dynamically-populating-drop-down-fields/
*/
add_filter( 'gform_pre_render_1', 'populate_dates' );
add_filter( 'gform_pre_validation_1', 'populate_dates' );
add_filter( 'gform_pre_submission_filter_1', 'populate_dates' );
View gravityforms-date-selection.php
<?php
/**
* Filters radio choices to include the next 14 days
*
* Place in the theme's functions.php file
* @link https://docs.gravityforms.com/dynamically-populating-drop-down-fields/
*/
add_filter( 'gform_pre_render_1', 'populate_dates' );
add_filter( 'gform_pre_validation_1', 'populate_dates' );
add_filter( 'gform_pre_submission_filter_1', 'populate_dates' );
@kylephillips
kylephillips / gravityforms-replace-radio-choices-textarea.php
Created Aug 19, 2019
Replace input text elements in the Gravity Forms "choice" editor with textareas, form multi-line values
View gravityforms-replace-radio-choices-textarea.php
add_action( 'gform_editor_js', 'replaceInputsWithTextareas' );
function replaceInputsWithTextareas() {
?>
<script type='text/javascript'>
gform.addAction('gform_load_field_choices', function(field){
field = GetSelectedField();
replaceInputs(field.id)
});
jQuery(document).on('gform_load_field_settings', function(e,field){
setTimeout(function(){
View nestedpages-custom-field-filters.php
add_filter('nestedpages_quickedit_custom_fields', addCustomPageFieldsLeft, 10, 3);
function addCustomPageFieldsLeft($fields, $post_type, $column)
{
if ( $column !== 'left' ) return $fields; // fields may be added to the left and right column
if ( $post_type->name !== 'post-type-name' ) return $fields; // add fields based on post type
$fields = [
[
'key' => 'field_name', // The meta key name
'label' => __('Custom Field', 'wp-nested-pages'), // The label for the field
'type' => 'date', // date|text|select
@kylephillips
kylephillips / nestedpages-query-filter.php
Created Mar 26, 2019
Filter the primary query in Nested Pages
View nestedpages-query-filter.php
add_filter('nestedpages_page_listing', 'nestedpagesQueryFilter');
function nestedpagesQueryFilter($args)
{
$args['post_status'][] = 'custom_post_status';
return $args;
}
View nested-pages-row-action-filters.php
<?php
/**
* For a list of all actions, see wp-nested-pages/app/Entities/PostType/PostTypeRepository, line 97
*/
// Hide/Show the "WPML" link if installed
add_filter('nestedpages_row_action_wpml', 'nestedPagesWpmlLink', 10, 2);
function nestedPagesWpmlLink($include, $post_type)
{
return true;
@kylephillips
kylephillips / nested-pages-hide-add-multiple.php
Created Jun 27, 2018
Hide the "Add Multiple" buttons from non-administrators in Nested Pages
View nested-pages-hide-add-multiple.php
/**
* Place in your theme's functions.php
*/
add_action('admin_head', 'hide_nested_pages_add_multiple');
function hide_nested_pages_add_multiple()
{
$user = wp_get_current_user();
$allowed_roles = ['administrator'];
if ( array_intersect($allowed_roles, $user->roles) ) return;
echo '<style>.open-bulk-modal, .nestedpages .action-buttons .nestedpages-dropdown ul li a.add-new-child, .nestedpages .action-buttons .nestedpages-dropdown ul li:nth-child(2) {display:none;}</style>';
@kylephillips
kylephillips / nested-pages-gutenberg-edit-link.php
Last active Mar 23, 2018
Point the "edit" links in Nested Pages to the Gutenberg editor if installed.
View nested-pages-gutenberg-edit-link.php
@kylephillips
kylephillips / favorites-open-new-window.js
Created Jun 28, 2017
Open a new window after a user has favorited an item (Favorites for WordPress)
View favorites-open-new-window.js
$(document).on('favorites-updated-single', function(event, favorites, post_id, site_id, status){
if ( status === 'inactive' ) return;
window.open("http://yourfavoriteurl.com", '_blank');
});
@kylephillips
kylephillips / favorites-button-css-filter.php
Last active Jul 9, 2019
Favorites for Wordpress: Using the button CSS filter
View favorites-button-css-filter.php
add_filter('favorites/button/css_classes', 'favoriteButtonCss', 10, 3);
function favoriteButtonCss($classes, $post_id, $site_id)
{
$classes .= ' my-custom-class';
return $classes;
}