This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Can’t move custom page builder widgets from theme to plugin

6 years ago · Last reply by Alex S 6 years ago

I’ve taken some custom SiteOrigin Page Builder widgets out of a theme and placed them in a new custom plugin. We are moving to a different theme.

In the main plugin file, I have:

require plugin_dir_url( __FILE__ ) . 'hdr003.php';
require plugin_dir_url( __FILE__ ) . 'hme006.php';
require plugin_dir_url( __FILE__ ) . 'hme007.php';
function purity_register_widgets(){
    register_widget('ICD_HDR003_Widget');
    register_widget('ICD_HME006_Widget');
    register_widget('ICD_HME007_Widget');
}
add_action( 'widgets_init', 'purity_register_widgets');

In, for example, hdr003.php, I have:

class ICD_HDR003_Widget extends WP_Widget {

However, I receive:

Fatal error: Class ‘WP_Widget’ not found

Hence, I’m trying to include in hdr003.php:

require_once(get_home_path(). 'wp-includes/class-wp-widget.php');

but this produces an error:

Fatal error: Uncaught Error: Call to undefined function get_home_path()

The function is a valid function.

If I replace that line with:

require_once(ABSPATH . 'wp-includes/class-wp-widget.php');

I receive:

include_once(ABSPATH/wp-includes/class-wp-widget.php): failed to open stream: No such file or directory

The file /wp-includes/class-wp-widget.php exists.

I’ve replaced /wp-admin & /wp-includes with newly downloaded copies.

Help appreciated.

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

1
  1. Alex S Staff 6 years, 11 months ago

    Hi Insight,

    Unfortunately, this isn’t something we can directly assist you with a fair amount of custom work and may, potentially, violate licensing agreements (we would need more information to confirm if this is the case). This is beyond the scope of what we can help you with on our forums, but you could hire a developer to assist you with this. We recommend using Codeable. You’ll be able to hire someone at an hourly rate to do this work for you.

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread