Plugin Directory

Changeset 3451261


Ignore:
Timestamp:
02/01/2026 07:33:48 AM (2 months ago)
Author:
solankisoftware
Message:

Fixed :: Elementer pro automatic containers deleted issue

Location:
central-media-library-for-network-websites
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • central-media-library-for-network-websites/trunk/central-media-library-for-network-sites.php

    r3451092 r3451261  
    33 * Plugin Name: Central Media Manager for Multisite
    44 * Description: Enables a central media library across all websites in a WordPress multisite network.
    5  * Version: 1.1.7
     5 * Version: 1.1.8
    66 * Author: Kirtikumar Solanki
    77 * Author URI: https://profiles.wordpress.org/solankisoftware/
  • central-media-library-for-network-websites/trunk/inc/cmlfnw-namespace.php

    r3451092 r3451261  
    12721272
    12731273/**
     1274 * Determine whether an Elementor data array represents a media control.
     1275 *
     1276 * Elementor element arrays commonly include an "id" field for element IDs.
     1277 * We only want to validate IDs that belong to media controls (image/gallery/etc.).
     1278 *
     1279 * @param array $data Elementor data array.
     1280 * @return bool True when the array looks like a media control.
     1281 */
     1282function cmlfnw_is_elementor_media_id_context( $data ) {
     1283    if ( ! is_array( $data ) ) {
     1284        return false;
     1285    }
     1286
     1287    // Element definitions use these keys and should never be treated as media controls.
     1288    if ( isset( $data['elType'] ) || isset( $data['elements'] ) || isset( $data['widgetType'] ) ) {
     1289        return false;
     1290    }
     1291
     1292    if ( ! isset( $data['id'] ) || ! is_numeric( $data['id'] ) ) {
     1293        return false;
     1294    }
     1295
     1296    // Media controls typically include a URL to the uploads folder or source=library.
     1297    if ( isset( $data['source'] ) && 'library' === $data['source'] ) {
     1298        return true;
     1299    }
     1300
     1301    if ( isset( $data['url'] ) && is_string( $data['url'] ) ) {
     1302        return ( strpos( $data['url'], 'wp-content/uploads' ) !== false );
     1303    }
     1304
     1305    // Some media controls include size/alt metadata.
     1306    if ( isset( $data['size'] ) || isset( $data['sizes'] ) || isset( $data['alt'] ) ) {
     1307        return true;
     1308    }
     1309
     1310    return false;
     1311}
     1312
     1313/**
    12741314 * Recursively validate attachment IDs in Elementor data structure.
    12751315 *
     
    12841324    foreach ( $data as $key => $value ) {
    12851325        // Check for common attachment ID fields in Elementor.
    1286         if ( in_array( $key, array( 'id', 'image_id', 'thumbnail_id', 'background_image', 'attachment_id' ), true ) && is_numeric( $value ) ) {
     1326        if ( in_array( $key, array( 'image_id', 'thumbnail_id', 'background_image', 'attachment_id' ), true ) && is_numeric( $value ) ) {
    12871327            $attachment_id = (int) $value;
    12881328            // If attachment doesn't exist in central library, remove the reference.
    12891329            if ( $attachment_id > 0 && ! cmlfnw_verify_attachment_exists( $attachment_id ) ) {
    12901330                $data[ $key ] = ''; // Clear invalid attachment ID.
     1331            }
     1332        } elseif ( 'id' === $key && is_numeric( $value ) && cmlfnw_is_elementor_media_id_context( $data ) ) {
     1333            $attachment_id = (int) $value;
     1334            if ( $attachment_id > 0 && ! cmlfnw_verify_attachment_exists( $attachment_id ) ) {
     1335                $data[ $key ] = '';
    12911336            }
    12921337        } elseif ( 'url' === $key && is_string( $value ) && strpos( $value, 'wp-content/uploads' ) !== false ) {
  • central-media-library-for-network-websites/trunk/readme.txt

    r3451092 r3451261  
    55Requires at least: 4.7
    66Tested up to: 6.9
    7 Stable tag: 1.1.7
     7Stable tag: 1.1.8
    88Requires PHP: 7.0
    99License: GPLv2 or later
     
    6363
    6464== Changelog ==
     65= 1.1.8 =
     66* Fixed Elementer containers automatic deleted issue
     67
    6568= 1.1.7 =
    6669* Fixed featured image issue in classic editor
Note: See TracChangeset for help on using the changeset viewer.