• With this specific plugin activated, you can no long change the icons of the carousel Pre < FWD > . This widget simply does not respond to the changes, it does not load the changes, the settings for icons become useless.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Same here…

    Plugin Author Charlie Etienne

    (@charlieetienne)

    Hi @davidjs and @ines-graphiste ,

    I tried to implement it but the way Elementor writes its own code is not exactly meant to be customized or hacked – to be more explicit, a lot of new features methods are private methods, making it impossible to call it from another plugin unless redefining it. The main problem of redefining methods in my own code is I’m not able to maintain my plugin as Elementor grows up and evolves. The more I overwrite Elementor methods the more it risks to break the site. I don’t want to be responsible to break Elementor on each updates itself on user websites. The purpose was to improve Elementor, not to break it.

    So, sorry but at this time I don’t plan to make this work.

    Cheers,

    Charlie

    Thread Starter davidjs

    (@davidjs)

    <?php
    /**
     * Plugin Name:       Custom links in Elementor Image Carousel
     * Description:       Add custom links in Elementor Image Carousel widget
     * Version:           1.1.2
     * Requires at least: 5.2
     * Requires PHP:      7.2
     * Author:            Charlie Etienne
     * Author URI:        https://web-nancy.fr
     * License:           GPL v2 or later
     * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     * Text Domain:       custom-links-eicw
     * Domain Path:       /languages
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    class CustomLinksEICW {
    
    	private static $instance;
    
    	final public static function get_instance(): CustomLinksEICW {
    		if (null === self::$instance) {
    			self::$instance = new self();
    		}
    
    		return self::$instance;
    	}
    
    	public function init() {
    		add_filter( 'attachment_fields_to_edit', [ $this, 'attachment_fields_to_edit' ], 10, 2 );
    		add_filter( 'attachment_fields_to_save', [ $this, 'attachment_fields_to_save' ], 10, 2 );
    		add_action( 'elementor/frontend/widget/before_render', [ $this, 'modify_carousel_settings' ] );
    	}
    
    	/**
    	 *  Adds 'elementor_carousel_custom_link' field to attachment
    	 *
    	 * @param $form_fields
    	 * @param $post
    	 *
    	 * @return array
    	 */
    	public function attachment_fields_to_edit( $form_fields, $post ): array {
    		$form_fields[ 'elementor_carousel_custom_link' ] = array(
    			'label' => __( 'Custom link', 'elementor' ),
    			'input' => 'text',
    			'value' => get_post_meta( $post->ID, 'elementor_carousel_custom_link', true ),
    			'helps' => __( 'This will add a link to images in Elementor Carousel', 'elementor' ),
    		);
    
    		$target  = (bool) get_post_meta( $post->ID, 'elementor_carousel_custom_link_target', true );
    		$checked = ( $target ) ? 'checked' : '';
    
    		$form_fields[ 'elementor_carousel_custom_link_target' ] = array(
    			'label' => __( 'Open in new tab ?', 'elementor' ),
    			'input' => 'html',
    			'html'  => "<input type='checkbox' $checked name='attachments[$post->ID][elementor_carousel_custom_link_target]' id='attachments[$post->ID][elementor_carousel_custom_link_target]' />",
    			'value' => $target,
    			'helps' => __( 'Open custom link in Elementor Carousel in new tab ?', 'elementor' ),
    		);
    
    		return $form_fields;
    	}
    
    	/**
    	 * Saves 'elementor_carousel_custom_link' field to attachment
    	 *
    	 * @param $post
    	 * @param $attachment
    	 *
    	 * @return WP_Post|array|null
    	 */
    	public function attachment_fields_to_save( $post, $attachment ) {
    		$attachment_link = $attachment[ 'elementor_carousel_custom_link' ];
    		$formated_link   = $attachment_link ?? '';
    		update_post_meta( $post[ 'ID' ], 'elementor_carousel_custom_link', $formated_link );
    
    		$link_target = isset( $attachment[ 'elementor_carousel_custom_link_target' ] ) ? 1 : 0;
    		update_post_meta( $post[ 'ID' ], 'elementor_carousel_custom_link_target', $link_target );
    
    		return $post;
    	}
    
    	/**
    	 * Modify Carousel settings
    	 */
    	public function modify_carousel_settings( $widget ) {
    		if ( 'image-carousel' !== $widget->get_name() ) {
    			return;
    		}
    
    		$settings = $widget->get_settings_for_display();
    		$slides   = $settings['carousel_images'];
    
    		if ( ! $slides || empty( $slides ) ) {
    			return;
    		}
    
    		$slides_with_links = [];
    
    		foreach ( $slides as $index => $attachment ) {
    			$link_url    = get_post_meta( $attachment['id'], 'elementor_carousel_custom_link', true );
    			$link_target = (bool) get_post_meta( $attachment['id'], 'elementor_carousel_custom_link_target', true );
    
    			$attachment['url']            = ! empty( $link_url ) ? $link_url : '';
    			$attachment['is_external']    = $link_target;
    			$slides_with_links[ $index ] = $attachment;
    		}
    
    		$widget->set_settings( 'carousel_images', $slides_with_links );
    	}
    
    }
    
    CustomLinksEICW::get_instance()->init();
    
    

    Im working on a fix. I dont think its right yet.

    • This reply was modified 1 year, 11 months ago by davidjs.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Confirmed – This plugin breaks the carousel icon functionality’ is closed to new replies.