Changeset 2302596
- Timestamp:
- 05/11/2020 11:54:40 AM (6 years ago)
- Location:
- wha-puzzle/trunk
- Files:
-
- 6 edited
-
css/main.min.css (modified) (1 diff)
-
images/icon-full-screen.png (modified) (previous)
-
images/icon-small-screen.png (modified) (previous)
-
js/puzzle.js (modified) (7 diffs)
-
readme.txt (modified) (1 diff)
-
wha-puzzle.php (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wha-puzzle/trunk/css/main.min.css
r2297630 r2302596 1 .wha-puzzle-container-admin h3{font-size:16px;margin:10px 0 10px 0}.wha-puzzle-container-admin .wha-puzzle-admin{border:1px solid #ccc;border-radius:10px;padding:10px;margin-bottom:20px;display:flex;align-items:center}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block{border-right:1px solid #ccc;padding:10px 10px;width:18%;text-align:center}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block label{display:block}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block select,.wha-puzzle-container-admin .wha-puzzle-admin>.item-block input{border:1px solid #c0b9b9;text-align:center}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block input.jscolor{width:75%;padding:5px 10px;border-radius:15px}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block select.select-horizontally,.wha-puzzle-container-admin .wha-puzzle-admin>.item-block select.select-vertical{width:100%}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block select.select-scaling{width:100%}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block{display:flex}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block>div{margin-top:15px}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block img{margin-right:10px}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block h6{margin:0;text-align:left;font-size:12px;color:#c41722}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block input{border:none}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block:last-child{border-right:none}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block:last-child h3{text-align:center}.wha-puzzle-container-admin .wha-puzzle-admin>.item-block:last-child h6{margin:5px 0;font-size:12px;color:#c41722}.wha-puzzle-container-admin .wha-puzzle-admin #whapz-slider{border:1px solid #b5b5b5;margin-top:10px;height:20px;background:#ededed}.wha-puzzle-container-admin .wha-puzzle-admin #whapz-slider #whapz-handle{width:3em;height:30px;top:50%;margin-top:-15px;text-align:center;line-height:1.6em;position:relative;background:#373737;cursor:pointer}.wha-puzzle-container-admin .wha-puzzle-admin #whapz-slider .value-wrapper{display:block;position:absolute;top:34px;left:-4px;border:1px solid grey;right:-13px;color:#000000}.wha-puzzle-container-admin .wha-puzzle-admin #whapz-slider .value-wrapper::before{content:'';position:absolute;display:block;left:20px;top:-16px;border:5px solid transparent;border-bottom:10px solid grey}#myCanvas{z-index:1000}#whapz-puzzle{text-align:center;max-width:100%}.whapz-panel-puzzle{background-color:#282828;float:left;width:100%;padding:5px 0;font-family:Tahoma, sans-serif}.whapz-panel-puzzle a{float:right;margin:5px 5px 0 0;text-align:right}.whapz-panel-puzzle a img{box-shadow:none !important}.whapz-panel-puzzle a:hover{text-decoration:none}.whapz-panel-puzzle .whapz-timer-wrap{float:left;width:80%;padding:0 10px 0 10px}.whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons{float:left;width:auto;text-align:left;padding:5px 10px 0 0}.whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input{width:55px;border:none;padding:15px 0;background-size:contain !important}.whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input.whapz-startButton{background:url("../images/icon-start.png") no-repeat 0 0}.whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input.whapz-resetButton{background:url("../images/icon-restart.png") no-repeat 0 0}.whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input:hover{cursor:pointer}.whapz-panel-puzzle .whapz-timer-wrap>.whapz-timer-item{float:left;width:auto;color:#FFF;font-size:30px}.whapz-panel-puzzle .whapz-completed{width:98%;float:left;font-size:18px;color:#3f8d39;font-family:"Courier New";border-top:1px solid #3e3c3c;margin:5px 5px 0 5px;text-align:center}.whapz-full{display:none;position:absolute;top:0;left:0;z-index:10000}#modal_form{width:100%;max-width:25%;border-radius:5px;border:1px #7f7f7f solid;background:#fff;position:fixed;left:37%;margin-top:-150px;display:none;z-index:1100;padding:30px 10px}#modal_form #modal_close{width:21px;height:21px;position:absolute;top:10px;right:10px;cursor:pointer;display:block;font-family:cursive;font-size:16px;}#modal_form .content{padding:15px;text-align:center}#modal_form .content h4{margin:7px 0}#modal_form .content p{border-top:1px solid #CCCC;padding-top:10px}#modal_form .content img{display:inline}#overlay{z-index:1003;position:fixed;background-color:#000;opacity:0.6;-moz-opacity:0.8;filter:alpha(opacity=80);width:100%;height:100%;top:0;left:0;cursor:pointer;display:none}@media (min-width: 300px) and (max-width: 768px){#whapz-puzzle>.whapz-panel-puzzle a{float:right;width:13%;padding-right:7px}#whapz-puzzle>.whapz-panel-puzzle .whapz-timer-wrap{width:80%;padding:5px 0 0 5px}#whapz-puzzle>.whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons{padding:0;width:auto;display:flex;align-items:center}#whapz-puzzle>.whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input{width:55px;padding:15px 7px;margin-right:7px}#whapz-puzzle>.whapz-panel-puzzle .whapz-timer-wrap>.whapz-timer-item{width:30%;font-size:24px}#whapz-puzzle>.whapz-panel-puzzle .whapz-completed{width:96%;float:left;font-size:20px;color:#3f8d39;border-top:1px solid #3e3c3c;margin:5px 5px 0 5px}#modal_form{max-width:85%;left:5%}} 1 .wha-puzzle-container-admin h3{ 2 font-size:16px; 3 margin:10px 0 10px 0; 4 } 5 .wha-puzzle-container-admin .wha-puzzle-admin{ 6 border:1px solid #ccc; 7 background: #f1f0f0; 8 padding:10px; 9 margin-bottom:20px; 10 display:flex; 11 align-items:center; 12 } 13 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block{ 14 border-right:1px solid #ccc; 15 padding:10px 10px; 16 width:15%; 17 text-align:center; 18 } 19 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block.last-item{ 20 width:25%; 21 } 22 .wha-puzzle-container-admin .wha-puzzle-admin .item-block.last-item{ 23 border-right:none; 24 } 25 26 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block label{ 27 display:block; 28 } 29 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block select, 30 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block input{ 31 border:1px solid #c0b9b9; 32 text-align:center; 33 } 34 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block input.jscolor{ 35 width:75%; 36 padding:5px 10px; 37 border-radius:15px; 38 } 39 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block select.select-horizontally, 40 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block select.select-vertical{ 41 width:100%; 42 } 43 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block select.select-scaling{ 44 width:100%; 45 } 46 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block{ 47 display:flex; 48 } 49 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block>div{ 50 margin-top:15px 51 } 52 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block img{ 53 margin-right:10px 54 } 55 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block h6{ 56 margin:0; 57 text-align:left; 58 font-size:12px; 59 color:#c41722 60 } 61 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block>.upload-block input{ 62 border:none 63 } 64 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block:last-child{ 65 border-right:none 66 } 67 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block:last-child h3{ 68 text-align:center 69 } 70 .wha-puzzle-container-admin .wha-puzzle-admin>.item-block:last-child h6{ 71 margin:5px 0; 72 font-size:12px; 73 color:#c41722 74 } 75 .wha-puzzle-container-admin .wha-puzzle-admin #whapz-slider{ 76 border:1px solid #b5b5b5; 77 margin-top:10px; 78 height:20px; 79 background:#ededed 80 } 81 .wha-puzzle-container-admin .wha-puzzle-admin #whapz-slider #whapz-handle{ 82 width:3em; 83 height:30px; 84 top:50%; 85 margin-top:-15px; 86 text-align:center; 87 line-height:1.6em; 88 position:relative; 89 background:#373737; 90 cursor:pointer 91 } 92 .wha-puzzle-container-admin .wha-puzzle-admin #whapz-slider .value-wrapper{ 93 display:block; 94 position:absolute; 95 top:34px; 96 left:-4px; 97 border:1px solid grey; 98 right:-13px; 99 color:#000000 100 } 101 .wha-puzzle-container-admin .wha-puzzle-admin #whapz-slider .value-wrapper::before{ 102 content:''; 103 position:absolute; 104 display:block; 105 left:20px; 106 top:-16px; 107 border:5px solid transparent; 108 border-bottom:10px solid grey 109 } 110 #myCanvas{ 111 z-index:1000 112 } 113 114 #whapz-puzzle{ 115 text-align:center; 116 max-width:100% 117 } 118 #whapz-puzzle input { 119 letter-spacing: normal; 120 } 121 .whapz-panel-puzzle{ 122 background: rgb(144,140,140); 123 background: linear-gradient(360deg, rgba(144,140,140,1) 0%, rgba(0,0,0,1) 100%); 124 float:left; 125 width:100%; 126 min-width: 350px; 127 padding:5px 0; 128 font-family:Tahoma, sans-serif 129 } 130 .whapz-panel-puzzle a{ 131 float:right; 132 margin:5px 5px 0 0; 133 box-shadow: none !important; 134 } 135 .whapz-panel-puzzle a img{ 136 box-shadow:none !important; 137 transition: .5s; 138 } 139 .whapz-panel-puzzle a:hover img{ 140 opacity: .3; 141 } 142 .whapz-panel-puzzle a:hover{ 143 text-decoration:none; 144 } 145 .whapz-panel-puzzle .whapz-timer-wrap{ 146 float:left; 147 width:max-content; 148 padding:0 10px 0 10px; 149 display: flex; 150 align-items: center; 151 } 152 .whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons{ 153 display: flex; 154 align-items: center; 155 padding:5px 10px 0 0; 156 } 157 .whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input{ 158 width:55px; 159 border:none; 160 padding:15px 0; 161 background-size:contain !important; 162 transition: all .3s linear; 163 } 164 .whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input.whapz-startButton{ 165 background:url("../images/icon-start.png") no-repeat 0 0 166 } 167 .whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input.whapz-resetButton{ 168 background:url("../images/icon-restart.png") no-repeat 0 0 169 } 170 .whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input:hover{ 171 cursor:pointer; 172 opacity: .3; 173 } 174 .whapz-panel-puzzle .whapz-timer-wrap>.whapz-timer-item{ 175 float:left; 176 width:auto; 177 color:#FFF; 178 font-size:30px; 179 } 180 181 182 183 184 /*** Begin customize form ***/ 185 186 .whapz-panel-puzzle .whapz-form-upload { 187 float: left; 188 width: max-content; 189 padding: 10px 10px 0 10px; 190 } 191 .whapz-panel-puzzle form { 192 display: flex; 193 align-items: center; 194 justify-content: space-around; 195 } 196 .whapz-panel-puzzle .whapz-form-upload form label { 197 margin: 0 10px 0 0; 198 font-size: 18px; 199 color: #0a0000; 200 background-color: white; 201 display: inline-block; 202 padding: 0 10px 0 35px; 203 cursor: pointer; 204 position: relative; 205 transition: all .3s linear; 206 line-height: 40px; 207 } 208 .whapz-panel-puzzle .whapz-form-upload form label:before { 209 content: ""; 210 background-image: url('/wp-content/plugins/wha-puzzle/images/icon-upload.png'); 211 background-size: 20px 20px; 212 width: 20px; 213 height: 20px; 214 background-repeat: no-repeat; 215 position: absolute; 216 left: 10px; 217 top: 10px; 218 } 219 .whapz-panel-puzzle .whapz-form-upload form label:hover { 220 background: #a7a7a7; 221 } 222 .whapz-panel-puzzle .whapz-form-upload .whapz-add-image { 223 background: #fff; 224 border-radius: 0; 225 font-size: 18px; 226 padding: 0 10px 0 10px; 227 color: #000; 228 font-weight: normal; 229 box-sizing: border-box; 230 cursor: pointer; 231 border: none; 232 text-transform: capitalize; 233 margin-left: 5px; 234 line-height: 40px; 235 } 236 .whapz-panel-puzzle .whapz-form-upload form .whapz-inputfile { 237 display: none; 238 } 239 240 241 @media (max-width: 639px){ 242 .whapz-panel-puzzle .whapz-form-upload { 243 width: 100%; 244 } 245 .whapz-panel-puzzle .whapz-form-upload form label { 246 width: 100%; 247 margin: 0; 248 padding: 0 10px 0 10px; 249 } 250 .whapz-panel-puzzle .whapz-form-upload form label:before { 251 content: none; 252 } 253 } 254 255 /*** End form ***/ 256 257 .whapz-panel-puzzle .whapz-completed{ 258 width:100%; 259 float:left; 260 font-size:18px; 261 color:#FFFFFF; 262 font-family:"Courier New"; 263 border-top:1px solid #7b7b7b; 264 text-align:center 265 } 266 .whapz-full{ 267 display:none; 268 position:absolute; 269 bottom:0; 270 left:0; 271 z-index:10000; 272 } 273 #modal_form{ 274 width:100%; 275 min-width: 360px; 276 max-width:25%; 277 border:1px #7f7f7f solid; 278 background:#fff; 279 position:fixed; 280 display:none; 281 z-index:1100; 282 padding:30px 10px; 283 top: 50%; 284 left: 50%; 285 margin-right: -50%; 286 transform: translate(-50%, -50%); 287 } 288 #modal_form #modal_close{ 289 width:21px; 290 height:21px; 291 position:absolute; 292 top:10px; 293 right:10px; 294 cursor:pointer; 295 display:block; 296 font-family:cursive; 297 font-size:16px; 298 } 299 #modal_form .content{ 300 padding:15px; 301 text-align:center; 302 font-family: cursive; 303 line-height: 1.3; 304 } 305 #modal_form .content h4{ 306 margin:7px 0 307 } 308 #modal_form .content p{ 309 border-top:1px solid #CCCC; 310 padding-top:10px; 311 margin-top: 10px; 312 display: flex; 313 justify-content: center; 314 } 315 #modal_form .content p a { 316 margin-right: 10px; 317 box-shadow: none; 318 } 319 #modal_form .content img{ 320 display:inline 321 } 322 #overlay{ 323 z-index:1003; 324 position:fixed; 325 background-color:#000; 326 opacity:0.6; 327 -moz-opacity:0.8; 328 filter:alpha(opacity=80); 329 width:100%; 330 height:100%; 331 top:0; 332 left:0; 333 cursor:pointer; 334 display:none 335 } 336 337 @media (max-width: 639px){ 338 #whapz-puzzle>.whapz-panel-puzzle .whapz-timer-wrap{ 339 width:75%; 340 } 341 } 342 343 @media (min-width: 640px) and (max-width: 768px){ 344 #whapz-puzzle>.whapz-panel-puzzle a{ 345 float:right; 346 padding-right:7px 347 } 348 #whapz-puzzle>.whapz-panel-puzzle .whapz-timer-wrap{ 349 width:35%; 350 padding:5px 0 0 5px; 351 } 352 #whapz-puzzle>.whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons{ 353 padding:0; 354 width:auto; 355 display:flex; 356 align-items:center; 357 } 358 #whapz-puzzle>.whapz-panel-puzzle .whapz-timer-wrap>.whapz-group-buttons input{ 359 width:55px; 360 padding:15px 7px; 361 margin-right:7px; 362 } 363 #whapz-puzzle>.whapz-panel-puzzle .whapz-timer-wrap>.whapz-timer-item{ 364 width:30%; 365 font-size:24px; 366 } 367 #whapz-puzzle>.whapz-panel-puzzle .whapz-completed{ 368 width:96%; 369 float:left; 370 font-size:20px; 371 color:#3f8d39; 372 border-top:1px solid #3e3c3c; 373 margin:5px 5px 0 5px; 374 } 375 #modal_form{ 376 max-width:85%; 377 } 378 } -
wha-puzzle/trunk/js/puzzle.js
r2285589 r2302596 12 12 var whapz_canvas_color = optional_puzzle_vars.whapz_canvas_color; 13 13 var whapz_opacity_img = optional_puzzle_vars.whapz_opacity_img; 14 var whapz_control_panel_upload = optional_puzzle_vars.whapz_control_panel_upload; 15 var whapz_post_id = optional_puzzle_vars.whapz_post_id; 14 16 var whapz_bg_color = 'rgb(255, 255, 255, 0)'; 15 17 … … 60 62 whapz_frame('full', width, height); 61 63 64 let whapz_cpu = ''; 65 if( whapz_control_panel_upload === '1' ){ 66 whapz_cpu = 67 "<div class='whapz-form-upload'>\n"+ 68 "<form id='formElem' enctype='multipart/form-data'>" + 69 "<input type='file' name='imagefile' id='imagefile' class='whapz-inputfile' />" + 70 "<label for='imagefile'>Choose Image</label>" + 71 "<input type='hidden' name='id_post' id='id_post' value='"+whapz_post_id+"'>" + 72 "<input class='whapz-add-image' name='add-image' type='button' value='Add Image'>" + 73 "</form></div>"; 74 } 75 62 76 $('body').append("<div class='whapz-panel-puzzle whapz-full'>" + 63 77 "<a id='whapz-button-full' title='Minimize screen' href='javascript:wha_screen(\"" + whapz_scaling + "\",flag=true);'>\n" + … … 69 83 "</div><div class='whapz-timer-item'>\n" + 70 84 "<span class='whapz-min'>00</span>:<span class='whapz-sec'>00</span></div></div>\n" + 85 whapz_cpu + 71 86 "<div class='whapz-completed'>Completed:<span></span></div>\n" + 72 87 "</div></div>"); … … 106 121 zog("ready from ZIM Frame"); // logs in console (F12 - choose console) 107 122 108 var stage = frame.stage;123 var stage = frame.stage; 109 124 var stageW = frame.width; 110 125 var stageH = frame.height; 111 126 112 $('#myCanvas').css({'top': ' 100px'});127 $('#myCanvas').css({'top': '-20px'}); 113 128 114 129 var puzzleX; … … 248 263 249 264 $('.whapz_tw_share').attr("href", "https://twitter.com/share?text=" + encodeURIComponent('I did in ') + "" + $('.whapz-min').eq(0).text() + ":" + $('.whapz-sec').eq(0).text() + " " + encodeURIComponent('minutes, can you beat my record?') + ""); 250 $('.whapz_fb_share').attr("href", "https://www.facebook.com/share.php? p[summary]=" + encodeURIComponent('I did in ') + "" + $('.whapz-min').eq(0).text() + ":" + $('.whapz-sec').eq(0).text() + " " + encodeURIComponent('minutes, can you beat my record?') + "");265 $('.whapz_fb_share').attr("href", "https://www.facebook.com/share.php?u=http://"+window.location.hostname+"&t=" + encodeURIComponent('I did in ') + "" + $('.whapz-min').eq(0).text() + ":" + $('.whapz-sec').eq(0).text() + " " + encodeURIComponent('minutes, can you beat my record?') + ""); 251 266 $('.whapz_ln_share').attr("href", "http://www.linkedin.com/shareArticle?summary=" + encodeURIComponent('I did in ') + "" + $('.whapz-min').eq(0).text() + ":" + $('.whapz-sec').eq(0).text() + " " + encodeURIComponent('minutes, can you beat my record?') + ""); 252 267 … … 354 369 355 370 stage.update(); // this is needed to show any changes 356 //$.cookie('whapz_full_screen', null); // delete cookie357 371 358 372 }); // end of ready … … 428 442 }; 429 443 444 445 /** 446 * Upload Image on Frontend Page 447 */ 448 449 window.onload = function() { 450 451 // Add event Button 452 $('.whapz-panel-puzzle .whapz-add-image').on('click',function(e){ 453 454 let btn = $(this); 455 let label = $('.whapz-panel-puzzle form label'); 456 let file_data = $('.whapz-panel-puzzle #imagefile').prop('files')[0]; 457 let form = document.getElementById('formElem'); 458 let id_post = $('.whapz-panel-puzzle #id_post').val(); 459 460 let form_data = new FormData(form); 461 462 if( undefined !== file_data && ( 463 file_data.type === 'image/png' || 464 file_data.type === 'image/jpg' || 465 file_data.type === 'image/gif' || 466 file_data.type === 'image/jpeg')) 467 { 468 469 form_data.append('file', file_data); 470 form_data.append('id_post', id_post); 471 form_data.append('action', 'frontend_image'); 472 473 let ajax_url ='/wp-admin/admin-ajax.php'; 474 475 $.ajax({ 476 url: ajax_url, 477 type: 'post', 478 async: true, 479 cache: false, 480 contentType: false, 481 enctype: 'multipart/form-data', 482 processData: false, 483 data: form_data, 484 beforeSend: function() { 485 btn.attr({'value':'','disabled':'disabled'}) 486 .css( 487 {'backgroundImage':'url("/wp-content/plugins/wha-puzzle/images/spinner.gif")', 488 'backgroundPosition':'center center', 489 'backgroundRepeat':'no-repeat', 490 'backgroundSize':'contain', 491 'width':'107px', 492 'cursor':'no-drop' 493 }); 494 }, 495 success: function (res) { 496 let result = JSON.parse(res); 497 if(result.status === 1){ 498 window.location.replace(window.location.pathname + window.location.search + window.location.hash); 499 } else { 500 btn.attr({'value':'Error uploaded'}).css({'backgroundColor':'#f7a4a4'}); 501 } 502 }, 503 error: function (response) { 504 btn.attr({'value':'Error uploaded'}).css({'backgroundColor':'#f7a4a4'}); 505 console.error(response); 506 } 507 }); 508 } else { 509 label.css({'backgroundColor':'#f7a4a4'}).text('Select Image'); 510 } 511 512 }); 513 514 }; 515 430 516 } 431 517 -
wha-puzzle/trunk/readme.txt
r2297630 r2302596 2 2 === Puzzles game === 3 3 Contributors: webhelpagency 4 Version: 1.0. 54 Version: 1.0.6 5 5 Donate link: http://webhelpagency.com/ 6 6 Tags: crossword, game, mind, puzzles -
wha-puzzle/trunk/wha-puzzle.php
r2297634 r2302596 4 4 * Plugin Name: WHA Puzzle 5 5 * Description: The plugin puzzle. 6 * Version: 1.0. 56 * Version: 1.0.6 7 7 * Author: WHA 8 8 * Author URI: http://webhelpagency.com/ … … 28 28 29 29 if (!defined('ABSPATH')) { 30 exit; // Exit if accessed directly31 }32 33 34 // If this file is called directly, abort.35 if (!defined('WPINC')) {36 30 exit; 37 31 } 38 32 39 define('WHA_PUZZLE_VERSION', '1.0.3'); 33 /** 34 * If this file is called directly, abort. 35 */ 36 if ( !defined('WPINC') ) { 37 exit; 38 } 39 40 define( 'WHA_PUZZLE_VERSION', '1.0.6' ); 40 41 41 42 function wha_puzzle_activation(){} … … 47 48 register_deactivation_hook(__FILE__, 'wha_puzzle_deactivation'); 48 49 49 50 // Add scripts & styles admin panel 50 /** 51 * Add scripts & styles admin panel 52 */ 51 53 if( ! function_exists('whapz_action_admin' ) ) { 52 54 … … 64 66 65 67 66 // Register scripts & styles frontend 68 /** 69 * Register scripts & styles frontend 70 */ 67 71 if( ! function_exists('whapz_setup_script' ) ) { 68 72 … … 88 92 89 93 90 // Initialization post type wha-puzzle 94 /** 95 * Initialization post type wha-puzzle 96 */ 91 97 if( ! function_exists('whapz_register_post_type' ) ) { 92 98 93 99 add_action('init', 'whapz_register_post_type'); 100 94 101 function whapz_register_post_type() { 95 102 … … 133 140 134 141 // Add new size images 135 add_image_size( 'desktop-puzzle-image', 800, 600, true ); // for desktop app136 add_image_size( 'mobile-puzzle-image', 320, 320); // for mobile app142 add_image_size( 'desktop-puzzle-image', 800, 600, true ); 143 add_image_size( 'mobile-puzzle-image', 320, 320); 137 144 138 145 //support post thumbnails … … 142 149 143 150 144 // Create puzzle page 151 /** 152 * Create puzzle page 153 */ 145 154 if( ! function_exists('whapz_create_puzzle_page' ) ) { 146 155 … … 166 175 167 176 168 // Create shortcode puzzle 177 /** 178 * Create shortcode puzzle 179 */ 169 180 if( ! function_exists('whapz_whagamepuzzle_func' ) ) { 170 181 … … 179 190 $html .= '<div id="whapz-puzzle">'; 180 191 $html .= '<div id="puzzleID-'.$id.'"></div>'; 192 193 $cpu = !empty(get_post_meta($id, 'whapz_control_panel_upload', true)) ? true : false; 181 194 182 195 $html .= "<div class='whapz-panel-puzzle whapz-small'> … … 191 204 <span class='whapz-min'>00</span>:<span class='whapz-sec'>00</span> 192 205 </div> 193 </div> 194 <div class='whapz-completed'>".__('Completed:','whapz_puzzle')." <span></span></div> 206 </div>"; 207 208 if( $cpu ): 209 210 $html .= " <div class='whapz-form-upload'> 211 <form id='formElem' enctype='multipart/form-data'> 212 <input type='file' name='imagefile' id='imagefile' class='whapz-inputfile' /> 213 <label for='imagefile'>Choose Image</label> 214 <input type='hidden' name='id_post' id='id_post' value='".$id."'> 215 <input class='whapz-add-image' name='add-image' type='button' value='Add Image'> 216 </form> 217 </div>"; 218 endif; 219 220 $html .= "<div class='whapz-completed'>".__('Completed:','whapz_puzzle')." <span></span></div> 195 221 </div>"; 196 222 … … 205 231 'whapz_mobile_image':'" . get_post_meta($id, 'whapz_mobile_image_puzzle', true) . "', 206 232 'whapz_canvas_color':'#" . get_post_meta($id, 'whapz_option_canvas_color', true) . "', 207 'whapz_opacity_img':'" . get_post_meta($id, 'whapz_option_opacity_img', true) . "'}; 233 'whapz_opacity_img':'" . get_post_meta($id, 'whapz_option_opacity_img', true) . "', 234 'whapz_control_panel_upload':'" . get_post_meta($id, 'whapz_control_panel_upload', true) . "', 235 'whapz_post_id':'" . get_post_meta($id, 'whapz_post_id', true) . "'}; 208 236 /* ]]> */ 209 237 </script>"; … … 215 243 <div class="content"> 216 244 <h4>'.__('Your time','whapz_puzzle').': <span class="whapz-used-minutes"></span>:<span class="whapz-used-second"></span></h4> 217 '. get_post_meta($id, 'whapz_option_congratulations', true).'245 '.wp_trim_words(get_post_meta($id, 'whapz_option_congratulations', true), 70,'...').' 218 246 <p> 219 247 <a class="whapz_fb_share" target="_blank" href="#"> … … 236 264 237 265 238 239 // Add shortcode option box 266 /** 267 * Add shortcode Option Box 268 */ 240 269 if( ! function_exists('whapz_puzzle_add_box_shortcode' ) ) { 241 270 … … 255 284 256 285 257 258 // Add Default Setting option box 286 /** 287 * Add Default Setting Option Box 288 */ 259 289 if( ! function_exists('whapz_puzzle_add_box_setting' ) ) { 260 290 … … 281 311 282 312 $var_opacity_img = (float) get_post_meta($post->ID, 'whapz_option_opacity_img', true); 313 314 $cpu_checked = !empty(get_post_meta($post->ID, 'whapz_control_panel_upload', true)) ? 'checked' : ''; 283 315 284 316 if($var_opacity_img !== .0) { … … 332 364 <input class="whapz_opacity_img" type="hidden" name="whapz_opacity_img" value="'.(float) $whapz_opacity_img.'"> 333 365 <span class="value-wrapper"><span class="value-output"></span>%</span></div></div></div>'; 366 echo '<div class="item-block last-item">'; 367 echo __('<h3>Allow image upload on frontend</h3>', 'whapz_puzzle'); 368 echo '<input type="checkbox" class="whapz-display-panel_upload" name="whapz_control_panel_upload" value="1" '.$cpu_checked.'>'; 369 echo __('<small>Allow users to upload images on their own. The image on frontend overwrites image inside admin panel.</small>', 'whapz_puzzle'); 370 echo '</div>'; 334 371 echo "<script> 335 372 /* <![CDATA[ */ … … 365 402 366 403 echo '<div class="editor_wrap"><h3>'.__('Congratulations text', 'whapz_puzzle').'</h3>'; 367 /* Congratulations text */368 404 wp_editor($whapz_congratulations, 'whapz_congratulations', $settings = array( 369 405 'wpautop' => true, … … 379 415 380 416 381 382 // Save data 417 /** 418 * Save data 419 */ 383 420 if( ! function_exists('whapz_save_data' ) ) { 384 421 … … 387 424 function whapz_save_data($post_id) { 388 425 389 if (!wp_verify_nonce($_POST['whapz_puzzle_noncename'], plugin_basename(__FILE__))) 390 return; 391 392 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) 393 return; 394 395 if (!current_user_can('edit_post', $post_id)) 396 return; 397 398 399 $attachment_id = get_post_thumbnail_id( $post_id ); 400 401 $array = wp_get_attachment_metadata( $attachment_id ); 402 403 if(!empty($array) && !empty($array['sizes']['thumbnail']['mime-type']) && ( 404 $array['sizes']['thumbnail']['mime-type'] == 'image/png' || 405 $array['sizes']['thumbnail']['mime-type'] == 'image/jpg' || 406 $array['sizes']['thumbnail']['mime-type'] == 'image/gif' || 407 $array['sizes']['thumbnail']['mime-type'] == 'image/jpeg')) 408 { 409 410 $url_image = $array['file']; 411 412 if(!empty($array['sizes']['desktop-puzzle-image']['file'])) { 413 414 // for desktop 415 $name_image = $array['sizes']['desktop-puzzle-image']['file']; 416 $meta_arr = explode('/', $url_image ); 417 $full_path_img = $meta_arr[0] . '/' . $meta_arr[1] . '/' . $name_image; 418 update_post_meta($post_id, 'whapz_desktop_image_puzzle', $full_path_img); 426 if( 'wha_puzzle' === get_post_type($post_id) ) { 427 428 if (!wp_verify_nonce($_POST['whapz_puzzle_noncename'], plugin_basename(__FILE__))) 429 return; 430 431 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) 432 return; 433 434 if (!current_user_can('edit_post', $post_id)) 435 return; 436 437 438 if( !isset($_POST['whapz_control_panel_upload']) ) { 439 440 $attachment_id = get_post_thumbnail_id( $post_id ); 441 442 $array = wp_get_attachment_metadata( $attachment_id ); 443 444 if(!empty($array) && !empty($array['sizes']['thumbnail']['mime-type']) && ( 445 $array['sizes']['thumbnail']['mime-type'] == 'image/png' || 446 $array['sizes']['thumbnail']['mime-type'] == 'image/jpg' || 447 $array['sizes']['thumbnail']['mime-type'] == 'image/gif' || 448 $array['sizes']['thumbnail']['mime-type'] == 'image/jpeg')) 449 { 450 451 $url_image = $array['file']; 452 453 if(!empty($array['sizes']['desktop-puzzle-image']['file'])) { 454 455 // for desktop 456 $name_image = $array['sizes']['desktop-puzzle-image']['file']; 457 $meta_arr = explode('/', $url_image ); 458 $full_path_img = $meta_arr[0] . '/' . $meta_arr[1] . '/' . $name_image; 459 update_post_meta($post_id, 'whapz_desktop_image_puzzle', $full_path_img); 460 461 } 462 463 if(!empty($array['sizes']['mobile-puzzle-image']['file'])) { 464 465 // for mobile 466 $mobile_name_image = $array['sizes']['mobile-puzzle-image']['file']; 467 $mobile_meta_arr = explode('/', $url_image ); 468 $mobile_full_path_img = $mobile_meta_arr[0] . '/' . $mobile_meta_arr[1] . '/' . $mobile_name_image; 469 update_post_meta($post_id, 'whapz_mobile_image_puzzle', $mobile_full_path_img); 470 } 471 472 if(empty($array['sizes']['desktop-puzzle-image']['file'])) { 473 474 $whapz_image_url = get_post_meta($attachment_id, '_wp_attached_file', true); 475 update_post_meta($post_id, 'whapz_desktop_image_puzzle', $whapz_image_url); 476 } 477 478 if(empty($array['sizes']['mobile-puzzle-image']['file'])) { 479 480 $whapz_image_url = get_post_meta($attachment_id, '_wp_attached_file', true); 481 update_post_meta($post_id, 'whapz_mobile_image_puzzle', $whapz_image_url); 482 } 483 } 484 else { 485 wp_die(__('Featured image is required. Invalid image format. Upload an image correct format, please','whapz_puzzle').' 486 <a href="/wp-admin/post.php?post='.$post_id.'&action=edit">Back edit page</a>'); 487 } 419 488 420 489 } 421 422 if(!empty($array['sizes']['mobile-puzzle-image']['file'])) { 423 424 // for mobile 425 $mobile_name_image = $array['sizes']['mobile-puzzle-image']['file']; 426 $mobile_meta_arr = explode('/', $url_image ); 427 $mobile_full_path_img = $mobile_meta_arr[0] . '/' . $mobile_meta_arr[1] . '/' . $mobile_name_image; 428 update_post_meta($post_id, 'whapz_mobile_image_puzzle', $mobile_full_path_img); 490 else { 491 492 $desktop_image_puzzle = get_post_meta($post_id, 'whapz_desktop_image_puzzle', true); 493 $mobile_image_puzzle = get_post_meta($post_id, 'whapz_mobile_image_puzzle', true); 494 495 if(empty($desktop_image_puzzle)) { 496 update_post_meta($post_id, 'whapz_desktop_image_puzzle', '/wp-content/plugins/wha-puzzle/images/desktop.jpg'); 497 } 498 499 if(empty($mobile_image_puzzle)) { 500 update_post_meta($post_id, 'whapz_mobile_image_puzzle', '/wp-content/plugins/wha-puzzle/images/mobile.jpg'); 501 } 502 429 503 } 430 504 431 if(empty($array['sizes']['desktop-puzzle-image']['file'])) { 432 433 $whapz_image_url = get_post_meta($attachment_id, '_wp_attached_file', true); 434 update_post_meta($post_id, 'whapz_desktop_image_puzzle', $whapz_image_url); 435 } 436 437 if(empty($array['sizes']['mobile-puzzle-image']['file'])) { 438 439 $whapz_image_url = get_post_meta($attachment_id, '_wp_attached_file', true); 440 update_post_meta($post_id, 'whapz_mobile_image_puzzle', $whapz_image_url); 441 } 442 } 443 else { 444 wp_die(__('Invalid image format. Upload an image correct format, please','whapz_puzzle').' 445 <a href="/wp-admin/post.php?post='.$_POST['post_id'].'&action=edit">Back edit page</a>'); 446 } 447 448 449 $whapz_horizontal_pieces = is_numeric($_POST['whapz_horizontal_pieces'])?$_POST['whapz_horizontal_pieces']:5; 450 $whapz_vertical_pieces = is_numeric($_POST['whapz_vertical_pieces'])?$_POST['whapz_vertical_pieces']:5; 451 $whapz_scaling = is_numeric($_POST['post_id'])?'puzzleID-'.$_POST['post_id'].'':0; 452 $whapz_congratulations = $_POST['whapz_congratulations_message']; 453 $whapz_canvas_color = (sanitize_hex_color_no_hash($_POST['whapz_canvas_color'])!= null)?$_POST['whapz_canvas_color']:'FFFFFF'; 454 $whapz_opacity_img = (is_numeric($_POST['whapz_opacity_img']) && $_POST['whapz_opacity_img'] >= 0 && $_POST['whapz_opacity_img'] <= 1)?$_POST['whapz_opacity_img']:1; 455 456 update_post_meta($post_id, 'whapz_option_horizontal_pieces', $whapz_horizontal_pieces); 457 update_post_meta($post_id, 'whapz_option_vertical_pieces', $whapz_vertical_pieces); 458 update_post_meta($post_id, 'whapz_option_scaling', $whapz_scaling); 459 update_post_meta($post_id, 'whapz_option_congratulations', $whapz_congratulations); 460 update_post_meta($post_id, 'whapz_option_canvas_color', $whapz_canvas_color); 461 update_post_meta($post_id, 'whapz_option_opacity_img', $whapz_opacity_img); 462 463 } 464 } 465 466 467 // Translit name uploaded file 505 506 $whapz_horizontal_pieces = is_numeric($_POST['whapz_horizontal_pieces'])?$_POST['whapz_horizontal_pieces']:5; 507 $whapz_vertical_pieces = is_numeric($_POST['whapz_vertical_pieces'])?$_POST['whapz_vertical_pieces']:5; 508 $whapz_scaling = is_numeric($_POST['post_id'])?'puzzleID-'.$_POST['post_id'].'':0; 509 $whapz_congratulations = $_POST['whapz_congratulations_message']; 510 $whapz_canvas_color = (sanitize_hex_color_no_hash($_POST['whapz_canvas_color'])!= null)?$_POST['whapz_canvas_color']:'FFFFFF'; 511 $whapz_opacity_img = (is_numeric($_POST['whapz_opacity_img']) && $_POST['whapz_opacity_img'] >= 0 && $_POST['whapz_opacity_img'] <= 1)?$_POST['whapz_opacity_img']:1; 512 $whapz_control_panel_upload = isset($_POST['whapz_control_panel_upload']) ? $_POST['whapz_control_panel_upload'] : 0; 513 $whapz_post_id = $post_id; 514 515 update_post_meta($post_id, 'whapz_option_horizontal_pieces', $whapz_horizontal_pieces); 516 update_post_meta($post_id, 'whapz_option_vertical_pieces', $whapz_vertical_pieces); 517 update_post_meta($post_id, 'whapz_option_scaling', $whapz_scaling); 518 update_post_meta($post_id, 'whapz_option_congratulations', $whapz_congratulations); 519 update_post_meta($post_id, 'whapz_option_canvas_color', $whapz_canvas_color); 520 update_post_meta($post_id, 'whapz_option_opacity_img', $whapz_opacity_img); 521 update_post_meta($post_id, 'whapz_control_panel_upload', $whapz_control_panel_upload); 522 update_post_meta($post_id, 'whapz_post_id', $whapz_post_id); 523 524 } 525 } 526 } 527 528 529 /** 530 * Translit name uploaded file 531 */ 468 532 if( ! function_exists('whapz_translit' ) ) { 469 533 … … 471 535 472 536 $text = mb_strtolower( $text, 'UTF-8' ); 473 $symbol_table = array('а' => 'a', 'б' => 'b','в' => 'v',537 $symbol_table = array('а' => 'a', 'б' => 'b', 'в' => 'v', 474 538 'г' => 'g', 'д' => 'd', 'е' => 'e', 475 'ё' => 'yo', 'ж' => 'zh','з' => 'z',539 'ё' => 'yo','ж' => 'zh','з' => 'z', 476 540 'и' => 'i', 'й' => 'j', 'к' => 'k', 477 541 'л' => 'l', 'м' => 'm', 'н' => 'n', … … 479 543 'с' => 's', 'т' => 't', 'у' => 'u', 480 544 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 481 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'shh',545 'ч' => 'ch', 'ш' => 'sh','щ' => 'shh', 482 546 'ъ' => "", 'ы' => 'y', 'ь' => "", 483 547 'э' => 'e', 'ю' => 'yu', 'я' => 'ya'); … … 487 551 488 552 } 553 554 555 /** 556 * AJAX Upload Image 557 */ 558 function whapz_add_frontend_image() { 559 560 $response = array(); 561 562 $post_id = $_POST['id_post']; 563 564 $attachment_id = media_handle_upload( 'imagefile', $post_id ); 565 566 if ( is_wp_error( $attachment_id ) ) { 567 568 $response['status'] = 0; 569 } 570 else { 571 572 $array = wp_get_attachment_metadata( $attachment_id ); 573 574 $url_image = $array['file']; 575 576 if( !empty($array['sizes']['desktop-puzzle-image']['file']) ) { 577 578 // for desktop 579 $name_image = $array['sizes']['desktop-puzzle-image']['file']; 580 $meta_arr = explode('/', $url_image ); 581 $full_path_img = $meta_arr[0] . '/' . $meta_arr[1] . '/' . $name_image; 582 update_post_meta($post_id, 'whapz_desktop_image_puzzle', $full_path_img); 583 584 } 585 586 if( !empty($array['sizes']['mobile-puzzle-image']['file']) ) { 587 588 // for mobile 589 $mobile_name_image = $array['sizes']['mobile-puzzle-image']['file']; 590 $mobile_meta_arr = explode('/', $url_image ); 591 $mobile_full_path_img = $mobile_meta_arr[0] . '/' . $mobile_meta_arr[1] . '/' . $mobile_name_image; 592 update_post_meta($post_id, 'whapz_mobile_image_puzzle', $mobile_full_path_img); 593 } 594 595 if( empty($array['sizes']['desktop-puzzle-image']['file']) ) { 596 597 $whapz_image_url = get_post_meta($attachment_id, '_wp_attached_file', true); 598 update_post_meta($post_id, 'whapz_desktop_image_puzzle', $whapz_image_url); 599 } 600 601 if( empty($array['sizes']['mobile-puzzle-image']['file']) ) { 602 603 $whapz_image_url = get_post_meta($attachment_id, '_wp_attached_file', true); 604 update_post_meta($post_id, 'whapz_mobile_image_puzzle', $whapz_image_url); 605 } 606 607 $response['status'] = 1; 608 } 609 610 echo json_encode($response); 611 612 wp_die(); 613 } 614 615 add_action( 'wp_ajax_frontend_image', 'whapz_add_frontend_image' ); 616 add_action( 'wp_ajax_nopriv_frontend_image', 'whapz_add_frontend_image' ); 617 618 619 620
Note: See TracChangeset
for help on using the changeset viewer.