'', 'name' => $this->addon_name(), 'type' =>'', 'order' =>'', 'location' =>'', 'page_id' =>'', 'page_type' =>'', 'before' => true, 'after' => true ]; $this->args = array_merge($defaults,$args); $this->base_preview_image_path = asset('assets/backend/page-builder'); try { $this->rand_number = random_int(999, 99999); } catch (\Exception $e) { } } /** * preview_image * this method must have to implement by all widget to show a preview image at admin panel so that user know about the design which he want to use * @since 1.0.0 * */ abstract public function preview_image(); /** * admin_render * this method must have to implement by all widget to render admin panel widget content * @since 1.0.0 * */ abstract public function admin_render(); /** * frontend_render * this method must have to implement by all widget to render frontend widget content * @since 1.0.0 * */ abstract public function frontend_render(); /** * widget_title * this method must have to implement by all widget to register widget title * @since 1.0.0 * */ abstract public function addon_title(); /** * addon_name * get addon name from class name * @since 1.0.0 * */ public function addon_name() { return substr(strrchr(static::class, "\\"),1); } /** * addon_namespace * get addon class namespace * @since 1.0.0 * */ public function addon_namespace() { return static::class; } /** * widget_name * this method must have to implement by all widget to register widget name * @since 1.0.0 * */ public function enable() : bool { // TODO: Implement widget_name() method. return true; } /** * default_fields * this method will return all the default field required by any widget * @since 1.0.0 * */ public function default_fields(): string { //all initial field $output = ''; $output .= !empty($this->args['id']) ? '' : ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= ''; return $output; } /** * get_settings * this method will return all the settings value saved for widget * @since 1.0.0 * */ public function get_settings() { $widget_data = !empty($this->args['id']) ? PageBuilder::find($this->args['id']) : []; $widget_data = !empty($widget_data) ? unserialize($widget_data->addon_settings,['class' => false]) : []; return $widget_data; } /** * widget_before * this method will add widget before html markup for widget in frontend * @since 1.0.0 */ public function addon_area_before($class = null) { return '
'; } /** * widget_after * this method will add widget after html markup for widget in frontend * @since 1.0.0 */ public function addon_area_after() { return '
'; } /** * admin_form_start * this method will init form markup for admin panel * @since 1.0.0 */ public function admin_form_start(): string { return '
'; } /** * admin_form_end * this method will end tag form markup for admin panel * @since 1.0.0 */ public function admin_form_end(): string { return '
'; } /** * admin_form_submit_button * this method will add a submit button for widget in admin panel * @since 1.0.0 */ public function admin_form_submit_button($text = null): string { $button_text = $text ?? __('Save Changes'); return ''; } /** * admin_form_submit_button * this method will add a submit button for widget in admin panel * @since 1.0.0 */ public function admin_language_tab(): string { $all_languages = LanguageHelper::all_languages(); $output = ''; return $output; } /** * admin_language_tab_start * this method will add language tab content start wrapper * @since 1.0.0 * */ public function admin_language_tab_start(){ return '
'; } /** * admin_language_tab_end * this method will add language tab content end wrapper * @since 1.0.0 * */ public function admin_language_tab_end(){ return '
'; } /** * admin_language_tab_content_start * this method will add language tab panel start * @since 1.0.0 * */ public function admin_language_tab_content_start($args){ return '
'; } /** * admin_language_tab_content_end * this method will add language tab panel end * @since 1.0.0 * */ public function admin_language_tab_content_end(){ return '
'; } public function admin_form_before(){ $markup = ''; if ($this->args['before']){ $markup .= '
  • '; } $markup .= '

    '.$this->addon_title().'

    '; return $markup; } public function admin_form_after(): string { $markup = '
    '; if ($this->args['after']){ $markup .= '
  • '; } return $markup; } public function get_preview_image($image_name): string { if (empty($image_name)){return '';} return ''; } }