�PNG  IHDR22?�� pHYs  �� OiCCPPhotoshop ICC profilexڝSgTS�=���BK���KoR RB���&*! J�!��Q�EEȠ�����Q, � ��!���������{�kּ������>���� �H3Q5� �B�������.@� $p�d!s�#�~<<+"��x� �M��0���B�\���t�8K�@z�B�@F���&S�`�cb�P-`'������{[�!�� e�Dh;��V�EX0fK�9�-0IWfH���� � 0Q��){`�##x��F�W<�+��*x��<�$9E�[-qWW.(�I+6aa�@.�y�2�4���������x����6��_-��"bb���ϫp@�t~��,/��;�m��%�h^ �u��f�@����W�p�~<�5�j>{�-�]c�K'Xt����o��(�h���w��?�G�%�fI�q^D$.Tʳ?�D��*�A��,���� �`6�B$��BB d�r`)��B(�Ͱ*`/�@4�Qh��p.�U�=p�a��(�� A�a!ڈb�X#����!�H�$ ɈQ"K�5H1R�T UH�=r9�\F��;�2����G1���Q=� �C��7�F� �dt1�����r�=�6��Ыhڏ>C�0��3�l0.��B�8, �c˱"� ���V����cϱw�E� 6wB aAHXLXN�H� $4� 7 �Q�'"��K�&���b21�XH,#��/{�C�7$�C2'��I��T��F�nR#�,��4H#���dk�9�, +ȅ����3��!�[ �b@q��S�(R�jJ��4�e�2AU��Rݨ�T5�ZB���R�Q��4u�9̓IK�����hh�i��t�ݕN��W���G���w ��Ljg(�gw��L�Ӌ�T071���oUX*�*|�� �J�&�*/T����ު U�U�T��^S}�FU3S� Ԗ�U��P�SSg�;���g�oT?�~Y��Y�L�OC�Q��_�� c�x,!k ��u�5�&���|v*�����=���9C3J3W�R�f?�q��tN �(���~���)�)�4L�1e\k����X�H�Q�G�6������E�Y��A�J'\'Gg����S�Sݧ �M=:��.�k���Dw�n��^��Lo��y���}/�T�m���G X� $� �<�5qo</���QC]�@C�a�a�ᄑ��<��F�F�i�\�$�m�mƣ&&!&KM�M�RM��)�;L;L���͢�֙5�=1�2��כ߷`ZxZ,����eI��Z�Yn�Z9Y�XUZ]�F���%ֻ�����N�N���gð�ɶ�����ۮ�m�}agbg�Ů��}�}��= ���Z~s�r:V:ޚΜ�?}����/gX���3��)�i�S��Ggg�s�󈋉K��.�>.���Ƚ�Jt�q]�z���������ۯ�6�i�ܟ�4�)�Y3s���C�Q��? ��0k߬~OCO�g��#/c/�W�װ��w��a�>�>r��>�<7�2�Y_�7��ȷ�O�o�_��C#�d�z����%g��A�[��z|!��?:�e����A���AA�������!h�쐭!��Α�i�P~���a�a��~ '���W�?�p�X�1�5w��Cs�D�D�Dޛg1O9�-J5*>�.j<�7�4�?�.fY��X�XIlK9.*�6nl������� �{�/�]py�����.,:�@L�N8��A*��%�w%� y��g"/�6ш�C\*N�H*Mz�쑼5y$�3�,幄'���L Lݛ:��v m2=:�1����qB�!M��g�g�fvˬe����n��/��k���Y- �B��TZ(�*�geWf�͉�9���+��̳�ې7�����ᒶ��KW-X潬j9�������(�x��oʿ�ܔ���Ĺd�f�f���-�[����n �ڴ �V����E�/��(ۻ��C���<��e����;?T�T�T�T6��ݵa��n��{��4���[���>ɾ�UUM�f�e�I���?�������m]�Nmq����#�׹���=TR��+�G�����w- 6 U����#pDy��� �� :�v�{���vg/jB��F�S��[b[�O�>����z�G��499�?r����C�d�&����ˮ/~�����јѡ�򗓿m|������������x31^�V���w�w��O�| (�h���SЧ��������c3-� cHRMz%������u0�`:�o�_�F5IDATx��ytUս�?�;���fN$$��@B�!�k��� -*�gE���j�O�kQ�ʠ`U�B_ �AÐ0%�Ȕ�@r3ޛ;߳��$�@��v����^�s����������$��ߢ !�W��5�̱'-٘������4�>�Rƫ$�G��0U�H}�_ _� #��k�MJ/=�9Du *ڲ�k�PQ;0��j|�*�$�^컂脛y���>�z×� B��� ��(�:$�ʔ_�6��C!B����MVx��a��ζyY����j��ƋY2�9�F�{r��r�딟F��Q��hY6��� x��[l��RC��������nt@��;P��3��� F�w��7��:�P���ɋ'���mj���Bƪ�$�Q�L��y��߷g��\���z����v5�p�v$�v櫻�`6~K �Y�X����,�:��"�o�e0II"(��,������l_�C���/4�+f�E�!q��:����u����c��樼.UE�@� �]K�W���$-�h]�JG���Dz)�`��.�A/ ���mᏣc�3jK� �!�>���$�Q�!�_�? \�C2(E �M$Z I{�U���s�ǣ���=��@Բe ޻��W�����@ �w����}�9v,)��.}*|"�s��di���,���G�]W�AC�������|<����[��ߕ������K�*�G nߴ!��‹��J�!��6(L�a)��Am��������;adf��:�xm��nh�;֦I��(���o�C~ډa?�=��s����h��E������xp����)���_���t��W�����´;8���`dz=(��@@�+,�;�`�fhl��XȌ�3,uI�~z(J����� �ZX�A����H'�À�㜦�82|��a�n�z2��I���� ���EY�h�ε<�0�q�{��C��v�˅��?"@��χ�x�WS+��N�~�KQ�J�8ل�� _.W��� !TU{�����,��"�� �;�������HI S� ��))�o�1�H�D� ���� (� ;����"Ҕ��,���� �F=���O��&�Ph>�`���y��߲ &S��P�<��'��1s�1cĂ�N����2)����@�u��tv��<�+�-&�����h��[!FSG���' � z z0��<����8d&�����E0�,��<��"!P�b4��� �{S�����X����.�囤���T��hEF��X�q0"-<����h���]�Py*����F⩍��@v�˂�Y08�� .q��a��s����(!<̫1�3�L�H��7sYW�`��qtu�\7��?�@�Y�� %Ka�x�GZ�*W�P��y�����N0r9��Z�c�%���q,��k�����!!,��>���IB��� �x1�Xu�Y���v-���ֺ��N������JP��a�2`�e5��w��u;�6�i���̃��(K���ťa��(l51��JL��O'%���]���ٖ뿉!��{*�p+f ���i8��D�ȑ���ܩ�M��V��ӟz��x�7Z�1i}�^͜���6e����x��)u�d�ˏ�V�eG�\�X1�����=n�U'�~Y����L�\,�(d!x ,�:�TW8� M`r���@��r+v�Q0��>^;˴�VbF��('����� �*O��i��j�Ӆ����^�S3&� ���{������.ی�� N;��NU%d0�Ce\r"�C�b��&t7N�7��� �ȪD�[%l�۪�$��'m?�A9tI�9>��NVL ��� 6v~M�����ъ�B���0����9$&=ώm��W�0���L���&��E���f�f��'+�9��hv��7,���M��6�D�&�^� �����8 D֮�����o��k^z��O��hP�8q�5d*��YVq3�{��������#LX4�?��jP=3�~�؅c�ݰ�̱�ұ��8̲��2�G�����j��έ�9��w7���U�X�w�85C��?!I&���o&����L���I#�^�eV�,�^t5�k� �xs˛\��U�8��."���{���ǵ�l4��ݼ�;��r"���G�/~���gJV�N糦��ZZ^k+NN�D��I$�=OE�z����|*�*{��%k���G��>�`9��b;�s���8,�qs��c��.b��q�%�>r��n�R�Ƨ�%�,�A��le#�8���}; 21�0�b�&�QX�f���q�00����$>�h�N�'�a3��A���/�r ��L5�8�GԲ'�����w;��c#�q1���h$*��V^�k��QĽ�b:i������� ����H F#�_���,��]g����Ը����`RUU���� ��"�qD���>-��ϤI�~��3�̴�����NZ[[555�eeek7�m����YF#[��Đ��R��i��L�H�r ��@��J-�Pŝ��_|�-��6y��ks�V�U~��6���w.����(��0A� 4��f��� /���C�xŊ�ٳ����z=6�����rg���mKo��o�/����a�g���?'9%9��P��斓��~���L{�� �H��{AW��B��$����v�1b�&Mb�ر��ر#�0`�`xMBp! )Z�Nmo�mZ�g�}�eذaWTVV ���'99��C5��&�&+5�bT>|8��PUUETT����&���t��~TE%��'������b�tEGG;RSS�S�N�v��ѯ��t����u1@�ޚ"f��͈���r'L�Ph��m��ƌ�74o��`�x�q�P���NRSS�X,�����l&&&��MFFA!-��`��ҷ�n��Yuu�����x<I�LB%����KԒ50�!�3�bz�����ʸKL���;---�l6[��`��������Ȏ;�����egg4��!D�T��jWujyZ��������K����%����p�^���X,6��sV=�ܖ����6�3�X ���4ҿ��A2�&����_k�;d�� �VfOIEND�B`� 0x0x
PHP 8.1.34
Preview: reconcile-downgraded-posts.php Size: 6.24 KB
/home2/astrociv/public_html/wp-content/plugins/elementor/modules/global-classes/database/migrations/reconcile-downgraded-posts.php
<?php

namespace Elementor\Modules\GlobalClasses\Database\Migrations;

use Elementor\Core\Database\Base_Migration;
use Elementor\Core\Upgrade\Manager;
use Elementor\Modules\GlobalClasses\Concerns\Has_Kit_Dependency;
use Elementor\Modules\GlobalClasses\Global_Class_Post;
use Elementor\Modules\GlobalClasses\Global_Class_Post_Type;
use Elementor\Modules\GlobalClasses\Global_Classes_Labels;
use Elementor\Modules\GlobalClasses\Global_Classes_Order;
use Elementor\Modules\GlobalClasses\Utils\Global_Class_Data_Normalizer;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Reconciles global class posts for users who already ran the posts migration.
 *
 * Upgrade states:
 * - A: still on aggregate structure, handled by `Migrate_To_Posts` (which now sets an initial edit timestamp).
 * - B: upgraded, downgraded to the aggregated structure, then edited classes.
 * - C: upgraded and kept editing classes in posts.
 *
 * B and C already have DB version 2, so they skip `Migrate_To_Posts`.
 * This migration aligns aggregate kit meta with class posts, for group B
 */
class Reconcile_Downgraded_Posts extends Base_Migration {
	use Has_Kit_Dependency;

	private const QUERY_LIMIT = 10; // Just a safety measurement to make sure we have a big-enough sample size of new edits' versions

	private const POST_STORAGE_INTRO_VERSION = '4.1.0';

	private $should_overwrite = null;

	public function up() {
		Global_Class_Post_Type::ensure_registered();

		$kit = $this->get_kit();

		if ( ! $kit ) {
			return;
		}

		$aggregate = Migrate_To_Posts::get_aggregate_global_classes( $kit );

		if ( empty( $aggregate ) || empty( $aggregate['items'] ) ) {
			return;
		}

		$items = Global_Class_Data_Normalizer::normalize_styles( $aggregate['items'] );
		$order = $aggregate['order'] ?? array_keys( $items );

		$touched_any = $this->reconcile_posts( $items );

		if ( ! $touched_any ) {
			return;
		}

		$this->sync_order_and_labels( $kit, $items, $order );

		Migrate_To_Posts::run_document_tracking( $kit );
	}

	private function reconcile_posts( array $items ): bool {
		$post_map = $this->build_post_map( $items );

		if ( null === $post_map ) {
			return false;
		}

		if ( ! $this->should_overwrite_existing_posts() ) {
			return false;
		}

		return $this->apply_reconciliation( $items, $post_map );
	}

	/**
	 * @return array<string, Global_Class_Post|null>|null Null when a Group A post is detected (edit timestamp found).
	 */
	private function build_post_map( array $items ): ?array {
		$post_map = [];

		foreach ( $items as $class_id => $item ) {
			$post = Global_Class_Post::find_by_class_id( $class_id, false );

			if ( $post && $post->has_edit_timestamp() ) {
				$this->set_should_overwrite( false );

				return null;
			}

			$post_map[ $class_id ] = $post;
		}

		return $post_map;
	}

	private function apply_reconciliation( array $items, array $post_map ): bool {
		$touched_any = false;

		foreach ( $items as $class_id => $item ) {
			$post = $post_map[ $class_id ];
			$normalized_item = Global_Class_Data_Normalizer::normalize_style( $class_id, $item );

			if ( ! $post ) {
				$created = Global_Class_Post::create(
					$normalized_item['id'],
					$normalized_item['label'],
					$normalized_item
				);

				if ( $created ) {
					$touched_any = true;
				}

				continue;
			}

			$normalized_data = Global_Class_Data_Normalizer::normalize_style_fields( $normalized_item );
			$post->update_data( $normalized_data );
			$post->update_label( $normalized_item['label'] );
			$touched_any = true;
		}

		return $touched_any;
	}

	private function set_should_overwrite( bool $should_overwrite ): void {
		$this->should_overwrite = $should_overwrite;
	}

	private function should_overwrite_existing_posts(): bool {
		if ( null !== $this->should_overwrite ) {
			return $this->should_overwrite;
		}

		$history = Manager::get_installs_history();
		$intro_ts = $history[ self::POST_STORAGE_INTRO_VERSION ] ?? null;

		if ( ! $intro_ts ) {
			$this->set_should_overwrite( true );

			return true;
		}

		global $wpdb;

		$cutoff = gmdate( 'Y-m-d H:i:s', (int) $intro_ts );
		$cpt = Global_Class_Post_Type::CPT;

		$versions = $wpdb->get_col(
			$wpdb->prepare(
				"SELECT pm.meta_value
				FROM {$wpdb->postmeta} pm
				INNER JOIN {$wpdb->posts} p ON p.ID = pm.post_id
					AND p.post_type <> %s
				WHERE pm.meta_key = '_elementor_version'
					AND pm.meta_value <> %s
					AND p.post_modified_gmt > %s
				ORDER BY pm.meta_value ASC
				LIMIT %d",
				$cpt,
				self::POST_STORAGE_INTRO_VERSION,
				$cutoff,
				self::QUERY_LIMIT
			)
		);

		foreach ( $versions as $version ) {
			if ( ! is_string( $version ) || '' === $version ) {
				continue;
			}

			if ( version_compare( $version, self::POST_STORAGE_INTRO_VERSION, '<' ) ) {
				$this->should_overwrite = true;

				return true;
			}
		}

		$this->set_should_overwrite( false );

		return false;
	}

	private function sync_order_and_labels( $kit, array $items, array $order ): void {
		$aggregated_ids = array_keys( $items );
		$frontend_order = Global_Classes_Order::make( $kit )->set_preview( false );
		$merged_order = array_values( array_unique( array_merge( $order, array_diff( $frontend_order->get_order(), $aggregated_ids ) ) ) );

		$frontend_order->set_order( $merged_order );

		$frontend_labels = Global_Classes_Labels::make( $kit )->set_preview( false );
		$label_map = $frontend_labels->get_labels();
		$label_to_id = array_flip( $label_map );

		foreach ( $merged_order as $id ) {
			$class_post = Global_Class_Post::find_by_class_id( $id, false );

			if ( $class_post && $class_post->was_edited() ) {
				$candidate = $class_post->get_label();
			} elseif ( isset( $items[ $id ] ) ) {
				$candidate = $items[ $id ]['label'];
			} else {
				continue;
			}

			// Original style using the current style's label
			$owner_id = $label_to_id[ $candidate ] ?? null;

			if ( $owner_id === $id ) {
				continue;
			}

			if ( null !== $owner_id ) {
				// Duplicate label - generate a unique one
				$candidate = Global_Classes_Labels::generate_unique_label( $candidate, array_values( $label_map ) );
			}

			if ( $class_post && $class_post->get_label() !== $candidate ) {
				$class_post->update_label( $candidate );
			}

			unset( $label_to_id[ $label_map[ $id ] ?? '' ] );
			$label_map[ $id ] = $candidate;
			$label_to_id[ $candidate ] = $id;
		}

		$frontend_labels->set_labels( $label_map );
	}
}

Directory Contents

Dirs: 0 × Files: 4
Name Size Perms Modified Actions
894 B lrwxr-xr-x 2026-09-08 12:13:51
Edit Download
9.15 KB lrwxr-xr-x 2026-09-08 12:13:51
Edit Download
3.10 KB lrwxr-xr-x 2026-09-08 12:13:51
Edit Download
6.24 KB lrwxr-xr-x 2026-09-08 12:13:51
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 0xNothings — Secure File Manager. All rights reserved. Built with ❤️ & Tailwind x Dark UI