为了账号安全,请及时绑定邮箱和手机立即绑定

简单的 WP 插件引发意外结束

简单的 WP 插件引发意外结束

PHP
ITMISS 2023-10-01 10:07:44
我创建了插件文件夹“my-plugin”,文件名为 my-plugin.php,内容如下。当我尝试打开插件时出现错误:“解析错误:语法错误,第 83 行 (...)\wp-content\plugins\my-plugin\my-plugin.php 中文件意外结束”。这是该文件中的最后一个空行。哪里有问题?<?php/** * @package my_plugin * @version 1.0 *//*Plugin Name: My pluginPlugin URI: http://wordpress.org/extend/plugins/#Description: This is an example pluginAuthor: Your NameVersion: 1.0Author URI: https://yourwebsite.com/*//** * Register a shortcode * * @param array $atts Array of shortcode attributes */function kinsta_get_posts_cb( $atts ){    // safely extract custom arguments and set default values    extract( shortcode_atts(            array(                'numberposts'       => 3,                'post_type'         => 'post',                'book_category'     => 'fantasy',                'year_published'    => 1900,                'price_min'         => 0,                'price_max'         => 50            ),            $atts,            'kinsta_get_posts'        ) );    // define the array of query arguments    $args = array(        'numberposts'   => $numberposts,        'post_type'     => $post_type,        'tax_query'     => array(            array(                'taxonomy'  => 'book_category',                'field'     => 'slug',                'terms'     => $book_category,            )        ),        'meta_query'    => array(            'relation'      => 'AND',            'year_clause'   => array(                'key'       => 'year_published',                'value'     => $year_published,                'type'      => 'numeric',                'compare'   => '>',            ),            'price_clause'  => array(                'key'       => 'price',                'value'     => array( $price_min, $price_max ),                'type'      => 'numeric',                'compare'   => 'BETWEEN',            )        ),        'orderby' => array( 'price_clause' => 'ASC' )    );
查看完整描述

1 回答

?
暮色呼如

TA贡献1853条经验 获得超9个赞

}显然,您忘记在文件末尾关闭。



查看完整回答
反对 回复 2023-10-01
  • 1 回答
  • 0 关注
  • 60 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信