settings = new Jetpack_Likes_Settings(); // We need to run on wp hook rather than init because we check is_amp_endpoint() // when bootstrapping hooks. add_action( 'wp', array( $this, 'action_init' ), 99 ); add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'jetpack_activate_module_likes', array( $this, 'set_social_notifications_like' ) ); add_action( 'jetpack_deactivate_module_likes', array( $this, 'delete_social_notifications_like' ) ); // The `enable_module_configurable` method doesn't exist in the WP.com loader implementation. if ( ! ( new Host() )->is_wpcom_simple() ) { Jetpack::enable_module_configurable( __FILE__ ); } add_filter( 'jetpack_module_configuration_url_likes', array( $this, 'jetpack_likes_configuration_url' ) ); add_action( 'admin_print_scripts-settings_page_sharing', array( $this, 'load_jp_css' ) ); add_filter( 'sharing_show_buttons_on_row_start', array( $this, 'configuration_target_area' ) ); $publicize_active = Jetpack::is_module_active( 'publicize' ); $sharedaddy_active = Jetpack::is_module_active( 'sharedaddy' ); if ( $publicize_active && ! $sharedaddy_active ) { // we have a sharing page but not the global options area. add_action( 'pre_admin_screen_sharing', array( $this->settings, 'sharing_block' ), 20 ); add_action( 'pre_admin_screen_sharing', array( $this->settings, 'updated_message' ), -10 ); } if ( ! $sharedaddy_active ) { add_action( 'admin_init', array( $this->settings, 'process_update_requests_if_sharedaddy_not_loaded' ) ); add_action( 'sharing_global_options', array( $this->settings, 'admin_settings_showbuttonon_init' ), 19 ); add_action( 'sharing_admin_update', array( $this->settings, 'admin_settings_showbuttonon_callback' ), 19 ); add_action( 'admin_init', array( $this->settings, 'add_meta_box' ) ); } else { add_filter( 'sharing_meta_box_title', array( $this->settings, 'add_likes_to_sharing_meta_box_title' ) ); add_action( 'start_sharing_meta_box_content', array( $this->settings, 'meta_box_content' ) ); } add_action( 'admin_init', array( $this, 'admin_discussion_likes_settings_init' ) ); // Likes notifications. add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_register_scripts' ) ); add_action( 'save_post', array( $this->settings, 'meta_box_save' ) ); add_action( 'edit_attachment', array( $this->settings, 'meta_box_save' ) ); add_action( 'sharing_global_options', array( $this->settings, 'admin_settings_init' ), 20 ); add_action( 'sharing_admin_update', array( $this->settings, 'admin_settings_callback' ), 20 ); } /** * Set the social_notifications_like option to `on` when the Likes module is activated. * * @since 3.7.0 */ public function set_social_notifications_like() { update_option( 'social_notifications_like', 'on' ); } /** * Delete the social_notifications_like option that was set to `on` on module activation. * * @since 3.7.0 */ public function delete_social_notifications_like() { delete_option( 'social_notifications_like' ); } /** * Overrides default configuration url * * @uses admin_url * @return string module settings URL */ public function jetpack_likes_configuration_url() { return admin_url( 'options-general.php?page=sharing#likes' ); } /** * Loads Jetpack's CSS on the sharing page so we can use .jetpack-targetable */ public function load_jp_css() { /** * Do we really need `admin_styles`? With the new admin UI, it's breaking some bits. * Jetpack::init()->admin_styles(); */ } /** * Load scripts and styles for front end. */ public function load_styles_register_scripts() { wp_enqueue_style( 'jetpack_likes', plugins_url( 'likes/style.css', __FILE__ ), array(), JETPACK__VERSION ); wp_register_script( 'jetpack_likes_queuehandler', Assets::get_file_url_for_environment( '_inc/build/likes/queuehandler.min.js', 'modules/likes/queuehandler.js' ), array(), JETPACK__VERSION, true ); } /** * Adds in the jetpack-targetable class so when we visit sharing#likes our like settings get highlighted by a yellow box * * @param string $html row heading for the sharedaddy "which page" setting. * @return string $html with the jetpack-targetable class and likes id. tbody gets closed after the like settings */ public function configuration_target_area( $html = '' ) { $html = "
" . $html; return $html; } /** * Options to be added to the discussion page (see also admin_settings_init, etc below for Sharing settings page) */ public function admin_discussion_likes_settings_init() { // Add a temporary section, until we can move the setting out of there and with the rest of the email notification settings. add_settings_section( 'likes-notifications', __( 'Likes Notifications', 'jetpack' ), array( $this, 'admin_discussion_likes_settings_section' ), 'discussion' ); add_settings_field( 'social-notifications', __( 'Email me whenever', 'jetpack' ), array( $this, 'admin_discussion_likes_settings_field' ), 'discussion', 'likes-notifications' ); // Register the setting. register_setting( 'discussion', 'social_notifications_like', array( $this, 'admin_discussion_likes_settings_validate' ) ); } /** Add email notification options to WordPress discussion settings */ public function admin_discussion_likes_settings_section() { // Atypical usage here. We emit jquery to move likes notification checkbox to be with the rest of the email notification settings. ?> admin_likes_get_option( 'social_notifications_like' ); ?> settings->is_likes_module_enabled() ) { return; } if ( ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) || ( defined( 'APP_REQUEST' ) && APP_REQUEST ) || ( defined( 'REST_API_REQUEST' ) && REST_API_REQUEST ) || ( defined( 'COOKIE_AUTH_REQUEST' ) && COOKIE_AUTH_REQUEST ) || ( defined( 'JABBER_SERVER' ) && JABBER_SERVER ) ) { return; } if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) { return; } add_filter( 'the_content', array( $this, 'post_likes' ), 30, 1 ); add_filter( 'the_excerpt', array( $this, 'post_likes' ), 30, 1 ); } /** * Load the CSS needed for the wp-admin area. */ public function load_admin_css() { ?> 0