Function Reference: geodir_wpml_frontend_duplicate_listing

Summary

Display WPML languages option in sidebar to allow authors to duplicate their listing.

Global Values

$post
(WP_Post|null) (required) The current post.

Default: None
$preview
(bool) (required) True if the current page is add listing preview page. False if not.

Default: None
$sitepress
(object) (required) Sitepress WPML object.

Default: None

Parameters

$content_html
(string) (required) The output html of the geodir_edit_post_link() function.

Default: None

Return Values

(string)
  • Filtered html of the geodir_edit_post_link() function.

Change Log

Since: 1.6.18

Source File

geodir_wpml_frontend_duplicate_listing() is located in geodirectory-functions/custom_functions.php [Line: 3051]

Source Code

function geodir_wpml_frontend_duplicate_listing( $content_html ) {
	global $post, $preview, $sitepress;

	if ( !empty( $post->ID ) && !$preview && geodir_is_page( 'detail' ) && geodir_wpml_allowed_to_duplicate( $post->ID ) ) {
		$post_id = $post->ID;
		$element_type = 'post_' . get_post_type( $post_id );
		$original_post_id = $sitepress->get_original_element_id( $post_id, $element_type );

		if ( $original_post_id == $post_id ) {
			$wpml_languages = $sitepress->get_active_languages();
			$post_language = $sitepress->get_language_for_element( $post_id, $element_type );

			if ( !empty( $wpml_languages ) && isset( $wpml_languages[ $post_language ] ) ) {
				unset( $wpml_languages[ $post_language ] );
			}

			if ( !empty( $wpml_languages ) ) {
				$trid  = $sitepress->get_element_trid( $post_id, $element_type );
				$element_translations = $sitepress->get_element_translations( $trid, $element_type );
				$duplicates = $sitepress->get_duplicates( $post_id );

				$wpml_content = '

' . __( 'Translate Listing', 'geodirectory' ) . '

'; $wpml_content .= ''; $wpml_content .= ''; $needs_translation = false; foreach ( $wpml_languages as $lang_code => $lang ) { $duplicates_text = ''; $translated = false; if ( !empty( $element_translations ) && isset( $element_translations[$lang_code] ) ) { $translated = true; if ( !empty( $duplicates ) && isset( $duplicates[$lang_code] ) ) { $duplicates_text = ' ' . __( '(duplicate)', 'geodirectory' ); } } else { $needs_translation = true; } $wpml_content .= ''; } if ( $needs_translation ) { $nonce = wp_create_nonce( 'geodir_duplicate_nonce' ); $wpml_content .= ''; } $wpml_content .= '
' . __( 'Language', 'geodirectory' ) . '' . __( 'Translate', 'geodirectory' ) . '
' . $lang['english_name'] . $duplicates_text . ' '; if ( $translated ) { $wpml_content .= ''; } else { $wpml_content .= ''; } $wpml_content .= '
 
'; $wpml_content .= '
'; $content_html .= $wpml_content; } } } return $content_html; }