Last active
January 23, 2019 08:56
-
-
Save NateWr/7e07054d09ab43d593dd to your computer and use it in GitHub Desktop.
Require phone number for Restaurant Reservations
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 | |
/** | |
* Plugin Name: Required Phone Number addon for Restaurant Reservations | |
* Plugin URI: http://themeofthecrop.com | |
* Description: Modify the Restaurant Reservations plugin to require the phone number. | |
* 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 | |
* Requires at least: 3.8 | |
* Tested up to: 3.9.1 | |
* | |
* Text Domain: rtbdomain | |
* Domain Path: /languages/ | |
* | |
* 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; | |
if ( !class_exists( 'rpnfrrInit' ) ) { | |
class rpnfrrInit { | |
/** | |
* Initialize the plugin and register hooks | |
*/ | |
public function __construct() { | |
// Require a phone number as well | |
add_action( 'rtb_validate_booking_submission', array( $this, 'validate_phone_number' ) ); | |
} | |
/** | |
* Require a phone number | |
* @since 0.0.1 | |
*/ | |
public function validate_phone_number( $booking ) { | |
if ( empty( $booking->phone ) ) { | |
$booking->validation_errors[] = array( | |
'field' => 'phone', | |
'post_variable' => $_POST['rtb-phone'], | |
'message' => __( 'Please enter a phone number where we can reach you.', RTB_TEXTDOMAIN ), | |
); | |
} | |
} | |
} | |
} // endif; | |
new rpnfrrInit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment