Changeset 1724865
- Timestamp:
- 09/05/2017 11:27:49 AM (9 years ago)
- Location:
- simple-baseball-scoreboard/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
ytmr_simple_baseball_scoreboard.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-baseball-scoreboard/trunk/readme.txt
r1724659 r1724865 2 2 Contributors: dogrow 3 3 Donate link: 4 Tags: baseball, score board4 Tags: baseball, score, scoreboard 5 5 Requires at least: 4.8.1 6 6 Tested up to: 4.8.1 7 Stable tag: 1. 17 Stable tag: 1.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 34 34 == ChangeLog == 35 35 36 = Version 1.2 = 37 38 * We made it possible to specify the whole width of the scoreboard. 39 36 40 = Version 1.1 = 37 41 38 * correct description42 * correct description 39 43 40 44 = Version 1.0 = -
simple-baseball-scoreboard/trunk/ytmr_simple_baseball_scoreboard.php
r1724517 r1724865 4 4 Plugin URI: https://php.dogrow.net/wordpressplugin/simple-baseball-scoreboard/ 5 5 Description: Generate baseball scoreboard from shortcode 6 Version: 1. 06 Version: 1.2 7 7 Author: DOGROW.NET 8 8 Author https://php.dogrow.net/ … … 102 102 } 103 103 ////////////////////////////////////////////////////////////////////// 104 public function proc_shortcode( $args ){ 105 return $this->sub_display_table($args); 106 } 107 ////////////////////////////////////////////////////////////////////// 108 public function proc_create_menu() { 109 add_submenu_page('options-general.php', 'Simple BBScoreboard', 'Simple BBScoreboard', 'administrator', __FILE__, array($this, 'proc_display_settings_page')); 110 } 111 ////////////////////////////////////////////////////////////////////// 112 public function proc_register_settings() { 113 register_setting($this->m_setting_group, $this->m_option_name, array($this, 'proc_handle_sanitization')); 114 } 115 ////////////////////////////////////////////////////////////////////// 116 public function proc_handle_sanitization($ary_set) { 117 $ary_options = $this->m_options; 118 foreach($ary_set as $key => &$ary_tv){ 119 $ary_options[$key]['v'] = esc_attr($ary_tv['v']); 120 } 121 return $ary_options; 122 } 123 ////////////////////////////////////////////////////////////////////// 124 public function proc_display_settings_page() { 125 //------------------------------------------------------------------ 126 $ary_set = get_option($this->m_option_name); 127 foreach($ary_set as &$ary_tv){ 128 $ary_tv['v'] = esc_attr($ary_tv['v']); 129 } 130 //------------------------------------------------------------------ 131 $ary_bw_sel = array('1px'=>'', '2px'=>'', '3px'=>''); 132 $ary_bw_sel[$ary_set['border_line_width']['v']] = 'selected'; 133 //------------------------------------------------------------------ 134 $args = array('fsize'=>'1.2', 'width'=>'600px', 'tm1'=>'GreenSox', 'tm2'=>'Monkeys', 'scr1'=>'0/0/1/1/0/3/0', 'scr2'=>'1/0/0/2/2/1/X'); 135 $html_scrboard = $this->sub_display_table($args); 136 //------------------------------------------------------------------ 137 echo <<< EOM 138 <div class="wrap"> 139 <h2>Simple Baseball Scoreboard</h2> 140 <h2>1. Usage</h2> 141 <p>Short code : <span style="background:#fff;color:#00f;padding:3px 5px;font-size:1.2rem">[ytmr_bb_scoreboard]</span></p> 142 <p>Parameters : <br /> 143 - fsize : font size [rem]<br /> 144 - tm1 : team name of the bat first<br /> 145 - tm2 : team name of the field first<br /> 146 - scr1, scr2 : run of the inning (separator is "/")<br /> 147 </p> 148 <p>sample : <span style="background:#fff;color:#00f;padding:3px 5px;font-size:1.2rem">[ytmr_bb_scoreboard fsize="1.2" width="600px" tm1="GreenSox" tm2="Monkeys" scr1="0/0/1/1/0/3/0" scr2="1/0/0/2/2/1/X"]</span></p> 149 {$html_scrboard} 150 <h2 style="margin-top:2.5rem">2. Settings</h2> 151 <form id="YTMRBBScoreBoard_form" method="post" action="options.php"> 152 EOM; 153 settings_fields($this->m_setting_group); 154 do_settings_sections($this->m_setting_group); 155 echo <<< EOM 156 <table class="form-table"> 157 <tr> 158 <th>{$ary_set['border_line_width']['t']}</th> 159 <td> 160 <select name="{$this->m_option_name}[border_line_width][v]"> 161 <option value="1px" {$ary_bw_sel['1px']}>thin</option> 162 <option value="2px" {$ary_bw_sel['2px']}>middle</option> 163 <option value="3px" {$ary_bw_sel['3px']}>thick</option> 164 </select> 165 </td> 166 </tr> 167 <tr> 168 <th>{$ary_set['border_line_color']['t']}</th> 169 <td> 170 <input type="color" name="{$this->m_option_name}[border_line_color][v]" value="{$ary_set['border_line_color']['v']}"> 171 </td> 172 </tr> 173 <tr> 174 <th>{$ary_set['background_color']['t']}</th> 175 <td> 176 <input type="color" name="{$this->m_option_name}[background_color][v]" value="{$ary_set['background_color']['v']}"> 177 </td> 178 </tr> 179 <tr> 180 <th>{$ary_set['box_color']['t']}</th> 181 <td> 182 <input type="color" name="{$this->m_option_name}[box_color][v]" value="{$ary_set['box_color']['v']}"> 183 </td> 184 </tr> 185 <tr> 186 <th>{$ary_set['text_color']['t']}</th> 187 <td> 188 <input type="color" name="{$this->m_option_name}[text_color][v]" value="{$ary_set['text_color']['v']}"> 189 </td> 190 </tr> 191 </table> 192 EOM; 193 submit_button(); 194 echo <<< EOM 195 </form> 196 </div> 197 EOM; 198 } 199 ////////////////////////////////////////////////////////////////////// 104 200 // args['fsize'] : text size [rem] 201 // args['width'] : whole width 105 202 // args['tm1'] : team name #1 106 203 // args['tm2'] : team name #2 107 204 // args['scr1'] : score #1 , separator='/' ex) 0/0/1/0/0/1 108 205 // args['scr2'] : score #2 109 public function proc_shortcode( $args){110 $fsize = (isset($args['fsize']))? $args['fsize'] : ' ';206 public function sub_display_table($args){ 207 $fsize = (isset($args['fsize']))? $args['fsize'] : '1'; 111 208 $tm1 = (isset($args['tm1']))? $args['tm1'] : 'team1'; 112 209 $tm2 = (isset($args['tm2']))? $args['tm2'] : 'team2'; 210 $width = (isset($args['width']))? $args['width'] : '100%'; 113 211 //------------------------------------------------------------------ 114 212 $html = ""; … … 143 241 return <<< EOM 144 242 <style type="text/css"> 243 div#YTMRBBScoreBoard{ 244 width: {$width} !important; 245 max-width: 100% !important; 246 } 145 247 div#YTMRBBScoreBoard .{$table_class} td{ 146 248 {$size} 249 } 147 250 </style> 148 251 <div id="YTMRBBScoreBoard"><table class="{$table_class}" style="width:100%">{$html}</table></div> 149 252 EOM; 150 return $str;151 }152 //////////////////////////////////////////////////////////////////////153 public function proc_create_menu() {154 add_submenu_page('options-general.php', 'Simple BBScoreboard', 'Simple BBScoreboard', 'administrator', __FILE__, array($this, 'proc_display_settings_page'));155 }156 //////////////////////////////////////////////////////////////////////157 public function proc_register_settings() {158 register_setting($this->m_setting_group, $this->m_option_name, array($this, 'proc_handle_sanitization'));159 }160 //////////////////////////////////////////////////////////////////////161 public function proc_handle_sanitization($ary_set) {162 $ary_options = $this->m_options;163 foreach($ary_set as $key => &$ary_tv){164 $ary_options[$key]['v'] = esc_attr($ary_tv['v']);165 }166 return $ary_options;167 }168 //////////////////////////////////////////////////////////////////////169 public function proc_display_settings_page() {170 //------------------------------------------------------------------171 $ary_set = get_option($this->m_option_name);172 foreach($ary_set as &$ary_tv){173 $ary_tv['v'] = esc_attr($ary_tv['v']);174 }175 //------------------------------------------------------------------176 $ary_bw_sel = array('1px'=>'', '2px'=>'', '3px'=>'');177 $ary_bw_sel[$ary_set['border_line_width']['v']] = 'selected';178 echo <<< EOM179 <div class="wrap">180 <h2>Simple Baseball Scoreboard</h2>181 <h2>1. Usage</h2>182 <p>Short code : <span style="background:#fff;color:#00f;padding:3px 5px;font-size:1.2rem">[ytmr_bb_scoreboard fsize=N tm1=NAME tm2=NAME scr1=RUN scr2=RUN]</span></p>183 <p>Parameters : <br />184 - fsize : font size [rem]<br />185 - tm1 : team name of the bat first<br />186 - tm2 : team name of the field first<br />187 - scr1, scr2 : run of the inning (separator is "/")<br />188 </p>189 <p>sample : <span style="background:#fff;color:#00f;padding:3px 5px;font-size:1.2rem">[ytmr_bb_scoreboard fsize="1.2" tm1="GreenSox" tm2="Monkeys" scr1="0/0/1/1/0/3/0" scr2="1/0/0/2/2/1/X"]</span></p>190 191 <style type="text/css">192 div#YTMRBBScoreBoard td{193 font-size: 1.2rem;194 </style>195 <div id="YTMRBBScoreBoard" style="width:30rem;max-width:100%">196 <table style="width:100%">197 <tr><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>R</td></tr>198 <tr><td><div class="inner">GreenSox</div></td><td><div class="inner">0</div></td><td><div class="inner">0</div></td><td><div class="inner">1</div></td><td><div class="inner">1</div></td><td><div class="inner">0</div></td><td><div class="inner">3</div></td><td><div class="inner">0</div></td><td><div class="inner">5</div></td></tr>199 <tr><td><div class="inner">Monkeys</div></td> <td><div class="inner">1</div></td><td><div class="inner">0</div></td><td><div class="inner">0</div></td><td><div class="inner">2</div></td><td><div class="inner">2</div></td><td><div class="inner">1</div></td><td><div class="inner">X</div></td><td><div class="inner">6</div></td></tr>200 </table>201 </div>202 203 <h2 style="margin-top:2.5rem">2. Settings</h2>204 <form id="YTMRBBScoreBoard_form" method="post" action="options.php">205 EOM;206 settings_fields($this->m_setting_group);207 do_settings_sections($this->m_setting_group);208 echo <<< EOM209 <table class="form-table">210 <tr>211 <th>{$ary_set['border_line_color']['t']}</th>212 <td>213 <input type="color" name="{$this->m_option_name}[border_line_color][v]" value="{$ary_set['border_line_color']['v']}">214 </td>215 </tr>216 <tr>217 <th>{$ary_set['text_color']['t']}</th>218 <td>219 <input type="color" name="{$this->m_option_name}[text_color][v]" value="{$ary_set['text_color']['v']}">220 </td>221 </tr>222 <tr>223 <th>{$ary_set['box_color']['t']}</th>224 <td>225 <input type="color" name="{$this->m_option_name}[box_color][v]" value="{$ary_set['box_color']['v']}">226 </td>227 </tr>228 <tr>229 <th>{$ary_set['background_color']['t']}</th>230 <td>231 <input type="color" name="{$this->m_option_name}[background_color][v]" value="{$ary_set['background_color']['v']}">232 </td>233 </tr>234 <tr>235 <th>{$ary_set['border_line_width']['t']}</th>236 <td>237 <select name="{$this->m_option_name}[border_line_width][v]">238 <option value="1px" {$ary_bw_sel['1px']}>thin</option>239 <option value="2px" {$ary_bw_sel['2px']}>middle</option>240 <option value="3px" {$ary_bw_sel['3px']}>thick</option>241 </select>242 </td>243 </tr>244 </table>245 EOM;246 submit_button();247 echo <<< EOM248 </form>249 </div>250 EOM;251 253 } 252 254 } // end of class
Note: See TracChangeset
for help on using the changeset viewer.