WPML
الحالة
محلولة بواسطة المطور
الإضافة/القالب ذو الصلة
WPRentals
وسوم الموضوع
Compatibility

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

في قالب WPRentals، عندما يبدّل المستخدمون اللغة في موقعهم، قد لا تُعرض الفواتير بشكل صحيح في جميع اللغات.

حل بديل مؤقت

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


  • افتح الملف …/wp-content/themes/wprentals/user_dashboard_invoices.php.

  • ابحث عن السطر 48.

  • استبدل:
    <?php
        $args = array(
            'post_type' => 'wpestate_invoice',
            'post_status'      => 'publish',
            'posts_per_page'   => -1 ,
            'author'           => $userID,
            'meta_query'       => array(
                    array(
                        'key'       => 'invoice_type',
                        'value'     =>  esc_html__( 'Reservation fee','wprentals'),
                        'type'      =>  'char',
                        'compare'   =>  'LIKE'
                        )
            ),
        );
    
    
    
        $prop_selection = new WP_Query($args);

  • بـ:
    <?php
        /*
        * >> WPML Workaround for compsupp-7254
        */
    
        // Original meta query
        $meta_query_value = esc_html__( 'Reservation fee','wprentals');
        $meta_query_compare = 'LIKE';
    
        // Modify meta_query if WPML is enabled
        if ( class_exists ('Sitepress') ) {
    
            $meta_query_value = [];
            $meta_query_value[] = esc_html__( 'Reservation fee','wprentals');
    
            $wpml_current_language = apply_filters( 'wpml_current_language', NULL );
            $wpml_languages = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' );
    
            if ( ! empty( $wpml_languages ) ) {
    
                foreach( $wpml_languages as $language ) {
                    // wpml_translate_single_string filter is not working because this string does not have a registered name
                    // Because of that, we will need to switch languages (then restore it later)
                    do_action( 'wpml_switch_language', $language['language_code'] );
                    $translated_string = esc_html__( 'Reservation fee','wprentals');
    
                    if ( ! in_array($translated_string, $meta_query_value) ) {
                        $meta_query_value[] = $translated_string;
                    }  
                }
    
                // Restore original language
                do_action( 'wpml_switch_language', $wpml_current_language );
            }
    
            $meta_query_compare = 'IN';
        }
    
        $args = array(
            'post_type'        => 'wpestate_invoice',
            'post_status'      => 'publish',
            'posts_per_page'   => -1 ,
            'author'           => $userID,
            'meta_query'       => array(
                array(
                    'key'       => 'invoice_type',
                    'value'     =>  $meta_query_value,
                    'type'      =>  'char',
                    'compare'   =>  $meta_query_compare,
                )
            ),
        );
        
        $prop_selection = new WP_Query($args);

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