diff --git a/composer.json b/composer.json index 816e476..96b5743 100644 --- a/composer.json +++ b/composer.json @@ -90,7 +90,7 @@ }, "autoload": { "psr-4": { - "Statify\\": "inc/" + "Pluginkollektiv\\Statify\\": "inc/" } }, "config": { diff --git a/inc/Api.php b/inc/Api.php index 64c877e..381713d 100644 --- a/inc/Api.php +++ b/inc/Api.php @@ -8,7 +8,7 @@ * @since 1.9 */ -namespace Statify; +namespace Pluginkollektiv\Statify; use WP_REST_Response; use WP_REST_Server; diff --git a/inc/Backend.php b/inc/Backend.php index a385a7f..26d4917 100644 --- a/inc/Backend.php +++ b/inc/Backend.php @@ -8,7 +8,7 @@ * @since 1.4.0 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify Backend * * @since 1.4.0 - * @since 2.0.0 renamed to Statify\Backend + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Backend */ class Backend { diff --git a/inc/Cron.php b/inc/Cron.php index c4130a8..ca19ba1 100644 --- a/inc/Cron.php +++ b/inc/Cron.php @@ -8,7 +8,7 @@ * @since 1.4.0 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify Cron * * @since 1.4.0 - * @since 2.0.0 renamed to Statify\Cron + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Cron */ class Cron extends Statify { diff --git a/inc/Dashboard.php b/inc/Dashboard.php index 58b1d65..da66580 100755 --- a/inc/Dashboard.php +++ b/inc/Dashboard.php @@ -8,7 +8,7 @@ * @since 1.1 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify Dashboard * * @since 1.1 - * @since 2.0.0 renamed to Statify\Dashboard + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Dashboard */ class Dashboard extends Statify { diff --git a/inc/Deactivate.php b/inc/Deactivate.php index 9ae9284..93f8c41 100644 --- a/inc/Deactivate.php +++ b/inc/Deactivate.php @@ -8,7 +8,7 @@ * @since 1.4.0 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify Deactivate * * @since 1.4.0 - * @since 2.0.0 renamed to Statify\Deactivate + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Deactivate */ class Deactivate { diff --git a/inc/Frontend.php b/inc/Frontend.php index 1876c3d..e43ddb5 100644 --- a/inc/Frontend.php +++ b/inc/Frontend.php @@ -8,7 +8,7 @@ * @since 1.4.0 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify Frontend * * @since 1.4.0 - * @since 2.0.0 renamed to Statify\Frontend + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Frontend */ class Frontend extends Statify { diff --git a/inc/Install.php b/inc/Install.php index 6193676..d98a866 100644 --- a/inc/Install.php +++ b/inc/Install.php @@ -8,7 +8,7 @@ * @since 0.1 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify Install * * @since 0.1 - * @since 2.0.0 renamed to Statify\Install + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Install */ class Install { diff --git a/inc/Settings.php b/inc/Settings.php index b40cd08..6ed9fc4 100755 --- a/inc/Settings.php +++ b/inc/Settings.php @@ -8,7 +8,7 @@ * @since 1.7 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed directly.. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify Settings * * @since 1.7 - * @since 2.0.0 renamed to Statify\Settings + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Settings */ class Settings { diff --git a/inc/Statify.php b/inc/Statify.php index c1ad816..e075046 100755 --- a/inc/Statify.php +++ b/inc/Statify.php @@ -8,7 +8,7 @@ * @since 0.1.0 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify. * * @since 0.1.0 - * @since 2.0.0 moved to Statify namespace + * @since 2.0.0 moved to Pluginkollektiv\Statify namespace */ class Statify { const TRACKING_METHOD_DEFAULT = 0; @@ -65,31 +65,31 @@ public static function init() { ); // Cron. - add_action( 'statify_cleanup', array( 'Statify\Cron', 'cleanup_data' ) ); + add_action( 'statify_cleanup', array( 'Pluginkollektiv\\Statify\Cron', 'cleanup_data' ) ); if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { // XMLRPC. - add_filter( 'xmlrpc_methods', array( 'Statify\XMLRPC', 'xmlrpc_methods' ) ); + add_filter( 'xmlrpc_methods', array( 'Pluginkollektiv\\Statify\Xmlrpc', 'xmlrpc_methods' ) ); } elseif ( is_admin() ) { // Backend. - add_action( 'wp_initialize_site', array( 'Statify\Install', 'init_site' ) ); - add_action( 'wp_uninitialize_site', array( 'Statify\Uninstall', 'init_site' ) ); - add_action( 'wp_dashboard_setup', array( 'Statify\Dashboard', 'init' ) ); - add_filter( 'plugin_row_meta', array( 'Statify\Backend', 'add_meta_link' ), 10, 2 ); - add_filter( 'plugin_action_links_' . STATIFY_BASE, array( 'Statify\Backend', 'add_action_link' ) ); - add_action( 'admin_init', array( 'Statify\Settings', 'register_settings' ) ); - add_action( 'admin_menu', array( 'Statify\Settings', 'add_admin_menu' ) ); - add_action( 'update_option_statify', array( 'Statify\Settings', 'action_update_options' ), 10, 2 ); + add_action( 'wp_initialize_site', array( 'Pluginkollektiv\\Statify\Install', 'init_site' ) ); + add_action( 'wp_uninitialize_site', array( 'Pluginkollektiv\\Statify\Uninstall', 'init_site' ) ); + add_action( 'wp_dashboard_setup', array( 'Pluginkollektiv\\Statify\Dashboard', 'init' ) ); + add_filter( 'plugin_row_meta', array( 'Pluginkollektiv\\Statify\Backend', 'add_meta_link' ), 10, 2 ); + add_filter( 'plugin_action_links_' . STATIFY_BASE, array( 'Pluginkollektiv\\Statify\Backend', 'add_action_link' ) ); + add_action( 'admin_init', array( 'Pluginkollektiv\\Statify\Settings', 'register_settings' ) ); + add_action( 'admin_menu', array( 'Pluginkollektiv\\Statify\Settings', 'add_admin_menu' ) ); + add_action( 'update_option_statify', array( 'Pluginkollektiv\\Statify\Settings', 'action_update_options' ), 10, 2 ); } else { // Frontend. - add_action( 'template_redirect', array( 'Statify\Frontend', 'track_visit' ) ); - add_filter( 'query_vars', array( 'Statify\Frontend', 'query_vars' ) ); - add_action( 'wp_footer', array( 'Statify\Frontend', 'wp_footer' ) ); + add_action( 'template_redirect', array( 'Pluginkollektiv\\Statify\Frontend', 'track_visit' ) ); + add_filter( 'query_vars', array( 'Pluginkollektiv\\Statify\Frontend', 'query_vars' ) ); + add_action( 'wp_footer', array( 'Pluginkollektiv\\Statify\Frontend', 'wp_footer' ) ); if ( function_exists( 'amp_is_request' ) || function_exists( 'is_amp_endpoint' ) ) { // Automattic AMP plugin present. - add_filter( 'amp_analytics_entries', array( 'Statify\Frontend', 'amp_analytics_entries' ) ); - add_filter( 'amp_post_template_analytics', array( 'Statify\Frontend', 'amp_post_template_analytics' ) ); + add_filter( 'amp_analytics_entries', array( 'Pluginkollektiv\\Statify\Frontend', 'amp_analytics_entries' ) ); + add_filter( 'amp_post_template_analytics', array( 'Pluginkollektiv\\Statify\Frontend', 'amp_post_template_analytics' ) ); } // Initialize REST API. if ( self::is_javascript_tracking_enabled() ) { - add_filter( 'rest_api_init', array( 'Statify\Api', 'init' ) ); + add_filter( 'rest_api_init', array( 'Pluginkollektiv\\Statify\Api', 'init' ) ); } } } diff --git a/inc/Table.php b/inc/Table.php index 74c295e..35e40f6 100644 --- a/inc/Table.php +++ b/inc/Table.php @@ -8,7 +8,7 @@ * @since 0.6 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify Table * * @since 0.6 - * @since 2.0.0 renamed to Statify\Table + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Table */ class Table { diff --git a/inc/Uninstall.php b/inc/Uninstall.php index a6bd6c3..570661d 100644 --- a/inc/Uninstall.php +++ b/inc/Uninstall.php @@ -8,7 +8,7 @@ * @since 0.1 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,7 +17,7 @@ * Statify Uninstall * * @since 0.1 - * @since 2.0.0 renamed to Statify\Uninstall + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Uninstall */ class Uninstall { diff --git a/inc/XMLRPC.php b/inc/Xmlrpc.php similarity index 93% rename from inc/XMLRPC.php rename to inc/Xmlrpc.php index 609f41a..cf73a0e 100644 --- a/inc/XMLRPC.php +++ b/inc/Xmlrpc.php @@ -8,7 +8,7 @@ * @since 1.1 */ -namespace Statify; +namespace Pluginkollektiv\Statify; // Quit if accessed outside WP context. defined( 'ABSPATH' ) || exit; @@ -17,9 +17,9 @@ * Statify XMLRPC * * @since 1.1 - * @since 2.0.0 renamed to Statify\XMLRPC + * @since 2.0.0 renamed to Pluginkollektiv\Statify\Xmlrpc */ -class XMLRPC { +class Xmlrpc { /** * Enhancement from the XMLRPC-method. diff --git a/statify.php b/statify.php index 13bcb75..98b01c2 100644 --- a/statify.php +++ b/statify.php @@ -7,7 +7,7 @@ * Author URI: https://pluginkollektiv.org/ * Plugin URI: https://statify.pluginkollektiv.org/ * License: GPLv3 or later - * Version: 1.9.0 + * Version: 2.0.0 * * @package WordPress */ @@ -20,38 +20,14 @@ define( 'STATIFY_FILE', __FILE__ ); define( 'STATIFY_DIR', dirname( __FILE__ ) ); define( 'STATIFY_BASE', plugin_basename( __FILE__ ) ); -define( 'STATIFY_VERSION', '1.9.0' ); +define( 'STATIFY_VERSION', '2.0.0' ); /* Hooks */ -add_action( - 'plugins_loaded', - array( - 'Statify\Statify', - 'init', - ) -); -register_activation_hook( - STATIFY_FILE, - array( - 'Statify\Install', - 'init', - ) -); -register_deactivation_hook( - STATIFY_FILE, - array( - 'Statify\Deactivate', - 'init', - ) -); -register_uninstall_hook( - STATIFY_FILE, - array( - 'Statify\Uninstall', - 'init', - ) -); +add_action( 'plugins_loaded', array( 'Pluginkollektiv\Statify\Statify', 'init' ) ); +register_activation_hook( STATIFY_FILE, array( 'Pluginkollektiv\Statify\Install', 'init' ) ); +register_deactivation_hook( STATIFY_FILE, array( 'Pluginkollektiv\\Statify\Deactivate', 'init' ) ); +register_uninstall_hook( STATIFY_FILE, array( 'Pluginkollektiv\\Statify\Uninstall', 'init' ) ); /* Composer Autoload */ require __DIR__ . '/vendor/autoload.php'; diff --git a/tests/test-api-tracking.php b/tests/test-api-tracking.php index 9f02e8e..d73bdd8 100644 --- a/tests/test-api-tracking.php +++ b/tests/test-api-tracking.php @@ -5,7 +5,7 @@ * @package Statify */ -namespace Statify; +namespace Pluginkollektiv\Statify; use DateTime; use WP_REST_Request; diff --git a/tests/test-cron.php b/tests/test-cron.php index 0460edd..f960c05 100644 --- a/tests/test-cron.php +++ b/tests/test-cron.php @@ -5,7 +5,7 @@ * @package Statify */ -namespace Statify; +namespace Pluginkollektiv\Statify; use DateTime; use WP_UnitTestCase; @@ -37,7 +37,7 @@ public function test_cronjob() { // Initialize normal cycle, configure storage period of 3 days. $this->init_statify_widget( 3 ); $this->assertNotFalse( - has_action( 'statify_cleanup', array( 'Statify\Cron', 'cleanup_data' ) ), + has_action( 'statify_cleanup', array( 'Pluginkollektiv\Statify\Cron', 'cleanup_data' ) ), 'Statify cleanup cron job should be registered in normal cycle (always)' ); @@ -45,7 +45,7 @@ public function test_cronjob() { define( 'DOING_CRON', true ); Statify::init(); $this->assertNotFalse( - has_action( 'statify_cleanup', array( 'Statify\Cron', 'cleanup_data' ) ), + has_action( 'statify_cleanup', array( 'Pluginkollektiv\Statify\Cron', 'cleanup_data' ) ), 'Statify cleanup cron job was not registered' ); diff --git a/tests/test-dashboard.php b/tests/test-dashboard.php index 619000b..36ad0e0 100644 --- a/tests/test-dashboard.php +++ b/tests/test-dashboard.php @@ -5,7 +5,7 @@ * @package Statify */ -namespace Statify; +namespace Pluginkollektiv\Statify; use DateTime; use WP_UnitTestCase; @@ -28,7 +28,9 @@ public function set_up() { // "Install" Statify, i.e. create tables and options. Install::init(); - if ( ! function_exists( 'Statify\wp_add_dashboard_widget' ) ) { + /* This function is typically defined in the root namespace. However, the hierarchy prefers this overridden + instance here, so it will be used for testing purposes. */ + if ( ! function_exists( 'Pluginkollektiv\Statify\wp_add_dashboard_widget' ) ) { global $widget_capture; $widget_capture = array(); diff --git a/tests/test-frontend.php b/tests/test-frontend.php index 66e9478..ddca667 100644 --- a/tests/test-frontend.php +++ b/tests/test-frontend.php @@ -5,7 +5,7 @@ * @package Statify */ -namespace Statify; +namespace Pluginkollektiv\Statify; use WP_UnitTestCase; @@ -23,7 +23,7 @@ public function test_wp_footer() { // Disable JS tracking. $this->init_statify_tracking( Statify::TRACKING_METHOD_DEFAULT ); $this->assertNotFalse( - has_action( 'wp_footer', array( 'Statify\Frontend', 'wp_footer' ) ), + has_action( 'wp_footer', array( 'Pluginkollektiv\Statify\Frontend', 'wp_footer' ) ), 'Statify footer action not registered' ); @@ -58,7 +58,7 @@ public function test_query_vars() { $this->assertNotFalse( has_action( 'query_vars', - array( 'Statify\Frontend', 'query_vars' ) + array( 'Pluginkollektiv\Statify\Frontend', 'query_vars' ) ), 'Statify query_vars action not registered' ); diff --git a/tests/test-statify.php b/tests/test-statify.php index 039f725..98eff24 100644 --- a/tests/test-statify.php +++ b/tests/test-statify.php @@ -5,7 +5,7 @@ * @package Statify */ -namespace Statify; +namespace Pluginkollektiv\Statify; use WP_UnitTestCase; diff --git a/tests/test-tracking.php b/tests/test-tracking.php index 07a2a89..d837811 100644 --- a/tests/test-tracking.php +++ b/tests/test-tracking.php @@ -5,7 +5,7 @@ * @package Statify */ -namespace Statify; +namespace Pluginkollektiv\Statify; use DateTime; use WP_UnitTestCase; @@ -40,7 +40,7 @@ public function test_default_tracking() { $this->assertNotFalse( has_action( 'template_redirect', - array( 'Statify\Frontend', 'track_visit' ) + array( 'Pluginkollektiv\Statify\Frontend', 'track_visit' ) ), 'Statify tracking action not registered' ); diff --git a/tests/trait-statify-test-support.php b/tests/trait-statify-test-support.php index 70fa9a3..31318c9 100644 --- a/tests/trait-statify-test-support.php +++ b/tests/trait-statify-test-support.php @@ -5,7 +5,7 @@ * @package Statify */ -namespace Statify; +namespace Pluginkollektiv\Statify; /** * Trait Statify_Test_Support. diff --git a/views/widget-back.php b/views/widget-back.php index 61b24dd..b6ff249 100644 --- a/views/widget-back.php +++ b/views/widget-back.php @@ -7,8 +7,10 @@ * @package Statify */ +namespace Pluginkollektiv\Statify; + // Quit if accessed outside WP context. -class_exists( 'Statify' ) || exit; ?> +class_exists( 'Pluginkollektiv\Statify\Statify' ) || exit; ?>