Skip to content

Instantly share code, notes, and snippets.

@n7studios
Created December 13, 2017 09:37
Show Gist options
  • Save n7studios/8c0203809eb18fc9a2a3b121c2f4085c to your computer and use it in GitHub Desktop.
Save n7studios/8c0203809eb18fc9a2a3b121c2f4085c to your computer and use it in GitHub Desktop.
WordPress to Buffer Pro: Change value of {url}
<?php
/**
* Plugin Name: WP to Buffer Pro: Change URL
* Plugin URI: http://www.wpzinc.com/plugins/wp-to-buffer-pro
* Version: 1.0.0
* Author: WP Zinc
* Author URI: http://www.wpzinc.com
* Description: Changes the {url} from your Post's URL to something else. Change code in this Plugin as necessary to define the URL you want.
*/
/**
* Change the URL in the Status Message's Text, before it is sent to Buffer
*
* @since 1.0.0
*
* @param array $args Buffer Status Message Arguments
* @param WP_Post $post WordPress Post to share
* @param string $profile_id Buffer Profile ID
* @param string $service Social Media Service the Profile ID belongs to
* @param string $status Post Status (publish or update)
* @return array Buffer Status Message Arguments
*/
function wp_to_buffer_pro_change_url( $args, $post, $profile_id, $service, $status ) {
// Define the URL you want to use instead
$new_url = 'https://www.wpzinc.com';
// Stop editing
// You shouldn't need to modify anything from here
$args['text'] = str_replace( get_bloginfo( 'url' ), $new_url, $args['text'] );
return $args;
}
add_filter( 'wp_to_buffer_pro_publish_build_args', 'wp_to_buffer_pro_change_url', 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment