Widgets error when configured from plugin,
-
Hi,
When I run my widgets from standard APF they work well, but when I run from my plugin not working.
It is as if these object libraries are not included in the compiler or not properly appoint somewhere to enable them to the plugin.
Could help me with something.
Thanks in advance as always for your great help.
-
Hi,
Make sure that the name of the factory class you extend has the prefix you set in the Generator page.
Hope it helps!
Hi miunosoft,
As always so attentive, thank you very much 🙂
It’s the first thing I’ve done, make sure that.
The rest of my plugin runs smoothly.
If I change AdminPageFramework_Widget by My_Plugin_AdminPageFramework_Widget {{and stop working
I get the message could not be found the My_Plugin_AdminPageFramework_Widget class.
Hi,
Make sure you include
admin-page-framework.phpof the generated framework files as it auto-loads framework classes.Hi,
I am sure that classes are loaded, the rest of the plugin works for me perfectly.
I compiled again APF from the area of administration and downloaded again, I still have the same problem.
A doubt. When should I load the widget?. now I do it from add_action (‘widgets_init’, array ($ this, ‘my_plugin_register_widgets’)); once loaded APF.
Grateful for your help
Can you post the entire error output? The error should indicate the path of the class file. Double check if the path exists.
Hi,
Fatal error: Class ‘My_Plugin_AdminPageFramework_Widget’ not found in /volume1/web/wp-content/plugins/myplugin/widgets/mywidget.php on line 8
only tells me that the class is not found.
/**
Admin Page Framework v3.5.8 by Michael Uno
Generated by PHP Class Files Script Generator <https://github.com/michaeluno/PHP-Class-Files-Script-Generator>
<http://en.michaeluno.jp/admin-page-framework>
Copyright (c) 2013-2015, Michael Uno; Licensed under MIT <http://opensource.org/licenses/MIT>
*/
abstract class My_Plugin_AdminPageFramework_Widget extends My_Plugin_AdminPageFramework_Widget_Controller {I’ve looked at the downloaded files and files exist, at some point the class is not called correctly when APF is used in a plugin.
Can you the contents of your
mywidget.php?<?php /** * Creates a widget. * * @since 1.0.0 */ class My_Plugin_Widget_APF extends My_Plugin_AdminPageFramework_Widget { /** * The user constructor. * * Alternatively you may use start_{instantiated class name} method. */ public function start() {} /** * Sets up arguments. * * Alternatively you may use set_up_{instantiated class name} method. */ public function setUp() { $this->setArguments( array( 'description' => __( 'Muestre un logotipo.', 'myplugin' ), ) ); } /** * Sets up the form. * * Alternatively you may use load_{instantiated class name} method. */ public function load( $oAdminWidget ) { $this->addSettingFields( array( 'field_id' => 'title', 'type' => 'text', 'title' => __( 'Título', 'myplugin' ), 'default' => 'Title', ), array( 'field_id' => 'default_image', 'type' => 'media', 'title' => __( 'Logo por defecto.', 'myplugin' ), ), array() ); } /** * Validates the submitted form data. * * Alternatively you may use validation_{instantiated class name} method. */ public function validate( $aSubmit, $aStored, $oAdminWidget ) { // Uncomment the following line to check the submitted value. // Xtend_AdminPageFramework_Debug::log( $aSubmit ); return $aSubmit; } /** * Print out the contents in the front-end. * * Alternatively you may use the content_{instantiated class name} method. */ public function content( $sContent, $aArguments, $aFormData ) { return $sContent . '<p>' . __( 'Hola mundo! Esto es un widget creado con Admin Page Framework.', 'myplugin' ) . '</p>'; //. My_Plugin_AdminPageFramework_Debug::get( $aArguments ) //. My_Plugin_AdminPageFramework_Debug::get( $aFormData ); } } new My_Plugin_Widget_APF( __( 'My Plugin : Widget APF', 'myplugin' ) // the widget title );If active APF plugin and change My_Plugin_AdminPageFramework_Widget by AdminPageFramework_Widget works perfectly. 🙁
Sorry I can not give more data to help, I’m looking at the same time we are here if I help you more.
I think if you play the same stage in their web site should give you the same error.
Try including
admin-page-framework.phpof the generated files at the beginning of yourmywidget.php.Hi,
It worked, and I found the reason 🙂
I was creating a class for the plugin and within this class called another class that handles call all internal classes. APF included.
Calling the APF class from the parent class works well.
The strange thing is that the rest of the plugin worked well so far fewer widgets.
As always, thank you very much for your time and help, hope this will help other developers who encounter the same predicament.
Not a problem. Glad to hear you sorted it out!
The topic ‘Widgets error when configured from plugin,’ is closed to new replies.