Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / functions.php
Created June 14, 2021 06:53 — forked from isaumya/functions.php
Attach files with Gravity Forms Notification Emails - Gravity Forms
<?php
//* Attaching file to the form notification user email
//* in gform_notification_7, the number 7 is the FORM ID
//* This snippet works with the newer version of Gravity Forms too
add_filter('gform_notification_7', 'add_attachment_pdf', 10, 3); //target form id 7, change to your form id
function add_attachment_pdf( $notification, $form, $entry ) {
//There is no concept of user notifications anymore, so we will need to target notifications based on other criteria,
//such as name or subject
if($notification["name"] == "User Notification - Life Lesson"){
//get upload root for WordPress
@dexit
dexit / gp-populate-anything-merge-tag-context-modifier.php
Created June 21, 2021 15:39 — forked from spivurno/gp-populate-anything-merge-tag-context-modifier.php
Gravity Perks // Populate Anything // Replace Merge Tags in Specific Context
<?php
/**
* Gravity Perks // Populate Anything // Replace Merge Tags in Specific Context
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* @video https://www.loom.com/share/d626a60769ee48579b6f426a677918a3
*
* This snippet allows you to replace a merge tag in the context of an entry selected in a GPPA-populated field. For
* example, if you populate a Drop Down field with entries and then have an HTML field which includes the {all_fields}
* merge tag, you could use the context modifier to specify that Drop Down field as the context like so:
@dexit
dexit / gp-nested-forms-triggered-population.php
Created June 21, 2021 15:39 — forked from spivurno/gp-nested-forms-triggered-population.php
Gravity Perks // Nested Forms // Add Child Entry on Trigger
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gp-nested-forms/gpnf-triggered-population.php
*/
/**
* Gravity Perks // Nested Forms // Add Child Entry on Trigger
*
* Auto-add a child entry to a Nested Form field, created with data from your parent form. This is useful when wanting
@dexit
dexit / gp-populate-anything-set-current-form-on-duplicate.php
Created June 21, 2021 15:39 — forked from spivurno/gp-populate-anything-set-current-form-on-duplicate.php
Gravity Perks // Populate Anything // Auto-update Form ID on Form Duplication
<?php
/**
* Gravity Perks // Populate Anything // Auto-update Form ID on Form Duplication
* http://gravitywiz.com/documentation/gravity-forms-populate-anything/
*
* When populating Gravity Forms Entries via Populate Anything, it can save time to automatically update the selected
* form ID to the new form ID when duplicating an existing form. To enable on any field, just set the
* "gppa-set-current-form" class on the CSS Class Name setting.
*/
add_action( 'gform_post_form_duplicated', function( $form_id, $new_id ) {
@dexit
dexit / wp-sessions-gf-out-of-the-box.php
Created June 21, 2021 15:39 — forked from spivurno/wp-sessions-gf-out-of-the-box.php
WP Sessions // Gravity Forms Out of the Box // Bed & Breakfast Demo
<?php
/**
* WP Sessions // Gravity Forms Out of the Box // Bed & Breakfast Demo
* http://wpsessions.com/sessions/gravity-forms-out-of-the-box/
* http://gravitywiz.com
*/
add_action( 'init', 'register_bnb_room_post_type', 0 );
function register_bnb_room_post_type() {
@dexit
dexit / gp-populate-anything-force-dyn-pop-on-gv-edit.php
Created June 21, 2021 15:39 — forked from spivurno/gp-populate-anything-force-dyn-pop-on-gv-edit.php
Gravity Perks // Populate Anything // Force Dynamic Population When Editing via Gravity View
<?php
/**
* Gravity Perks // Populate Anything // Force Dynamic Population When Editing via Gravity View
* http://gravitywiz.com/documentation/gravity-forms-populate-anything/
*/
add_filter( 'gravityview/edit_entry/field_value', function( $field_value, $field ) {
// Update "123" to your form ID and "4" to your field ID.
if ( $field->formId == 123 && $field->id == 4 ) {
if ( isset( $GLOBALS['gppa-field-values'] ) ) {
$hydrated_field = gp_populate_anything()->hydrate_field( $field, GFAPI::get_form( $field->formId ), array(), null, false );
@dexit
dexit / functions.php
Created June 22, 2021 07:12 — forked from Tusko/functions.php
WP Ajax search (ACF included)
<?php
/* Wordpress Custom Search by title, ACF, post_meta */
// Wordpress ?s= redirect to /search/
function wpa_search_redirect() {
global $wp_rewrite;
if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) { return; }
$search_base = $wp_rewrite->search_base;
if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false) {
wp_redirect(home_url("/{$search_base}/" . urlencode(get_query_var('s'))));
@dexit
dexit / facetwp 3.8+ dropdowns with chosen()
Created July 28, 2021 02:56 — forked from remcokalf/facetwp 3.8+ dropdowns with chosen()
Fixes for dropdowns facets and sortbox with .chosen() in FacetWP 3.8+ because Facetwp fUtil library does not pick up jQuery.trigger change events from chosen().
(function ($) {
$(document).on('facetwp-loaded', function () {
// Facetwp Dropdowns to chosen dropdows
$('.facetwp-dropdown option:first-child').text('');
$('.facetwp-dropdown').attr('data-placeholder', 'All');
$('.facetwp-dropdown').chosen({disable_search_threshold: 50, allow_single_deselect: true});
// Facetwp Sort box to chosen dropdows
function my_remove_wp_seo_meta_box() {
remove_meta_box('wpseo_meta', YOUR_POST_TYPE_NAME_HERE, 'normal');
}
add_action('add_meta_boxes', 'my_remove_wp_seo_meta_box', 100);
@dexit
dexit / wp-admin-add-posts-state.php
Created September 19, 2021 14:51 — forked from deckerweb/wp-admin-add-posts-state.php
Snippet to add post state to a WordPress page
<?php
//======================================================================
// Add post state to the projects page
//======================================================================
add_filter( 'display_post_states', 'ecs_add_post_state', 10, 2 );
function ecs_add_post_state( $post_states, $post ) {