讓wordpress留言評論框,增加實用工具及自訂簡碼
點擊數: 2019
文章目錄
完成後,是這樣子的
步驟一、在主題的comments.php
適當的位置貼入以下語法,至於詳細位置,現在很難說了。
早期主題比較簡單,現在主題比較複雜。
像我的主題的comments.php裡面是沒有東西,是在另外一個檔案。
-
"editor_tools">
-
"editor">
- class="btn-base small-btn-base round-btn btn-hot-pink" href="javascript:SIMPALED.Editor.strong()">粗體
- class="btn-base small-btn-base round-btn btn-pink" href="javascript:SIMPALED.Editor.em()">私密
- class="btn-base small-btn-base round-btn btn-blue-1" href="javascript:;" id="font-color">顏色
- class="btn-base small-btn-base round-btn btn-blue-2" href="javascript:SIMPALED.Editor.del()">刪除線
"padding-top: 10px;">
"fontcolor">
步驟二、在主題裡面新增js語法
- //評論的js
- jQuery(function(){
- jQuery("#fontcolor").hide(500);
- jQuery("#font-color").click(function(){
- jQuery("#fontcolor").toggle(500);
- });
- });
- jQuery(function(){
- jQuery("#fontcolor").hide();
- jQuery("#comment").click(function(){
- });
- });
- jQuery(function() {
- function addEditor(a, b, c) {
- if (document.selection) {
- a.focus();
- sel = document.selection.createRange();
- c ? sel.text = b + sel.text + c: sel.text = b;
- a.focus()
- } else if (a.selectionStart || a.selectionStart == '0') {
- var d = a.selectionStart;
- var e = a.selectionEnd;
- var f = e;
- c ? a.value = a.value.substring(0, d) + b + a.value.substring(d, e) + c + a.value.substring(e, a.value.length) : a.value = a.value.substring(0, d) + b + a.value.substring(e, a.value.length);
- c ? f += b.length + c.length: f += b.length - e + d;
- if (d == e && c) f -= c.length;
- a.focus();
- a.selectionStart = f;
- a.selectionEnd = f
- } else {
- a.value += b + c;
- a.focus()
- }
- }
- var myDate = new Date();
- var mytime=myDate.toLocaleTimeString()
- var g = document.getElementById('comment') || 0;
- var h = {
- strong: function() {
- addEditor(g, '', '')
- },
- em: function() {
- addEditor(g, '[p]', '[/p]')
- },
- del: function() {
- addEditor(g, '
', '') - },
- sign: function() {
- addEditor(g, '今天簽到啦!時間:' + mytime, '')
- },
- red: function() {
- addEditor(g, '"color: red">', '')
- },
- fuchsia: function() {
- addEditor(g, '"color: fuchsia">', '')
- },
- purple: function() {
- addEditor(g, '"color: purple">', '')
- },
- orange: function() {
- addEditor(g, '"color: orange">', '')
- },
- yellow: function() {
- addEditor(g, '"color: yellow">', '')
- },
- olive: function() {
- addEditor(g, '"color: olive">', '')
- },
- lime: function() {
- addEditor(g, '"color: lime">', '')
- },
- maroon: function() {
- addEditor(g, '"color: maroon">', '')
- },
- aqua: function() {
- addEditor(g, '"color: aqua">', '')
- },
- teal: function() {
- addEditor(g, '"color: teal">', '')
- },
- green: function() {
- addEditor(g, '"color: green">', '')
- },
- blue: function() {
- addEditor(g, '"color: blue">', '')
- },
- navy: function() {
- addEditor(g, '"color: navy">', '')
- },
- gray: function() {
- addEditor(g, '"color: gray">', '')
- },
- deepskyblue: function() {
- addEditor(g, '"color: deepskyblue">', '')
- },
- gold: function() {
- addEditor(g, '"color: gold">', '')
- }, silver: function() {
- addEditor(g, '"color: silver">', '')
- },
- black: function() {
- addEditor(g, '"color: black">', '')
- }
- };
- window['SIMPALED'] = {};
- window['SIMPALED']['Editor'] = h
- });
步驟三、增加css的語法
- /*
- ===========================
- 按鈕
- ===========================
- */
- .btn-base
- {
- width: 140px !important;
- height: 49px;
- line-height: 49px;
- display: inline-block !important;
- cursor: pointer;
- border-radius: 5px;
- text-align: center;
- margin: 4px 4px 4px 0;
- color: #fff !important;
- font-size: 14px;
- padding: 0 !important;
- }
- button:hover, button, .sidebar-nav *, .btn-base, .btn-base:hover, .small-btn-base:hover, a.btn-primary:hover, button:hover, .form-actions a.btn {
- transition: all 200ms linear 0s !important;
- }
- .btn-base:hover, .small-btn-base:hover {
- background: none repeat scroll 0 0 #262626 !important;
- color: #FFFFFF !important;
- }
- .btn-hot-pink {
- background-color: #EE2465;
- }
- .btn-pink {
- background-color: #ec6681;
- }
- .btn-purple-low {
- background-color: #5e5668;
- }
- .btn-gray {
- background-color: #9d9ea6;
- }
- .btn-blue-1 {
- background-color: #278aab;
- }
- .btn-blue-2 {
- background-color: #199dac;
- }
- .btn-green {
- background-color: #4c8624;
- }
- .btn-blue-3 {
- background-color: #7fcdcd;
- }
- .btn-orange {
- background-color: #e15d44;
- }
- .btn-red-orange {
- background-color: #dc4123;
- }
- .btn-yellow {
- background-color: #f9c62d;
- }
- .btn-blue-4 {
- background-color: #09c0be;
- }
- div .small-btn-base{
- width: 92px !important;
- text-align: center;
- height: 29px;
- line-height: 29px;
- display: inline-block !important;
- cursor: pointer;
- border-radius: 5px;
- margin: 4px 4px 4px 0;
- color: #fff !important;
- }
- .round-btn {
- border-radius: 25px !important;
- width: 137px !important;
- height: 40px;
- line-height: 37px;
- }
- a.btn-primary:hover, button:hover, .form-actions a.btn:hover {
- background: none repeat scroll 0 0 #262626 !important;
- color: #FFFFFF !important;
- }
- button:hover, button, .sidebar-nav *, .btn-base, .btn-base:hover, .small-btn-base:hover, a.btn-primary:hover, button:hover, .form-actions a.btn {
- transition: all 200ms linear 0s !important;
- }
- /** 評論工具 **/
- #smiley{
- padding-bottom: 10px;
- }
- #editor_tools{
- height: 35px;
- line-height: 32px;
- }
- #editor_tools a{
- color: #777;
- display: inline-block;
- padding: 0 8px;
- height: 30px;
- border-right: 1px solid #ddd;
- }
- #editor_tools a:hover{
- color: #333;
- text-decoration: none;
- }
- #fontcolor{
- width: 377px;
- height: 16px;
- line-height: 20px;
- border: 2px #e0e0e0 solid;
- z-index: 99999;
- padding: 2px 0px 2px 2px;
- }
- #fontcolor a{
- display: inline-block;
- height: 16px;
- width: 16px;
- }