diff --git a/_inc/lib/class.core-rest-api-endpoints.php b/_inc/lib/class.core-rest-api-endpoints.php index d19e73d384f46..9b4ecf92cd6a7 100644 --- a/_inc/lib/class.core-rest-api-endpoints.php +++ b/_inc/lib/class.core-rest-api-endpoints.php @@ -789,17 +789,19 @@ public static function jumpstart_activate( $data ) { $hidden = array(); // Set some sharing settings - $sharing = new Sharing_Service(); - $sharing_options['global'] = array( - 'button_style' => 'icon', - 'sharing_label' => $sharing->default_sharing_label, - 'open_links' => 'same', - 'show' => array( 'post' ), - 'custom' => isset( $sharing_options['global']['custom'] ) ? $sharing_options['global']['custom'] : array() - ); + if ( class_exists( 'Sharing_Service' ) ) { + $sharing = new Sharing_Service(); + $sharing_options['global'] = array( + 'button_style' => 'icon', + 'sharing_label' => $sharing->default_sharing_label, + 'open_links' => 'same', + 'show' => array( 'post' ), + 'custom' => isset( $sharing_options['global']['custom'] ) ? $sharing_options['global']['custom'] : array() + ); - $result['sharing_options'] = update_option( 'sharing-options', $sharing_options ); - $result['sharing_services'] = update_option( 'sharing-services', array( 'visible' => $visible, 'hidden' => $hidden ) ); + $result['sharing_options'] = update_option( 'sharing-options', $sharing_options ); + $result['sharing_services'] = update_option( 'sharing-services', array( 'visible' => $visible, 'hidden' => $hidden ) ); + } } // If all Jumpstart modules were activated diff --git a/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php b/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php index e1cb5eb64a0c4..e0cc5354d34f8 100644 --- a/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php +++ b/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php @@ -471,6 +471,10 @@ public function update_module( $data ) { break; case 'sharing_services': + if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { + break; + } + $sharer = new Sharing_Service(); // If option value was the same, consider it done. @@ -480,6 +484,10 @@ public function update_module( $data ) { case 'button_style': case 'sharing_label': case 'show': + if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { + break; + } + $sharer = new Sharing_Service(); $grouped_options = $sharer->get_global_options(); $grouped_options[ $option ] = $value; @@ -487,6 +495,10 @@ public function update_module( $data ) { break; case 'custom': + if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { + break; + } + $sharer = new Sharing_Service(); $updated = $sharer->new_service( stripslashes( $value['sharing_name'] ), stripslashes( $value['sharing_url'] ), stripslashes( $value['sharing_icon'] ) ); @@ -495,6 +507,10 @@ public function update_module( $data ) { break; case 'sharing_delete_service': + if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) { + break; + } + $sharer = new Sharing_Service(); $updated = $sharer->delete_service( $value ); break; @@ -1012,4 +1028,4 @@ function jetpack_do_after_gravatar_hovercards_deactivation() { // When Gravatar Hovercards is deactivated, disable them automatically. update_option( 'gravatar_disable_hovercards', 'disabled' ); } -add_action( 'jetpack_deactivate_module_gravatar-hovercards', 'jetpack_do_after_gravatar_hovercards_deactivation' ); \ No newline at end of file +add_action( 'jetpack_deactivate_module_gravatar-hovercards', 'jetpack_do_after_gravatar_hovercards_deactivation' ); diff --git a/json-endpoints/class.wpcom-json-api-sharing-buttons-endpoint.php b/json-endpoints/class.wpcom-json-api-sharing-buttons-endpoint.php index 2bca82618546a..4ff4a82bb2395 100644 --- a/json-endpoints/class.wpcom-json-api-sharing-buttons-endpoint.php +++ b/json-endpoints/class.wpcom-json-api-sharing-buttons-endpoint.php @@ -7,7 +7,9 @@ abstract class WPCOM_JSON_API_Sharing_Button_Endpoint extends WPCOM_JSON_API_End protected $sharing_service; protected function setup() { - $this->sharing_service = new Sharing_Service(); + if ( class_exists( 'Sharing_Service' ) ) { + $this->sharing_service = new Sharing_Service(); + } if ( ! current_user_can( 'manage_options' ) ) { return new WP_Error( 'forbidden', 'You do not have the capability to manage sharing buttons for this site', 403 ); @@ -30,7 +32,7 @@ public function format_sharing_button( $button ) { // Status is either "disabled" or the visibility value $response['visibility'] = $this->get_button_visibility( $button ); } - + if ( ! empty( $button->icon ) ) { // Only pre-defined sharing buttons include genericon $response['genericon'] = $button->icon;