d' => 0, ), ), 'user' => array( 'current_user' => self::get_current_user_data(), ), ); /** * Filter the admin script data. * * When using this filter, ensure that the data is added only if it is used by some script. * This filter may be called on almost every admin page load. So, one should check if the data is needed/used on that page. * For example, the social (publicize) data is used only on Social admin page, Jetpack settings page and the post editor. * So, the social data should be added only on those pages. * * @since 2.3.0 * * @param array $data The script data. */ return apply_filters( 'jetpack_admin_js_script_data', $data ); } /** * Get the public script data. * * @return array */ protected static function get_public_script_data() { $data = array(); /** * Filter the public script data. * * See the docs for `jetpack_admin_js_script_data` filter for more information. * * @since 2.3.0 * * @param array $data The script data. */ return apply_filters( 'jetpack_public_js_script_data', $data ); } /** * Get the site title. * * @return string */ protected static function get_site_title() { $title = get_bloginfo( 'name' ); return $title ? $title : esc_url_raw( ( get_site_url() ) ); } /** * Get the site icon. * * @return string */ protected static function get_site_icon() { if ( ! has_site_icon() ) { return ''; } /** * Filters the site icon using Photon. * * @see https://developer.wordpress.com/docs/photon/ * * @param string $url The URL of the site icon. * @param array|string $args An array of arguments, e.g. array( 'w' => '300', 'resize' => array( 123, 456 ) ), or in string form (w=123&h=456). */ return apply_filters( 'jetpack_photon_url', get_site_icon_url(), array( 'w' => 64 ) ); } /** * Get the current user data. * * @return array */ protected static function get_current_user_data() { $current_user = wp_get_current_user(); return array( 'display_name' => $current_user->display_name, 'id' => $current_user->ID, 'capabilities' => array( 'manage_options' => current_user_can( 'manage_options' ), 'manage_modules' => current_user_can( 'jetpack_manage_modules' ), ), ); } }