删除几个 WordPress 插件 记录一下

1 All-in-One WP Migration

Migration tool for all your blog data. Import or Export your blog content with a single click.

6.70版本 | 由ServMask | 查看详情
2 DX-auto-save-images

Automatically keep the remote picture to the local, and automatically generate thumbnails. 自动保持远程图片到本地,并且自动生成缩略图。

1.4.0版本 | 由大侠wp | 查看详情
3 Netease Music

WordPress 音乐播放器,支持网易云音乐和虾米音乐。

3.1.0版本 | 由bigfa | 查看详情
4 Pretty Links

Shrink, track and share any URL on the Internet from your WordPress website!

2.1.6版本 | 由Blair Williams | 查看详情
5 Really Simple SSL

无需任何设定的轻量级插件来让你的网站有 SSL 证明

3.0.2版本 | 由Rogier Lankhorst | 查看详情
6 SO Pinyin Slugs

Transforms Chinese character titles (of Posts, Pages and all other content types that use slugs) into a permalink friendly slug, showing pinyin that can be read by humans and (Chinese) search engines alike.

2.1.2版本 | 由SO WP | 查看详情
7 WP Baidu Map

A real Baidu map plugin.

1.2.1版本 | 由suifengtec | 查看详情

微信小程序 文章加载占位样式 CSS Placeholder

类似豆瓣 APP 动画闪烁效果

WXML:

<view class="text-loading">
  <view class='pic-loading-line'></view>
  <view class='text-loading-line-first'>
    <view class='text-loading-line'></view>
    <view class='text-loading-line'></view>
    <view class='text-loading-line'></view>
  </view>
  <view class='text-loading-line-second'>
    <view class='text-loading-line'></view>
    <view class='text-loading-line'></view>
    <view class='text-loading-line'></view>
  </view>
</view>

WXSS:

.text-loading {
  width: 90%;
  margin:50rpx;
  /* border:1rpx solid #ccc; */
}

.text-loading .pic-loading-line {
  display: inline-block;
  width: 130rpx;
  height: 130rpx;
  margin-right: 20rpx;
  margin-bottom: 20rpx;
  animation: pulse 1s infinite ease-in-out;
}

.text-loading .text-loading-line-first {
  display: inline-block;
  width: 70%;
  height: 150rpx;
}

.text-loading .text-loading-line-second {
  display: inline-block;
  width: 100%;
  height: 150rpx;
}

.text-loading-line {
  height: 30rpx;
  margin-bottom: 20rpx;  
  width: 100%;
  animation: pulse 1s infinite ease-in-out;
}

.text-loading-line:nth-child(1) {
  width: 100%;
}

.text-loading-line:nth-child(2) {
  width: 90%;
}

.text-loading-line:nth-child(3) {
  width: 50%;
}

@keyframes pulse {
  0% {
    background-color: rgba(165, 165, 165, 0.1);
  }

  50% {
    background-color: rgba(165, 165, 165, 0.3);
  }

  100% {
    background-color: rgba(165, 165, 165, 0.1);
  }
}

 

微信小程序 重写 Radio CheckBox 样式 美化单选框复选框

单选按钮 Radio

wxss:

/*  重写 radio 样式  */
/* 未选中的 背景样式 */
radio .wx-radio-input{
   border-radius: 50%;/* 圆角 */
   width: 40rpx;
   height: 40rpx;
}
/* 选中后的 背景样式 (红色背景 无边框 可根据UI需求自己修改) */
radio .wx-radio-input.wx-radio-input-checked{
   border: none;
   background: red;
}
/* 选中后的 对勾样式 (白色对勾 可根据UI需求自己修改) */
radio .wx-radio-input.wx-radio-input-checked::before{
   border-radius: 50%;/* 圆角 */
   width: 40rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
   height: 40rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
   line-height: 40rpx;
   text-align: center;
   font-size:30rpx; /* 对勾大小 30rpx */
   color:#fff; /* 对勾颜色 白色 */
   background: transparent;
   transform:translate(-50%, -50%) scale(1);
   -webkit-transform:translate(-50%, -50%) scale(1);
}
复选按钮 Checkbox

wxss:

/*  重写 checkbox 样式  */
/* 未选中的 背景样式 */
checkbox .wx-checkbox-input{
   border-radius: 50%;/* 圆角 */
   width: 40rpx; /* 背景的宽 */
   height: 40rpx; /* 背景的高 */
}
/* 选中后的 背景样式 (红色背景 无边框 可根据UI需求自己修改) */
checkbox .wx-checkbox-input.wx-checkbox-input-checked{
   border: none;
   background: red;
}
/* 选中后的 对勾样式 (白色对勾 可根据UI需求自己修改) */
checkbox .wx-checkbox-input.wx-checkbox-input-checked::before{
   border-radius: 50%;/* 圆角 */
   width: 40rpx;/* 选中后对勾大小,不要超过背景的尺寸 */
   height: 40rpx;/* 选中后对勾大小,不要超过背景的尺寸 */
   line-height: 40rpx;
   text-align: center;
   font-size:30rpx; /* 对勾大小 30rpx */
   color:#fff; /* 对勾颜色 白色 */
   background: transparent;
   transform:translate(-50%, -50%) scale(1);
   -webkit-transform:translate(-50%, -50%) scale(1);
}

 

PHP 实现无限极分类生成分类树的方法

<?php

$data = array (
  array (
    'id' => 4,
    'category_name' => '要闻',
    'pid' => 3,
    'created_at' => '2018-06-21 17:33:55',
    'updated_at' => '2018-06-21 17:33:55',
  ),
  array (
    'id' => 3,
    'category_name' => '新闻',
    'pid' => 0,
    'created_at' => '2018-06-21 17:33:45',
    'updated_at' => '2018-06-21 17:33:45',
  ),
  array (
    'id' => 5,
    'category_name' => '企业服务',
    'pid' => 3,
    'created_at' => '2018-06-21 17:34:12',
    'updated_at' => '2018-06-21 17:34:12',
  ),
  array (
    'id' => 6,
    'category_name' => '大新闻',
    'pid' => 0,
    'created_at' => '2018-06-26 14:41:28',
    'updated_at' => '2018-06-26 14:41:28',
  ),
  array (
    'id' => 7,
    'category_name' => '优惠',
    'pid' => 6,
    'created_at' => '2018-06-26 14:41:45',
    'updated_at' => '2018-06-26 14:41:45',
  ),
);
echo "<pre>";
//var_export($data);



function getTree($list,$pid=0,$level=0) {
  static $tree = array();
  foreach($list as $row) {
    if($row['parentID']==$pid) {
      $row['level'] = $level;
      $tree[] = $row;
      getTree($list, $row['id'], $level + 1);
    }
  }
  return $tree;
}

function makeTree($arr){
  $refer = array();
  $tree = array();
  foreach($arr as $k => $v){
    $refer[$v['id']] = & $arr[$k]; //创建主键的数组引用
  }
  foreach($arr as $k => $v){
    $pid = $v['pid'];  //获取当前分类的父级id
    if($pid == 0){
      $tree[] = & $arr[$k];  //顶级栏目
    }else{
      if(isset($refer[$pid])){
        $refer[$pid]['subcat'][] = & $arr[$k]; //如果存在父级栏目,则添加进父级栏目的子栏目数组中
      }
    }
  }
  return $tree;
}


$a = makeTree($data);
print_r($a);

$b = getTree($data);
print_r($b);

输出:

Array
(
    [0] => Array
        (
            [id] => 3
            [category_name] => 新闻
            [pid] => 0
            [created_at] => 2018-06-21 17:33:45
            [updated_at] => 2018-06-21 17:33:45
            [subcat] => Array
                (
                    [0] => Array
                        (
                            [id] => 4
                            [category_name] => 要闻
                            [pid] => 3
                            [created_at] => 2018-06-21 17:33:55
                            [updated_at] => 2018-06-21 17:33:55
                        )

                    [1] => Array
                        (
                            [id] => 5
                            [category_name] => 企业服务
                            [pid] => 3
                            [created_at] => 2018-06-21 17:34:12
                            [updated_at] => 2018-06-21 17:34:12
                        )

                )

        )

    [1] => Array
        (
            [id] => 6
            [category_name] => 大新闻
            [pid] => 0
            [created_at] => 2018-06-26 14:41:28
            [updated_at] => 2018-06-26 14:41:28
            [subcat] => Array
                (
                    [0] => Array
                        (
                            [id] => 7
                            [category_name] => 优惠
                            [pid] => 6
                            [created_at] => 2018-06-26 14:41:45
                            [updated_at] => 2018-06-26 14:41:45
                        )

                )

        )

)
Array
(
    [0] => Array
        (
            [id] => 4
            [category_name] => 要闻
            [pid] => 3
            [created_at] => 2018-06-21 17:33:55
            [updated_at] => 2018-06-21 17:33:55
            [level] => 0
        )

    [1] => Array
        (
            [id] => 3
            [category_name] => 新闻
            [pid] => 0
            [created_at] => 2018-06-21 17:33:45
            [updated_at] => 2018-06-21 17:33:45
            [level] => 0
        )

    [2] => Array
        (
            [id] => 5
            [category_name] => 企业服务
            [pid] => 3
            [created_at] => 2018-06-21 17:34:12
            [updated_at] => 2018-06-21 17:34:12
            [level] => 0
        )

    [3] => Array
        (
            [id] => 6
            [category_name] => 大新闻
            [pid] => 0
            [created_at] => 2018-06-26 14:41:28
            [updated_at] => 2018-06-26 14:41:28
            [level] => 0
        )

    [4] => Array
        (
            [id] => 7
            [category_name] => 优惠
            [pid] => 6
            [created_at] => 2018-06-26 14:41:45
            [updated_at] => 2018-06-26 14:41:45
            [level] => 0
        )

)

 

微信小程序地图服务使用 百度坐标系经纬度 方法 百度坐标系转 GCJ02

微信小程序使用 百度地图提供的坐标进行定位的时候会造成位置偏移,究其原因是百度地图未使用常规的国测局坐标(火星坐标,GCJ02)、或WGS84坐标系 而使用了自己的坐标系 百度坐标系

会造成经纬度上的一公里左右的偏移。

但百度只提供 WGS84、GCJ02 坐标系转百度坐标系的接口,而未提供百度坐标系转 WGS84、GCJ02坐标系

互联网在线地图使用的坐标系:

火星坐标系:

  • iOS 地图(其实是高德)
  • Gogole地图
  • 搜搜、阿里云、高德地图

百度坐标系:

  • 当然只有百度地图

WGS84坐标系:

  • 国际标准,谷歌国外地图、osm地图等国外的地图一般都是这个

微信小程序使用百度坐标系经纬度的解决方式:

腾讯位置服务提供了 微信小程序 JavaScript SDK,可进行其他坐标系的逆向解析,包含以下坐标系转换至腾讯坐标系:

  • GPS坐标
  • sogou经纬度
  • baidu经纬度
  • mapbar经纬度
  • [默认]腾讯、google、高德坐标
  • sogou墨卡托

接口文档: http://lbs.qq.com/qqmap_wx_jssdk/method-reverseGeocoder.html

PHP 自定义函数 记录错误 / LOG日志到文件

public function log($res){
    $err_date = date("Ym", time());
    $address = '/error';
    if (!is_dir($address)) {
        mkdir($address, 0700, true);
    }
    $address = $address.'/'.$err_date . '_error.log';
    $error_date = date("Y-m-d H:i:s", time());
    if(!empty($_SERVER['HTTP_REFERER'])) {
        $file = $_SERVER['HTTP_REFERER'];
    } else {
        $file = $_SERVER['REQUEST_URI'];
    }
    if(is_array($res)) {
        $res_real = "$error_date\t$file\n";
        error_log($res_real, 3, $address);
        $res = var_export($res,true);
        $res = $res."\n";
        error_log($res, 3, $address);
    } else {
        $res_real = "$error_date\t$file\t$res\n";
        error_log($res_real, 3, $address);
    }
}

 

微信小程序 JavaScript 时间比较函数 JS 日期比较

// 时间比较函数
compareDate:function (startDate, endDate) {
  var arrStart = startDate.split("-");
  var startTime = new Date(arrStart[0], arrStart[1], arrStart[2]);
  var startTimes = startTime.getTime();
  var arrEnd = endDate.split("-");
  var endTime = new Date(arrEnd[0], arrEnd[1], arrEnd[2]);
  var endTimes = endTime.getTime();
  if(endTimes<startTimes) {
    return false;
  }
return true;
},

 

微信小程序实现点击滑动展开效果动画

js

let animationShowHeight = 300;
Page({
  /**
   * 页面的初始数据
   */
  data: {
    animation: ''
  },
  // 下来
  btnClick: function () {
    var animation = wx.createAnimation({
      transformOrigin: "50% 50%",
      duration: 1000,
      timingFunction: "ease",
      delay: 0
    })
    this.animation = animation
    animation.translateY(animationShowHeight).step()
    this.setData({
      animation: animation.export(),
    })
  },
  // 上去
  btnClickTo: function () {
    var animation = wx.createAnimation({
      transformOrigin: "50% 50%",
      duration: 1000,
      timingFunction: "ease",
      delay: 0
    })
    this.animation = animation
    animation.translateY(0).step()
    this.setData({
      animation: animation.export(),
    })
  }  
})

wxml

<button type="primary" bindtap="btnClick"> 点我下去 </button>
<button type="primary" bindtap="btnClickTo"> 点我回去 </button>
<view class="body-view" animation="{{animation}}">
  <view>我一会就出来吓死你</view>
  <view>我一会就出来吓死你</view>
  <view>我一会就出来吓死你</view>
</view>