Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Set Jetpack Publicize Default Message
*
* @package SetJetpackPublicizeDefaultMessage
* @author Bernhard Kau
* @license GPLv3
*
* @wordpress-plugin
* Plugin Name: Set Jetpack Publicize Default Message
* Plugin URI: https://kau-boys.com
* Description: Sets the default sharing message
* Version: 0.1
* Author: Bernhard Kau
* Author URI: https://kau-boys.com
* Text Domain: set-jetpack-publicize-default-message
*/
/**
* Save a post metadata for a default sharing title if none is set.
*/
function set_jetpack_publicize_default_message() {
global $post;
if ( ! empty( $post->ID ) ) {
if ( ! $wpas_title = get_post_meta( $post->ID, '_wpas_mess', true ) ) {
/* translators: %s: the name of the blog */
$custom_message = sprintf(
__( 'Check out this new awesome blog post on %s!', 'set-jetpack-publicize-default-message' ),
get_bloginfo( 'name' )
);
update_post_meta( $post->ID, '_wpas_mess', $custom_message );
}
}
}
add_action( 'post_submitbox_misc_actions', 'set_jetpack_publicize_default_message' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.