publicize = $publicize;
add_action( 'init', array( $this, 'init' ) );
}
/**
* Initialize UI-related functionality.
*/
public function init() {
$this->publicize_settings_url = $this->publicize->publicize_connections_url();
// Show only to users with the capability required to manage their Publicize connections.
if ( ! $this->publicize->current_user_can_access_publicize_data() ) {
return;
}
// Assets (css, js).
if ( $this->in_jetpack ) {
add_action( 'load-settings_page_sharing', array( $this, 'load_assets' ) );
}
add_action( 'admin_head-post.php', array( $this, 'post_page_metabox_assets' ) );
add_action( 'admin_head-post-new.php', array( $this, 'post_page_metabox_assets' ) );
// Management of publicize (sharing screen, ajax/lightbox popup, and metabox on post screen).
add_action( 'pre_admin_screen_sharing', array( $this, 'admin_page' ) );
add_action( 'post_submitbox_misc_actions', array( $this, 'post_page_metabox' ) );
}
/**
* If the ShareDaddy plugin is not active we need to add the sharing settings page to the menu still
*/
public function sharing_menu() {
add_submenu_page(
'options-general.php',
esc_html__( 'Sharing Settings', 'jetpack' ),
esc_html__( 'Sharing', 'jetpack' ),
'publish_posts',
'sharing',
array( $this, 'wrapper_admin_page' )
);
}
/**
* Add admin page with wrapper.
*/
public function wrapper_admin_page() {
Jetpack_Admin_Page::wrap_ui( array( $this, 'management_page' ) );
}
/**
* Management page to load if Sharedaddy is not active so the 'pre_admin_screen_sharing' action exists.
*/
public function management_page() {
?>
WordPress.com sharing page to manage your publicize connections or use the button below.", 'jetpack' ),
array(
'a' => array(
'href' => array(),
'class' => array(),
'data-jptracks-name' => array(),
),
)
),
esc_url( $this->publicize->publicize_connections_url() )
);
?>
publicize->default_prefix;
$default_prefix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_prefix ) );
$default_message = $this->publicize->default_message;
$default_message = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_message ) );
$default_suffix = $this->publicize->default_suffix;
$default_suffix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_suffix ) );
$max_length = defined( 'JETPACK_PUBLICIZE_TWITTER_LENGTH' ) ? JETPACK_PUBLICIZE_TWITTER_LENGTH : 280;
$max_length = $max_length - 24; // t.co link, space.
?>
publicize->get_connections( 'linkedin' );
if ( is_array( $connections ) ) {
foreach ( $connections as $index => $connection ) {
if ( $this->publicize->is_invalid_linkedin_connection( $connection ) ) {
$must_reauth[ $index ] = 'LinkedIn';
}
}
}
return $must_reauth;
}
/**
* Controls the metabox that is displayed on the post page
* Allows the user to customize the message that will be sent out to the social network, as well as pick which
* networks to publish to. Also displays the character counter and some other information.
*/
public function post_page_metabox() {
global $post;
if ( ! $this->publicize->post_type_is_publicizeable( $post->post_type ) ) {
return;
}
$connections_data = $this->publicize->get_filtered_connection_data();
$available_services = $this->publicize->get_services( 'all' );
if ( ! is_array( $available_services ) ) {
$available_services = array();
}
if ( ! is_array( $connections_data ) ) {
$connections_data = array();
}
?>
get_metabox_form_connected( $connections_data );
$must_reauth = $this->get_must_reauth_connections();
if ( ! empty( $must_reauth ) ) {
foreach ( $must_reauth as $connection_name ) {
?>
%s',
esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) )
);
}
?>
get_metabox_form_disconnected( $available_services );
?>
publicize->post_is_done_sharing();
$all_connections_done = true;
ob_start();
?>