diff --git a/inc/class-statify-api.php b/inc/class-statify-api.php
index 99e69f9..c609bc6 100644
--- a/inc/class-statify-api.php
+++ b/inc/class-statify-api.php
@@ -31,7 +31,7 @@ class Statify_Api extends Statify {
*
* @return void
*/
- public static function init() {
+ public static function init(): void {
if ( Statify::is_javascript_tracking_enabled() ) {
register_rest_route(
self::REST_NAMESPACE,
@@ -88,7 +88,7 @@ public static function check_authentication( $errors ) {
*
* @return WP_REST_Response The response.
*/
- public static function track_visit( $request ) {
+ public static function track_visit( WP_REST_Request $request ): WP_REST_Response {
// Only do something if snippet use is actually configured.
if ( Statify::is_javascript_tracking_enabled() ) {
// Nonce verification, if necessary. We do not rely on the WP REST default mechanisms.
@@ -121,7 +121,7 @@ public static function track_visit( $request ) {
*
* @return WP_REST_Response The response.
*/
- public static function get_stats( $request ) {
+ public static function get_stats( WP_REST_Request $request ): WP_REST_Response {
$refresh = '1' === $request->get_param( 'refresh' );
$stats = Statify_Dashboard::get_stats( $refresh );
diff --git a/inc/class-statify-backend.php b/inc/class-statify-backend.php
index 5c8209d..24ad963 100644
--- a/inc/class-statify-backend.php
+++ b/inc/class-statify-backend.php
@@ -29,7 +29,7 @@ class Statify_Backend {
*
* @return array Merged links
*/
- public static function add_meta_link( $input, $file ) {
+ public static function add_meta_link( array $input, string $file ): array {
// Other plugins?
if ( STATIFY_BASE !== $file ) {
@@ -55,7 +55,7 @@ public static function add_meta_link( $input, $file ) {
*
* @return array Merged links
*/
- public static function add_action_link( $input ) {
+ public static function add_action_link( array $input ): array {
// Rights?
if ( ! current_user_can( 'manage_options' ) ) {
diff --git a/inc/class-statify-cron.php b/inc/class-statify-cron.php
index 969c770..7d53e05 100644
--- a/inc/class-statify-cron.php
+++ b/inc/class-statify-cron.php
@@ -24,7 +24,7 @@ class Statify_Cron extends Statify {
* @since 0.3.0
* @version 1.4.0
*/
- public static function cleanup_data() {
+ public static function cleanup_data(): void {
// Global.
global $wpdb;
diff --git a/inc/class-statify-dashboard.php b/inc/class-statify-dashboard.php
index cf8f7c4..00bdaa7 100755
--- a/inc/class-statify-dashboard.php
+++ b/inc/class-statify-dashboard.php
@@ -31,7 +31,7 @@ class Statify_Dashboard extends Statify {
*
* @since 0.1.0
*/
- public static function init() {
+ public static function init(): void {
// Filter user_can_see_stats.
if ( ! self::user_can_see_stats() ) {
@@ -72,7 +72,7 @@ public static function init() {
* @since 0.1.0
* @version 1.4.0
*/
- public static function add_style() {
+ public static function add_style(): void {
// Register CSS.
wp_register_style(
@@ -106,7 +106,7 @@ public static function add_style() {
* @since 0.1.0
* @version 1.4.0
*/
- public static function add_js() {
+ public static function add_js(): void {
// Register JS.
wp_register_script(
@@ -155,7 +155,7 @@ public static function add_js() {
* @since 0.1.0
* @version 1.4.0
*/
- public static function print_frontview() {
+ public static function print_frontview(): void {
// Load JS.
wp_enqueue_script( 'chartist_js' );
@@ -174,7 +174,7 @@ public static function print_frontview() {
* @since 0.4.0
* @version 1.4.0
*/
- public static function print_backview() {
+ public static function print_backview(): void {
// Capability check.
if ( ! current_user_can( 'edit_dashboard' ) ) {
@@ -203,7 +203,7 @@ public static function print_backview() {
*
* @return void
*/
- private static function _save_widget_options() {
+ private static function _save_widget_options(): void {
// Check the nonce field from the dashboard form.
if ( ! check_admin_referer( 'statify-dashboard' ) ) {
return;
@@ -248,7 +248,7 @@ private static function _save_widget_options() {
* @since 1.4.0
* @version 1.4.0
*/
- private static function _get_version() {
+ private static function _get_version(): void {
// Get plugin meta.
$meta = get_plugin_data( STATIFY_FILE );
@@ -267,7 +267,7 @@ private static function _get_version() {
*
* @return array $data stats data from cache or database
*/
- public static function get_stats( $force_refresh = false ) {
+ public static function get_stats( bool $force_refresh = false ): array {
// Get from cache if enabled.
if ( ! $force_refresh ) {
@@ -304,7 +304,7 @@ public static function get_stats( $force_refresh = false ) {
*
* @return array DB results
*/
- private static function _select_data() {
+ private static function _select_data(): array {
// Global.
global $wpdb;
diff --git a/inc/class-statify-deactivate.php b/inc/class-statify-deactivate.php
index bdfce5b..b906c7d 100644
--- a/inc/class-statify-deactivate.php
+++ b/inc/class-statify-deactivate.php
@@ -24,7 +24,7 @@ class Statify_Deactivate {
* @since 1.4.0
* @version 1.4.0
*/
- public static function init() {
+ public static function init(): void {
// Delete transients.
delete_transient( 'statify_data' );
diff --git a/inc/class-statify-frontend.php b/inc/class-statify-frontend.php
index 0521bbb..278a657 100644
--- a/inc/class-statify-frontend.php
+++ b/inc/class-statify-frontend.php
@@ -27,7 +27,7 @@ class Statify_Frontend extends Statify {
*
* @return void
*/
- public static function track_visit() {
+ public static function track_visit(): void {
if ( self::is_javascript_tracking_enabled() ) {
return;
}
@@ -55,7 +55,7 @@ public static function track_visit() {
*
* @return array $vars Output with plugin variables
*/
- public static function query_vars( $vars ) {
+ public static function query_vars( array $vars ): array {
$vars[] = 'statify_referrer';
$vars[] = 'statify_target';
@@ -69,7 +69,7 @@ public static function query_vars( $vars ) {
* @since 1.1.0
* @version 1.4.1
*/
- public static function wp_footer() {
+ public static function wp_footer(): void {
// JS tracking disabled or AMP is used for the current request.
if (
! self::is_javascript_tracking_enabled() ||
@@ -109,11 +109,7 @@ public static function wp_footer() {
*
* @param array $analytics_entries Analytics entries.
*/
- public static function amp_analytics_entries( $analytics_entries ) {
- if ( ! is_array( $analytics_entries ) ) {
- $analytics_entries = array();
- }
-
+ public static function amp_analytics_entries( array $analytics_entries ): array {
// Analytics script is only relevant, if "JS" tracking is enabled, to prevent double tracking.
if ( self::is_javascript_tracking_enabled() ) {
$analytics_entries['statify'] = array(
@@ -132,11 +128,7 @@ public static function amp_analytics_entries( $analytics_entries ) {
*
* @param array $analytics Analytics.
*/
- public static function amp_post_template_analytics( $analytics ) {
- if ( ! is_array( $analytics ) ) {
- $analytics = array();
- }
-
+ public static function amp_post_template_analytics( array $analytics ): array {
// Analytics script is only relevant, if "JS" tracking is enabled, to prevent double tracking.
if ( self::is_javascript_tracking_enabled() ) {
$analytics['statify'] = array(
@@ -154,7 +146,7 @@ public static function amp_post_template_analytics( $analytics ) {
*
* @return array Configuration array.
*/
- private static function make_amp_config() {
+ private static function make_amp_config(): array {
$cfg = array(
'requests' => array(
'pageview' => rest_url( Statify_Api::REST_NAMESPACE . '/' . Statify_Api::REST_ROUTE_TRACK ),
diff --git a/inc/class-statify-install.php b/inc/class-statify-install.php
index ee7ecf4..3c2ad7e 100644
--- a/inc/class-statify-install.php
+++ b/inc/class-statify-install.php
@@ -26,7 +26,7 @@ class Statify_Install {
*
* @param bool $network_wide Whether the plugin was activated network-wide or not.
*/
- public static function init( $network_wide = false ) {
+ public static function init( bool $network_wide = false ): void {
if ( $network_wide && is_multisite() ) {
$sites = get_sites();
@@ -53,9 +53,9 @@ public static function init( $network_wide = false ) {
*
* @param int $site_id Site ID.
*/
- public static function init_site( $site_id ) {
+ public static function init_site( int $site_id ): void {
- switch_to_blog( (int) $site_id );
+ switch_to_blog( $site_id );
self::_apply();
@@ -68,7 +68,7 @@ public static function init_site( $site_id ) {
* @since 0.1.0
* @version 1.4.0
*/
- private static function _apply() {
+ private static function _apply(): void {
// Cleanup any leftover transients.
delete_transient( 'statify_data' );
diff --git a/inc/class-statify-settings.php b/inc/class-statify-settings.php
index 4e12bce..22da285 100755
--- a/inc/class-statify-settings.php
+++ b/inc/class-statify-settings.php
@@ -23,7 +23,7 @@ class Statify_Settings {
*
* @return void
*/
- public static function register_settings() {
+ public static function register_settings(): void {
register_setting( 'statify', 'statify', array( __CLASS__, 'sanitize_options' ) );
// Global settings.
@@ -127,7 +127,7 @@ public static function register_settings() {
*
* @return void
*/
- public static function options_days() {
+ public static function options_days(): void {
?>
@@ -140,7 +140,7 @@ public static function options_days() {
*
* @return void
*/
- public static function options_snippet() {
+ public static function options_snippet(): void {
?>
@@ -162,7 +162,7 @@ public static function options_snippet() {
* @param int $value the value for the input radio.
* @param string $label the label.
*/
- private static function show_snippet_option( $value, $label ) {
+ private static function show_snippet_option( int $value, string $label ): void {
?>