The code you used should work.
BTW to me, as the code is not working, the best approach would be to unset the og:url
from Jetpack and do it on your own? I’m taking your code and adding mine and editing where necessary:
<?php
/**
* Change HTTPS to HTTP
* @param string $url Default URL.
* @return string Modified URL.
* -----------------------------------
*/
function https_to_http_url( $url ) {
$url = str_replace('https://', 'http://', $url );
return $url;
}
/**
* Altering Jetpack OG URL
* We're going to strip out the og:url produced by Jetpack.
* @param array $tags Array of Open graph tags.
* @return array Modified array of Open graph tags.
* -----------------------------------
*/
function jetpack_removing_og_url( $tags ) {
//unset completely, we'll produce our own
unset( $tags['og:url'] );
return $tags;
}
add_filter( 'jetpack_open_graph_tags', 'jetpack_removing_og_url' );
/**
* Add custom og:url
* Adding our custom Open Graph URL meta tag on our own.
* -----------------------------------
*/
function wpse233574_custom_og_url() {
//Jetpack-way to retrieve the URL
if ( is_home() || is_front_page() ) {
$front_page_id = get_option( 'page_for_posts' );
if ( 'page' == get_option( 'show_on_front' ) && $front_page_id && is_home() )
$url = get_permalink( $front_page_id );
else
$url = home_url( "https://wordpress.stackexchange.com/" );
} else if ( is_author() ) {
$author = get_queried_object();
if ( ! empty( $author->user_url ) ) {
$url = $author->user_url;
} else {
$url = get_author_posts_url( $author->ID );
}
} else if ( is_singular() ) {
global $post;
$url = get_permalink( $post->ID );
}
//Modifying the URL for our custom purpose
$modified_url = https_to_http_url( $url );
//Finally print the meta tag
echo '<meta property="og:url" content="'. esc_url($modified_url) .'" />';
}
add_action( 'wp_head', 'wpse233574_custom_og_url' );