apply_filters( 'wpml_element_link', int $element_id, string $element_type, string $link_text, array $optional_parameters, string $anchor, bool $echo, bool $return_original_if_missing )
- النوع
- filter
- الفئة
- استرداد المحتوى المحلي
- إصدار WPML
- 3.2
الوصف
يُرجع رابط نوع المقالة أو رابط مصطلح التصنيف باللغة الحالية.
* ملاحظة: توجد طرق بديلة للحصول على رابط العنصر تمنح المطورين تحكماً أكبر في مخرجات HTML.
يقدّم WordPress عدداً من الدوال للقيام بذلك مثل get_permalink()، وget_term_link()، إلخ.
إذا كنت تخطط لاستخدام دوال تتطلب نوع المقالة أو معرّف المصطلح كمعلمة، فقد ترغب في الاطلاع على المرشِّح wpml_object_id.
الوسطاء
- $element_id
- (int) (مطلوب) معرف نوع المنشور (post، page، attachment، custom post) أو مصطلح التصنيف (tag، category، custom taxonomy) المراد الارتباط به
- $element_type
- (string) (اختياري) نوع العنصر المراد الارتباط به. يمكن أن يكون ‘post’، ‘page’، ‘attachment’، '{custom post}'، ‘tag’، ‘category’، '{custom taxonomy}'. القيمة الافتراضية هي ‘post’
- $link_text
- (string) (اختياري) نص الرابط. القيمة الافتراضية هي اسم العنصر
- $optional_parameters
- (array) (اختياري) وسائط الرابط
- $anchor
- (string) (اختياري) نقطة الارتساء للرابط
- $echo
- (bool) (اختياري) 0|false للإرجاع أو 1|true لطباعة الرابط المترجم. القيمة الافتراضية هي true
- $return_original_if_missing
- (bool) (اختياري) إذا تم تعيينه إلى true، فسيرجع دائماً قيمة (القيمة الأصلية، إذا كانت الترجمة مفقودة). القيمة الافتراضية هي TRUE
مثال على الاستخدام
أمثلة
//produces: <a href="/hello-world/">Hello World!</a> apply_filters( 'wpml_element_link', 1 ); //produces: <a href="/sample-page/">Custom link text for the sample page</a> apply_filters( 'wpml_element_link', 2, 'page', __( 'Custom link text for the sample page' ) ); //produces: <a href="/sample-page/?category=foo&bar=baz">Sample Page</a> apply_filters( 'wpml_element_link', 2, 'page', '', array( 'category'=>'foo', 'bar'=>'baz' ) ); //produces: <a href="/sample-page/#contact">Sample Page</a> apply_filters( 'wpml_element_link', 2, 'page', '', '', 'contact' ); //produces: <a href="/category/uncategorized/">Uncategorized</a> apply_filters( 'wpml_element_link', 1, 'category' ); //produces: <a href="/ar/?attachment_id=25">'Attachment image title</a> apply_filters( 'wpml_element_link', 25, 'attachment', __( 'Attachment image title' ) );
خطاطيف ذات صلة
wpml_media_url, wpml_media_id, force_suppress_filters, wpml_get_translated_slug, wpml_home_url, wpml_translate_single_string, wpml_translate_string, wpml_elements_without_translations, wpml_permalink, wpml_unfiltered_admin_string