Certainly! Below are the full file replacements with the minimal surgical changes applied for both of your requests:
1) widgets/portfolio-list-widget.php
Replace your entire register_controls() method with this exact code:
protected function register_controls() {
// Content Section
$this->start_controls_section(
'section_content',
[
'label' => esc_html__( 'Portfolio List Content', 'my-custom-portfolio-widget' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new Repeater();
$repeater->add_control(
'portfolio_item_title',
[
'label' => esc_html__( 'Title', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Portfolio Item Title', 'my-custom-portfolio-widget' ),
'placeholder' => esc_html__( 'Enter your title', 'my-custom-portfolio-widget' ),
'label_block' => true,
]
);
$repeater->add_control(
'portfolio_item_category',
[
'label' => esc_html__( 'Category', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Category Name', 'my-custom-portfolio-widget' ),
'placeholder' => esc_html__( 'Enter category', 'my-custom-portfolio-widget' ),
'label_block' => true,
]
);
$repeater->add_control(
'media_type',
[
'label' => esc_html__( 'Media Type', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SELECT,
'default' => 'image',
'options' => [
'image' => esc_html__( 'Image', 'my-custom-portfolio-widget' ),
'self_hosted_video' => esc_html__( 'Self-Hosted Video', 'my-custom-portfolio-widget' ),
'youtube' => esc_html__( 'YouTube Video', 'my-custom-portfolio-widget' ),
'vimeo' => esc_html__( 'Vimeo Video', 'my-custom-portfolio-widget' ),
],
]
);
$repeater->add_control(
'portfolio_item_image',
[
'label' => esc_html__( 'Image', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::MEDIA,
'default' => [ 'url' => Utils::get_placeholder_image_src() ],
'condition' => [ 'media_type' => 'image' ],
]
);
$repeater->add_control(
'portfolio_item_video',
[
'label' => esc_html__( 'Self-Hosted Video', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::MEDIA,
'media_type' => 'video',
'condition' => [ 'media_type' => 'self_hosted_video' ],
]
);
$repeater->add_control(
'youtube_video_url',
[
'label' => esc_html__( 'YouTube Video URL', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::URL,
'placeholder' => esc_html__( 'http://youtube.com/watch?v=VIDEO_ID', 'my-custom-portfolio-widget' ),
'label_block' => true,
'show_external' => false,
'condition' => [ 'media_type' => 'youtube' ],
]
);
$repeater->add_control(
'vimeo_video_url',
[
'label' => esc_html__( 'Vimeo Video URL', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::URL,
'placeholder' => esc_html__( 'https://vimeo.com/VIDEO_ID', 'my-custom-portfolio-widget' ),
'label_block' => true,
'show_external' => false,
'condition' => [ 'media_type' => 'vimeo' ],
]
);
$repeater->add_control(
'portfolio_item_link',
[
'label' => esc_html__( 'Link', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::URL,
'placeholder' => esc_html__( 'https://your-link.com', 'my-custom-portfolio-widget' ),
'show_external' => true,
'default' => [
'url' => '#',
'is_external' => true,
'nofollow' => true,
],
]
);
$this->add_control(
'portfolio_items',
[
'label' => esc_html__( 'Portfolio Items', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'portfolio_item_title' => esc_html__( 'Portfolio #1', 'my-custom-portfolio-widget' ),
'portfolio_item_category' => esc_html__( 'Design', 'my-custom-portfolio-widget' ),
'media_type' => 'image',
],
[
'portfolio_item_title' => esc_html__( 'Portfolio #2', 'my-custom-portfolio-widget' ),
'portfolio_item_category' => esc_html__( 'Development', 'my-custom-portfolio-widget' ),
'media_type' => 'image',
],
],
'title_field' => '{{{ portfolio_item_title }}}',
]
);
$this->end_controls_section();
// Style Section
$this->start_controls_section(
'section_style',
[
'label' => esc_html__( 'Portfolio List Style', 'my-custom-portfolio-widget' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'item_background_color',
[
'label' => esc_html__( 'Item Background Color', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .my-custom-portfolio-list-item' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'media_height',
[
'label' => esc_html__( 'Media Height', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', 'vh', 'em', '%' ],
'range' => [
'px' => [ 'min' => 0, 'max' => 1000 ],
'vh' => [ 'min' => 0, 'max' => 100 ],
'%' => [ 'min' => 0, 'max' => 100 ],
],
'default' => [ 'unit' => 'vh', 'size' => 80 ],
'selectors' => [
'{{WRAPPER}} .my-custom-portfolio-list-item-media' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'media_object_fit',
[
'label' => esc_html__( 'Media Fit', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SELECT,
'default' => 'cover',
'options' => [
'fill' => esc_html__( 'Fill', 'my-custom-portfolio-widget' ),
'cover' => esc_html__( 'Cover', 'my-custom-portfolio-widget' ),
'contain' => esc_html__( 'Contain', 'my-custom-portfolio-widget' ),
'none' => esc_html__( 'None', 'my-custom-portfolio-widget' ),
],
'selectors' => [
'{{WRAPPER}} .my-custom-portfolio-list-item-media img, {{WRAPPER}} .my-custom-portfolio-list-item-media video, {{WRAPPER}} .my-custom-portfolio-video-embed iframe' => 'object-fit: {{VALUE}};',
],
]
);
$this->add_control(
'media_object_position',
[
'label' => esc_html__( 'Media Alignment (Object Position)', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SELECT,
'default' => 'center',
'options' => [
'center' => esc_html__( 'Center', 'my-custom-portfolio-widget' ),
'top' => esc_html__( 'Top', 'my-custom-portfolio-widget' ),
'bottom' => esc_html__( 'Bottom', 'my-custom-portfolio-widget' ),
'left' => esc_html__( 'Left', 'my-custom-portfolio-widget' ),
'right' => esc_html__( 'Right', 'my-custom-portfolio-widget' ),
'top left' => esc_html__( 'Top Left', 'my-custom-portfolio-widget' ),
'top right' => esc_html__( 'Top Right', 'my-custom-portfolio-widget' ),
'bottom left' => esc_html__( 'Bottom Left', 'my-custom-portfolio-widget' ),
'bottom right' => esc_html__( 'Bottom Right', 'my-custom-portfolio-widget' ),
],
'selectors' => [
'{{WRAPPER}} .my-custom-portfolio-list-item-media img, {{WRAPPER}} .my-custom-portfolio-list-item-media video, {{WRAPPER}} .my-custom-portfolio-video-embed iframe' => 'object-position: {{VALUE}};',
],
]
);
$this->add_control(
'text_alignment',
[
'label' => esc_html__( 'Text Alignment', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => esc_html__( 'Left', 'my-custom-portfolio-widget' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'my-custom-portfolio-widget' ),
'icon' => 'eicon-text-align-center',
],
'flex-end' => [
'title' => esc_html__( 'Right', 'my-custom-portfolio-widget' ),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'flex-start',
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .my-custom-portfolio-list-item-info' => 'justify-content: {{VALUE}};',
],
]
);
// Title colors and typography
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .my-custom-title' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'my-custom-portfolio-widget' ),
'selector' => '{{WRAPPER}} .my-custom-title',
]
);
// Individual margin control for Title (NEW)
$this->add_responsive_control(
'title_margin',
[
'label' => esc_html__( 'Title Margin', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'allowed_dimensions' => [ 'left', 'right' ],
'selectors' => [
'{{WRAPPER}} .my-custom-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'default' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
'unit' => 'px',
],
]
);
// Category colors and typography
$this->add_control(
'category_color',
[
'label' => esc_html__( 'Category Color', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .my-custom-category' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'category_typography',
'label' => esc_html__( 'Category Typography', 'my-custom-portfolio-widget' ),
'selector' => '{{WRAPPER}} .my-custom-category',
]
);
// Individual margin control for Category (NEW)
$this->add_responsive_control(
'category_margin',
[
'label' => esc_html__( 'Category Margin', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'allowed_dimensions' => [ 'left', 'right' ],
'selectors' => [
'{{WRAPPER}} .my-custom-category' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'default' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
'unit' => 'px',
],
]
);
// Footer container margin control
$this->add_responsive_control(
'footer_margin',
[
'label' => esc_html__( 'Footer Margin', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .my-custom-portfolio-list-item-footer' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'default' => [
'top' => 10,
'right' => 0,
'bottom' => 0,
'left' => 0,
'unit' => 'px',
],
]
);
// Footer vertical alignment (existing)
$this->add_control(
'footer_vertical_alignment',
[
'label' => esc_html__( 'Footer Vertical Alignment', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SELECT,
'default' => 'center',
'options' => [
'flex-start' => esc_html__( 'Top', 'my-custom-portfolio-widget' ),
'center' => esc_html__( 'Center', 'my-custom-portfolio-widget' ),
'flex-end' => esc_html__( 'Bottom', 'my-custom-portfolio-widget' ),
],
'selectors' => [
'{{WRAPPER}} .my-custom-portfolio-list-item-footer' => 'align-items: {{VALUE}};',
],
]
);
// Footer horizontal alignment (existing)
$this->add_control(
'footer_horizontal_alignment',
[
'label' => esc_html__( 'Footer Horizontal Alignment', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SELECT,
'default' => 'space-between',
'options' => [
'flex-start' => esc_html__( 'Left', 'my-custom-portfolio-widget' ),
'center' => esc_html__( 'Center', 'my-custom-portfolio-widget' ),
'flex-end' => esc_html__( 'Right', 'my-custom-portfolio-widget' ),
'space-between' => esc_html__( 'Space Between', 'my-custom-portfolio-widget' ),
'space-around' => esc_html__( 'Space Around', 'my-custom-portfolio-widget' ),
'space-evenly' => esc_html__( 'Space Evenly', 'my-custom-portfolio-widget' ),
],
'selectors' => [
'{{WRAPPER}} .my-custom-portfolio-list-item-footer' => 'justify-content: {{VALUE}};',
],
]
);
// Pagination container margin (existing)
$this->add_responsive_control(
'pagination_margin',
[
'label' => esc_html__( 'Pagination Margin', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .swiper-pagination' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'default' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
'unit' => 'px',
],
]
);
// Pagination alignment (existing)
$this->add_control(
'pagination_alignment',
[
'label' => esc_html__( 'Pagination Alignment', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'my-custom-portfolio-widget' ),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'my-custom-portfolio-widget' ),
'icon' => 'eicon-h-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'my-custom-portfolio-widget' ),
'icon' => 'eicon-h-align-right',
],
],
'default' => 'center',
'selectors' => [
'{{WRAPPER}} .swiper-pagination' => 'text-align: {{VALUE}};',
],
]
);
$this->end_controls_section();
// Carousel Settings Section with fade effect and fade speed added
$this->start_controls_section(
'section_swiper_settings',
[
'label' => esc_html__( 'Carousel Settings', 'my-custom-portfolio-widget' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'effect',
[
'label' => esc_html__( 'Transition Effect', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SELECT,
'default' => 'slide',
'options' => [
'slide' => esc_html__( 'Slide', 'my-custom-portfolio-widget' ),
'fade' => esc_html__( 'Fade', 'my-custom-portfolio-widget' ),
],
]
);
$this->add_control(
'fade_speed',
[
'label' => esc_html__( 'Fade Transition Speed (ms)', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::NUMBER,
'min' => 100,
'max' => 5000,
'step' => 100,
'default' => 500,
'condition' => [ 'effect' => 'fade' ],
]
);
$this->add_control(
'slides_per_view',
[
'label' => esc_html__( 'Slides Per View', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::NUMBER,
'min' => 1,
'max' => 10,
'step' => 1,
'default' => 3,
'condition' => [ 'effect!' => 'fade' ],
]
);
$this->add_control(
'space_between',
[
'label' => esc_html__( 'Space Between Slides', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::NUMBER,
'min' => 0,
'max' => 100,
'step' => 1,
'default' => 30,
'condition' => [ 'effect!' => 'fade' ],
]
);
$this->add_control(
'loop_carousel',
[
'label' => esc_html__( 'Loop Carousel', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'my-custom-portfolio-widget' ),
'label_off' => esc_html__( 'No', 'my-custom-portfolio-widget' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'autoplay',
[
'label' => esc_html__( 'Autoplay', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'my-custom-portfolio-widget' ),
'label_off' => esc_html__( 'No', 'my-custom-portfolio-widget' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'autoplay_delay',
[
'label' => esc_html__( 'Autoplay Delay (ms)', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::NUMBER,
'min' => 1000,
'max' => 10000,
'step' => 100,
'default' => 3000,
'condition' => [ 'autoplay' => 'yes' ],
]
);
$this->add_control(
'show_navigation',
[
'label' => esc_html__( 'Navigation Arrows', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'my-custom-portfolio-widget' ),
'label_off' => esc_html__( 'Hide', 'my-custom-portfolio-widget' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'show_pagination',
[
'label' => esc_html__( 'Pagination Dots', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'my-custom-portfolio-widget' ),
'label_off' => esc_html__( 'Hide', 'my-custom-portfolio-widget' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'pagination_bottom_offset',
[
'label' => esc_html__( 'Pagination Dots Offset From Bottom', 'my-custom-portfolio-widget' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%' ],
'range' => [
'px' => [ 'min' => -100, 'max' => 200 ],
'%' => [ 'min' => -50, 'max' => 100 ],
],
'default' => [ 'unit' => 'px', 'size' => 0 ],
'condition' => [ 'show_pagination' => 'yes' ],
'selectors' => [
'{{WRAPPER}} .swiper-pagination' => 'bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_section();
}
Also replace the $swiper_options definition inside your render() method entirely with this:
$swiper_options = [
'effect' => $settings['effect'],
'speed' => ( 'fade' === $settings['effect'] ) ? intval( $settings['fade_speed'] ) : 300,
'slidesPerView' => ( 'fade' === $settings['effect'] ) ? 1 : intval( $settings['slides_per_view'] ),
'spaceBetween' => ( 'fade' === $settings['effect'] ) ? 0 : intval( $settings['space_between'] ),
'loop' => ( 'yes' === $settings['loop_carousel'] ),
'autoplay' => ( 'yes' === $settings['autoplay'] ) ? ['delay' => $settings['autoplay_delay']] : false,
'navigation' => ( 'yes' === $settings['show_navigation'] ) ? ['nextEl' => '.swiper-button-next', 'prevEl' => '.swiper-button-prev'] : false,
'pagination' => ( 'yes' === $settings['show_pagination'] ) ? ['el' => '.swiper-pagination', 'clickable' => true] : false,
'fadeEffect' => [
'crossFade' => true,
],
'breakpoints' => ( 'fade' === $settings['effect'] ) ? [] : [
640 => ['slidesPerView' => 1, 'spaceBetween' => 20],
768 => ['slidesPerView' => 2, 'spaceBetween' => 40],
1024 => [
'slidesPerView' => intval( $settings['slides_per_view'] ),
'spaceBetween' => intval( $settings['space_between'] ),
],
],
];
2) assets/js/portfolio-list.js
Replace the entire file content with this (only added a small block to handle fade effect settings properly):
(function ($) {
'use strict';
var DEBUG = false;
if (DEBUG) {
console.log('portfolio-list.js STARTING EXECUTION!');
}
// Store swiper instances to avoid multiple initializations
var swiperInstances = new Map();
function initPortfolioSwipers() {
var swiperContainers = $('.my-custom-portfolio-list.swiper'); // Updated selector
if (swiperContainers.length) {
swiperContainers.each(function () {
var $container = $(this);
// Prevent double initialization:
if (swiperInstances.has(this)) {
if (DEBUG) {
console.log('Swiper already initialized:', this);
}
return;
}
var swiperOptions = $container.data('swiper-options') || {};
// Fix navigation selectors by DOM elements, not strings:
if (swiperOptions.navigation && typeof swiperOptions.navigation === 'object') {
var nextEl = $container.find('.swiper-button-next')[0];
var prevEl = $container.find('.swiper-button-prev')[0];
if (nextEl && prevEl) {
swiperOptions.navigation.nextEl = nextEl;
swiperOptions.navigation.prevEl = prevEl;
} else {
// Disable if any missing, to prevent errors
swiperOptions.navigation = false;
}
}
// Fix pagination element similarly:
if (swiperOptions.pagination && typeof swiperOptions.pagination === 'object') {
var paginationEl = $container.find('.swiper-pagination')[0];
if (paginationEl) {
swiperOptions.pagination.el = paginationEl;
} else {
swiperOptions.pagination = false;
}
}
// Special handling for fade effect
if( swiperOptions.effect === 'fade' ){
swiperOptions.fadeEffect = swiperOptions.fadeEffect || {};
swiperOptions.fadeEffect.crossFade = true;
swiperOptions.virtualTranslate = true;
}
if (typeof Swiper !== 'undefined') {
var swiperInstance = new Swiper(this, swiperOptions);
swiperInstances.set(this, swiperInstance);
if (DEBUG) {
console.log('Swiper initialized on:', this);
console.log(swiperInstance);
}
} else if (DEBUG) {
console.warn('Swiper library not found. Please ensure it is enqueued.');
}
});
}
}
// Run once on document ready (frontend page load)
$(document).ready(function () {
initPortfolioSwipers();
});
// Run when Elementor frontend initializes our widget in editor and live preview
$(window).on('elementor/frontend/init', function () {
// Hook into our widget’s render event - THIS EXACTLY matches widget name (replace dots with dashes)
elementorFrontend.hooks.addAction('frontend/element_ready/portfolio-list-widget.default', function () {
initPortfolioSwipers();
});
});
})(jQuery);
3) assets/css/portfolio-list.css
Replace only this entire CSS block for .my-custom-no-style-link in your existing CSS with the following to enlarge the clickable area while keeping styling clean:
.my-custom-no-style-link {
color: inherit !important;
text-decoration: none !important;
/* Change to inline-block to allow padding */
display: inline-block;
/* Add horizontal padding to enlarge clickable area */
padding-left: 6px;
padding-right: 6px;
/* Show pointer cursor to indicate clickable */
cursor: pointer !important;
/* Ensure clickable */
pointer-events: auto;
}
.my-custom-no-style-link:hover,
.my-custom-no-style-link:focus,
.my-custom-no-style-link:active {
text-decoration: none !important;
outline: none !important;
color: inherit !important;
}
Notes:
- The widget PHP changes only add new controls & modify swiper options to support fade effect with fade speed.
- JS changes only add special fade handling for swiper initialization.
- CSS changes only adjust link display and padding for bigger clickable areas but keep visual appearance unchanged.
These changes are minimal and should integrate seamlessly into your existing code.
If you want the entire full widget PHP file or complete CSS file with these merged, just say so. Otherwise, these replacements are ready to paste where indicated.
Let me know if you want me to assist with that or anything else!