• Resolved kentsor

    (@kentsor)


    I’m trying to work out how to add a new widget to elementor, using the boilerplate from [ redundant link removed ]

    This question is about where to place the actual file that has the widget code.

    I downloaded the two files from github, keeping everything including the filenames unchanged. I have successfully gotten the plugin to show up in the dashboard and it is executed.

    The plugin code seems to look for the widget code at “plugins/elementor/my-widget.php” so that is where I have put that file. It is definitely there.

    I have included the code I think is failing below. In order to find out why the widget is not showing up I put debug statements in the plugin code (not shown here), the problem is that locate_template return nil so $template_file is nil and thus the if statement is not executed and the widget is not registered.

    Now, another question, why would you ever place your widget code inside the elementor plugin as it would get wiped out by an update?

    $widget_file = ‘plugins/elementor/my-widget.php’;
    $template_file = locate_template( $widget_file );

    if ( $template_file && is_readable( $template_file ) ) {
    require_once $template_file;
    Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Elementor\Widget_My_Custom_Elementor_Thing() );
    }

    Thanks in advance for any help
    Kent

    • This topic was modified 6 years, 4 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Location of new widget file’ is closed to new replies.