-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpuffles.php
109 lines (101 loc) · 4.74 KB
/
puffles.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
<?php
/**
* Puffles - for Club Penguin Bloggers
*
* @author Aurorum
* @package Puffles
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: Puffles - for Club Penguin Bloggers
* Plugin URI: https://github.com/Aurorum/club-penguin-wordpress-plugin
* Description: Currently offers a playercard generator based on Club Penguin's assets.
* Version: 1.1
* Author: Aurorum
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: puffles
*/
function pufflesPlayercardGeneratorShortcode($content = null)
{
$data = array(
'directory' => plugins_url('/assets/', __FILE__)
);
// This ensures compatibility with Automattic's "Page Optimize" plugin.
// Update the page ID to suit your own site if that plugin is enabled!
if ( get_option( 'page_optimize-js', true ) && get_the_ID() === 31388 ) {
add_filter( 'js_do_concat', '__return_false' );
}
wp_register_script('puffles-items', plugin_dir_url(__FILE__) . 'items.js', '', '', true);
wp_enqueue_script('puffles-items');
wp_register_script('puffles_scripts', plugin_dir_url(__FILE__) . 'scripts.js', '', '', true);
wp_localize_script('puffles_scripts', 'pufflesPlayercardItems', $data);
wp_enqueue_script('puffles_scripts');
$pufflesEmptyFile = plugins_url('assets/empty.png', __FILE__);
return '
<div style="display:none">
<img id="puffles-1-item-image" src="' . plugins_url('/assets/15.png', __FILE__) . '">
<img id="puffles-2-item-image" src="' . $pufflesEmptyFile . '">
<img id="puffles-3-item-image" src="' . $pufflesEmptyFile . '">
<img id="puffles-4-item-image" src="' . $pufflesEmptyFile . '">
<img id="puffles-5-item-image" src="' . $pufflesEmptyFile . '">
<img id="puffles-6-item-image" src="' . $pufflesEmptyFile . '">
<img id="puffles-7-item-image" src="' . $pufflesEmptyFile . '">
<img id="puffles-8-item-image" src="' . $pufflesEmptyFile . '">
<img id="puffles-9-item-image" src="' . $pufflesEmptyFile . '">
<img id="puffles-10-item-image" src="' . $pufflesEmptyFile . '">
</div>
<div class="puffles-playercard-generator is-loading" id="puffles-playercard">
<div class="puffles-playercard-generator-loading-placeholder"></div>
<div class="puffles-playercard-generator-wrapper">
<div class="puffles-playercard-generator-item-search">
<label for="puffles-item-search">Search item by name or ID:</label>
<input type="search" id="puffles-item-search" name="puffles-item-search">
<button onclick="pufflesSearchItem(false)">Search</button>
<button onclick="pufflesSearchItem(true)">Add</button>
<p id="puffles-item-search-result" class="puffles-playercard-item-search-result"></p>
<p id="puffles-item-search-error" class="puffles-playercard-item-search-error"></p>
</div>
<canvas id="puffles-canvas" class="puffles-playercard-canvas" width="600" height="600">
Your browser does not support this generator - sorry!
</canvas>
<a onclick="pufflesGenerateRandomPlayercard()" class="puffles-playercard-action">Generate random playercard</a>
<a onclick="pufflesClearPlayercard()" class="puffles-playercard-action clear-action">Clear</a>
</div>
<div class="puffles-playercard-generator-items">
<select id="puffles-1-item" onchange="pufflesUpdateItem(1)" size="4">
</select>
<select id="puffles-2-item" onchange="pufflesUpdateItem(2)" size="4">
</select>
<select id="puffles-3-item" onchange="pufflesUpdateItem(3)" size="4">
</select>
<select id="puffles-4-item" onchange="pufflesUpdateItem(4)" size="4">
</select>
<select id="puffles-5-item" onchange="pufflesUpdateItem(5)" size="4">
</select>
<select id="puffles-6-item" onchange="pufflesUpdateItem(6)" size="4">
</select>
<select id="puffles-7-item" onchange="pufflesUpdateItem(7)" size="4">
</select>
<select id="puffles-8-item" onchange="pufflesUpdateItem(8)" size="4">
</select>
<select id="puffles-9-item" onchange="pufflesUpdateItem(9)" size="4">
</select>
<div class="puffles-playercard-generator-download-button-wrapper">
<a
id="puffles-playercard-download"
download="club-penguin-playercard"
href=""
class="puffles-playercard-generator-download-button"
>Download playercard</a
>
</div>
</div>
</div>';
}
add_shortcode('playercard-generator', 'pufflesPlayercardGeneratorShortcode');
function pufflesEnqueuePlayercardStyling()
{
wp_enqueue_style('puffles-styles', plugin_dir_url(__FILE__) . 'style.css');
}
add_action('wp_enqueue_scripts', 'pufflesEnqueuePlayercardStyling');