在主题根目录下创建 server
.php
文件,并上传到主题根目录下 rizhtu
与 ripro
不一样
RiPro
下载弹幕美化 *@author
凌山博客 *@url
https
://lingshan
.info
*/require_once
($_SERVER
['DOCUMENT_ROOT
'] . '/wp
-config
.php
');require_once
($_SERVER
['DOCUMENT_ROOT
'] . '/wp
-includes
/wp
-db
.php
'); $list
= $wpdb
->get_results
("SELECT
*FROM
$paylog_table_name
WHERE
status
=1ORDER
BY
pay_time
DESC
limit
10"); $mode
=intval
($_GET
['mode
']); $barrages
=array
();foreach
($list
as
$value
) { $info
=substr_replace
(get_user_by
('id
', $value
->user_id
)->user_login
, '**', '2') . " 刚刚下载了 " .mb_substr
(get_the_title
($value
->post_id
), 0, 8); $img
=str_replace
('http
:', 'https
:',get_user_meta
($value
->user_id
)['user_custom_avatar
'][0]); $href
=get_permalink
($value
->post_id
); $new
=array
( 'info
' => $info
, 'img
' => $img
, 'href
' => $href
, 'speed
' => 15, 'color
' => '#fff
', 'bottom
' => 70, 'close
' =>false
);array_push
($barrages
, $new
); };if
($mode
=== 1) {echo
json_encode
($barrages
[array_rand
($barrages
)]); }elseif
($mode
=== 2) {echo
json_encode
($barrages
); }
创建 jquery
.barrager
.js
文件,并上传到主题的 js
/文件下,js
内容见下方代码
记得将 js
文件中的(网址)和(主题名)改为自己的正确路径,别忘了网址的 http
/https
。
修改主题的 header
.php
文件,引用刚刚创建的 js
文件,在主题前插入代码
在主题 style
.css
文件里插入样式代码
.barrage
{position
:fixed
;bottom
:70px;right
:-500px;display
:inline
-block
;width
: 500px;z
-index
: 99999} .barrage_box
{background
-color
:rgba
(0,0,0,.5);padding
-right
: 8px;height
: 40px;display
:inline
-block
;border
-radius
: 25px;transition
:all
.3s;} .barrage_box
.portrait
{display
:inline
-block
;margin
-top
: 4px;margin
-left
: 4px;width
: 32px;height
: 32px;border
-radius
: 50%;overflow
:hidden
;} .barrage_box
.portrait
img
{width
: 100%;height
: 100%;} .barrage_box
div
.p
a
{margin
-right
: 2px;font
-size
: 14px;color
: #fff
;line
-height
: 40px;margin
-left
: 18px; } .barrage_box
div
.p
a
:hover
{text
-decoration
:underline
;} .barrage_box
.close
{visibility
:hidden
;opacity
: 0;text
-align
:center
;width
:25px;height
: 25px;margin
-left
: 20px;border
-radius
: 50%;background
:rgba
(255,255,255,.1);margin
-top
:8px;background
-image
:url
(close
.png
);} .barrage_box
:hover
.close
{visibility
:visible
;opacity
: 1;} .barrage_box
.close
a
{display
:block
;} .barrage_box
.close
.icon
-close
{font
-size
: 14px;color
:rgba
(255,255,255,.5);display
:inline
-block
;margin
-top
: 5px; } .barrage
.z
{float
:left
!important
;} .barrage
a
{text
-decoration
:none
;}
转载请注明:汇站网 » 日主题与 RIPro
主题实现全站滚动下载弹幕教程