Recent

Database_Command class Pro only

Database_Command

Database management commands for Top 10.

EXAMPLES

# Show status of all four Top 10 tables
$ wp top10 db status

# Create any missing tables
$ wp top10 db create-tables

# Prune old data (dry run)
$ wp top10 db prune --dry-run

Namespace: WebberZone\Top_Ten\Pro\CLI
Since: 4.3.0
Source: includes/cli/class-database-command.php line 35 Extends: Base_Command

Methods

status()

Show database status for all four Top 10 tables.

OPTIONS

[—format=] : Output format (table, json, csv). Default: table.

[—network] : Show status for all sites in the network.

[—blog-id=] : Specific blog ID to show status for (multisite only).

EXAMPLES

wp top10 db status
wp top10 db status --format=json
wp top10 db status --network

Line: 60

public function status( array $args, array $assoc_args ): void;
TypeNameDescription
array$argsCommand arguments.
array$assoc_argsCommand associative arguments.

Returns: void

create_tables()

Create any missing Top 10 tables using dbDelta.

OPTIONS

[—dry-run] : Show what would be created without making changes.

[—network] : Create tables for all sites in the network.

[—blog-id=] : Specific blog ID to create tables for (multisite only).

EXAMPLES

wp top10 db create-tables
wp top10 db create-tables --dry-run
wp top10 db create-tables --network

Line: 104

public function create_tables( array $args, array $assoc_args ): void;
TypeNameDescription
array$argsCommand arguments.
array$assoc_argsCommand associative arguments.

Returns: void

update_tables()

Apply schema upgrades via dbDelta (same as plugin activation).

OPTIONS

[—dry-run] : Show what would happen without making changes.

[—network] : Apply schema upgrades for all sites in the network.

[—blog-id=] : Specific blog ID to upgrade (multisite only).

EXAMPLES

wp top10 db update-tables
wp top10 db update-tables --dry-run
wp top10 db update-tables --network

Line: 153

public function update_tables( array $args, array $assoc_args ): void;
TypeNameDescription
array$argsCommand arguments.
array$assoc_argsCommand associative arguments.

Returns: void

recreate_tables()

Recreate Top 10 tables with optional backup.

OPTIONS

[—table=

] : Which table(s) to recreate: overall, daily, funnel, log, all. Default: all.

[—no-backup] : Skip creating a backup table before recreating.

[—force] : Skip interactive confirmation.

[—dry-run] : Show what would happen without making changes.

[—network] : Recreate tables for all sites in the network.

[—blog-id=] : Specific blog ID to recreate tables for (multisite only).

EXAMPLES

wp top10 db recreate-tables
wp top10 db recreate-tables --table=daily --no-backup
wp top10 db recreate-tables --table=funnel --force
wp top10 db recreate-tables --table=log --force
wp top10 db recreate-tables --force --dry-run
wp top10 db recreate-tables --network

Line: 214

public function recreate_tables( array $args, array $assoc_args ): void;
TypeNameDescription
array$argsCommand arguments.
array$assoc_argsCommand associative arguments.

Returns: void

prune()

Prune old rows from the daily and/or visits log table.

OPTIONS

[—days=] : Retention period in days for the daily table. Default: tptn_maintenance_days filter or 180.

[—log-days=] : Retention period in days for the visits log table. Default: tptn_log_retention_days filter or 30.

[—table=

] : Which table to prune: daily, log, all. Default: all.

[—batch-size=] : Number of rows to delete per iteration. Default: 1000.

[—force] : Skip interactive confirmation.

[—dry-run] : Show counts without deleting.

[—network] : Prune for all sites in the network.

[—blog-id=] : Specific blog ID to prune (multisite only).

EXAMPLES

wp top10 db prune
wp top10 db prune --days=90 --table=daily --dry-run
wp top10 db prune --log-days=7 --table=log --force
wp top10 db prune --network

Line: 321

public function prune( array $args, array $assoc_args ): void;
TypeNameDescription
array$argsCommand arguments.
array$assoc_argsCommand associative arguments.

Returns: void

aggregate()

Force-drain the visits funnel into the log and count tables.

OPTIONS

[—batch-size=] : Max funnel rows to process per run. Default: 10000.

[—dry-run] : Show how many funnel rows would be aggregated without processing them.

[—network] : Run aggregation for all sites in the network.

[—blog-id=] : Specific blog ID to aggregate (multisite only).

EXAMPLES

wp top10 db aggregate
wp top10 db aggregate --batch-size=5000
wp top10 db aggregate --dry-run

Line: 439

public function aggregate( array $args, array $assoc_args ): void;
TypeNameDescription
array$argsCommand arguments.
array$assoc_argsCommand associative arguments.

Returns: void

truncate()

Truncate one or more Top 10 tables.

OPTIONS

[—table=

] : Which table to truncate: overall, daily, log, funnel, all. Default: all.

[—force] : Skip interactive confirmation.

[—dry-run] : Show what would be truncated without making changes.

[—network] : Truncate tables for all sites in the network.

[—blog-id=] : Specific blog ID to truncate tables for (multisite only).

EXAMPLES

wp top10 db truncate --table=funnel --force
wp top10 db truncate --table=all --dry-run
wp top10 db truncate --network --force

Line: 501

public function truncate( array $args, array $assoc_args ): void;
TypeNameDescription
array$argsCommand arguments.
array$assoc_argsCommand associative arguments.

Returns: void

cleanup_orphans()

Remove count rows for posts that no longer exist.

OPTIONS

[—table=

] : Which table to clean: overall, daily, all. Default: all.

[—batch-size=] : Rows to delete per iteration. Default: 1000.

[—force] : Skip interactive confirmation.

[—dry-run] : Count orphan rows without deleting.

[—network] : Run for all sites in the network.

[—blog-id=] : Specific blog ID (multisite only).

EXAMPLES

wp top10 db cleanup-orphans --dry-run
wp top10 db cleanup-orphans --table=overall --force

Line: 584

public function cleanup_orphans( array $args, array $assoc_args ): void;
TypeNameDescription
array$argsCommand arguments.
array$assoc_argsCommand associative arguments.

Returns: void