fahimmurshed

class-page-title.php

Oct 20th, 2025
1,183
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.65 KB | None | 0 0
  1. <?php
  2. /// Replace the code: wp-content/themes/woodmart/inc/modules/layouts/elementor/woocommerce/class-page-title.php
  3.  
  4. <?php
  5. /**
  6.  * Page title map.
  7.  *
  8.  * @package Woodmart
  9.  */
  10.  
  11. namespace XTS\Modules\Layouts;
  12.  
  13. use Elementor\Widget_Base;
  14. use Elementor\Controls_Manager;
  15. use Elementor\Plugin;
  16. use XTS\Modules\Layouts\Global_Data as Builder_Data;
  17.  
  18. if ( ! defined( 'ABSPATH' ) ) {
  19.     exit; // Direct access not allowed.
  20. }
  21.  
  22. // Prevent redeclaration error.
  23. if ( ! class_exists( 'XTS\\Modules\\Layouts\\Page_Title' ) ) {
  24.  
  25.     /**
  26.      * Elementor widget that inserts an embeddable content into the page.
  27.      */
  28.     class Page_Title extends Widget_Base {
  29.         /**
  30.          * Get widget name.
  31.          *
  32.          * @return string Widget name.
  33.          */
  34.         public function get_name() {
  35.             return 'wd_page_title';
  36.         }
  37.  
  38.         /**
  39.          * Get widget title.
  40.          *
  41.          * @return string Widget title.
  42.          */
  43.         public function get_title() {
  44.             return esc_html__( 'Page title', 'woodmart' );
  45.         }
  46.  
  47.         /**
  48.          * Get widget icon.
  49.          *
  50.          * @return string Widget icon.
  51.          */
  52.         public function get_icon() {
  53.             return 'wd-icon-wc-page-title';
  54.         }
  55.  
  56.         /**
  57.          * Get widget categories.
  58.          *
  59.          * @return array Widget categories.
  60.          */
  61.         public function get_categories() {
  62.             return array( 'wd-woocommerce-elements' );
  63.         }
  64.  
  65.         /**
  66.          * Show in panel.
  67.          *
  68.          * @return bool Whether to show the widget in the panel or not.
  69.          */
  70.         public function show_in_panel() {
  71.             return woodmart_woocommerce_installed();
  72.         }
  73.  
  74.         /**
  75.          * Register the widget controls.
  76.          */
  77.         protected function register_controls() {
  78.             $this->start_controls_section(
  79.                 'general_style_section',
  80.                 array(
  81.                     'label' => esc_html__( 'General', 'woodmart' ),
  82.                     'tab'   => Controls_Manager::TAB_STYLE,
  83.                 )
  84.             );
  85.  
  86.             $this->add_control(
  87.                 'css_classes',
  88.                 array(
  89.                     'type'         => 'wd_css_class',
  90.                     'default'      => 'wd-page-title-el',
  91.                     'prefix_class' => '',
  92.                 )
  93.             );
  94.  
  95.             $this->add_control(
  96.                 'full_width',
  97.                 array(
  98.                     'label'   => esc_html__( 'Full width', 'woodmart' ),
  99.                     'type'    => Controls_Manager::SWITCHER,
  100.                     'default' => '',
  101.                 )
  102.             );
  103.  
  104.             $this->end_controls_section();
  105.         }
  106.  
  107.         /**
  108.          * Render the widget output on the frontend.
  109.          */
  110.         protected function render() {
  111.             $settings = wp_parse_args(
  112.                 $this->get_settings_for_display(),
  113.                 array(
  114.                     'enable_title'       => 'yes',
  115.                     'enable_breadcrumbs' => 'yes',
  116.                     'enable_categories'  => 'yes',
  117.                     'full_width'         => '',
  118.                 )
  119.             );
  120.  
  121.             $title_classes = '';
  122.  
  123.             if ( $settings['full_width'] ) {
  124.                 $title_classes .= ' wd-section-stretch';
  125.             }
  126.  
  127.             Builder_Data::get_instance()->set_data( 'builder', true );
  128.             Builder_Data::get_instance()->set_data( 'title_classes', $title_classes );
  129.             Builder_Data::get_instance()->set_data( 'layout_id', get_the_ID() );
  130.  
  131.             Main::setup_preview();
  132.  
  133.             woodmart_enqueue_inline_style( 'el-page-title-builder' );
  134.  
  135.             if ( is_product_taxonomy() || is_shop() || is_product_category() || is_product_tag() || woodmart_is_product_attribute_archive() ) {
  136.                 woodmart_enqueue_inline_style( 'woo-shop-page-title' );
  137.  
  138.                 if ( ! woodmart_get_opt( 'shop_title' ) ) {
  139.                     woodmart_enqueue_inline_style( 'woo-shop-opt-without-title' );
  140.                 }
  141.  
  142.                 if ( woodmart_get_opt( 'shop_categories' ) ) {
  143.                     woodmart_enqueue_inline_style( 'shop-title-categories' );
  144.                     woodmart_enqueue_inline_style( 'woo-categories-loop-nav-mobile-accordion' );
  145.                 }
  146.             }
  147.  
  148.             woodmart_page_title();
  149.  
  150.             Main::restore_preview();
  151.         }
  152.     }
  153.  
  154.     // Register the widget only once.
  155.     Plugin::instance()->widgets_manager->register( new Page_Title() );
  156.  
  157. } // End if class_exists check.
  158.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment