doudula1974 2017-12-20 08:20
浏览 35

创建Wordpress小部件但找不到类

I'm trying to create a wordpress plugin that just deserve a listing of something everyone don't care but I have to do it

I choose to create widgets but I got an error

Can you help me please ?

PS : I am very very noob

Fatal error: Class 'Proprietaires_Widget' not found in /opt/lampp/htdocs/tests/wordpress/wp-includes/class-wp-widget-factory.php on line 100

I do not see where I could have been wrong

Code :

<?php

/*
Plugin Name: Zero plugin
Plugin URI: http://zero-plugin.com
Description: Un plugin d'introduction pour le développement sous WordPress
Version: 0.1
Author: Midnight Falcon
Author URI: http://votre-site.com
License: GPL2
*/

class EDL
{
    public function __construct()
    {
        include 'proprietaires.php';
        new Proprietaires();
        add_filter( 'pre_get_document_title', array($this, 'modifier_titre'), 10); 
    }

    public function modifier_titre($title)
    {
        return 'EDL' . $title;
    }
}
new EDL();
?>

<?php
class Proprietaires
{
    public function __construct()
    {
        add_filter('wp_get_document_title', array($this, 'modify_page_title'), 20) ;
        add_action('widgets_init', function(){register_widget('Proprietaires_Widget');});
    }

    public function modify_page_title($title)
    {
        return  'EDL -  Propriétaires' . $title ;
    }
}
    public function modify_page_title($title)
    {
        return  'EDL -  Propriétaires' . $title ;
    }
}


<?php
class Proprietaires_Widget extends WP_Widget
{
    public function __construct()
    {
        parent::__construct('Liste_proprietaires', 'Liste des propriétaires', array('description' => 'Affiche la liste des propriétaires.'));
    }

    public function widget($args, $instance)
    {
        echo 'Liste des propriooooos';
    }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?