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 | |
/** | |
* Recover or Reset the default WordPress user roles and caps | |
* Install it as a WordPress plugin, activate it and deativate. That's it. | |
* | |
* @wordpress-plugin | |
* Plugin Name: tinyGod Recover User Roles | |
* Plugin URI: | |
* Author: luistinygod | |
* Author URI: https://tinygod.pt |
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 | |
/** | |
* Redirect the visitor to the single entry view after updating the entry | |
*/ | |
function my_gv_redirect_after_update_to_single_entry_view( $form, $entry_id ) { | |
?> | |
<script> | |
jQuery(document).ready( function() { | |
window.location.replace( window.location.href.split('?')[0] ); | |
}); |
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 | |
/** | |
* When using the Advanced Filter extension to filter entries to show just the ones created by the user logged-in | |
* BUT remove the restriction to a certain role of users ( administrators or editors ) | |
* | |
* Replace the following to your own values: | |
* - REPLACE_BY_VIEW_ID, use the view id where this logic applies | |
* - REPLACE_BY_THE_ROLE, use 'administrator' or 'editor' or your own custom role | |
* |
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 | |
/** Modify the content returned from the Custom Content field */ | |
add_filter( 'gravityview/fields/custom/content_before', 'my_gv_custom_content_before', 10, 1 ); | |
/** | |
* Removes the custom content field's content in case a certain entry field is empty | |
* Replace the MY_FIELD_ID by the field id (check it on the Gravity Forms form definition) | |
* | |
* @param string $content Custom Content field content | |
* @return string |
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 | |
/** | |
* Add the `gv-grid` class to the list container | |
*/ | |
function my_gv_list_container( $classes ) { | |
return $classes . ' gv-grid'; | |
} | |
add_filter( 'gravityview/render/container/class', 'my_gv_list_container', 10, 1 ); | |
/** |
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 | |
/** | |
* Retrieve a WP_Query object | |
*/ | |
function my_complex_query( $refresh = false ) { | |
$last_changed = wp_cache_get_last_changed( 'my_group_my_post_type' ); | |
$cache_key = 'my_result'.md5( $param1 . $param2 ).$last_changed; | |
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
const persistInterval = 24*60*60*1000; // 1 day | |
const plugin = store => { | |
store.subscribe( ( mutation, state ) => { | |
// Save to local storage all the changes made in the cart state | |
if( 'shop/addToCart' === mutation.type || 'shop/removeFromCart' === mutation.type ) { | |
let record = { data: state.shop.cart, ts: new Date().getTime() + persistInterval }; | |
try { |
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 | |
/** | |
* Get the featured posts for a specific menu location | |
* | |
* @param string $theme_location As defined in the register_nav_menus call | |
* | |
* @return array|bool|mixed Array of Post IDs | |
*/ | |
function my_theme_get_featured_posts( $theme_location = '' ) { | |
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 | |
/** Modify the content returned from the Custom Content field */ | |
add_filter( 'gravityview/fields/custom/content_before', 'my_gv_custom_content_before', 10, 1 ); | |
/** | |
* Replaces the %CALC% placeholder by the result of a calc operation between entries' fields | |
* | |
* @param string $content Custom Content field content | |
* @return string | |
*/ |
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 | |
/** | |
* Use the cordinates (Latitude and Longitude) instead of the address to position the markers over the Maps | |
* Replace 'MY_LATITUDE_FIELD_ID' and 'MY_LONGITUDE_FIELD_ID' by the form field ids containing the latitude and longitude | |
* @param array $fields Gravity Forms fields IDs containing the latitude and longitude | |
* @param GravityView_View object $view Current View object | |
*/ | |
function my_gv_maps_lat_long_fields( $fields, $view ) { | |
return array( 'MY_LATITUDE_FIELD_ID', 'MY_LONGITUDE_FIELD_ID' ); |
NewerOlder