博客

  • RiPro-V2付费视频演示介绍-多集

    RiTheme主题-是一个高品质的WordPress正版主题开发下载,致力于为广大站长提供更加便利的资源付费类主题,方便站长运营管理快速整合资源变现。目前ritheme系列下主要有RiPro主题,RiPlus主题,Rimini主题,Rizhuti,都是资源类主题,功能已ripro为代表,最多的功能,最成熟的版本,推荐RiPro。更加专业,资源,素材,源码站运营首选,支付宝原生/当面付、微信扫码/H5支付、码支付、虎皮椒、PAYJS。QQ/微信/微博一键登录,付费下载、付费查看、支持卡密、会员、推广佣金、作者佣金、前端发布资源等。

    视频演示介绍

    需要文章 形式 设置为视频格式,布局风格设置为背景才显示模块)输入视频地址,每行一个,支持mp4/m3u8常见格式,不支持平台解析
    [rihide]付费隐藏内容付费隐藏内容付费隐藏内容付费隐藏内容付费隐藏内容[/rihide]

    图片相册展示

    支持图片相册灯箱

     

  • 一直很安静 吉他弹唱欣赏分享

  • 你了解php中pcntl_fork吗代码高亮展示

    关于pcntl_fork()函数是php-pcntl模块中用于创建进程的函数。本篇文章将会带领你们一同走进充满奥秘的PHP中,一起出发吧!!!

    pcntl_fork()函数是php-pcntl模块中用于创建进程的函数。(不支持windows)
    至于php_pcntl扩展如何安装开启这里就不介绍了,只分析pcntl_fork()这个函数本身。
    60ab53692e180267

    $one = 123;$one++;$two = time();$pid = [];$pid = pcntl_fork();$three = time();

    当:pcntl_fork()函数执行的时候,会创建一个子进程。子进程会复制当前进程,也就是父进程的所有:数据,代码,还有状态。

    1.当pcntl_fork()创建子进程成功后,在父进程内,返回子进程号,在子进程内返回0,失败则返回-1

    2.子进程会复制父进程的代码,数据。那么就说明:子,父进程拥有的代码和数据会一模一样。

    3.重点:子进程会复制父进程的状态,那么就有上面的示例代码:在第五行执行了pcntl_fork,那么创建出的子进程,代码也是从第五行开始执行的。又子进程复制了数据,代码。所以,在子进程内同理存在:$one,$two等变量

    for ($i = 0; $i < 3; $i++) {
    
    $pid = pcntl_fork();}sleep(30);
    
    /*!
    Theme Name: RiPro-V5
    Theme URI: https://ritheme.com/
    Author: RiTheme.com
    Author URI: https://ritheme.com/
    Description: RiPro主题全新V5版本,是一个优秀且功能强大、易于管理、现代化的WordPress虚拟资源商城主题。支持首页模块化布局和WP原生小工具模块化首页可拖拽设置,让您的网站设计体验更加舒适。同时支持了高级筛选、自带会员生态系统、超全支付接口等众多功能,无需依赖插件即可实现。此外,主题还支持卡密、充值、站内币、会员、推广佣金、统计、自定义币种、自定义会员标识、支持自定义SEO信息等多种功能,为您的网站提供更加完整的解决方案。
    Version: 5.0.0
    */

    那么:上面的for循环,实际会产生多少个子进程?答案是7个,在linux下,用ps命令将可以看到8个进程(1个父进程,7个子进程)
    原因:父进程在 i = 0 时 , 创 建 出 一 个 子 进 程 0 , 此 时 的 子 进 程 , 还 会 继 续 执 行 循 环 。 创 建 出 属 于 自 己 的 子 进 程 。 同 理 : i=0时,创建出一个子进程0,此时的子进程,还会继续执行循环。创建出属于自己的子进程。同理: i=0时,创建出一个子进程0,此时的子进程,还会继续执行循环。创建出属于自己的子进程。同理:i=1时也会这样……

  • 代码高亮插件-文章内容模块展示

    文章内容常见格式展示,文章内容模块展示,文章内自带视频,灯箱相册,单图片灯箱,代码高亮,外部视频引入等

    wordpress自带插入文章

    RiPro主题设置高级分类文章菜单

    抽绳袋 手袋样机(免费资源演示)

    wordpress自带插入视频展示

    相册灯箱展示 自适应对其

    代码展示 代码高亮

    <?php
    /**
     * The sidebar containing the main widget area
     * 默认首页,非模块化首页,博客格式布局
     *
     * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials https://developer.wordpress.org/themes/basics/template-files/#template-partials
     *
     * @package ripro-v2
     */
    
    get_header();
    
    dynamic_sidebar('modules');
    
    get_footer();
    
    ?>

    外链视频插入展示

  • WordPress函数Wp_link_pages教程实现文章内容分页

    假如一篇文章很长,而你的WordPress主题又没有做侧边栏随动,那么页面排版就会非常难看,比如代码狗博客。WordPress函数wp_link_pages就可以解决这个问题,它能将一篇长文章分成几个页面来显示,实现文章内容分页,这样就不会影响到网页的排版。

    假如一篇文章很长,而你的WordPress主题又没有做侧边栏随动,那么页面排版就会非常难看,比如WP爱好者博客。WordPress函数wp_link_pages就可以解决这个问题,它能将一篇长文章分成几个页面来显示,实现文章内容分页,这样就不会影响到网页的排版。

    函数位于wp-includes/post-template.php文件中,由于内容太多,所以这里就不贴源码了。

    函数用法

    <?php wp_link_pages( $args ); ?>

    参数说明

    <?php   $args = array(   'before'           => '<p>' . __( 'Pages:', 'twentyfourteen' ),   'after'            => '</p>',   'link_before'      => '',   'link_after'       => '',   'next_or_number'   => 'number',   'separator'        => ' ',   'nextpagelink'     => __( 'Next page', 'twentyfourteen'),   'previouspagelink' => __( 'Previous page', 'twentyfourteen' ),   'pagelink'         => '%',   'echo'             => 1  ); ?>
    • before – 字符串。所有链接之前的文本,默认值<p>Pages:(通常和after搭配使用)
    • after – 字符串。所有链接之后的文本,默认值</p>(通常和before搭配使用)
    • link_before – 字符串。单个链接文本之前的文本,默认为空
    • link_after – 字符串。单个链接文本之后的文本,默认为空
    • next_or_number – 字符串。选择使用数字分页还是上一页、下一页文本分页,可选number或next,默认number
    • separator – 字符串。页码分隔符,默认似乎是空格
    • nextpagelink – 字符串。下一页链接文本,默认Next page
    • previouspagelink – 字符串。上一页链接文本,默认Previous page
    • pagelink – 字符串。页码的字符串格式,百分号%会被替换成数字,如页%会生成 “页1”、“页2”这样的样式
    • echo – 布尔型。选择是要返回结果还是直接输出,默认为True,返回NULL或返回内容;设置为false,则直接输出HTML格式

    使用实例

    1、全部使用默认值,下一页、上一页使用段落标签,Page 1,Page 2作为分页页码:

    <?php wp_link_pages();?>

    2、使用段落标签包围分页链接

    <?php wp_link_pages('before=<p>&after=</p>&next_or_number=number&pagelink=page %');?>

    3、使用div包围分页链接,便于CSS样式修改

    <?php wp_link_pages('before=<div id="page-links">&after=</div>');?>

    提示:可以CSS中对#page-links进入样式修改

    分页方法

    在文章内容页模板single.php中找到输出文章内容的WordPress函数the_content,然后在下面添加一行代码:

    <?php wp_link_pages('before=<div id="page-links">&after=</div>');?>

    然后在后台编辑文章时,在你需要分页的地方使用

    <!–nextpage–>

    注意:这段分页代码必须在文本模式下使用,或者直接开启快捷按钮,点击按钮即可增加分页。

  • WordPress函数The_search_query输出搜索关键词

    几乎WordPress网站都带有站内搜索的功能,我们如何在搜索结果页中显示搜索关键词呢?the_search_query函数能帮我们输出搜索关键词,下面是WordPress函数the_search_query的详细用法。

    几乎WordPress网站都带有站内搜索的功能,我们如何在搜索结果页中显示搜索关键词呢?the_search_query函数能帮我们输出搜索关键词,下面是WordPress函数the_search_query的详细用法。

    函数描述

    显示搜索查询的内容。应通过esc_attr()函数确保它是安全的再显示在HTML标签上。

    函数原型

    the_search_query函数位于wp-includes/general-template.php文件中,下面是它的源代码,官方在线地址:https://developer.wordpress.org/reference/functions/the_search_query/

    function the_search_query() {     /**      * Filters the contents of the search query variable for display.      *      * @since 2.3.0      *      * @param mixed $search Contents of the search query variable.      */     echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) ); }

    函数用法

    在你的搜索模板文件search.php中放置如下代码,将会显示通过搜索表单提交的关键词。

    <?php the_search_query(); ?>
    <?php echo esc_html( get_search_query( false ) ); ?>

    该函数不带参数,上面的两种方式输出的结果一样。

  • WordPress函数Single_post_title文章页输出文章标题

    WordPress中输出文章标题的函数有不少,方式也很多,比如the_title、$post->title等等,single_post_title函数也可以输出文章页文章标题,下面是它的结构与用法,看看它与the_title函数的区别在哪儿。

    WordPress中输出文章标题的函数有不少,方式也很多,比如the_title、$post->title等等,single_post_title函数也可以输出文章页文章标题,下面是它的结构与用法,看看它与the_title函数的区别在哪儿。

    函数描述

    显示文章页面标题,single_post_title这个函数没有过滤器,但是你可以自己定义。

    函数原型

    single_post_title函数位于wp-includes/general-template.php文件中,下面是它的源代码。

    function single_post_title( $prefix = '', $display = true ) {     $_post = get_queried_object();     if ( !isset($_post->post_title) )         return;     /**      * Filters the page title for a single post.      *      * @since 0.71      *      * @param string $_post_title The single post page title.      * @param object $_post       The current queried object as returned by get_queried_object().      */     $title = apply_filters( 'single_post_title', $_post->post_title, $_post );     if ( $display )         echo $prefix . $title;     else         return $prefix . $title; }

    构造很清楚,结合源代码,我们可以更清晰的看到函数的参数含义。

    参数说明$prefix

    字符串值,默认为空

    在文章标题前输出的内容

    $display

    布尔值,默认值:true

    是否输出标题,如果为false,只返回结果而不输出。

    简单使用

    输出当前文章:WordPress函数single_post_title文章页输出文章标题

    <h2><?php single_post_title( '当前文章: ' ); ></h2>
  • WordPress函数Wp_insert_comment插入评论到数据库中

     WordPress主题制作过程中,我认为最为复杂的就是评论处理部分。当然这个复杂只是相对而言,不论多么复杂到最后都是对WordPress函数的灵活运用,下面我们一起用wp_insert_comment函数插入一条评论到数据库中,了解下wp_insert_comment函数的构成与使用方法。

    WordPress主题制作过程中,我认为最为复杂的就是评论处理部分。当然这个复杂只是相对而言,不论多么复杂到最后都是对WordPress函数的灵活运用,下面我们一起用wp_insert_comment函数插入一条评论到数据库中,了解下wp_insert_comment函数的构成与使用方法。

    函数描述

    插入一条评论到数据库中。

    函数原型

    wp_insert_comment函数位与wp-includes/comment.php文件中,由于源码太长,这里就不贴代码了,大家可以去官方查看wp_insert_comment函数的源码,地址:https://developer.wordpress.org/reference/functions/wp_insert_comment/

    wp_insert_comment( array $commentdata )

    参数说明

    $commentdata

    评论数据数组,内容如下:

    • ‘comment_agent’
      (string) 用户评论时的代理标识,默认空。
    • ‘comment_approved’
      (int|string) 是否有评论已经得到了批准,默认1。
    • ‘comment_author’
      (string) 评论者的名字,默认为空。
    • ‘comment_author_email’
      (string) 评论者的邮箱地址,默认为空。
    • ‘comment_author_IP’
      (string) 评论者的ip,默认为空。
    • ‘comment_author_url’
      (string) 评论者的url地址,默认为空。
    • ‘comment_content’
      (string) 评论内容。
    • ‘comment_date’
      (string) 评论提交的日期,手动指定时必须指定日期时区comment_date_gmt参数,默认当前日期。
    • ‘comment_date_gmt’
      (string) 评论提交时的时区,默认是站点所选时区。
    • ‘comment_karma’
      (int) The karma of the comment. Default 0.这玩意儿看不懂是什么,默认0
    • ‘comment_parent’
      (int) 评论所属父评论id,如果有的话(就是楼主评论id)
    • ‘comment_post_ID’
      (int) 涉及到的评论文章id,默认0。
    • ‘comment_type’
      (string) 评论类型,默认空。
    • ‘comment_meta’
      (array) 键/值对数组存储在commentmeta新评论。
    • ‘user_id’
      (int)评论用户的id,默认0。

    返回值

    成功插入返回插入的评论id,失败返回false。

    使用方法

    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); $comment_id = wp_insert_comment( $commentdata );

    评论插入数据库的WordPress函数还有:WordPress函数wp_new_comment添加新评论

  • WordPress函数Wp_new_comment添加新评论

    给WordPress添加评论的函数有好几个,方式也多种多样,虽然方法多,但每个方法的功能却不完全一样,比如使用WordPress函数wp_new_comment添加新评论,就会检查是否有重复评论,避免出现可以刷评论的bug。

    给WordPress添加评论的函数有好几个,方式也多种多样,虽然方法多,但每个方法的功能却不完全一样,比如使用WordPress函数wp_new_comment添加新评论,就会检查是否有重复评论,避免出现可以刷评论的bug。

    函数描述

    添加一条新评论到数据库中(重点在新字上)。这个函数会通过过滤器和钩子判断评论数据是否被允许添加到WordPress数据库中,而wp_insert_comment函数则不会检查,直接添加到数据库。

    函数原型

    wp_new_comment函数位于wp-includes/comment.php文件中,由于源码过长,这里j就不贴源代码了,大家可以到WordPress官方在线查看源码,地址:https://developer.wordpress.org/reference/functions/wp_new_comment/

    参数说明

    wp_new_comment函数参数与wp_insert_comment函数参数差不多,只是多了一个是否返回wp_error错误对象的参数而已。

    wp_new_comment( array $commentdata, bool $avoid_die = false )

    $commentdata

    (array) 评论数组。

    • ‘comment_agent’
      (string) 用户评论时的代理标识,默认空。
    • ‘comment_approved’
      (int|string) 是否有评论已经得到了批准,默认1。
    • ‘comment_author’
      (string) 评论者的名字,默认为空。
    • ‘comment_author_email’
      (string) 评论者的邮箱地址,默认为空。
    • ‘comment_author_IP’
      (string) 评论者的ip,默认为空。
    • ‘comment_author_url’
      (string) 评论者的url地址,默认为空。
    • ‘comment_content’
      (string) 评论内容。
    • ‘comment_date’
      (string) 评论提交的日期,手动指定时必须指定日期时区comment_date_gmt参数,默认当前日期。
    • ‘comment_date_gmt’
      (string) 评论提交时的时区,默认是站点所选时区。
    • ‘comment_karma’
      (int) The karma of the comment. Default 0.这玩意儿看不懂是什么,默认0
    • ‘comment_parent’
      (int) 评论所属父评论id,如果有的话(就是楼主评论id)
    • ‘comment_post_ID’
      (int) 涉及到的评论文章id,默认0。
    • ‘comment_type’
      (string) 评论类型,默认空。
    • ‘comment_meta’
      (array) 键/值对数组存储在commentmeta新评论。
    • ‘user_id’
      (int)评论用户的id,默认0。

    $avoid_die

    (bool)是否返回wp_error错误对象,默认false,不返回直接输出错误。

    简单使用

    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');  $comment_id = wp_new_comment( $commentdata,true); if(is_wp_error($comment_id)){  err( '重复评论' ); } }

    如果使用了ajax提交评论,返回wp_error错误对象会导致你的文章布局错乱,正确的ajax评论提交接口应判断是否返回了wp_error错误对象,根据返回不同自定义返回内容。另外wp_insert_comment函数也能插入评论到数据库:WordPress函数wp_insert_comment插入评论到数据库中

  • WordPress函数Get_the_category获取分类信息详解

    WordPress获取分类信息get_the_category这个WordPress函数平时用得比较少,一般也很少用到它,get_the_category函数的功能是获取与查询参数相关的数据,利用这个性质,我们可以制作一些文章相关项,增加内链,提高SEO优化效果。

    函数原型

    get_the_category函数位于wp-includes/category-template.php文件中。

    function get_the_category( $id = false ) {     $categories = get_the_terms( $id, 'category' );     if ( ! $categories || is_wp_error( $categories ) )         $categories = array();       $categories = array_values( $categories );       foreach ( array_keys( $categories ) as $key ) {         _make_cat_compat( $categories[$key] );     }       /**      * Filters the array of categories to return for a post.      *      * @since 3.1.0      * @since 4.4.0 Added `$id` parameter.      *      * @param array $categories An array of categories to return for the post.      * @param int   $id         ID of the post.      */     return apply_filters( 'get_the_categories', $categories, $id ); }

    可以看到get_the_category函数与get_the_terms函数相关,至于get_the_terms函数的用法,这里就不多讲了,太偏僻,我很少用,需要的可以自行查看WordPress开发手册。

    参数

    get_the_category( int $id = false )

    $post->ID (当前文章的编号)

    注意,这个函数只能在WordPress主循环中使用!

    简单用法

    显示类别的图片

    <?php foreach((get_the_category()) as $category) {     echo '<img src="http://www.2zzt.com/images/' . $category->cat_ID . '.jpg" alt="' . $category->cat_name . '" />'; } ?>

    显示第一个类别的名称

    <?php  $category = get_the_category();  echo $category[0]->cat_name;  ?>

    显示第一个类别的连接

    <?php  $category = get_the_category();  if($category[0]){  echo '<a href="'.get_category_link($category[0]->term_id ).'">'.$category[0]->cat_name.'</a>';  } ?>

    获取指定文章编号的类别信息

    <?php  global $post;  $categories = get_the_category($post->ID);  var_dump($categories);  ?>

    返回对象的成员

    cat_ID

    类别编号,存储在term_id字段

    cat_name

    类别名称,存储在name字段

    category_nicename

    别名,存储在slug字段

    category_description

    类别描述,存储在description字段

    category_parent

    父类别编号,没有父类的为0,存储在parent字段

    category_count

    类别使用的数量,存储在count字段