Server IP : 85.214.239.14 / Your IP : 3.145.43.200 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/wordpress/wp-content/themes/Divi/includes/builder/frontend-builder/theme-builder/ |
Upload File : |
<?php /** * Disable language filtering of terms in TB. * * @since 4.2 * * @param string $parent_id * @param string $child_type * @param string $child_value */ function et_theme_builder_wpml_disable_term_filters( $parent_id, $child_type, $child_value ) { global $sitepress; if ( ! $sitepress || 'taxonomy' !== $child_type ) { return; } remove_filter( 'terms_clauses', array( $sitepress, 'terms_clauses' ), 10 ); remove_filter( 'get_terms_args', array( $sitepress, 'get_terms_args_filter' ), 10 ); remove_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1 ); } add_action( 'et_theme_builder_before_get_template_setting_child_options', 'et_theme_builder_wpml_disable_term_filters', 10, 3 ); /** * Enable language filtering of terms in TB. * * @since 4.2 * * @param string $parent_id * @param string $child_type * @param string $child_value */ function et_theme_builder_wpml_enable_term_filters( $parent_id, $child_type, $child_value ) { global $sitepress; if ( ! $sitepress || 'taxonomy' !== $child_type ) { return; } add_filter( 'terms_clauses', array( $sitepress, 'terms_clauses' ), 10, 3 ); add_filter( 'get_terms_args', array( $sitepress, 'get_terms_args_filter' ), 10, 2 ); add_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1, 1 ); } add_action( 'et_theme_builder_after_get_template_setting_child_options', 'et_theme_builder_wpml_enable_term_filters', 10, 3 ); /** * Normalize an object ID to it's base language ID if it is a translation. * * @since 4.2 * * @param integer $id WPML object ID. * @param string $type Type. * @param string $subtype Subtype. * * @return integer */ function et_theme_builder_wpml_normalize_object_id( $id, $type, $subtype ) { return apply_filters( 'wpml_object_id', $id, $subtype, true ); } add_filter( 'et_theme_builder_template_setting_filter_validation_id', 'et_theme_builder_wpml_normalize_object_id', 10, 3 ); /** * Prioritize IDs for the current active language over translated IDs * when comparing template settings priority. * * @since 4.2 * * @param string $prioritized_setting Prioritized setting. * @param string $a First translated id. * @param string $b Second translated id. * @param ET_Theme_Builder_Request $request * * @return string */ function et_theme_builder_wpml_prioritize_translated_id( $prioritized_setting, $a, $b, $request ) { $a_id = ''; $a_id_translated = ''; $b_id = ''; $b_id_translated = ''; $a_matches = array(); $b_matches = array(); // Match singular:post_type:<post_type>:id:<id> $singular = '/^singular:post_type:([^:]+):id:(\d+)$/i'; // Match singular:post_type:<post_type>:children:id:<id> $singular_children = '/^singular:post_type:([^:]+):children:id:(\d+)$/i'; // Match singular:taxonomy:<taxonomy>:term:id:<id> $singular_term = '/^singular:taxonomy:([^:]+):term:id:(\d+)$/i'; // Match archive:taxonomy:<taxonomy>:term:id:<id> $archive_term = '/^archive:taxonomy:([^:]+):term:id:(\d+)$/i'; if ( preg_match( $singular, $a, $a_matches ) && preg_match( $singular, $b, $b_matches ) ) { $a_id = (int) $a_matches[2]; $a_id_translated = et_theme_builder_wpml_normalize_object_id( $a_id, 'post', $a_matches[1] ); $b_id = (int) $b_matches[2]; $b_id_translated = et_theme_builder_wpml_normalize_object_id( $b_id, 'post', $b_matches[1] ); } elseif ( preg_match( $singular_children, $a, $a_matches ) && preg_match( $singular_children, $b, $b_matches ) ) { $a_id = (int) $a_matches[2]; $a_id_translated = et_theme_builder_wpml_normalize_object_id( $a_id, 'post', $a_matches[1] ); $b_id = (int) $b_matches[2]; $b_id_translated = et_theme_builder_wpml_normalize_object_id( $b_id, 'post', $b_matches[1] ); } elseif ( preg_match( $singular_term, $a, $a_matches ) && preg_match( $singular_term, $b, $b_matches ) ) { $a_id = (int) $a_matches[2]; $a_id_translated = et_theme_builder_wpml_normalize_object_id( $a_id, 'taxonomy', $a_matches[1] ); $b_id = (int) $b_matches[2]; $b_id_translated = et_theme_builder_wpml_normalize_object_id( $b_id, 'taxonomy', $b_matches[1] ); } elseif ( preg_match( $archive_term, $a, $a_matches ) && preg_match( $archive_term, $b, $b_matches ) ) { $a_id = (int) $a_matches[2]; $a_id_translated = et_theme_builder_wpml_normalize_object_id( $a_id, 'taxonomy', $a_matches[1] ); $b_id = (int) $b_matches[2]; $b_id_translated = et_theme_builder_wpml_normalize_object_id( $b_id, 'taxonomy', $b_matches[1] ); } if ( $a_id && $a_id_translated && $a_id_translated === $a_id ) { // $a is an exact match for the current request and not a translated match so we prioritize it. return $a; } if ( $b_id && $b_id_translated && $b_id_translated === $b_id ) { // $b is an exact match for the current request and not a translated match so we prioritize it. return $b; } // Neither $a nor $b are exact matches so don't prioritize either. return $prioritized_setting; } add_filter( 'et_theme_builder_prioritized_template_setting', 'et_theme_builder_wpml_prioritize_translated_id', 10, 6 );