This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display a list of the 10 most favorited posts | |
* @see https://wordpress.org/plugins/favorites/ | |
*/ | |
$favorites_query = new WP_Query(array( | |
'post_type' => array('post'), | |
'posts_per_page' => 10, | |
'meta_key' => 'simplefavorites_count', | |
'orderby' => 'meta_value_num', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Using this method, a GET parameter can be passed to the page, enabling a simple locator form to be populated and submitted dynamically. | |
* One use case may exist where the user submits a gravity form, and is redirected to a list of locations without needing to resubmit the simple locator form. | |
* This code would be placed in a page template. | |
*/ | |
// First, we check if a GET parameter named "search" exists. If so, we sanitize it and set it for our use | |
// This could be passed via a link, or through another form submission | |
$location_search = ( isset($_GET['search']) ) ? sanitize_text_field($_GET['search']) : false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( is_user_logged_in() ) : | |
the_favorites_button(); | |
else : | |
// Place any logged-out messaging/JS here | |
?> | |
<p>Please log in to save favorites</p> | |
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Allow a user to email a list of favorites | |
* Place in functions.php and update to suit your specific form and needs | |
* @link https://www.gravityhelp.com/documentation/article/gform_notification/ | |
*/ | |
add_filter( 'gform_notification_1', 'email_favorites_list', 10, 3 ); | |
function email_favorites_list($notification, $form, $entry) | |
{ | |
// Get the user's favorites and create a list | |
$favorites = get_user_favorites(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove Posts from Being Displayed in the Nested Pages List | |
* @param $args - array of WP_Query arguments | |
* @see wp-nested-pages/app/Entities/Listing/Listing: Line 274 | |
*/ | |
add_filter('nestedpages_page_listing', 'remove_from_nested_pages'); | |
function remove_from_nested_pages($args) | |
{ | |
$remove_ids = array(); // Array of Post IDs to exclude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |