Skip to content

Instantly share code, notes, and snippets.

Avatar

Zack Katz zackkatz

View GitHub Profile
@zackkatz
zackkatz / gravityview-next-prev-entry-nav.php
Last active May 24, 2023 18:28
GravityView - Show Next/Prev Entry Navigation
View gravityview-next-prev-entry-nav.php
<?php
/**
* ::WARNING::
* This is an early work-in-progress!
*
* There are known issues, namely: This works only with no search values for now.
* It supports sorting, but that's pretty much it. It hasn't been thoroughly tested!
* Use at your own risk.
*
* @license GPL-2.0+
@zackkatz
zackkatz / gravityview-filter-by-gravity-flow-assignee.php
Last active March 10, 2023 20:17
GravityView - Filter Entry Notes by Gravity Flow Assignee.
View gravityview-filter-by-gravity-flow-assignee.php
<?php
/**
* GravityView - Filter Entry Notes by Gravity Flow Assignee.
* @license https://opensource.org/license/gpl-2-0/ GPL-2.0
*/
apply_filters( 'gravityview/entry_notes/get_notes', 'filter_gravityview_notes_by_gravity_flow_assignee', 10, 2 );
/**
* Filter the notes by Gravity Flow assignee.
@zackkatz
zackkatz / gv-remote-entry-approval-notes.php
Created March 10, 2023 19:56 — forked from rafaehlers/gv-remote-entry-approval-notes.php
Prevent Entry Approval Notes from displaying on the View
View gv-remote-entry-approval-notes.php
<?php // DO NOT COPY THIS LINE
add_filter( 'gravityview/entry_notes/get_notes', 'gv_remove_entry_approval_notes', 10, 2 );
function gv_remove_entry_approval_notes( $notes, $entry_id ) {
foreach($notes as $key => $note){
if (strpos( $note->value, 'WordPress') !== false){
unset( $notes[ $key] );
}
}
return $notes;
@zackkatz
zackkatz / gv-divi-widgets.php
Last active March 8, 2023 17:50 — forked from rafaehlers/gv-divi-widgets.php
Prevent a Divi-powered theme from disabling GravityView's widgets when the View is embedded in a page
View gv-divi-widgets.php
<?php
/**
* Prevent Divi from using the "Grab the first post image" setting.
*
* It uses et_first_image() which uses apply_filters( 'the_content' ) which causes
* a conflict GravityView, which uses 'the_content' filter.
*
* @param bool $setting Is the setting enabled and the request is not Buddypress?
*
@zackkatz
zackkatz / gravityview-datatables-override-cell-value.php
Created January 31, 2023 17:08
GravityView DataTables - Override cell output based on values
View gravityview-datatables-override-cell-value.php
<?php
/**
* This is an example of modifying the appearance of a cell in DataTables based on the value.
*
* DO NOT USE THIS CODE WITHOUT MODIFICATION.
*
* @license https://www.gnu.org/licenses/gpl-2.0.html GPLv2 or later
*
* @param array $row The entry row HTML to be rendered in DataTables.
@zackkatz
zackkatz / gravityimport-prevent-import-based-on-role.php
Last active November 16, 2022 23:49
GravityImport - Prevent users with the role "editor" from importing entries
View gravityimport-prevent-import-based-on-role.php
/**
* Remove the ability of a user to import entries based on their role.
*
* @param array $caps Array of capabilities required to display the UI.
*
* @return array
*/
add_filter( 'gravityview/import/capabilities', function ( $caps ) {
// REPLACE THIS with the role you want to exclude from importing entries.
@zackkatz
zackkatz / disable-paging-search-and-length.php
Last active September 29, 2022 16:16
GravityView DataTables - Remove the page length, pagination menus, and search field
View disable-paging-search-and-length.php
<?php // DO NOT COPY THIS LINE!!!!!
add_filter( 'gravityview_datatables_js_options', 'gv_dt_disable_paging_search_and_length_menus', 10, 3 );
/**
* Remove the page length, pagination menus, and search field from DataTables
* @param array $dt_config DataTables options
* @param int $view_id View ID
* @param WP_Post $post Current WordPress post object
*
@zackkatz
zackkatz / gravityview-reverse-entry-notes.php
Created July 12, 2022 02:04
GravityView - Reverse the order of Entry Notes
View gravityview-reverse-entry-notes.php
<?php
add_filter( 'gravityview/entry_notes/get_notes', function( $notes ) {
if ( ! $notes ) {
return $notes;
}
return array_reverse( $notes, true );
} );
@zackkatz
zackkatz / gravityview-datatables-prevent-state.php
Created May 27, 2022 19:27
GravityView DataTables - Prevent state saving when refreshing
View gravityview-datatables-prevent-state.php
<?php
add_filter( 'gravityview_datatables_js_options', 'gv_dt_prevent_state_save', 10, 3 );
/**
* Prevent DataTables from saving state between page loads.
* @param array $dt_config DataTables options
* @param int $view_id View ID
* @param WP_Post $post Current WordPress post object
@zackkatz
zackkatz / site_url-shortcode.php
Created March 31, 2022 19:22
Adds a shortcode to return the WordPress site's URL
View site_url-shortcode.php
<?php
// Shortcode for Site URL - Use [site_url] for Shortcode
add_action( 'init', function() {
add_shortcode( 'site_url', function( $atts = null, $content = null ) {
return site_url();
} );
} );