我试着用WordPress编写简单的插件.但当我try 激活它时,我得到了错误的"通知:未定义的偏移:1"我如何修复它?谢谢大家的关注.
if (!defined('ABSPATH')) {
die;
}
class ledproperty {
public function register() {
add_action('init', [$this, 'custom_post_type']);
}
public function custom_post_type() {
register_post_type('property',
array(
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'properties'),
'label' => 'Property',
'supports' => array('title', 'editor', 'thumbnail')
));
}
static function activation() {
flush_rewrite_rules();
}
static function deactivation() {
flush_rewrite_rules();
}
}
if(class_exists('ledproperty')) {
$ledproperty = new ledproperty();
$ledproperty -> register();
}
register_activation_hook(__FILE__, array($ledproperty), 'activation');
register_deactivation_hook(__FILE__, array($ledproperty), 'deactivation');