Skip to content

Commit

Permalink
add vendor Prefix "Pluginkollektiv\" to namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
stklcode committed Apr 1, 2023
1 parent 7d6a6d1 commit 9a8a06c
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 86 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
},
"autoload": {
"psr-4": {
"Statify\\": "inc/"
"Pluginkollektiv\\Statify\\": "inc/"
}
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion inc/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.9
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

use WP_REST_Response;
use WP_REST_Server;
Expand Down
4 changes: 2 additions & 2 deletions inc/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.4.0
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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 {

Expand Down
4 changes: 2 additions & 2 deletions inc/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.4.0
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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 {

Expand Down
4 changes: 2 additions & 2 deletions inc/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.1
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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 {

Expand Down
4 changes: 2 additions & 2 deletions inc/Deactivate.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.4.0
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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 {

Expand Down
4 changes: 2 additions & 2 deletions inc/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.4.0
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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 {

Expand Down
4 changes: 2 additions & 2 deletions inc/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 0.1
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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 {

Expand Down
4 changes: 2 additions & 2 deletions inc/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.7
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed directly..
defined( 'ABSPATH' ) || exit;
Expand All @@ -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 {

Expand Down
36 changes: 18 additions & 18 deletions inc/Statify.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 0.1.0
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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;
Expand Down Expand Up @@ -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' ) );
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions inc/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 0.6
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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 {

Expand Down
4 changes: 2 additions & 2 deletions inc/Uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 0.1
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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 {

Expand Down
6 changes: 3 additions & 3 deletions inc/XMLRPC.php → inc/Xmlrpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.1
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

// Quit if accessed outside WP context.
defined( 'ABSPATH' ) || exit;
Expand All @@ -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.
Expand Down
36 changes: 6 additions & 30 deletions statify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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';
2 changes: 1 addition & 1 deletion tests/test-api-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package Statify
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

use DateTime;
use WP_REST_Request;
Expand Down
6 changes: 3 additions & 3 deletions tests/test-cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package Statify
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

use DateTime;
use WP_UnitTestCase;
Expand Down Expand Up @@ -37,15 +37,15 @@ 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)'
);

// Initialize cron cycle.
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'
);

Expand Down
6 changes: 4 additions & 2 deletions tests/test-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package Statify
*/

namespace Statify;
namespace Pluginkollektiv\Statify;

use DateTime;
use WP_UnitTestCase;
Expand All @@ -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();

Expand Down
Loading

0 comments on commit 9a8a06c

Please sign in to comment.