| @@ -101,12 +101,30 @@ | ||
| 101 | 101 | Jetpack::enable_module_configurable( __FILE__ ); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | add_filter( 'jetpack_module_configuration_url_likes', array( $this, 'jetpack_likes_configuration_url' ) ); |
| 105 | + add_action( 'admin_print_scripts-settings_page_sharing', array( $this, 'load_jp_css' ) ); | |
| 106 | + add_filter( 'sharing_show_buttons_on_row_start', array( $this, 'configuration_target_area' ) ); | |
| 105 | 107 | |
| 108 | + $publicize_active = Jetpack::is_module_active( 'publicize' ); | |
| 106 | 109 | $sharedaddy_active = Jetpack::is_module_active( 'sharedaddy' ); |
| 107 | 110 | |
| 111 | + if ( $this->settings->needs_own_sharing_menu( $sharedaddy_active ) ) { | |
| 112 | + /* | |
| 113 | + * Sharedaddy is what registers Settings > Sharing, and it is off, so we | |
| 114 | + * register that screen ourselves; our settings are displayed on it. | |
| 115 | + */ | |
| 116 | + add_action( 'admin_menu', array( $this->settings, 'sharing_menu' ) ); | |
| 117 | + } elseif ( $publicize_active && ! $sharedaddy_active ) { | |
| 118 | + // we have a sharing page but not the global options area. | |
| 119 | + add_action( 'pre_admin_screen_sharing', array( $this->settings, 'sharing_block' ), 20 ); | |
| 120 | + add_action( 'pre_admin_screen_sharing', array( $this->settings, 'updated_message' ), -10 ); | |
| 121 | + } | |
| 122 | + | |
| 108 | 123 | if ( ! $sharedaddy_active ) { |
| 124 | + add_action( 'admin_init', array( $this->settings, 'process_update_requests_if_sharedaddy_not_loaded' ) ); | |
| 125 | + add_action( 'sharing_global_options', array( $this->settings, 'admin_settings_showbuttonon_init' ), 19 ); | |
| 126 | + add_action( 'sharing_admin_update', array( $this->settings, 'admin_settings_showbuttonon_callback' ), 19 ); | |
| 109 | 127 | add_action( 'admin_init', array( $this->settings, 'add_meta_box' ) ); |
| 110 | 128 | } else { |
| 111 | 129 | add_filter( 'sharing_meta_box_title', array( $this->settings, 'add_likes_to_sharing_meta_box_title' ) ); |
| 112 | 130 | add_action( 'start_sharing_meta_box_content', array( $this->settings, 'meta_box_content' ) ); |
| @@ -117,8 +135,10 @@ | ||
| 117 | 135 | add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_register_scripts' ) ); |
| 118 | 136 | |
| 119 | 137 | add_action( 'save_post', array( $this->settings, 'meta_box_save' ) ); |
| 120 | 138 | add_action( 'edit_attachment', array( $this->settings, 'meta_box_save' ) ); |
| 139 | + add_action( 'sharing_global_options', array( $this->settings, 'admin_settings_init' ), 20 ); | |
| 140 | + add_action( 'sharing_admin_update', array( $this->settings, 'admin_settings_callback' ), 20 ); | |
| 121 | 141 | } |
| 122 | 142 | |
| 123 | 143 | /** |
| 124 | 144 | * Set the social_notifications_like option to `on` when the Likes module is activated. |
| @@ -149,31 +169,17 @@ | ||
| 149 | 169 | } |
| 150 | 170 | |
| 151 | 171 | /** |
| 152 | 172 | * Loads Jetpack's CSS on the sharing page so we can use .jetpack-targetable |
| 153 | - * | |
| 154 | - * @deprecated 16.3 Settings > Sharing is a plain WordPress settings screen now. | |
| 155 | - * | |
| 156 | - * @return void | |
| 157 | 173 | */ |
| 158 | 174 | public function load_jp_css() { |
| 159 | - _deprecated_function( __METHOD__, 'jetpack-16.3' ); | |
| 175 | + /** | |
| 176 | + * Do we really need `admin_styles`? With the new admin UI, it's breaking some bits. | |
| 177 | + * Jetpack::init()->admin_styles(); | |
| 178 | + */ | |
| 160 | 179 | } |
| 161 | 180 | |
| 162 | 181 | /** |
| 163 | - * Adds in the jetpack-targetable class so when we visit sharing#likes our like settings get highlighted by a yellow box | |
| 164 | - * | |
| 165 | - * @deprecated 16.3 The Likes settings have a section of their own on Settings > Sharing. | |
| 166 | - * | |
| 167 | - * @param string $html row heading for the sharedaddy "which page" setting. | |
| 168 | - * @return string The unchanged $html. | |
| 169 | - */ | |
| 170 | - public function configuration_target_area( $html = '' ) { | |
| 171 | - _deprecated_function( __METHOD__, 'jetpack-16.3' ); | |
| 172 | - return $html; | |
| 173 | - } | |
| 174 | - | |
| 175 | - /** | |
| 176 | 182 | * Load scripts and styles for front end. |
| 177 | 183 | */ |
| 178 | 184 | public function load_styles_register_scripts() { |
| 179 | 185 | // Likes are only rendered on pages that display post content. |
| @@ -205,9 +211,20 @@ | ||
| 205 | 211 | ); |
| 206 | 212 | } |
| 207 | 213 | |
| 208 | 214 | /** |
| 209 | - * Options to be added to the discussion page. The Sharing settings live in Sharing_Likes\Settings\Likes_Section. | |
| 215 | + * Adds in the jetpack-targetable class so when we visit sharing#likes our like settings get highlighted by a yellow box | |
| 216 | + * | |
| 217 | + * @param string $html row heading for the sharedaddy "which page" setting. | |
| 218 | + * @return string $html with the jetpack-targetable class and likes id. tbody gets closed after the like settings | |
| 219 | + */ | |
| 220 | + public function configuration_target_area( $html = '' ) { | |
| 221 | + $html = "<tbody id='likes' class='jetpack-targetable'>" . $html; | |
| 222 | + return $html; | |
| 223 | + } | |
| 224 | + | |
| 225 | + /** | |
| 226 | + * Options to be added to the discussion page (see also admin_settings_init, etc below for Sharing settings page) | |
| 210 | 227 | */ |
| 211 | 228 | public function admin_discussion_likes_settings_init() { |
| 212 | 229 | // Add a temporary section, until we can move the setting out of there and with the rest of the email notification settings. |
| 213 | 230 | add_settings_section( 'likes-notifications', __( 'Likes Notifications', 'jetpack' ), array( $this, 'admin_discussion_likes_settings_section' ), 'discussion' ); |