-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmb2-dutch-license-plate.php
96 lines (83 loc) · 3.45 KB
/
cmb2-dutch-license-plate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/**
* Plugin Name: Dutch License Plate Field for CMB2
* Plugin URI: https://github.com/automex/cmb2-dutch-license-plate-field
* GitHub Plugin URI: https://github.com/automex/cmb2-dutch-license-plate-field
* Description: Dutch License Plate Field for CMB2
* Version: 1.0.0
* Author: Automex.website
* Author URI: http://automex.website
* License: GPLv3
* Text Domain: amex-dutch-license-plate
* Domain Path: /languages
*/
class AMEX_Dutch_License_Plate {
const VERSION = '1.0.0';
public function __construct() {
/* CMB2 Dutch License Plate Field Small */
add_filter( 'cmb2_render_dutch_license_plate_small', array( $this, 'render_callback_for_dutch_license_plate_small' ), 10, 5 );
add_filter( 'cmb2_sanitize_dutch_license_plate_small', array( $this, 'sanitize_dutch_license_plate'), 10, 2 );
/* CMB2 Dutch License Plate Field Large */
add_filter( 'cmb2_render_dutch_license_plate_large', array( $this, 'render_callback_for_dutch_license_plate_large' ), 10, 5 );
add_filter( 'cmb2_sanitize_dutch_license_plate_large', array( $this, 'sanitize_dutch_license_plate'), 10, 2 );
}
/* CMB2 Dutch License Plate Field Small */
public function render_callback_for_dutch_license_plate_small( $field, $escaped_value, $object_id, $object_type, $field_type_object ) {
$this->amex_css_js( $field ); ?>
<span class="kenteken small">
<span class="blue">
<span><img src="<?php echo plugins_url('assets/images/stars.svg', __FILE__ ); ?>" alt=""></span>
<span class="countrycode">nl</span>
</span>
<?php echo $field_type_object->input( array(
'type' => 'text',
'name' => $field_type_object->_name(),
'id' => $field_type_object->_id(),
'value' => $escaped_value,
'class' => 'nl',
'placeholder' => 'XP-004-T',
'spellcheck' => 'false',
'autocomplete' => 'off',
'maxlength' => '8',
'desc' => ''
) ); ?>
</span>
<?php echo $field_type_object->_desc( true );
}
/* CMB2 Dutch License Plate Field Large */
public function render_callback_for_dutch_license_plate_large( $field, $escaped_value, $object_id, $object_type, $field_type_object ) {
$this->amex_css_js( $field ); ?>
<span class="kenteken">
<span class="blue">
<span><img src="<?php echo plugins_url('assets/images/stars.svg', __FILE__ ); ?>" alt=""></span>
<span class="countrycode">nl</span>
</span>
<?php echo $field_type_object->input( array(
'type' => 'text',
'name' => $field_type_object->_name(),
'id' => $field_type_object->_id(),
'value' => $escaped_value,
'class' => 'nl',
'placeholder' => 'XP-004-T',
'spellcheck' => 'false',
'autocomplete' => 'off',
'maxlength' => '8',
'desc' => ''
) ); ?>
</span>
<?php echo $field_type_object->_desc( true );
}
/* Sanitize */
public function sanitize_dutch_license_plate( $null, $new ) {
$new = preg_replace('/[^a-zA-Z0-9]/', '', $new);
return $new;
}
public function amex_css_js( $field ) {
$asset_path = apply_filters( 'amex_asset_path', plugins_url( '', __FILE__ ) );
wp_enqueue_style('amex_kentekenplaat_css', $asset_path . '/assets/css/style.min.css', array(), self::VERSION );
wp_enqueue_script('amex_kentekenplaat_js', $asset_path . '/assets/js/kentekenplaat.min.js', array( 'jquery' ), self::VERSION, true );
wp_enqueue_script('amex_main_js', $asset_path . '/assets/js/main.js', array( 'jquery' ), self::VERSION, true );
}
}
new AMEX_Dutch_License_Plate();
?>