Custom widget doesn’t activate.
-
Custom widget won’t activate. I folowed your guide but widget doesn’t work. I activated it but after page reload it’s disabled again and I can’t use it.
I created plugin
<?php /* Plugin Name: My Extended Widgets Description: Custom Widgets. Version: 0.1 */ function add_my_awesome_widgets_collection($folders){ $folders[] = __DIR__ . '/widgets'; return $folders; } add_filter('siteorigin_widgets_widget_folders', 'add_my_awesome_widgets_collection');
and widget:
<?php /* Widget Name: First Test Widget!! Description: An example widget. Author: Me */ class My_First_Test_Widget extends SiteOrigin_Widget { function __construct() { //Here you can do any preparation required before calling the parent constructor, such as including additional files or initializing variables. //Call the parent constructor with the required arguments. parent::__construct( // The unique id for your widget. 'my-first-test-widget', // The name of the widget for display purposes. __('First Test Widget', 'hello-world-widget-text-domain'), // The $widget_options array, which is passed through to WP_Widget. // It has a couple of extras like the optional help URL, which should link to your sites help or support page. array( 'description' => __('A hello world widget.', 'hello-world-widget-text-domain'), 'help' => 'https://example.com/hello-world-widget-docs', ), //The $control_options array, which is passed through to WP_Widget array( ), //The $form_options array, which describes the form fields used to configure SiteOrigin widgets. We'll explain these in more detail later. array( 'text' => array( 'type' => 'text', 'label' => __('Hello world! goes here.', 'siteorigin-widgets'), 'default' => 'Hello world!' ), ), //The $base_folder path string. plugin_dir_path(__FILE__) ); } function get_template_name($instance) { return 'first-widget-template'; } function get_template_dir($instance) { return 'templates'; } function get_style_name($instance) { return ''; } } siteorigin_widget_register('my-first-test-widget', __FILE__, 'My_First_Test_Widget');
This is my directory structure : https://prnt.sc/hzf0fg
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Custom widget doesn’t activate.’ is closed to new replies.