1

I'm using the QTranslateX plugin at its latest version, 3.4.6.8, in a fresh WordPress 4.7.1 installation. At the moment everything is working OK.

But I've seen that in JSON-oembed pages there's some content not being internationalized. Take a look at this example on my site. The title property on the JSON object returned by that shows [:es]Noticias[:en]News[:] (i.e. the title before QTranslateX applies i18n) instead of Noticias.

I've discovered this issue while trying to post a message in LinkedIn. When they try to get the title to display a better link along some introduction and a image, they internally fetch this page in order to figure out the title of the link.

Does anyone know if this can be fixed easily or do I need another plugin to get support for it? Thanks in advance!

0

I have the same problem. i've changed a bit, i'm no more a coder, the oembed.php file in the function get_oembed_response_data like this:

/**
 * Retrieves the oEmbed response data for a given post.
 *
 * @since 4.4.0
 *
 * @param WP_Post|int $post  Post object or ID.
 * @param int         $width The requested width.
 * @return array|false Response data on success, false if post doesn't exist.
 */
function get_oembed_response_data( $post, $width ) {
    $post  = get_post( $post );
    $width = absint( $width );


    $title = $post->post_title;
    $title = str_replace("[:it]","",$title);
    $title = str_replace("[:en]","",$title);
    $title = str_replace("[:]","",$title);


    if ( ! $post ) {
        return false;
    }

    if ( 'publish' !== get_post_status( $post ) ) {
        return false;
    }

    /**
     * Filters the allowed minimum and maximum widths for the oEmbed response.
     *
     * @since 4.4.0
     *
     * @param array $min_max_width {
     *     Minimum and maximum widths for the oEmbed response.
     *
     *     @type int $min Minimum width. Default 200.
     *     @type int $max Maximum width. Default 600.
     * }
     */
    $min_max_width = apply_filters( 'oembed_min_max_width', array(
        'min' => 200,
        'max' => 600
    ) );

    $width  = min( max( $min_max_width['min'], $width ), $min_max_width['max'] );
    $height = max( ceil( $width / 16 * 9 ), 200 );

    $data = array(
        'version'       => '1.0',
        'provider_name' => get_bloginfo( 'name' ),
        'provider_url'  => get_home_url(),
        'author_name'   => get_bloginfo( 'name' ),
        'author_url'    => get_home_url(),
        'title'         => $title,
        'type'          => 'link',
    );

    $author = get_userdata( $post->post_author );

    if ( $author ) {
        $data['author_name'] = $author->display_name;
        $data['author_url']  = get_author_posts_url( $author->ID );
    }

    /**
     * Filters the oEmbed response data.
     *
     * @since 4.4.0
     *
     * @param array   $data   The response data.
     * @param WP_Post $post   The post object.
     * @param int     $width  The requested width.
     * @param int     $height The calculated height.
     */
    return apply_filters( 'oembed_response_data', $data, $post, $width, $height );
}

Is not the solution but is just a workaround Fabio

  • Never modify a core file. – cybmeta Jul 11 '17 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.