/
gamedevquotes.php
174 lines (126 loc) · 6.25 KB
/
gamedevquotes.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/*
Plugin Name: Game Dev Quotes
Plugin URI: http://www.tonyw.io/game-dev-quotes
Description: A simple way to style game developer quotes as they are on the developers site.
Author: TonyW
Version: 1.6.0
Author URI: http://www.tonyw.io
*/
// Bring in our styles from "quotestyle.css" so everything gets formatted correctly.
function nwxgdq_styles() {
wp_register_style( 'game-dev-quotes-css', plugins_url( 'assets/css/quotestyle.min.css', __FILE__ ) );
wp_enqueue_style( 'game-dev-quotes-css', plugins_url( 'assets/css/quotestyle.min.css', __FILE__ ) );
}
add_action( 'wp_enqueue_scripts', 'nwxgdq_styles' );
//process our "bluepost" shortcode
function nwx_blue_post( $atts, $content = null ) {
// Check for source URL. If filled out insert correct code, if not leave source link out.
if ( isset( $atts['url'] ) && $atts['url'] != '' ) {
if ( substr( $atts['url'], 0, 4 ) == 'http' ) {
$nwxgdqsrc = ' - (<a href="' . $atts['url'] . '">source</a>)';
} else {
$nwxgdqsrc = ' - (<a href="http://' . $atts['url'] . '">source</a>)';
}
} else {
$nwxgdqsrc = '';
}
// Wrap everything in the colors we want. Pull out the "Name" attributed to the post and the content then display it.
return '<div class="bluepost"><span style="color: #ffffff; font-weight: bold;">' . $atts['name'] . $nwxgdqsrc . '</span><span style="position: absolute; top:0; right:0; "><img src=" ' . plugins_url( 'assets/img/blizz.gif', __FILE__ ) . '"></span> <p> ' . $content . '</p></div>';
}
add_shortcode( 'bluepost', 'nwx_blue_post' );
// Process our "torpost" shortcode
function nwx_tor_post( $atts, $content = null ) {
// Check for source URL. If filled out insert correct code, if not leave source link out.
if ( isset( $atts['url'] ) && $atts['url'] != '' ) {
if ( substr( $atts['url'], 0, 4 ) == 'http' ) {
$nwxgdqsrc = ' - (<a href="' . $atts['url'] . '">source</a>)';
} else {
$nwxgdqsrc = ' - (<a href="http://' . $atts['url'] . '">source</a>)';
}
} else {
$nwxgdqsrc = '';
}
// Wrap everything in the colors we want. Pull out the "Name" attributed to the post and the content then display it.
return '<div class="torpost"><span style="color:white; font-weight: bold;">' . $atts['name'] . $nwxgdqsrc . '</span><span style="position: absolute; top:0; right:0;"><img src=" ' . plugins_url( 'assets/img/tordev.png', __FILE__ ) . '"></span> <p> ' . $content . '</p></div>';
}
add_shortcode( 'torpost', 'nwx_tor_post' );
//Process our "ps2post" shortcode
function nwx_ps2_post( $atts, $content = null ) {
// Check for source URL. If filled out insert correct code, if not leave source link out.
if ( isset( $atts['url'] ) && $atts['url'] != '' ) {
if ( substr( $atts['url'], 0, 4 ) == 'http' ) {
$nwxgdqsrc = ' - (<a href="' . $atts['url'] . '">source</a>)';
} else {
$nwxgdqsrc = ' - (<a href="http://' . $atts['url'] . '">source</a>)';
}
} else {
$nwxgdqsrc = '';
}
// Wrap everything in the colors we want. Pull out the "Name" attributed to the post and the content then display it.
return '<div class="ps2post"><span style="color:red; font-weight: bold;">' . $atts['name'] . $nwxgdqsrc . '</span><span style="position: absolute; top:0; right:0;"><img src=" ' . plugins_url( 'assets/img/ps2dev.png', __FILE__ ) . '"></span> <p> ' . $content . '</p></div>';
}
add_shortcode( 'ps2post', 'nwx_ps2_post' );
//Process our "valvepost" shortcode
function nwx_valve_post( $atts, $content = null ) {
// Check for source URL. If filled out insert correct code, if not leave source link out.
if ( isset( $atts['url'] ) && $atts['url'] != '' ) {
if ( substr( $atts['url'], 0, 4 ) == 'http' ) {
$nwxgdqsrc = ' - (<a href="' . $atts['url'] . '">source</a>)';
} else {
$nwxgdqsrc = ' - (<a href="http://' . $atts['url'] . '">source</a>)';
}
} else {
$nwxgdqsrc = '';
}
// Wrap everything in the colors we want. Pull out the "Name" attributed to the post and the content then display it.
return '<div class="valvepost"><span style="color: #aedd08; font-weight: bold;">' . $atts['name'] . $nwxgdqsrc . '</span><span style="position: absolute; top:0; right:0;"><img src=" ' . plugins_url( 'assets/img/valvedev.png', __FILE__ ) . '"></span> <p> ' . $content . '</p></div>';
}
add_shortcode( 'valvepost', 'nwx_valve_post' );
//Process our "aapost" shortcode
function gdq_aa_post( $atts, $content = null ) {
// Check for source URL. If filled out insert correct code, if not leave source link out.
if ( isset( $atts['url'] ) && $atts['url'] != '' ) {
if ( substr( $atts['url'], 0, 4 ) == 'http' ) {
$nwxgdqsrc = ' - (<a href="' . $atts['url'] . '">source</a>)';
} else {
$nwxgdqsrc = ' - (<a href="http://' . $atts['url'] . '">source</a>)';
}
} else {
$nwxgdqsrc = '';
}
// Wrap everything in the colors we want. Pull out the "Name" attributed to the post and the content then display it.
return '<div class="aapost"><span style="color: #FFF; font-weight: bold; padding-right: 30px; border-bottom: 1px solid #15911D; padding-bottom: 2px;">' . $atts['name'] . $nwxgdqsrc . '</span><span style="position: absolute; top:2px; right:2px; width:35px; height:35px;"><img src=" ' . plugins_url( 'assets/img/aalogo.png', __FILE__ ) . '"></span> <p> ' . $content . ' </p></div>';
}
add_shortcode( 'aapost', 'gdq_aa_post' );
/* Adding support for TinyMCE button */
/*----------------------------*/
function nwxgdq_register_button( $buttons ) {
// inserting a seperator between existing buttons and our new one
array_push( $buttons, '|', 'nwxgdq_button' );
return $buttons;
}
/* Add our button to tinyMCE */
/*----------------------*/
function nwxgdq_button() {
// Skip if user doesn't have permission
if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ){
return;
}
// Add in rich editor mode
if ( get_user_option( 'rich_editing' ) == 'true' ) {
add_filter( 'mce_external_plugins', 'add_nwxgdq_plugin' );
add_filter( 'mce_buttons', 'nwxgdq_register_button' );
}
}
// init button control
add_action( 'init', 'nwxgdq_button' );
// adding our button to the bar
function add_nwxgdq_plugin( $nwxgdq_plugin_array ) { ?>
<script type="text/javascript">
var plugins_url = '<?php echo esc_html( plugins_url() ); ?>';
</script>
<?php
$nwxgdq_plugin_array[ 'nwxgdq_button' ] = plugins_url( 'assets/js/nwxgdq_button.min.js', __FILE__ );
return $nwxgdq_plugin_array;
}