Source of file MslsCustomColumnTaxonomy.php

Size: 1,355 Bytes - Last Modified: 2018-02-05T14:23:18+00:00

/home/dennisploetner/Projects/Multisite-Language-Switcher/includes/MslsCustomColumnTaxonomy.php

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
<?php
/**
 * MslsCustomColumnTaxonomy
 * @author Dennis Ploetner <re@lloc.de>
 * @since 0.9.8
 */

namespace lloc\Msls;

/**
 * Handling of existing/not existing translations in the backend 
 * listings of various taxonomies
 * @package Msls
 */
class MslsCustomColumnTaxonomy extends MslsCustomColumn {

	/**
	 * Factory
	 *
	 * @codeCoverageIgnore
	 *
	 * @return MslsCustomColumnTaxonomy
	 */
	public static function init() {
		$options    = MslsOptions::instance();
		$collection = MslsBlogCollection::instance();
		$obj        = new static( $options, $collection );

		if ( ! $options->is_excluded() ) {
			$taxonomy = MslsTaxonomy::instance()->get_request();

			if ( ! empty( $taxonomy ) ) {
				add_filter( "manage_edit-{$taxonomy}_columns" , [ $obj, 'th' ] );
				add_action( "manage_{$taxonomy}_custom_column" , [ $obj, 'column_default' ], 10, 3 );
				add_action( "delete_{$taxonomy}", [ $obj, 'delete' ] );
			}
		}

		return $obj;
	}

	/**
	 * Table body
	 *
	 * @param string $deprecated
	 * @param string $column_name
	 * @param int $item_id
	 */
	public function column_default( $deprecated, $column_name, $item_id ) {
		$this->td( $column_name, $item_id );
	}

	/**
	 * Delete
	 *
	 * @codeCoverageIgnore
	 *
	 * @param int $object_id
	 */
	public function delete( $object_id ) {
		$this->save( $object_id, MslsOptionsTax::class );
	}

}