acme.sh 用法

安装 acme.sh

curl https://get.acme.sh | sh -s email=your-email@outlook.com

设置别名,方便使用:

alias acme.sh=~/.acme.sh/acme.sh

申请证书:

acme.sh --issue -d notes.wujie.me  --nginx

或

acme.sh --issue -d notes.wujie.me  --webroot /var/www/notes.wujie.me

部署证书:

acme.sh --install-cert -d notes.wujie.me --key-file /etc/nginx/ssl/notes.wujie.me.key --fullchain-file /etc/nginx/ssl/notes.wujie.me.pem --reloadcmd "service nginx force-reload"

删除证书:

acme.sh --remove -d notes.wujie.me

删除后记得到 /root/.acme.sh/ 目录下找到域名文件夹,一并删除。

官方文档:https://github.com/acmesh-official/acme.sh/wiki/%E8%AF%B4%E6%98%8E

卸载xcode命令行工具

如果需要卸载xcode命令行工具,可以执行

sudo rm -rf /Library/Developer/CommandLineTools

接下来,运行以下命令来清理 xcode-select 的路径设置:

sudo xcode-select --reset

如果你还希望彻底删除与 Xcode 相关的文件,可以运行:

sudo rm -rf /Applications/Xcode.app

最后,验证命令行工具是否已成功删除:

xcode-select -p

如果没有输出或输出的是一个不存在的路径,则表示命令行工具已成功删除。

MacBook安装Homebrew

执行下面的命令以安装homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

在安装homebrew之前,需要先安装xcode命令行工具,上面的安装脚本会进行检查,如果没安装xcode命令行工具,会自动进行安装。

如果需要手动安装xcode命令行工具,可以执行:

xcode-select --install

WordPress自定义文章类型,在管理列表页显示分类名

只需要在register_taxonomy函数的第三个参数中,添加show_admin_column=>true即可。代码如下:

<?php

/**
 * 为产品 post type 添加分类功能
 */
add_action('init', 'my_taxonomies_product', 0);
function my_taxonomies_product() {
    $labels = array(
        'name'              => _x('产品分类', 'taxonomy 名称'),
        'singular_name'     => _x('产品分类', 'taxonomy 单数名称'),
        'search_items'      => __('搜索产品分类'),
        'all_items'         => __('所有产品分类'),
        'parent_item'       => __('该产品分类的上级分类'),
        'parent_item_colon' => __('该产品分类的上级分类:'),
        'edit_item'         => __('编辑产品分类'),
        'update_item'       => __('更新产品分类'),
        'add_new_item'      => __('添加新的产品分类'),
        'new_item_name'     => __('新产品分类'),
        'menu_name'         => __('产品分类'),
    );
    $args = array(
        'labels' => $labels,
        'hierarchical' => true,
        'show_admin_column' => true,
    );
    register_taxonomy('product_category', 'product', $args);
}

如果要在列表中添加自定义字段,即wp_postmeta表中的字段(通过meta_box添加的),可以使用下面的代码:

<?php

// 在列表中把加的字段显示出来
add_action("manage_posts_custom_column",  "product_custom_columns");
function product_custom_columns($column) {
    global $post;
    switch ($column) {
        case "product_director":
            echo get_post_meta($post->ID, '_product_director', true);
            break;
    }
}

add_filter("manage_edit-product_columns", "movie_edit_columns");
function movie_edit_columns($columns) {
    $columns['product_director'] = '产品分类';
    return $columns;
}

WordPress在single页面获取自定发布类型的分类

在详情页面,即single页面获取自定义发布类型的分类

<?php

/** 第一个参数表是当前文章的ID, 第二个参数表示所属的分类法,即taxonomy name。在single页面时可以直接使用 $post->ID **/
$terms = get_the_terms($post->ID, 'product_category');
if ($terms && !is_wp_error($terms)) :
    $terms_name_arr = array();
    foreach ($terms as $term) {
        $terms_name_arr[] = $term->name;
    }
    $terms_name_str = join(" ", $terms_name_arr);
endif;
echo $terms_name_str;