Skip to content

Instantly share code, notes, and snippets.

View kylephillips's full-sized avatar

Kyle Phillips kylephillips

  • Atlanta, Georgia
View GitHub Profile
<?php
// Place this in functions.php
add_filter('nestedpages_default_submenu_text', 'defaultPagesText', 10, 2);
function defaultPagesText($text, $post_type)
{
return ( $post_type->name == 'page' ) ? 'WordPress Pages' : $text;
}
@kylephillips
kylephillips / block-animations-allowed-blocks-filter.js
Created June 21, 2022 21:09
Apply a JS filter to the allowed blocks in wp-block-animations plugin
/**
* In this example, we're adding a custom "acf/carousel" block to the array of supported block types for block animations
* We've added this JS file to the script dependencies required by the plugin, using the wp_block_animations_script_dependencies hook.
* Additionally, when enqueueing this file, we've added `wp-hooks` as a dependency to ensure the global object is available
*/
wp.hooks.addFilter(
'wp_block_animations_allowed_blocks',
'allowed_blocks',
addCustomBlockAnimations
<?php
add_filter('wp_block_animations_script_dependencies', 'blockAnimationDependencies);
/**
* We are adding our custom script containing our addFilter reference to the plugin dependencies.
* This way, we ensure the plugin scripts run after we add our filter
*/
function blockAnimationDependencies($deps)
{
$deps[] = 'custom-script-handle';
<?php
add_filter('nestedpages_row_parent_css_classes', 'nestedpages_filter_row_css_classes', 10, 3);
/**
* Filter the <li> element css classes for nested pages rows
* @param str - $row_classes - the CSS classes for output
* @param obj - $post - the current post object
* @param obj - $post_type_object - the current post type object
*/
function nestedpages_filter_row_css_classes($row_classes, $post, $post_type_object)
{
<?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' );
<?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 August 19, 2019 21:31
Replace input text elements in the Gravity Forms "choice" editor with textareas, form multi-line values
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(){
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 March 26, 2019 19:55
Filter the primary query in Nested Pages
add_filter('nestedpages_page_listing', 'nestedpagesQueryFilter');
function nestedpagesQueryFilter($args)
{
$args['post_status'][] = 'custom_post_status';
return $args;
}