publicize = $publicize;
add_action( 'admin_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).
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( '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
*
* @deprecated 0.42.3
*/
public function sharing_menu() {
add_submenu_page(
'options-general.php',
esc_html__( 'Sharing Settings', 'jetpack-publicize-pkg' ),
esc_html__( 'Sharing', 'jetpack-publicize-pkg' ),
'publish_posts',
'sharing',
array( $this, 'wrapper_admin_page' )
);
}
/**
* Add admin page with wrapper.
*
* @deprecated 0.42.3
*/
public function wrapper_admin_page() {
if ( class_exists( 'Jetpack_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.
*
* @deprecated 0.42.3
*/
public function management_page() {
?>
WordPress.com sharing page to manage your Jetpack Social connections or use the button below.", 'jetpack-publicize-pkg' ),
array(
'a' => array(
'href' => array(),
'class' => array(),
'data-jptracks-name' => array(),
),
)
),
esc_url( $this->publicize->publicize_connections_url() )
);
?>
is_block_editor ) {
return;
}
$is_atomic_site = ( new Host() )->is_woa_site();
$is_simple_site = ( new Host() )->is_wpcom_simple();
$site_type = $is_atomic_site ? 'atomic' : ( $is_simple_site ? 'simple' : 'jetpack' );
Assets::register_script(
'jetpack-social-classic-editor-options',
'../build/classic-editor-connections.js',
__FILE__,
array(
'in_footer' => true,
'enqueue' => true,
'textdomain' => 'jetpack-publicize-pkg',
)
);
$is_simple_site = ( new Host() )->is_wpcom_simple();
wp_add_inline_script(
'jetpack-social-classic-editor-options',
'var jetpackSocialClassicEditorOptions = ' . wp_json_encode(
array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'connectionsUrl' => esc_url( $this->publicize_settings_url ),
'isEnhancedPublishingEnabled' => $this->publicize->has_enhanced_publishing_feature(),
'resharePath' => '/jetpack/v4/publicize/{postId}',
'isReshareSupported' => ! $is_simple_site && Current_Plan::supports( 'republicize' ),
'siteType' => $site_type,
)
),
'before'
);
$default_prefix = $this->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;
$broken_connections = array();
ob_start();
?>
connection management page.',
'Some of your social connections are broken. Reconnect them on the
connection management page.',
count( $broken_connections ),
'jetpack-publicize-pkg'
),
array(
'a' => array(
'href' => array(),
'target' => array(),
'rel' => array(),
),
)
),
esc_url( $this->publicize->publicize_connections_url() )
);
?>