�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`�
Warning: session_start(): Session cannot be started after headers have already been sent in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 124

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 130

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 131

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 132

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 133

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 134

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 135
0x0x
PHP 8.2.31
Preview: Dispatcher.php Size: 14.84 KB
/home/mciraet/www/wp-content/plugins/polylang-pro/src/integrations/ACF/Dispatcher.php
<?php
/**
 * @package Polylang-Pro
 */

namespace WP_Syntex\Polylang_Pro\Integrations\ACF;

use WP_Post;
use WP_Term;
use Translations;
use PLL_Language;
use PLL_Export_Data;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Entity\Post;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Entity\Term;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Entity\Media;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Entity\Blocks;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Strategy\Copy;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Location_Language;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Strategy\Synchronize;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Strategy\Collect_Post_Ids;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Strategy\Collect_Term_Ids;
use WP_Syntex\Polylang_Pro\Integrations\ACF\Entity\Abstract_Object;

/**
 * This class is part of the ACF compatibility.
 * Holds all hooks registrations regarding field translations logic.
 * Controls and applies strategies to ACF fields regarding
 * object types and context (e.g. export, import, update, new translation creation, blocks...).
 *
 * @since 3.7
 */
class Dispatcher {
	/**
	 * Setup filters.
	 *
	 * @since 3.7
	 *
	 * @return void
	 */
	public static function on_acf_init() {
		/*
		 * Removes ACF fields from synchronized metas by Polylang, this way ACF integration manage itself the synchronization.
		 * Applied after `PLL_Sync_Post_Model::copy_post_metas/copy_taxonomies` for it to be effective.
		 */
		add_filter( 'pll_copy_post_metas', array( Post::class, 'remove_acf_metas_from_pll_sync' ), 10, 4 );
		add_filter( 'pll_copy_term_metas', array( Term::class, 'remove_acf_metas_from_pll_sync' ), 10, 4 );

		add_action( 'pll_post_synchronized', array( static::class, 'on_post_synchronized' ), 10, 4 );

		add_action( 'pll_duplicate_term', array( static::class, 'on_duplicate_term' ), 10, 3 );

		add_filter( 'acf/update_value', array( static::class, 'update' ), 5, 3 );
		add_filter( 'acf/pre_render_field', array( static::class, 'translate_rendered_field' ), 10, 2 );

		add_action( 'pll_after_post_translation', array( static::class, 'translate' ), 10, 4 );
		add_action( 'pll_after_term_translation', array( static::class, 'translate' ), 10, 4 );
		add_action( 'pll_after_post_export', array( static::class, 'export' ), 10, 3 );
		add_action( 'pll_after_term_export', array( static::class, 'export' ), 10, 3 );

		add_filter( 'pll_collect_post_ids', array( static::class, 'collect_post_ids' ), 10, 2 );
		add_filter( 'pll_collect_term_ids', array( static::class, 'collect_term_ids' ), 10, 2 );

		if ( PLL()->options['media_support'] ) {
			add_action( 'pll_translate_media', array( static::class, 'copy_media_fields' ), 10, 3 );
		}

		add_action( 'admin_enqueue_scripts', array( Post::class, 'admin_enqueue_scripts' ) );
		add_action( 'admin_enqueue_scripts', array( Term::class, 'admin_enqueue_scripts' ) );
		add_action( 'wp_ajax_acf_post_lang_choice', array( Post::class, 'on_ajax_post_lang_choice' ) );
		add_action( 'wp_ajax_acf_term_lang_choice', array( Term::class, 'on_ajax_term_lang_choice' ) );
		add_filter( 'acf/fields/relationship/query', array( static::class, 'add_language_to_query' ), 10, 3 );
		add_filter( 'acf/fields/post_object/query', array( static::class, 'add_language_to_query' ), 10, 3 );
	}

	/**
	 * Initializes ACF blocks integration when blocks are registered.
	 *
	 * @since 3.7
	 *
	 * @return void
	 */
	public static function on_blocks_registered(): void {
		if ( ! function_exists( 'acf_get_block_types' ) || empty( acf_get_block_types() ) ) {
			return;
		}

		add_filter( 'pll_collect_post_ids', array( static::class, 'collect_post_ids_in_blocks' ), 10, 2 );
		add_filter( 'pll_collect_term_ids', array( static::class, 'collect_term_ids_in_blocks' ), 10, 2 );
		add_filter( 'pll_translate_blocks_with_context', array( static::class, 'copy_blocks' ), 10, 3 );
		add_filter( 'pll_filter_translated_post', array( static::class, 'translate_blocks' ), 10, 4 );
		add_action( 'pll_after_post_export', array( static::class, 'export_blocks' ), 10, 2 );
	}

	/**
	 * Filters the field about to be rendered.
	 *
	 * @since 3.7
	 *
	 * @param array      $field  Custom field definition.
	 * @param int|string $acf_id ACF post ID.
	 * @return mixed Modified custom field.
	 */
	public static function translate_rendered_field( $field, $acf_id ) {
		$object = static::get_by_acf_id( $acf_id );
		return empty( $object ) ? $field : $object->translate_rendered_field( $field );
	}

	/**
	 * Filters the custom field value when updated.
	 *
	 * @since 3.7
	 *
	 * @param mixed      $value  Custom field value.
	 * @param int|string $acf_id ACF post ID.
	 * @param array      $field  Custom field definition.
	 * @return mixed Modified custom field value.
	 */
	public static function update( $value, $acf_id, $field ) {
		$object = static::get_by_acf_id( $acf_id );
		return empty( $object ) ? $value : $object->update( $value, $field );
	}

	/**
	 * Copies or synchronizes ACF custom fields when using Polylang's copy post function (and not the post-new.php where ACF filters are applied).
	 * (e.g. using bulk translate, creating a synchronized post).
	 *
	 * @since 3.7
	 *
	 * @param int    $post_id    ID of the source post.
	 * @param int    $tr_post_id ID of the target post.
	 * @param string $lang       Language of the target post.
	 * @param string $sync      `sync` if doing synchro, `copy` otherwise.
	 * @return void
	 *
	 * @phpstan-param 'sync'|'copy' $sync
	 */
	public static function on_post_synchronized( $post_id, $tr_post_id, $lang, $sync ) {
		( new Post( $post_id ) )->on_post_synchronized( $tr_post_id, $lang, $sync );
	}

	/**
	 * Export custom fields to translate.
	 *
	 * @since 3.7
	 *
	 * @param PLL_Export_Data $export The export object.
	 * @param object          $from   The object to export.
	 * @param object|null     $to     The translated object if it exists, `null` otherwise.
	 * @return void
	 */
	public static function export( $export, $from, $to ) {
		$object = self::get_by_object( $from );
		if ( ! empty( $object ) && $export instanceof PLL_Export_Data ) {
			$object->export( $export, $to );
		}
	}

	/**
	 * Collects post IDs from fields.
	 *
	 * @since 3.7
	 *
	 * @param int[]   $linked_ids Object IDs linked to a post.
	 * @param WP_Post $post       The post we get other post from.
	 * @return int[]
	 */
	public static function collect_post_ids( $linked_ids, $post ) {
		$object = self::get_by_object( $post );

		if ( ! empty( $object ) ) {
			return array_merge( (array) $linked_ids, ( new Collect_Post_Ids() )->get( $object ) );
		}

		return $linked_ids;
	}

	/**
	 * Collects post IDs from fields in ACF blocks.
	 *
	 * @since 3.7
	 *
	 * @param int[]   $linked_ids Object IDs linked to a post.
	 * @param WP_Post $post       The post we get other post from.
	 * @return int[]
	 */
	public static function collect_post_ids_in_blocks( $linked_ids, $post ) {
		if ( has_blocks( $post ) ) {
			$linked_ids = array_merge( (array) $linked_ids, ( new Collect_Post_Ids() )->get( new Blocks( $post->ID ) ) );
		}

		return $linked_ids;
	}

	/**
	 * Collects term IDs from fields.
	 *
	 * @since 3.7
	 *
	 * @param int[]   $linked_ids Object IDs linked to a post.
	 * @param WP_Post $post       The post we get other term from.
	 * @return int[]
	 */
	public static function collect_term_ids( $linked_ids, $post ) {
		$object = self::get_by_object( $post );

		if ( ! empty( $object ) ) {
			return array_merge( (array) $linked_ids, ( new Collect_Term_Ids() )->get( $object ) );
		}

		return $linked_ids;
	}


	/**
	 * Collects term IDs from fields in ACF blocks.
	 *
	 * @since 3.7
	 *
	 * @param int[]   $linked_ids Object IDs linked to a post.
	 * @param WP_Post $post       The post we get other term from.
	 * @return int[]
	 */
	public static function collect_term_ids_in_blocks( $linked_ids, $post ) {
		if ( has_blocks( $post ) ) {
			$linked_ids = array_merge( (array) $linked_ids, ( new Collect_Term_Ids() )->get( new Blocks( $post->ID ) ) );
		}

		return $linked_ids;
	}

	/**
	 * Translates the custom fields from a given object.
	 *
	 * @since 3.7
	 *
	 * @param object       $from         Source object to get the custom fields from.
	 * @param object       $to           Translated object to translate the custom fields from.
	 * @param PLL_Language $target_lang  Target language object.
	 * @param Translations $translations A set of translations to search the custom fields translations in.
	 * @return void
	 */
	public static function translate( $from, $to, $target_lang, $translations ) {
		/*
		 * Remove filter for `Dispatcher::translate_rendered_field` to avoid running `Strategy\Copy` on the same object.
		 * For instance, when translating fields with DeepL, we don't want to override the translated values with the original ones with `Strategy\Copy`.
		 */
		remove_filter( 'acf/pre_render_field', array( self::class, 'translate_rendered_field' ) );

		$object = self::get_by_object( $from );
		if ( ! empty( $object ) && $target_lang instanceof PLL_Language && $translations instanceof Translations ) {
			$object->translate( $to, $target_lang, $translations );
		}
	}


	/**
	 * Adds the language of the current object to the arguments that will be used for the query
	 * in the `relationship` and `post_object` ACF fields.
	 *
	 * @since 3.7
	 *
	 * @param array      $args   Arguments to retrieve posts.
	 * @param array      $field  The current field.
	 * @param int|string $acf_id ACF post ID.
	 * @return array The arguments to retrieve posts with the current object language.
	 */
	public static function add_language_to_query( $args, $field, $acf_id ) {
		/**
		 * Gets the language sent with AJAX to reload fields in the right language.
		 * For the term creation page, since there is no current language.
		 * And for the term edit page when switching languages, since the language is not saved on switch.
		 * See `addFilter` on `relationship_ajax_data` and `select2_ajax_data` in `term.js` for the language dispatch.
		 */
		$language = isset( $_POST['lang'] ) ? PLL()->model->languages->get( sanitize_key( $_POST['lang'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing
		if ( isset( $language ) && $language instanceof PLL_Language ) {
			$args['lang'] = $language->slug;
			return $args;
		}

		// Otherwise it's a term editing page (displayed without language switch) or a post editing/creation page.
		$object = static::get_by_acf_id( $acf_id );
		return empty( $object ) ? $args : $object->add_language_to_query( $args );
	}

	/**
	 * Translates the media fields.
	 *
	 * @since 3.7
	 *
	 * @param int          $from_id         The source media ID.
	 * @param int          $to_id           The target media ID.
	 * @param PLL_Language $target_language The target language.
	 * @return void
	 */
	public static function copy_media_fields( $from_id, $to_id, $target_language ) {
		( new Media( $from_id ) )->copy_fields( $to_id, $target_language );
	}

	/**
	 * Saves ACF fields for a term that was automatically duplicated when a post has been duplicated.
	 *
	 * @since 3.7
	 *
	 * @param int    $from Term ID of the source term.
	 * @param int    $to   Term ID of the new term translation.
	 * @param string $lang Language code of the new translation.
	 * @return void
	 */
	public static function on_duplicate_term( $from, $to, $lang ) {
		$lang = PLL()->model->get_language( $lang );
		if ( $lang instanceof PLL_Language ) {
			( new Term( $from ) )->apply_to_all_fields(
				new Copy(),
				$to,
				array( 'target_language' => $lang )
			);
		}
	}

	/**
	 * Copies the field values in blocks.
	 *
	 * @since 3.7
	 *
	 * @param array        $blocks      The blocks.
	 * @param PLL_Language $target_lang The target language.
	 * @param WP_Post|null $source_post The source post, `null` if not available.
	 * @return array The blocks.
	 */
	public static function copy_blocks( $blocks, $target_lang, $source_post ) {
		if ( ! is_array( $blocks ) || ! $target_lang instanceof PLL_Language || ! $source_post instanceof WP_Post ) {
			return $blocks;
		}
		return ( new Blocks() )->copy( $blocks, $target_lang, $source_post );
	}

	/**
	 * Translates fields in blocks during import.
	 *
	 * @since 3.7
	 *
	 * @param WP_Post      $to              Translated post where to translate the custom fields included in blocks.
	 * @param WP_Post      $from            Source post where to get the custom fields included in blocks.
	 * @param PLL_Language $target_lang     The target language.
	 * @param Translations $translations    A set of translations where to search translations of the custom fields translations included in blocks.
	 * @return WP_Post The translated post.
	 */
	public static function translate_blocks( $to, $from, $target_lang, $translations ) {
		if ( ! $to instanceof WP_Post ) {
			return $to;
		}

		return ( new Blocks( $from->ID ) )->translate( $to, $target_lang, $translations );
	}

	/**
	 * Adds ACF fields in blocks to the exported data.
	 *
	 * @since 3.7
	 *
	 * @param PLL_Export_Data $export The export data.
	 * @param WP_Post         $from   The source post.
	 * @return void
	 */
	public static function export_blocks( $export, $from ) {
		( new Blocks( $from->ID ) )->export( $export );
	}

	/**
	 * Builds an Abstract_Object based on the object type, typically post or term.
	 *
	 * @since 3.7
	 *
	 * @param int|string $acf_id ACF post ID.
	 * @return Abstract_Object|null.
	 */
	protected static function get_by_acf_id( $acf_id ): ?Abstract_Object {
		$decoded = acf_decode_post_id( $acf_id );
		$id      = (int) $decoded['id'];

		switch ( $decoded['type'] ) {
			case 'post':
				if ( PLL()->options['media_support'] && 'attachment' === get_post_type( $id ) ) {
					return new Media( $id );
				}
				if ( pll_is_translated_post_type( (string) get_post_type( $id ) ) ) {
					return new Post( $id );
				}
				break;
			case 'term':
				$term = get_term( $id );
				if ( $term instanceof WP_Term && pll_is_translated_taxonomy( $term->taxonomy ) ) {
					return new Term( $id );
				}

				// No nonce to check.
				if ( 0 === $id && ! empty( $_GET['new_lang'] ) && ! empty( $_GET['taxonomy'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
					&& pll_is_translated_taxonomy( sanitize_key( $_GET['taxonomy'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
					// This is a term creation with `term_0`, see `acf_form_taxonomy::add_term()`.
					return new Term( $id );
				}
				break;
		}

		return null;
	}

	/**
	 * Builds an Abstract_Object based on the WP object, typically `WP_Post` or `WP_Term`.
	 *
	 * @since 3.7
	 *
	 * @param object $object The object.
	 * @return Abstract_Object|null.
	 */
	protected static function get_by_object( $object ): ?Abstract_Object {
		if ( $object instanceof WP_Post ) {
			if ( 'attachment' === $object->post_type && PLL()->options['media_support'] ) {
				return new Media( $object->ID );
			}
			if ( pll_is_translated_post_type( $object->post_type ) ) {
				return new Post( (int) $object->ID );
			}
		}
		if ( $object instanceof WP_Term && pll_is_translated_taxonomy( $object->taxonomy ) ) {
			return new Term( $object->term_id );
		}

		return null;
	}
}

Directory Contents

Dirs: 5 × Files: 8
Name Size Perms Modified Actions
Entity DIR
- drwxr-xr-x 2026-08-16 07:30:00
Edit Download
Fields DIR
- drwxr-xr-x 2026-08-16 07:30:00
Edit Download
js DIR
- drwxr-xr-x 2026-08-16 07:30:00
Edit Download
Labels DIR
- drwxr-xr-x 2026-08-16 07:30:00
Edit Download
Strategy DIR
- drwxr-xr-x 2026-08-16 07:30:00
Edit Download
489 B lrw-r--r-- 2026-06-02 09:29:17
Edit Download
14.84 KB lrw-r--r-- 2026-06-02 09:29:17
Edit Download
3.54 KB lrw-r--r-- 2026-06-02 09:29:17
Edit Download
735 B lrw-r--r-- 2026-06-02 09:29:17
Edit Download
2.97 KB lrw-r--r-- 2026-06-02 09:29:17
Edit Download
3.24 KB lrw-r--r-- 2026-06-02 09:29:17
Edit Download
2.15 KB lrw-r--r-- 2026-06-02 09:29:17
Edit Download
5.67 KB lrw-r--r-- 2026-06-02 09:29:17
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