Hotel Raxa - Advanced Booking System Implementation
🏨 Hotel Booking Enhancements: - Implemented Eagle Booking Advanced Pricing add-on - Added Booking.com-style rate management system - Created professional calendar interface for pricing - Integrated deals and discounts functionality 💰 Advanced Pricing Features: - Dynamic pricing models (per room, per person, per adult) - Base rates, adult rates, and child rates management - Length of stay discounts and early bird deals - Mobile rates and secret deals implementation - Seasonal promotions and flash sales 📅 Availability Management: - Real-time availability tracking - Stop sell and restriction controls - Closed to arrival/departure functionality - Minimum/maximum stay requirements - Automatic sold-out management 💳 Payment Integration: - Maintained Redsys payment gateway integration - Seamless integration with existing Eagle Booking - No modifications to core Eagle Booking plugin 🛠️ Technical Implementation: - Custom database tables for advanced pricing - WordPress hooks and filters integration - AJAX-powered admin interface - Data migration from existing Eagle Booking - Professional calendar view for revenue management 📊 Admin Interface: - Booking.com-style management dashboard - Visual rate and availability calendar - Bulk operations for date ranges - Statistics and analytics dashboard - Modal dialogs for quick editing 🔧 Code Quality: - WordPress coding standards compliance - Secure database operations with prepared statements - Proper input validation and sanitization - Error handling and logging - Responsive admin interface 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Color Validation
|
||||
*
|
||||
* @package Redux Framework/Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Color', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Color
|
||||
*/
|
||||
class Redux_Validation_Color extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Validate Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since ReduxFramework 3.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
|
||||
if ( empty( $this->value ) || ( 'transparent' === $this->value ) || is_array( $this->value ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$test = str_replace( '#', '', Redux_Core::strtolower( trim( $this->value ) ) );
|
||||
if ( ! in_array( strlen( $test ), array( 3, 6 ), true ) ) {
|
||||
// translators: %1$s: sanitized value. %2$s: Old value.
|
||||
$this->field['msg'] = $this->field['msg'] ?? sprintf( esc_html__( 'Invalid HTML color code %1$s. Please enter a valid code. No value was saved.', 'redux-framework' ), '<code>' . $this->value . '</code>' );
|
||||
|
||||
$this->warning = $this->field;
|
||||
$this->value = '';
|
||||
|
||||
return;
|
||||
} else {
|
||||
$this->field['msg'] = '';
|
||||
$this->warning = $this->field;
|
||||
|
||||
}
|
||||
|
||||
$sanitized_value = Redux_Colors::sanitize_color( $this->value );
|
||||
|
||||
if ( $sanitized_value !== $this->value ) {
|
||||
// translators: %1$s: sanitized value. %2$s: Old value.
|
||||
$this->field['msg'] = $this->field['msg'] ?? sprintf( esc_html__( 'Sanitized value and saved as %1$s instead of %2$s.', 'redux-framework' ), '<code>' . $sanitized_value . '</code>', '<code>' . $this->value . '</code>' );
|
||||
|
||||
$this->field['old'] = $this->value;
|
||||
$this->field['current'] = $sanitized_value;
|
||||
|
||||
$this->warning = $this->field;
|
||||
}
|
||||
|
||||
$this->value = strtoupper( $sanitized_value );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Numeric with comma validation
|
||||
*
|
||||
* @package ReduxFramework/Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Comma_Numeric', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Comma_Numeric
|
||||
*/
|
||||
class Redux_Validation_Comma_Numeric extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Validation Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
|
||||
$this->value = preg_replace( '/\s/', '', $this->value );
|
||||
$parts = explode( ',', $this->value );
|
||||
|
||||
if ( empty( $this->value ) || 0 === $this->value || 1 === count( $parts ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must provide a comma separated list of numerical values for this option.', 'redux-framework' );
|
||||
|
||||
if ( ! is_numeric( str_replace( ',', '', $this->value ) ) || false === strpos( $this->value, ',' ) ) {
|
||||
$this->value = ( isset( $this->current ) ) ? $this->current : '';
|
||||
$this->field['current'] = $this->value;
|
||||
|
||||
$this->error = $this->field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* CSS validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Css', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Css
|
||||
*/
|
||||
class Redux_Validation_Css extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Validation Function.
|
||||
* Takes the vars and validates them
|
||||
*
|
||||
* @since ReduxFramework 3.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'Unsafe strings were found in your CSS and have been filtered out.', 'redux-framework' );
|
||||
|
||||
$data = $this->value;
|
||||
|
||||
$data = wp_filter_nohtml_kses( $data );
|
||||
$data = str_replace( '>', '>', $data );
|
||||
$data = stripslashes( $data );
|
||||
|
||||
if ( $data !== $this->value ) {
|
||||
$this->field['current'] = $data;
|
||||
$this->warning = $this->field;
|
||||
}
|
||||
|
||||
$this->value = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Date validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Date', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Date
|
||||
*/
|
||||
class Redux_Validation_Date extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Validation Function.
|
||||
* Takes the vars and validates them.
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'This field must be a valid date.', 'redux-framework' );
|
||||
|
||||
$string = str_replace( '/', '', $this->value );
|
||||
|
||||
if ( ! is_numeric( $string ) ) {
|
||||
$this->value = ( isset( $this->current ) ) ? $this->current : '';
|
||||
$this->field['current'] = $this->value;
|
||||
$this->error = $this->field;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( '/' !== $this->value[2] ) {
|
||||
$this->value = ( isset( $this->current ) ) ? $this->current : '';
|
||||
$this->field['current'] = $this->value;
|
||||
$this->error = $this->field;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( '/' !== $this->value[5] ) {
|
||||
$this->value = ( isset( $this->current ) ) ? $this->current : '';
|
||||
$this->field['current'] = $this->value;
|
||||
$this->error = $this->field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* EMail validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Email', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Email
|
||||
*/
|
||||
class Redux_Validation_Email extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must provide a valid email for this option.', 'redux-framework' );
|
||||
|
||||
if ( ! is_email( $this->value ) ) {
|
||||
$this->value = ( isset( $this->current ) ) ? $this->current : '';
|
||||
$this->field['current'] = $this->value;
|
||||
|
||||
$this->error = $this->field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom HTML validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Html_Custom', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Html_Custom
|
||||
*/
|
||||
class Redux_Validation_Html_Custom extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and validates them
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'Invalid HTML was found in this field and has been removed.', 'redux-framework' );
|
||||
|
||||
if ( isset( $this->field['allowed_html'] ) ) {
|
||||
$html = wp_kses( $this->value, $this->field['allowed_html'] );
|
||||
|
||||
if ( $html !== $this->value ) {
|
||||
$this->field['current'] = $html;
|
||||
$this->warning = $this->field;
|
||||
}
|
||||
|
||||
$this->value = $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Javascript validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Js', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Js
|
||||
*/
|
||||
class Redux_Validation_Js extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Validation Function.
|
||||
* Takes the vars and validates them
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'Javascript has been successfully escaped.', 'redux-framework' );
|
||||
|
||||
$js = esc_js( $this->value );
|
||||
|
||||
if ( $js !== $this->value ) {
|
||||
$this->field['current'] = $js;
|
||||
$this->warning = $this->field;
|
||||
}
|
||||
|
||||
$this->value = $js;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* No HTML validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_No_Html', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_No_Html
|
||||
*/
|
||||
class Redux_Validation_No_Html extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Validate Function.
|
||||
* Takes the vars and validates them
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must not enter any HTML in this field. All HTML has been removed.', 'redux-framework' );
|
||||
|
||||
$newvalue = wp_strip_all_tags( $this->value );
|
||||
|
||||
if ( $this->value !== $newvalue ) {
|
||||
$this->field['current'] = $newvalue;
|
||||
$this->warning = $this->field;
|
||||
}
|
||||
|
||||
$this->value = $newvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* No Special Chars validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_No_Special_Chars', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_No_Special_Chars
|
||||
*/
|
||||
class Redux_Validation_No_Special_Chars extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and validates them
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must not enter any special characters in this field, all special characters have been removed.', 'redux-framework' );
|
||||
|
||||
$val = preg_match( '/[^a-zA-Z0-9_ -]/s', $this->value );
|
||||
|
||||
if ( $val > 0 ) {
|
||||
$this->field['current'] = $this->current;
|
||||
|
||||
$this->warning = $this->field;
|
||||
}
|
||||
|
||||
$this->value = preg_replace( '/[^a-zA-Z0-9_ -]/s', '', $this->value );
|
||||
|
||||
$this->field['current'] = $this->value;
|
||||
$this->sanitize = $this->field;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Not Empty validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Not_Empty', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Not_Empty
|
||||
*/
|
||||
class Redux_Validation_Not_Empty extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Validation Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'This field cannot be empty. Please provide a value.', 'redux-framework' );
|
||||
|
||||
if ( ! isset( $this->value ) || '' === $this->value || 0 === strlen( $this->value ) ) {
|
||||
$this->error = $this->field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Numeric validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Numeric', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Numeric
|
||||
*/
|
||||
class Redux_Validation_Numeric extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and outputs the HTML for the field in the settings
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must provide a numerical value for this option.', 'redux-framework' );
|
||||
|
||||
if ( ! is_numeric( $this->value ) ) {
|
||||
$this->value = ( isset( $this->current ) ) ? $this->current : '';
|
||||
$this->field['current'] = $this->value;
|
||||
|
||||
$this->error = $this->field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Preg Replace validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Preg_Replace', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Preg_Replace
|
||||
*/
|
||||
class Redux_Validation_Preg_Replace extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Validate Function.
|
||||
* Takes the vars and validates them
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$that = $this;
|
||||
$this->value = preg_replace( $this->field['preg']['pattern'], $that->field['preg']['replacement'], $this->value );
|
||||
$this->field['current'] = $this->value;
|
||||
|
||||
$this->sanitize = $this->field;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Str Replace validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Str_Replace', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Str_Replace
|
||||
*/
|
||||
class Redux_Validation_Str_Replace extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Validate Function.
|
||||
* Takes the vars and validates them
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->value = str_replace( $this->field['str']['search'], $this->field['str']['replacement'], $this->value );
|
||||
|
||||
$this->field['current'] = $this->value;
|
||||
$this->sanitize = $this->field;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Unique Slug validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Unique_Slug', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Unique_Slug
|
||||
*/
|
||||
class Redux_Validation_Unique_Slug extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Validation Function.
|
||||
* Takes the vars and validates them
|
||||
*
|
||||
* @since ReduxFramework 3.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
global $wpdb, $wp_rewrite;
|
||||
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'That URL slug is in use, please choose another.', 'redux-framework' );
|
||||
$this->field['flush_permalinks'] = $this->field['flush_permalinks'] ?? false;
|
||||
|
||||
$slug = $this->value;
|
||||
|
||||
$feeds = $wp_rewrite->feeds;
|
||||
if ( ! is_array( $feeds ) ) {
|
||||
$feeds = array();
|
||||
}
|
||||
|
||||
// Post slugs must be unique across all posts.
|
||||
$result = wp_cache_get( 'redux-post-name' );
|
||||
if ( false === $result ) {
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery
|
||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $slug ) );
|
||||
|
||||
wp_cache_set( 'redux-post-name', $post_name_check );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter whether the post slug would be bad as a flat slug.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param bool $bad_slug Whether the post slug would be bad as a flat slug.
|
||||
* @param string $slug The post slug.
|
||||
* @param string $post_type Post type.
|
||||
*/
|
||||
if ( $post_name_check || in_array( $slug, $feeds, true ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
|
||||
$suffix = 2;
|
||||
|
||||
do {
|
||||
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
||||
|
||||
$result = wp_cache_get( 'redux-alt-post-name' );
|
||||
if ( false === $result ) {
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery
|
||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $alt_post_name ) );
|
||||
|
||||
wp_cache_set( 'redux-alt-post-name', $result );
|
||||
}
|
||||
|
||||
$suffix ++;
|
||||
} while ( $post_name_check );
|
||||
|
||||
$slug = $alt_post_name;
|
||||
$this->value = ( isset( $this->current ) ) ? $this->current : '';
|
||||
$this->field['msg'] = sprintf( $this->field['msg'], $slug );
|
||||
$this->field['current'] = $this->value;
|
||||
$this->error = $this->field;
|
||||
} elseif ( isset( $this->field['flush_permalinks'] ) && true === $this->field['flush_permalinks'] ) {
|
||||
add_action( 'init', array( $this, 'flush_permalinks' ), 99 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush WordPress permalinks.
|
||||
*/
|
||||
public function flush_permalinks() {
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* URL validation
|
||||
*
|
||||
* @package Redux Framework
|
||||
* @subpackage Validation
|
||||
* @author Kevin Provance (kprovance) & Dovy Paukstys
|
||||
* @version 4.0.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'Redux_Validation_Url', false ) ) {
|
||||
|
||||
/**
|
||||
* Class Redux_Validation_Url
|
||||
*/
|
||||
class Redux_Validation_Url extends Redux_Validate {
|
||||
|
||||
/**
|
||||
* Field Render Function.
|
||||
* Takes the vars and validates them
|
||||
*
|
||||
* @since ReduxFramework 1.0.0
|
||||
*/
|
||||
public function validate() {
|
||||
$this->field['msg'] = $this->field['msg'] ?? esc_html__( 'You must provide a valid URL for this option.', 'redux-framework' );
|
||||
|
||||
if ( false === filter_var( $this->value, FILTER_VALIDATE_URL ) ) {
|
||||
$this->value = ( isset( $this->current ) ) ? $this->current : '';
|
||||
$this->field['current'] = $this->value;
|
||||
|
||||
$this->error = $this->field;
|
||||
} else {
|
||||
$this->value = esc_url_raw( $this->value );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Silence is golden.
|
||||
*
|
||||
* @package Redux Framework
|
||||
*/
|
||||
|
||||
echo null;
|
||||
Reference in New Issue
Block a user