plugin_url = theme_dir_url(__FILE__); //Call the parent constructor with the required arguments. parent::__construct( // The unique id for your widget. 'apt_wood_menu', // The name of the widget for display purposes. __('APT Wood Menu', 'apt-news'), // 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' => __('Display menu using wood as a background', 'apt-news'), 'help' => 'https://aptarmy.github.io/apt-news.io/hello-world-widget-docs', 'panels_groups' => array('apt_widgets'), ), //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( // Select menu 'menu' => array( 'type' => 'select', 'label' => __('Select which menu will be shown as accordion menu.', 'apt-news'), 'default' => 'not_selected', 'options' => $this->get_all_menus() ), 'menu_height' => array( 'type' => 'number', 'label' => __('Menu height', 'apt-news'), 'default' => '597', ), 'menu_background_image' => array( 'type' => 'media', 'library' => 'image', 'label' => __('background image', 'apt-news'), 'default' => '0', ), $this->get_media_query_id() => $this->get_media_query_options(), ), //The $base_folder path string. plugin_dir_path(__FILE__) ); } /* Get template file */ function get_template_name($instance) { return 'template'; } /* Get less file */ function get_style_name($instance) { return 'style'; } /* set less variable */ function get_less_variables($instance){ /** * $menu_background_image * prepare background image variable * @var string */ $menu_background_image = 'url('; if ($instance['menu_background_image'] == 0) { $menu_background_image .= $this->plugin_url . 'images/wooden-bg.jpg'; } else { $menu_background_image .= wp_get_attachment_image_src($instance['menu_background_image'], 'full')[0]; } $menu_background_image .= ')'; /** * Send array to less */ return array( 'menu_background_image' => $menu_background_image, 'menu_height' => $instance['menu_height'] . 'px', ); } } // siteorigin_widget_register($desired_widget_id, $path_to_widget, $class_used_to_create_widget) siteorigin_widget_register('apt_wood_menu', __FILE__, 'APT_Wood_Menu');