WPML
الحالة
محلولة بواسطة المطور
تم حلها في
Bricks 2.0
الإضافة/القالب ذو الصلة
Bricks
وسوم الموضوع
Compatibility

نظرة عامة على المشكلة

في قالب Bricks، عندما يُضبط شرط النموذج للعرض فقط لمصطلحات محددة (مثل تصنيف معين)، لا يُطبّق الشرط بشكل صحيح في النماذج المترجمة.

حل بديل مؤقت

يُرجى التأكد من أخذ نسخة احتياطية كاملة لموقعك قبل المتابعة.

الجزء الأول


  • اذهب إلى WPML > إعدادات > حقول مخصصة.

  • ابحث عن الحقل _bricks_template_settings.

  • اضبطه على «نسخ»

الجزء الثاني


  • افتح ملف functions.php الخاص بقالبك.

  • أضف الكود التالي:
    /**
     * WPML Workaround for compsupp-7667
     */
    add_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10, 4);
    function wpml_compsupp7667_bricks_translate_template_conditions($value, $post_id, $key, $single) {
        if ($key !== '_bricks_template_settings') {
            return $value;
        }
    
        // Remove filter temporarily to avoid infinite loop
        remove_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10);
        
        // Get all meta values
        $raw_values = get_post_meta($post_id, $key, false);
        
        // Add filter back
        add_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10, 4);
    
        // If we have no values, return the original
        if (empty($raw_values)) {
            return $value;
        }
    
        // Process the array structure
        foreach ($raw_values as &$settings) {
            if (is_array($settings) && isset($settings['templateConditions'])) {
                foreach ($settings['templateConditions'] as &$condition) {
                    if (!empty($condition['archiveTerms']) && is_array($condition['archiveTerms'])) {
                        foreach ($condition['archiveTerms'] as &$termString) {
                            if (strpos($termString, '::') !== false) {
                                list($taxonomy, $termId) = explode('::', $termString);
                                $translatedId = apply_filters('wpml_object_id', intval($termId), $taxonomy, true);
                                if ($translatedId) {
                                    $termString = $taxonomy . '::' . $translatedId;
                                }
                            }
                        }
                    }
                }
            }
        }
    
        return $raw_values;
    }

جميع المشاكل المعروفة →