Error trying to extend WP_Job_Manager_Widget
-
I am trying to extend the recent jobs widget with my own widget class (simply overriding the content-widget-job_listing template won’t do in this case as I need conditional filtering on the returned recent jobs), but the code below is giving me a ‘Class ‘WP_Job_Manager_Widget’ not found’ error.
I’ve set the priority of the register_widget function very late (99) in the loading process, but still not working.
class GJ_Recent_Jobs_Widget extends WP_Job_Manager_Widget { public function __construct() { global $wp_post_types; $this->widget_cssclass = 'job_manager widget_recent_jobs'; $this->widget_description = __( 'Display a list of recent listings on your site, optionally matching a keyword and location.', 'wp-job-manager' ); $this->widget_id = 'widget_gj_recent_jobs'; $this->widget_name = sprintf( __( 'GJ Recent %s', 'wp-job-manager' ), $wp_post_types['job_listing']->labels->name ); $this->settings = array( 'title' => array( 'type' => 'text', 'std' => sprintf( __( 'Recent %s', 'wp-job-manager' ), $wp_post_types['job_listing']->labels->name ), 'label' => __( 'Title', 'wp-job-manager' ) ), 'keyword' => array( 'type' => 'text', 'std' => '', 'label' => __( 'Keyword', 'wp-job-manager' ) ), 'location' => array( 'type' => 'text', 'std' => '', 'label' => __( 'Location', 'wp-job-manager' ) ), 'number' => array( 'type' => 'number', 'step' => 1, 'min' => 1, 'max' => '', 'std' => 10, 'label' => __( 'Number of listings to show', 'wp-job-manager' ) ) ); $this->register(); } // function widget() to be here (modified version of WP_Job_Manager_Widget_Recent_Jobs's) } add_action('widgets_init', 'gjcontent_register_widgets', 99); function gjcontent_register_widgets() { register_widget( 'GJ_Recent_Jobs_Widget' ); }
Interestingly, when I replace WP_Job_Manager_Widget_Recent_Jobs with WP_Widget_Text (the standard text widget that ships with WP), it also says this class is not found … why can’t I extend a widget class defined in a different plugin to my own?
I’ve also tried putting the above code in my functions.php (instead of in my own plugin where it currently is) but still same issue.
help much appreciated
- The topic ‘Error trying to extend WP_Job_Manager_Widget’ is closed to new replies.