-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwp-egdform.php
133 lines (120 loc) · 3.23 KB
/
wp-egdform.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
/*
Plugin Name: EGD Form
Plugin URI: https://github.com/ichderfisch/wp-egdform
Description: Plugin that adds a shortcode which outputs a player search within the European Go Database (EGD)
Version: 0.0.2
Author: Daniel Maslowski, Dennis Fischer, Denis Weber
Author URI: http://www.ichderfisch.de
*/
/**
* Add CSS & JS
*/
function register_egdform_css_js() {
// Register CSS
wp_register_style(
'egdform',
plugins_url( 'wp-egdform/css/style.css?v=1' )
);
// Register JS
wp_register_script(
'egdform',
plugins_url( 'wp-egdform/js/script.js' ),
array( 'jquery' )
);
wp_register_script(
'egdtable',
plugins_url( 'wp-egdform/js/table.js' ),
array( 'jquery' )
);
wp_register_script(
'egccalc',
plugins_url( 'wp-egdform/js/priceCalc.js' )
);
// Datatables
wp_register_style(
'datatables',
'https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.css'
);
wp_register_script(
'datatables',
'https://cdn.datatables.net/v/dt/dt-1.10.13/datatables.min.js',
array( 'jquery' )
);
wp_register_script(
'datatablesAltstring',
'https://cdn.datatables.net/plug-ins/1.10.13/sorting/alt-string.js',
array( 'jquery' )
);
// Enqueue them all
wp_enqueue_style( 'egdform' );
wp_enqueue_script( 'egdform' );
wp_enqueue_script( 'egdtable' );
wp_enqueue_script( 'egccalc' );
wp_enqueue_style( 'datatables' );
wp_enqueue_script( 'datatables' );
}
add_action( 'wp_enqueue_scripts', 'register_egdform_css_js' );
// Add Shortcode
function show_egdform_results( $atts ) {
// Attributes
$atts = shortcode_atts(array(), $atts);
$bracketIdCssUrl = 'http://www.eurogofed.org/newick/tournament.css?id=' . $atts['id'];
$bracketIdJsUrl = 'http://www.eurogofed.org/newick/script.js?id=' . $atts['id'];
$output = '
<div class="egd-search">
<div class="egd-search__form">
<span class="egd-search__helper">Find your EGD ID:</span>
<label class="egd-search__label visually-hidden" for="egd-first-name">
First name
</label>
<input
class="egd-search__input"
id="egd-first-name"
placeholder="First name"
/>
<label class="egd-search__label visually-hidden" for="egd-last-name">
Last name
</label>
<input
class="egd-search__input"
id="egd-last-name"
placeholder="Last Name"
/>
<button
id="egd-find-id"
class="fusion-button button-default button-small"
>
Search
</button>
</div>
</div>
<div class="egd-search" style="margin-top: 10px;">
<div class="egd-search__form">
<span class="egd-search__helper">Search by EGD ID:</span>
<label class="egd-search__label visually-hidden" for="egd-id">
Last name
</label>
<input
class="egd-search__input"
id="egd-id"
placeholder="EGD ID"
/>
<button
id="egd-find-player"
class="fusion-button button-default button-small"
>
Search
</button>
</div>
</div>
<img
id="edg-spinner"
src="/wp-includes/images/spinner-2x.gif"
style="display: none;"
/>
<ul id="egd-search-results"></ul>';
return $output;
}
add_shortcode( 'egd-form', 'show_egdform_results' );
?>