Download the PHP package humanmade/orphan-command without Composer

On this page you can find all versions of the php package humanmade/orphan-command. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package orphan-command

Orphan Command

WP-CLI command to list and delete orphan WordPress entities and metadata.


Introduction

WordPress offers dedicated APIs that are to be used for CRUD operations on the various core data structures. For example, when you delete a comment via wp_delete_comment( $comment_id, true ), WordPress takes care that all metadata for that comment gets automatically deleted as well. Great!

However, people do not always do what is right—on purpose, or by accident. The reason for that could be that someone deleted entities and/or metadata directly in the DB (instead of using the respective WordPress API to handle that data). This might make sense when you want to reduce a large production or staging database export, and therefore delete (random) posts etc. Or maybe someone only did a partial database import, or partial migration. Over time, you might end up with a database that is full of orphaned entries. Comment metadata for comments that no longer exist, comments for non-existing posts, or revisions of posts that don't exist anymore.

Orphan Command provides a new WP-CLI command, wp orphan, that lets you easily spot orphans, and even delete them, if you want.

Table of Contents

Installation

Composer

Install with Composer:

By default, Orphan Command will be installed as WP-CLI package. However, it can also be installed as WordPress plugin, for example, by using a custom install path.

Manual

In case you're not managing your entire site via Composer, you can also clone this repository into your site's plugins directory.

Then, install and set up PHP auto-loading:

Finally, go to your site's Plugins page, and activate Orphan Command.

Requirements

PHP

Orphan Command requires PHP 7.2 or higher.

WordPress

Orphan Command requires WordPress 3.3 or higher.

WP-CLI

Orphan Command requires WP-CLI 2.5 or higher.

Commands

In general, all commands support the following three actions:

By default, the output of list is a comma-separated list of IDs. This can be changed by using the --format option, which supports the following values:

Some commands support additional options that are explained in the following sections.

wp orphan blog meta

The wp orphan blog meta command lets you list and delete all blog metadata referencing blogs that don't exist anymore.

List all orphan blog metadata:

Delete all orphan blog metadata:

wp orphan comment

The wp orphan comment command lets you list and delete all comments referencing posts that don't exist anymore.

In addition to --format, the wp orphan comment command also supports the following options:

List all orphan comments of any comment type:

List all orphan reactions:

Delete all orphan comments of any comment type:

Delete all orphan default comments only:

Note: Since comments can be nested (i.e., a comment can have a parent comment), an orphan comment could also be a comment referencing another comment that does not exist anymore. This is not what this command does, though. The main reason is that a comment referencing a non-existing post will usually not be exposed to site visitors.

A future version of Orphan Command might allow to also list/delete comments referencing non-existing parent comments.

wp orphan comment meta

The wp orphan comment meta command lets you list and delete all comment metadata referencing comments that don't exist anymore.

List all orphan comment metadata:

Delete all orphan comment metadata:

wp orphan post

The wp orphan post command lets you list and delete all posts referencing parent posts that don't exist anymore.

In addition to --format, the wp orphan post command also supports the following options:

List all orphan posts of any post type:

List all orphan pages:

Delete all orphan posts of any post type:

Delete all orphan default posts only:

wp orphan post meta

The wp orphan post meta command lets you list and delete all post metadata referencing posts that don't exist anymore.

List all orphan post metadata:

Delete all orphan post metadata:

wp orphan revision

The wp orphan revision command lets you list and delete all revisions referencing original posts that don't exist anymore.

Revisions are one of the Custom Post Types included in WordPress. Since they are somewhat special in that a revision with a non-existing original (parent) post is of no use whatsoever, and since there is a dedicated API for revisions (e.g., wp_delete_post_revision), Orphan Command provides a custom command for managing revisions.

List all orphan revisions:

Delete all orphan revisions:

wp orphan term meta

The wp orphan term meta command lets you list and delete all term metadata referencing terms that don't exist anymore.

List all orphan term metadata:

Delete all orphan term metadata:

wp orphan user meta

The wp orphan user meta command lets you list and delete all user metadata referencing users that don't exist anymore.

List all orphan user metadata:

Delete all orphan user metadata:

Extending Orphan Command

If you want to customize or extend the functionality of Orphan Command, you can either extend any of the actual command classes, or you could write your own based on either the Orphan_Command or Orphan_Meta_Command class included in Orphan Command.

All relevant class methods are marked protected or public, so you can redefine or decorate any behavior. For example, the Orphan_Post_Command class enhances the get_query method to inject the post type passed to the command, if any.

Frequently Asked Questions

What about terms?

For terms, there is no clear definition of orphans. An orphan term could be defined in one of several ways:

To some extent, this is similar to comments. However, there it is more of an interpretation issue, which is why Orphan Command, by default, defines orphan comments as comments referencing non-existing posts.

A future version of Orphan Command might allow to also list/delete orphan terms.

What about site/network metadata or options?

The terminology in WordPress around blog metadata and options, network options, and site metadata and options is quite confusing!

Some facts:

What about use case XYZ?

Yes, there are most certainly several possible use cases around orphan data and metadata missing. However, this is on purpose.

While it may be a good idea to list all users of a specific role that are not added to any site, or to delete all orphan posts with a specific status, this would be out of scope.

Orphan Command provides easy access to tasks that a lot of people might want to perform a lot of times; not more.

That said, you should be able to use existing WP-CLI commands such as wp <entity> list|delete or wp db query to accomplish any of the above examples quite easily.

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


All versions of orphan-command with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
composer/installers Version ^1.0 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package humanmade/orphan-command contains the following files

Loading the files please wait ....