-text"> 2611 a4345e5759 first commit лет назад: 5 2612 a4345e5759 first commit лет назад: 5 2612_fsm a4345e5759 first commit лет назад: 5 2612_vm a4345e5759 first commit лет назад: 5 2613 a4345e5759 first commit лет назад: 5 2615 a4345e5759 first commit лет назад: 5 2615_fsm a4345e5759 first commit лет назад: 5 2615_vm a4345e5759 first commit лет назад: 5 2616 a4345e5759 first commit лет назад: 5 2616_fsm a4345e5759 first commit лет назад: 5 2616_vm a4345e5759 first commit лет назад: 5 2617 a4345e5759 first commit лет назад: 5 2617_fsm a4345e5759 first commit лет назад: 5 2617_vm a4345e5759 first commit лет назад: 5 2618 a4345e5759 first commit лет назад: 5 2618_fsm a4345e5759 first commit лет назад: 5 2618_vm a4345e5759 first commit лет назад: 5 2619 a4345e5759 first commit лет назад: 5 2619_fsm a4345e5759 first commit лет назад: 5 2619_vm a4345e5759 first commit лет назад: 5 2620 a4345e5759 first commit лет назад: 5 2620_fsm a4345e5759 first commit лет назад: 5 2650 a4345e5759 first commit лет назад: 5 2651 a4345e5759 first commit лет назад: 5 2652 a4345e5759 first commit лет назад: 5 2653 a4345e5759 first commit лет назад: 5 2654 a4345e5759 first commit лет назад: 5 2655 a4345e5759 first commit лет назад: 5 2656 a4345e5759 first commit лет назад: 5 2657 a4345e5759 first commit лет назад: 5 2658 a4345e5759 first commit лет назад: 5 2659 a4345e5759 first commit лет назад: 5 2660 a4345e5759 first commit лет назад: 5 2661 a4345e5759 first commit лет назад: 5 2662 a4345e5759 first commit лет назад: 5 2663 a4345e5759 first commit лет назад: 5 2664 a4345e5759 first commit лет назад: 5 2665 a4345e5759 first commit лет назад: 5 2666 a4345e5759 first commit лет назад: 5 2667 a4345e5759 first commit лет назад: 5 2668 a4345e5759 first commit лет назад: 5 2669 a4345e5759 first commit лет назад: 5 2670 a4345e5759 first commit лет назад: 5 2673 a4345e5759 first commit лет назад: 5 2674 a4345e5759 first commit лет назад: 5 2675 a4345e5759 first commit лет назад: 5 2678 a4345e5759 first commit лет назад: 5 2679 a4345e5759 first commit лет назад: 5 2680 a4345e5759 first commit лет назад: 5 2681 a4345e5759 first commit лет назад: 5 2682 a4345e5759 first commit лет назад: 5 2683 a4345e5759 first commit лет назад: 5 2684 a4345e5759 first commit лет назад: 5 2685 a4345e5759 first commit лет назад: 5 2686 a4345e5759 first commit лет назад: 5 2687 a4345e5759 first commit лет назад: 5 2688 a4345e5759 first commit лет назад: 5 2689 a4345e5759 first commit лет назад: 5 2690 a4345e5759 first commit лет назад: 5 2691 a4345e5759 first commit лет назад: 5 2692 a4345e5759 first commit лет назад: 5 2693 a4345e5759 first commit лет назад: 5 2696 a4345e5759 first commit лет назад: 5 2699 a4345e5759 first commit лет назад: 5 2701 a4345e5759 first commit лет назад: 5 2702 a4345e5759 first commit лет назад: 5 2703 a4345e5759 first commit лет назад: 5 2704 a4345e5759 first commit лет назад: 5 2753 a4345e5759 first commit лет назад: 5 2753_fsm a4345e5759 first commit лет назад: 5 2753_vm a4345e5759 first commit лет назад: 5 2754 a4345e5759 first commit лет назад: 5 2755 a4345e5759 first commit лет назад: 5 2756 a4345e5759 first commit лет назад: 5 2757 a4345e5759 first commit лет назад: 5 2830 a4345e5759 first commit лет назад: 5 2831 a4345e5759 first commit лет назад: 5 2832 a4345e5759 first commit лет назад: 5 2833 a4345e5759 first commit лет назад: 5 2834 a4345e5759 first commit лет назад: 5 2835 a4345e5759 first commit лет назад: 5 2836 a4345e5759 first commit лет назад: 5 2837 a4345e5759 first commit лет назад: 5 2838 a4345e5759 first commit лет назад: 5 2838_fsm a4345e5759 first commit лет назад: 5 2838_vm a4345e5759 first commit лет назад: 5 2839 a4345e5759 first commit лет назад: 5 2840 a4345e5759 first commit лет назад: 5 2840_fsm a4345e5759 first commit лет назад: 5 2840_vm a4345e5759 first commit лет назад: 5 2841 a4345e5759 first commit лет назад: 5 2995 a4345e5759 first commit лет назад: 5 2996 a4345e5759 first commit лет назад: 5 3079 a4345e5759 first commit лет назад: 5 3079_fsm a4345e5759 first commit лет назад: 5 3079_vm a4345e5759 first commit лет назад: 5 3080 a4345e5759 first commit лет назад: 5 3081 a4345e5759 first commit лет назад: 5 3085 a4345e5759 first commit лет назад: 5 3118 a4345e5759 first commit лет назад: 5 3119 a4345e5759 first commit лет назад: 5 3164 a4345e5759 first commit лет назад: 5 3256 a4345e5759 first commit лет назад: 5 3257 a4345e5759 first commit лет назад: 5 3258 a4345e5759 first commit лет назад: 5 3350 a4345e5759 first commit лет назад: 5 3351 a4345e5759 first commit лет назад: 5 3379 a4345e5759 first commit лет назад: 5 3380 a4345e5759 first commit лет назад: 5 3381 a4345e5759 first commit лет назад: 5 3394 a4345e5759 first commit лет назад: 5 3394_fsm a4345e5759 first commit лет назад: 5 3394_vm a4345e5759 first commit лет назад: 5 3395 a4345e5759 first commit лет назад: 5 3429 a4345e5759 first commit лет назад: 5 3430 a4345e5759 first commit лет назад: 5 3431 a4345e5759 first commit лет назад: 5 3433 a4345e5759 first commit лет назад: 5 3439 a4345e5759 first commit лет назад: 5 3440 a4345e5759 first commit лет назад: 5 3455 a4345e5759 first commit лет назад: 5 3456 a4345e5759 first commit лет назад: 5 3456_fsm a4345e5759 first commit лет назад: 5 3456_vm a4345e5759 first commit лет назад: 5 3466 a4345e5759 first commit лет назад: 5 3467 a4345e5759 first commit лет назад: 5 3468 a4345e5759 first commit лет назад: 5 3501 a4345e5759 first commit лет назад: 5 3502 a4345e5759 first commit лет назад: 5 3503 a4345e5759 first commit лет назад: 5 3534 a4345e5759 first commit лет назад: 5 3541 a4345e5759 first commit лет назад: 5 3541_fsm a4345e5759 first commit лет назад: 5 3541_vm a4345e5759 first commit лет назад: 5 3542 a4345e5759 first commit лет назад: 5 3574 a4345e5759 first commit лет назад: 5 3575 a4345e5759 first commit лет назад: 5 3576 a4345e5759 first commit лет назад: 5 3596 a4345e5759 first commit лет назад: 5 3597 a4345e5759 first commit лет назад: 5 3598 a4345e5759 first commit лет назад: 5 3599 a4345e5759 first commit лет назад: 5 3600 a4345e5759 first commit лет назад: 5 3600_fsm a4345e5759 first commit лет назад: 5 3600_vm a4345e5759 first commit лет назад: 5 3601 a4345e5759 first commit лет назад: 5 3601_fsm a4345e5759 first commit лет назад: 5 3601_vm a4345e5759 first commit лет назад: 5 3602 a4345e5759 first commit лет назад: 5 3602_fsm a4345e5759 first commit лет назад: 5 3602_vm a4345e5759 first commit лет назад: 5 3603 a4345e5759 first commit лет назад: 5 3603_fsm a4345e5759 first commit лет назад: 5 3603_vm a4345e5759 first commit лет назад: 5 3604 a4345e5759 first commit лет назад: 5 3605 a4345e5759 first commit лет назад: 5 3606 a4345e5759 first commit лет назад: 5 3607 a4345e5759 first commit лет назад: 5 3608 a4345e5759 first commit лет назад: 5 3609 a4345e5759 first commit лет назад: 5 3712 a4345e5759 first commit лет назад: 5 3764 a4345e5759 first commit лет назад: 5 3764_fsm a4345e5759 first commit лет назад: 5 3764_vm a4345e5759 first commit лет назад: 5 3766 a4345e5759 first commit лет назад: 5 3767 a4345e5759 first commit лет назад: 5 3997 a4345e5759 first commit лет назад: 5 4143 a4345e5759 first commit лет назад: 5 4144 a4345e5759 first commit лет назад: 5 4145 a4345e5759 first commit лет назад: 5 4146 a4345e5759 first commit лет назад: 5 4147 a4345e5759 first commit лет назад: 5 4148 a4345e5759 first commit лет назад: 5 4149 a4345e5759 first commit лет назад: 5 4150 a4345e5759 first commit лет назад: 5 4151 a4345e5759 first commit лет назад: 5 4152 a4345e5759 first commit лет назад: 5 4153 a4345e5759 first commit лет назад: 5 4154 a4345e5759 first commit лет назад: 5 4155 a4345e5759 first commit лет назад: 5 4156 a4345e5759 first commit лет назад: 5 4157 a4345e5759 first commit лет назад: 5 4158 a4345e5759 first commit лет назад: 5 4159 a4345e5759 first commit лет назад: 5 4160 a4345e5759 first commit лет назад: 5 4161 a4345e5759 first commit лет назад: 5 4162 a4345e5759 first commit лет назад: 5 4163 a4345e5759 first commit лет назад: 5 4164 a4345e5759 first commit лет назад: 5 4165 a4345e5759 first commit лет назад: 5 4166 a4345e5759 first commit лет назад: 5 4167 a4345e5759 first commit лет назад: 5 4168 a4345e5759 first commit лет назад: 5 4169 a4345e5759 first commit лет назад: 5 4170 a4345e5759 first commit лет назад: 5 4171 a4345e5759 first commit лет назад: 5 4172 a4345e5759 first commit лет назад: 5 4173 a4345e5759 first commit лет назад: 5 4174 a4345e5759 first commit лет назад: 5 5002 a4345e5759 first commit лет назад: 5 548 a4345e5759 first commit лет назад: 5 549 a4345e5759 first commit лет назад: 5 6102 a4345e5759 first commit лет назад: 5 6104 a4345e5759 first commit лет назад: 5 6106 a4345e5759 first commit лет назад: 5 6110 a4345e5759 first commit лет назад: 5 6111 a4345e5759 first commit лет назад: 5 6112 a4345e5759 first commit лет назад: 5 6113 a4345e5759 first commit лет назад: 5 6117 a4345e5759 first commit лет назад: 5 826 a4345e5759 first commit лет назад: 5 827 a4345e5759 first commit лет назад: 5 828 a4345e5759 first commit лет назад: 5 PG_VERSION a4345e5759 first commit лет назад: 5 pg_filenode.map a4345e5759 first commit лет назад: 5 pg_internal.init a4345e5759 first commit лет назад: 5 tum/whitesports - Gogs: Simplico Git Service

Sin descripción

notes.php 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. /**
  3. * Module Name: Notifications
  4. * Module Description: Receive instant notifications of site comments and likes.
  5. * Sort Order: 13
  6. * First Introduced: 1.9
  7. * Requires Connection: Yes
  8. * Requires User Connection: Yes
  9. * Auto Activate: Yes
  10. * Module Tags: Other
  11. * Feature: General
  12. * Additional Search Queries: notification, notifications, toolbar, adminbar, push, comments
  13. */
  14. use Automattic\Jetpack\Connection\Manager as Connection_Manager;
  15. if ( !defined( 'JETPACK_NOTES__CACHE_BUSTER' ) ) define( 'JETPACK_NOTES__CACHE_BUSTER', JETPACK__VERSION . '-' . gmdate( 'oW' ) );
  16. class Jetpack_Notifications {
  17. public $jetpack = false;
  18. /**
  19. * Singleton
  20. * @static
  21. */
  22. public static function init() {
  23. static $instance = array();
  24. if ( !$instance ) {
  25. $instance[0] = new Jetpack_Notifications;
  26. }
  27. return $instance[0];
  28. }
  29. function __construct() {
  30. $this->jetpack = Jetpack::init();
  31. add_action( 'init', array( &$this, 'action_init' ) );
  32. }
  33. function wpcom_static_url($file) {
  34. $i = hexdec( substr( md5( $file ), -1 ) ) % 2;
  35. return 'https://s' . $i . '.wp.com' . $file;
  36. }
  37. // return the major version of Internet Explorer the viewer is using or false if it's not IE
  38. public static function get_internet_explorer_version() {
  39. static $version;
  40. if ( isset( $version ) ) {
  41. return $version;
  42. }
  43. $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
  44. preg_match( '/MSIE (\d+)/', $user_agent, $matches );
  45. $version = empty( $matches[1] ) ? null : $matches[1];
  46. if ( empty( $version ) || !$version ) {
  47. return false;
  48. }
  49. return $version;
  50. }
  51. public static function current_browser_is_supported() {
  52. static $supported;
  53. if ( isset( $supported ) ) {
  54. return $supported;
  55. }
  56. $ie_version = self::get_internet_explorer_version();
  57. if ( false === $ie_version ) {
  58. return $supported = true;
  59. }
  60. if ( $ie_version < 8 ) {
  61. return $supported = false;
  62. }
  63. return $supported = true;
  64. }
  65. function action_init() {
  66. //syncing must wait until after init so
  67. //post types that support comments
  68. $filt_post_types = array();
  69. $all_post_types = get_post_types();
  70. foreach ( $all_post_types as $post_type ) {
  71. if ( post_type_supports( $post_type, 'comments' ) ) {
  72. $filt_post_types[] = $post_type;
  73. }
  74. }
  75. if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
  76. return;
  77. if ( !has_filter( 'show_admin_bar', '__return_true' ) && !is_user_logged_in() )
  78. return;
  79. if ( !self::current_browser_is_supported() )
  80. return;
  81. // Do not show notifications in the Site Editor, which is always in fullscreen mode.
  82. global $pagenow;
  83. // phpcs:ignore WordPress.Security.NonceVerification
  84. if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'gutenberg-edit-site' === $_GET['page'] ) {
  85. return;
  86. }
  87. add_action( 'admin_bar_menu', array( &$this, 'admin_bar_menu'), 120 );
  88. add_action( 'wp_head', array( &$this, 'styles_and_scripts'), 120 );
  89. add_action( 'admin_head', array( &$this, 'styles_and_scripts') );
  90. }
  91. function styles_and_scripts() {
  92. $is_rtl = is_rtl();
  93. if ( Jetpack::is_module_active( 'masterbar' ) ) {
  94. /**
  95. * Can be used to force Notifications to display in RTL style.
  96. *
  97. * @module notes
  98. *
  99. * @since 4.8.0
  100. *
  101. * @param bool true Should notifications be displayed in RTL style. Defaults to false.
  102. */
  103. $is_rtl = apply_filters( 'a8c_wpcom_masterbar_enqueue_rtl_notification_styles', false );
  104. }
  105. if ( ! $is_rtl ) {
  106. wp_enqueue_style( 'wpcom-notes-admin-bar', $this->wpcom_static_url( '/wp-content/mu-plugins/notes/admin-bar-v2.css' ), array( 'admin-bar' ), JETPACK_NOTES__CACHE_BUSTER );
  107. } else {
  108. wp_enqueue_style( 'wpcom-notes-admin-bar', $this->wpcom_static_url( '/wp-content/mu-plugins/notes/rtl/admin-bar-v2-rtl.css' ), array( 'admin-bar' ), JETPACK_NOTES__CACHE_BUSTER );
  109. }
  110. wp_enqueue_style( 'noticons', $this->wpcom_static_url( '/i/noticons/noticons.css' ), array( 'wpcom-notes-admin-bar' ), JETPACK_NOTES__CACHE_BUSTER );
  111. $this->print_js();
  112. // attempt to use core or plugin libraries if registered
  113. $script_handles = array();
  114. if ( !wp_script_is( 'mustache', 'registered' ) ) {
  115. wp_register_script( 'mustache', $this->wpcom_static_url( '/wp-content/js/mustache.js' ), null, JETPACK_NOTES__CACHE_BUSTER );
  116. }
  117. $script_handles[] = 'mustache';
  118. if ( !wp_script_is( 'underscore', 'registered' ) ) {
  119. wp_register_script( 'underscore', $this->wpcom_static_url( '/wp-includes/js/underscore.min.js' ), null, JETPACK_NOTES__CACHE_BUSTER );
  120. }
  121. $script_handles[] = 'underscore';
  122. if ( !wp_script_is( 'backbone', 'registered' ) ) {
  123. wp_register_script( 'backbone', $this->wpcom_static_url( '/wp-includes/js/backbone.min.js' ), array( 'underscore' ), JETPACK_NOTES__CACHE_BUSTER );
  124. }
  125. $script_handles[] = 'backbone';
  126. wp_register_script( 'wpcom-notes-common', $this->wpcom_static_url( '/wp-content/mu-plugins/notes/notes-common-v2.js' ), array( 'jquery', 'underscore', 'backbone', 'mustache' ), JETPACK_NOTES__CACHE_BUSTER );
  127. $script_handles[] = 'wpcom-notes-common';
  128. $script_handles[] = 'jquery';
  129. $script_handles[] = 'jquery-migrate';
  130. $script_handles[] = 'jquery-core';
  131. wp_enqueue_script( 'wpcom-notes-admin-bar', $this->wpcom_static_url( '/wp-content/mu-plugins/notes/admin-bar-v2.js' ), array( 'wpcom-notes-common' ), JETPACK_NOTES__CACHE_BUSTER );
  132. $script_handles[] = 'wpcom-notes-admin-bar';
  133. if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
  134. add_filter(
  135. 'script_loader_tag',
  136. function ( $tag, $handle ) use ( $script_handles ) {
  137. if ( in_array( $handle, $script_handles, true ) ) {
  138. $tag = preg_replace( '/(?<=<script)(?=\s|>)/i', ' data-ampdevmode', $tag );
  139. }
  140. return $tag;
  141. },
  142. 10,
  143. 2
  144. );
  145. }
  146. }
  147. function admin_bar_menu() {
  148. global $wp_admin_bar, $current_blog;
  149. if ( !is_object( $wp_admin_bar ) )
  150. return;
  151. $wpcom_locale = get_locale();
  152. if ( !class_exists( 'GP_Locales' ) ) {
  153. if ( defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) && file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
  154. require JETPACK__GLOTPRESS_LOCALES_PATH;
  155. }
  156. }
  157. if ( class_exists( 'GP_Locales' ) ) {
  158. $wpcom_locale_object = GP_Locales::by_field( 'wp_locale', $wpcom_locale );
  159. if ( $wpcom_locale_object instanceof GP_Locale ) {
  160. $wpcom_locale = $wpcom_locale_object->slug;
  161. }
  162. }
  163. $classes = 'wpnt-loading wpn-read';
  164. $wp_admin_bar->add_menu( array(
  165. 'id' => 'notes',
  166. 'title' => '<span id="wpnt-notes-unread-count" class="' . esc_attr( $classes ) . '">
  167. <span class="noticon noticon-notification"></span>
  168. </span>',
  169. 'meta' => array(
  170. 'html' => '<div id="wpnt-notes-panel2" class="intrinsic-ignore" style="display:none" lang="' . esc_attr( $wpcom_locale ) . '" dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"><div class="wpnt-notes-panel-header"><span class="wpnt-notes-header">' . __( 'Notifications', 'jetpack' ) . '</span><span class="wpnt-notes-panel-link"></span></div></div>',
  171. 'class' => 'menupop',
  172. ),
  173. 'parent' => 'top-secondary',
  174. ) );
  175. }
  176. function print_js() {
  177. $link_accounts_url = is_user_logged_in() && ! ( new Connection_Manager( 'jetpack' ) )->is_user_connected() ? Jetpack::admin_url() : false;
  178. ?>
  179. <script data-ampdevmode type="text/javascript">
  180. /* <![CDATA[ */
  181. var wpNotesIsJetpackClient = true;
  182. var wpNotesIsJetpackClientV2 = true;
  183. <?php if ( $link_accounts_url ) : ?>
  184. var wpNotesLinkAccountsURL = '<?php print $link_accounts_url; ?>';
  185. <?php endif; ?>
  186. /* ]]> */
  187. </script>
  188. <?php
  189. }
  190. }
  191. Jetpack_Notifications::init();