Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/
@mgratch
mgratch / RCP_login_redirect.php
Created May 8, 2015 22:39
Automatically redirect users to where they came from upon logging in and out. Warning this does cause a problem when logging out from a restricted content page.
<?php
function mg_rcp_hijack_login_url() {
global $rcp_options;
if( isset( $rcp_options['login_redirect'] ) ) {
$login_url = get_the_permalink( $rcp_options['login_redirect'] );
}
return $login_url;
}
@mgratch
mgratch / GravityViewEmailOnApproval.php
Created May 12, 2015 01:46
this will add the approval event to gravityforms notifications and then send that approval notification upon approval via GravityView.
add_filter( 'gform_notification_events', 'gw_add_manual_notification_event' );
function gw_add_manual_notification_event( $events ) {
$events['su_approval'] = __( 'Send Approval' );
return $events;
}
add_action('gravityview/approve_entries/approved','su_send_approval');
function su_send_approval($entry_id){
$entry = RGFormsModel::get_lead($entry_id);
@mgratch
mgratch / GravityView-update-post-status.php
Last active November 20, 2018 02:29
This will update the post status from pending to publish or vice versa when approved/dissaproved using GravityView.
add_action('gravityview/approve_entries/approved','publish_pending_testimonial');
function publish_pending_testimonial($entry_id){
$entry = RGFormsModel::get_lead($entry_id);
if ($entry['post_id'] != null){
$my_post = array(
'ID' => $entry['post_id'],
'post_status' => 'publish'
);
@mgratch
mgratch / programatically-submit-gravityforms-entries
Created May 14, 2015 22:22
Upon entry approval (via GravityView) from form 8 or 10 entry data will be submitted to form 12.
add_action('gravityview/approve_entries/approved','submit_master_map_form');
function submit_master_map_form($entry_id, $input_values = array()){
$entry = RGFormsModel::get_lead($entry_id);
$form_id = $entry['form_id'];
if ($form_id == 8){
//Select drop down option based on which form data is coming from
$input_values['input_15'] = 'Chapter';
/**
* Part of GravityView_Ratings_Reviews plugin. This script is enqueued from
* front-end view that has ratings-reviews setting enabled.
*
* globals jQuery, GV_MAPS, google
*/
// make sure GV_MAPS exists
window.GV_MAPS = window.GV_MAPS || {};
@mgratch
mgratch / redirect_finder.php
Created July 1, 2015 17:31
Find the redirects!
<?php
if (!is_admin()){
add_filter( 'wp_redirect', function () { debug_print_backtrace(); exit; },999 );
}
?>
@mgratch
mgratch / content.php
Created July 9, 2015 02:14
Getting 'lwi_slideshowimages' fails with pods active
/**
* Getting this specific metadata is returning
* boolean (false)
*/
$stuff = get_post_meta(get_the_ID(),'lwi_slideshowimage',false);
var_dump($stuff);
<?php
/*
* Plugin Name: Convert Meta Fields
* Description: batch convert metadata for metroinvestments update
* Author: Marc Gratch
* Author URI: http://marcgratch.com
* Version: 0.1.0
*/
/**
window.MI_MAPS = window.MI_MAPS || {};
window.MI_MAPS.current_map = window.MI_MAPS.current_map || {};
function generate_map( el ) {
var Map_Data = {};
Map_Data.lat = el.attr('data-lat');
Map_Data.long = el.attr('data-long');
Map_Data.id = el.find('.googleMap').attr('id');
Map_Data.myLatlng = new google.maps.LatLng(Map_Data.lat, Map_Data.long);
Map_Data.mapOptions = {