当前日期时间
当前时间:
网站标志
Logo
全站搜索
广告位
phpweb图片广告
广告位
phpweb图片广告
自定内容

phpweb已经是国内最强的的开源电子商务系统了,但并非完美,因为任何...

互联网3年一轮回,京东凡客等电商品牌在三年之前也不过是小打小闹,而如...

电商已经成为趋势,传统行业的竞争已经逐渐演变到网络上,也有不少用Weboss...

phpweb系统是固定的模式,适用于大部分行业与需求。但有一些行业还是有自己...

当前位置
文章正文

WordPress友情链接模板(附网址检测)

发表:管理员  发表时间:2021-07-12 09:53:51   阅读:(1611)次  

有一些做网站的朋友,自己的站点有许多的友情链接,难免有个别站长无法长期坚持,中途放弃。于是就有必要去除那些无法访问的链接,一个个访问查看很麻烦。若以原站头像是否显示来判断,有些不准确,比如开了防盗链或头像不来自原站。这样网址自动检测就非常有必要了。

image.png

实现方法:

1.新建页面模板,比如命名为links-check.php,代码如下:

<?php 

/*

 *Template Name: 链接检测模版

 *作者:草莓互联

 *网站:www.100cm.cn

 */

get_header(); 

// 网址访问判断

function httpcode($url){

        $ch = curl_init();

        $timeout = 5;

        curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);

        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

        curl_setopt($ch, CURLOPT_HEADER, 1);

        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

        curl_setopt($ch,CURLOPT_URL,$url);

        curl_exec($ch);

        return $httpcode = curl_getinfo($ch,CURLINFO_HTTP_CODE);

        curl_close($ch);

}

//链接访问状态判断函数

function link_status($link)

{

    //ini_set('max_execution_time',15);

    $status=httpcode($link);

    if($status == 200 ) 

        return "<p><i class="fa fa-check-circle" aria-hidden="true"></i> 访问正常</p>";

    else

        return "<font color="#CCA700"><i class="fa fa-exclamation-circle" aria-hidden="true"></i>  无法访问</font>";

}

 

//列出指定链接

function the_link_items($id = null)

{

    $bookmarks = get_bookmarks('orderby=date&category=' . $id);

    $output = '';

    if (!empty($bookmarks)) {

        $output .= '<ul class="link-items fontSmooth">';

        foreach ($bookmarks as $bookmark) {

            if (empty($bookmark->link_description)) {

                $bookmark->link_description = __('This guy is so lazy ╮(╯▽╰)╭', 'sakurairo');

            }

 

            if (empty($bookmark->link_image)) {

                $bookmark->link_image = 'https://view.moezx.cc/images/2017/12/30/Transparent_Akkarin.th.jpg';

            }

            $output .= '<li class="link-item"><a class="link-item-inner effect-apollo" href="' . $bookmark->link_url . '" title="' . $bookmark->link_description . '" target="_blank" rel="friend"><img src="' . $bookmark->link_image . '" src="/load/inload.svg"><span class="sitename">' . $bookmark->link_name . '</span><span>' . link_status($bookmark->link_url). '</span><div class="linkdes">' . $bookmark->link_description . '</div></a></li>';

        }

        $output .= '</ul>';

    }

    return $output;

}

 

//列出所有链接

function link_items()

{

    $linkcats = get_terms('link_category');

    if (!empty($linkcats)) {

        foreach ($linkcats as $linkcat) {

            $result .= '<h3 class="link-title"><span class="link-fix">' . $linkcat->name . '</span></h3>';

            if ($linkcat->description) {

                $result .= '<div class="link-description">' . $linkcat->description . '</div>';

            }

 

            $result .= the_link_items($linkcat->term_id);

        }

    } else {

        $result = the_link_items();

    }

    return $result;

}

 

?>

    <?php while(have_posts()) : the_post(); ?>

    <?php if( !get_post_thumbnail_id(get_the_ID())) { ?>

    <span class="linkss-title"><?php the_title();?></span>

    <?php } ?>

        <article <?php post_class("post-item"); ?>>

            <?php the_content(); ?>

            <div class="links">

                <?php echo link_items();//列出所有友情链接,若列出分组id为49的则改为the_link_items('49') ?>

            </div>

        </article>

    <?php endwhile; ?>

<?php

get_footer();

2.引入css,命名为add-style.css,代码如下:

@charset "utf-8";

/*

Theme Name: Sakurairo

Author:by XnSay

Author URI: https://xnsay.com/

Tags: 多彩、轻松上手、体验完善、高自定义度

*/

.al_year{margin-left:-55px}

 

.cat-des p {

    display: inline-block;

    padding-left: 10px

}

 

h1 {

    clear: both

}

 

h1.cat-title {

    display: inline-block;

    font-size: 25px;

    font-weight: 400;

    padding-right: 15px;

    border-right: 1px dashed #ddd;

    color: #0084FE

}

 

header.page-header {

    position: relative;

    text-align: center;

    margin-bottom: 50px;

    color: #9C9C9C

}

 

.links {

    margin-bottom: 80px

}

 

.links ul {

    margin: 0;

    list-style: none;

    padding: 0;

    width: 100%;

    display: inline-block

}

 

.links ul li {

    width: 32%;

    float: left;

    border: 1px solid #0084FE;

    padding: 10px 15px;

    margin: 4px 4px;

    position: relative;

    overflow: hidden;

    -webkit-transition: all .3s;

    transition: all .3s;

    border-radius: 10px

}

 

.links ul li img {

    float: left;

    box-shadow: inset 0 0 10px #0084FE;

    padding: 5px;

    opacity: 1;

    transform: rotate(0);

    -webkit-transform: rotate(0);

    -moz-transform: rotate(0);

    -o-transform: rotate(0);

    -ms-transform: rotate(0);

    transition: all ease 1s;

    -webkit-transition: all ease 1s;

    -moz-transition: all ease 1s;

    -o-transition: all ease 1s;

    margin-top: 3px;

    width: 70px;

    height: 70px;

    padding: 1px;

    border-radius: 100%

}

 

.links ul li:hover img {

    transform: rotate(360deg);

    -webkit-transform: rotate(360deg);

    -moz-transform: rotate(360deg);

    -o-transform: rotate(360deg);

    -ms-transform: rotate(360deg)

}

 

span.sitename {

    font-size: 20px;

    margin-top: 85px;

    margin-left: 8px;

    color: #000;

    padding-bottom: 10px;

    display: block;

    -webkit-transition: all .3s;

    transition: all .3s;

    overflow: hidden;

    text-overflow: ellipsis;

    -o-text-overflow: ellipsis;

    white-space: nowrap

}

 

.linkdes {

    color: #000;

    font-size: 14px;

    padding: 4px 0;

    margin-left: 8px;

    border-top: 1px dotted #0084FE;

    text-overflow: ellipsis;

    overflow: hidden;

    white-space: nowrap;

    line-height: 20px;

    -webkit-transition: all .5s;

    transition: all .5s

}

 

.link-title {

    font-weight: 400;

    color: #6D6D6D;

    padding-left: 10px;

    border-left: none;

    margin: 50px 0 20px

}

 

.link-title span.link-fix {

    padding-left: 10px;

    border-left: 3px solid #0084FE;

}

 

.links ul li:before {

    content: "";

    background-color: #0084FE;

    -webkit-transform: skew(45deg, 0);

    transform: skew(45deg, 0);

    width: 0;

    height: 100%;

    position: absolute;

    top: 0;

    left: -60px;

    z-index: -1;

    -webkit-transition: all .5s;

    transition: all .5s

}

 

.links ul li:hover {

    color: #27323A;

    border: 1px solid #0084FE

}

 

.links ul li:hover:before {

    width: 180%

}

 

.links ul li:hover .linkdes {

    border-top: 1px dashed #fff

}

 

span.linkss-title {

    font-size: 25px;

    text-align: center;

    display: block;

    margin: 50px 0 30px;

    letter-spacing: 5px

}

 

.mashiro-tips {

    opacity: 0;

    width: 250px;

    height: auto;

    min-height: 70px;

    margin: -20px 20px;

    padding: 5px 10px;

    border-radius: 12px;

    box-sizing: border-box;

    box-shadow: 0 0 2px 0 rgba(0, 0, 0, .12), 0 2px 2px 0 rgba(0, 0, 0, .24);

    transition: box-shadow .2s ease;

    background: #fff;

    color: #212121;

    font-size: 12px;

    text-overflow: ellipsis;

    overflow: hidden;

    position: absolute;

    animation-delay: 5s;

    animation-duration: 50s;

    animation-iteration-count: infinite;

    animation-name: shake;

    animation-timing-function: ease-in-out

}

 

@keyframes shake {

    2% {

        transform: translate(.5px, -1.5px) rotate(-.5deg)

    }

    4% {

        transform: translate(.5px, 1.5px) rotate(1.5deg)

    }

    6% {

        transform: translate(1.5px, 1.5px) rotate(1.5deg)

    }

    8% {

        transform: translate(2.5px, 1.5px) rotate(.5deg)

    }

    10% {

        transform: translate(.5px, 2.5px) rotate(.5deg)

    }

    12% {

        transform: translate(1.5px, 1.5px) rotate(.5deg)

    }

    14% {

        transform: translate(.5px, .5px) rotate(.5deg)

    }

    16% {

        transform: translate(-1.5px, -.5px) rotate(1.5deg)

    }

    18% {

        transform: translate(.5px, .5px) rotate(1.5deg)

    }

    20% {

        transform: translate(2.5px, 2.5px) rotate(1.5deg)

    }

    22% {

        transform: translate(.5px, -1.5px) rotate(1.5deg)

    }

    24% {

        transform: translate(-1.5px, 1.5px) rotate(-.5deg)

    }

    26% {

        transform: translate(1.5px, .5px) rotate(1.5deg)

    }

    28% {

        transform: translate(-.5px, -.5px) rotate(-.5deg)

    }

    30% {

        transform: translate(1.5px, -.5px) rotate(-.5deg)

    }

    32% {

        transform: translate(2.5px, -1.5px) rotate(1.5deg)

    }

    34% {

        transform: translate(2.5px, 2.5px) rotate(-.5deg)

    }

    36% {

        transform: translate(.5px, -1.5px) rotate(.5deg)

    }

    38% {

        transform: translate(2.5px, -.5px) rotate(-.5deg)

    }

    40% {

        transform: translate(-.5px, 2.5px) rotate(.5deg)

    }

    42% {

        transform: translate(-1.5px, 2.5px) rotate(.5deg)

    }

    44% {

        transform: translate(-1.5px, 1.5px) rotate(.5deg)

    }

    46% {

        transform: translate(1.5px, -.5px) rotate(-.5deg)

    }

    48% {

        transform: translate(2.5px, -.5px) rotate(.5deg)

    }

    50% {

        transform: translate(-1.5px, 1.5px) rotate(.5deg)

    }

    52% {

        transform: translate(-.5px, 1.5px) rotate(.5deg)

    }

    54% {

        transform: translate(-1.5px, 1.5px) rotate(.5deg)

    }

    56% {

        transform: translate(.5px, 2.5px) rotate(1.5deg)

    }

    58% {

        transform: translate(2.5px, 2.5px) rotate(.5deg)

    }

    60% {

        transform: translate(2.5px, -1.5px) rotate(1.5deg)

    }

    62% {

        transform: translate(-1.5px, .5px) rotate(1.5deg)

    }

    64% {

        transform: translate(-1.5px, 1.5px) rotate(1.5deg)

    }

    66% {

        transform: translate(.5px, 2.5px) rotate(1.5deg)

    }

    68% {

        transform: translate(2.5px, -1.5px) rotate(1.5deg)

    }

    70% {

        transform: translate(2.5px, 2.5px) rotate(.5deg)

    }

    72% {

        transform: translate(-.5px, -1.5px) rotate(1.5deg)

    }

    74% {

        transform: translate(-1.5px, 2.5px) rotate(1.5deg)

    }

    76% {

        transform: translate(-1.5px, 2.5px) rotate(1.5deg)

    }

    78% {

        transform: translate(-1.5px, 2.5px) rotate(.5deg)

    }

    80% {

        transform: translate(-1.5px, .5px) rotate(-.5deg)

    }

    82% {

        transform: translate(-1.5px, .5px) rotate(-.5deg)

    }

    84% {

        transform: translate(-.5px, .5px) rotate(1.5deg)

    }

    86% {

        transform: translate(2.5px, 1.5px) rotate(.5deg)

    }

    88% {

        transform: translate(-1.5px, .5px) rotate(1.5deg)

    }

    90% {

        transform: translate(-1.5px, -.5px) rotate(-.5deg)

    }

    92% {

        transform: translate(-1.5px, -1.5px) rotate(1.5deg)

    }

    94% {

        transform: translate(.5px, .5px) rotate(-.5deg)

    }

    96% {

        transform: translate(2.5px, -.5px) rotate(-.5deg)

    }

    98% {

        transform: translate(-1.5px, -1.5px) rotate(-.5deg)

    }

    0%,

    100% {

        transform: translate(0, 0) rotate(0)

    }

}

 

@-webkit-keyframes glitch-loop-1 {

    0% {

        clip: rect(36px, 9999px, 9px, 0)

    }

    25% {

        clip: rect(25px, 9999px, 99px, 0)

    }

    50% {

        clip: rect(50px, 9999px, 102px, 0)

    }

    75% {

        clip: rect(30px, 9999px, 92px, 0)

    }

    100% {

        clip: rect(91px, 9999px, 98px, 0)

    }

}

 

@keyframes glitch-loop-1 {

    0% {

        clip: rect(36px, 9999px, 9px, 0)

    }

    25% {

        clip: rect(25px, 9999px, 99px, 0)

    }

    50% {

        clip: rect(50px, 9999px, 102px, 0)

    }

    75% {

        clip: rect(30px, 9999px, 92px, 0)

    }

    100% {

        clip: rect(91px, 9999px, 98px, 0)

    }

}

 

@-webkit-keyframes glitch-loop-2 {

    0% {

        top: -1px;

        left: 1px;

        clip: rect(65px, 9999px, 119px, 0)

    }

    25% {

        top: -6px;

        left: 4px;

        clip: rect(79px, 9999px, 19px, 0)

    }

    50% {

        top: -3px;

        left: 2px;

        clip: rect(68px, 9999px, 11px, 0)

    }

    75% {

        top: 0;

        left: -4px;

        clip: rect(95px, 9999px, 53px, 0)

    }

    100% {

        top: -1px;

        left: -1px;

        clip: rect(31px, 9999px, 149px, 0)

    }

}

 

@keyframes glitch-loop-2 {

    0% {

        top: -1px;

        left: 1px;

        clip: rect(65px, 9999px, 119px, 0)

    }

    25% {

        top: -6px;

        left: 4px;

        clip: rect(79px, 9999px, 19px, 0)

    }

    50% {

        top: -3px;

        left: 2px;

        clip: rect(68px, 9999px, 11px, 0)

    }

    75% {

        top: 0;

        left: -4px;

        clip: rect(95px, 9999px, 53px, 0)

    }

    100% {

        top: -1px;

        left: -1px;

        clip: rect(31px, 9999px, 149px, 0)

    }

}

 

.art .art-content #archives a:before,

.art .art-content .al_mon_list li:before {

    content: none

}

 

#archives ul {

    list-style: none;

    margin-bottom: 0;

    left: -45px

}

 

#archives li {

    list-style: none

}

 

#archives li>ul,

li>ol {

    margin-left: -2.7em

}

 

#archives h3 {

    margin-top: 0;

    margin-bottom: 0

}

 

.art-content #archives .al_mon_list {

    position: relative;

    padding: 10px 0;

    display: inline-block;

    vertical-align: middle

}

 

.art .art-content #archives a {

    color: #000

}

 

.art .art-content #archives a:hover {

    color: #0084FE

}

 

.art .art-content #archives .al_year {

    padding-left: 100px

}

 

.art .art-content .al_mon_list .al_post_list>li,

.art-content #archives .al_mon_list .al_mon {

    position: relative;

    color: #0084FE;

}

 

.art-content #archives .al_mon_list .al_mon,

.art-content #archives .al_mon_list span {

    padding: 0;

    border-radius: 0;

    margin: 0;

    color: #0084FE;

    background: 0 0;

    font-weight: 400

}

 

.art .art-content #archives a {

    font-weight: 400

}

 

.art .art-content .al_mon_list {

    width: 100%

}

 

.art .art-content .al_mon_list .al_post_list>li:before {

    position: absolute;

    left: 116px;

    background: #fff;

    height: 12px;

    width: 12px;

    border-radius: 6px;

    top: 6px;

    content: ""

}

 

.art .art-content .al_mon_list .al_post_list>li:after {

    position: absolute;

    left: 118px;

    background: #0084FE;

    height: 8px;

    width: 8px;

    border-radius: 6px;

    top: 8px;

    content: ""

}

 

.art-content #archives .al_mon_list .al_mon:before {

    position: absolute;

    left: 113px;

    background: #fff;

    height: 18px;

    width: 18px;

    border-radius: 9px;

    top: 3px;

    content: ""

}

 

.art-content #archives .al_mon_list .al_mon:after {

    position: absolute;

    left: 116px;

    background: #0084FE;

    height: 12px;

    width: 12px;

    border-radius: 6px;

    top: 6px;

    content: ""

}

 

.art .art-content .al_mon_list .al_post_list>li {

    padding-left: 140px

}

 

.art-content #archives .al_mon,

.art-content #archives .al_mon_list .al_post_list {

    display: block

}

 

.art-content #archives .al_mon_list:before {

    max-height: 100%;

    height: 100%;

    width: 4px;

    background: #0084FE;

    position: absolute;

    left: 120px;

    content: "";

    top: 0

}

 

.art .art-content .al_mon_list .al_post_list>li:before,

.art-content #archives .al_mon_list .al_mon:before {

    -webkit-box-shadow: 1px 1px 1px #bbb;

    box-shadow: 1px 1px 1px #bbb

}

 

.art .art-content .al_mon_list .al_post_list>li:after,

.art-content #archives .al_mon_list .al_mon:after {

    background: #0084FE

}

 .art-content #archives{margin-left:16%}

 #al_expand_collapse{margin-right:30%}

 #page .type-page {margin:0 18%}


 

假如我们资讯/文章对您有所帮助,您可以通过扫描捐赠二维码支持一下我们~

感谢您对我们的支持,您的小小支持让我们有信心走得更远!

脚注信息
© 2005-2015 草莓互联(100cm.cn) 广州同福信息科技有限公司 版权所有,并保留所有权利。

广州市东莞庄一横路116号 粤ICP备11046216号

经营性网站备案信息 广州网络警察报警平台 不良信息举报中心  百度信誉档案 广州工商红盾网 可信网站认证