Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@NateWr
Created November 24, 2014 16:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NateWr/3b190da01cd3746fa583 to your computer and use it in GitHub Desktop.
Save NateWr/3b190da01cd3746fa583 to your computer and use it in GitHub Desktop.
Add a notification tag to Restaurant Reservations that pulls the address and directions link from Business Profile
<?php
/**
* Plugin Name: Address Notification Tag for Restaurant Reservations
* Plugin URI: http://themeofthecrop.com
* Description: Add a template tag for notification requests that will print a business's address and a link to get directions from Google.
* Version: 1.0
* Author: Theme of the Crop
* Author URI: http://themeofthecrop.com
* License: GNU General Public License v2.0 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along with this program; if not, write
* to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Add the address template tag
*/
if ( !function_exists( 'rtbbp_address_template_tag' ) ) {
add_filter( 'rtb_notification_template_tags', 'rtbbp_address_template_tag', 10, 2 );
function rtbbp_address_template_tag( $template_tags, $notification ) {
// Pass an empty string if we can't locate the address properly
// or the Business Profile plugin isn't active.
$address = '';
if ( function_exists( 'bpwfwp_print_contact_card' ) ) {
$address = bpwfwp_print_contact_card(
array(
'show_name' => false,
'show_phone' => false,
'show_contact' => false,
'show_opening_hours' => false,
'show_opening_hours_brief' => false,
'show_map' => false,
)
);
}
$template_tags['{address}'] = $address;
return $template_tags;
}
} // endif;
/**
* Display the address template tag in the admin panel
*/
if ( !function_exists( 'rtbbp_address_template_tag_note' ) ) {
add_filter( 'rtb_notification_template_tag_descriptions', 'rtbbp_address_template_tag_note' );
function rtbbp_address_template_tag_note( $template_tag_descriptions ) {
$template_tag_descriptions['{address}'] = __( 'The address of this restaurant and a link to get directions from Google' );
return $template_tag_descriptions;
}
} // endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment