Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/StoreApi
File: Formatters.php
<?php
[0] Fix | Delete
namespace Automattic\WooCommerce\StoreApi;
[1] Fix | Delete
[2] Fix | Delete
use \Exception;
[3] Fix | Delete
use Automattic\WooCommerce\StoreApi\Formatters\DefaultFormatter;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Formatters class.
[7] Fix | Delete
*
[8] Fix | Delete
* Allows formatter classes to be registered. Formatters are exposed to extensions via the ExtendSchema class.
[9] Fix | Delete
*/
[10] Fix | Delete
class Formatters {
[11] Fix | Delete
/**
[12] Fix | Delete
* Holds an array of formatter class instances.
[13] Fix | Delete
*
[14] Fix | Delete
* @var array
[15] Fix | Delete
*/
[16] Fix | Delete
private $formatters = [];
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Get a new instance of a formatter class.
[20] Fix | Delete
*
[21] Fix | Delete
* @throws Exception An Exception is thrown if a non-existing formatter is used and the user is admin.
[22] Fix | Delete
*
[23] Fix | Delete
* @param string $name Name of the formatter.
[24] Fix | Delete
* @return FormatterInterface Formatter class instance.
[25] Fix | Delete
*/
[26] Fix | Delete
public function __get( $name ) {
[27] Fix | Delete
if ( ! isset( $this->formatters[ $name ] ) ) {
[28] Fix | Delete
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && current_user_can( 'manage_woocommerce' ) ) {
[29] Fix | Delete
throw new Exception( $name . ' formatter does not exist' );
[30] Fix | Delete
}
[31] Fix | Delete
return new DefaultFormatter();
[32] Fix | Delete
}
[33] Fix | Delete
return $this->formatters[ $name ];
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Register a formatter class for usage.
[38] Fix | Delete
*
[39] Fix | Delete
* @param string $name Name of the formatter.
[40] Fix | Delete
* @param string $class A formatter class name.
[41] Fix | Delete
*/
[42] Fix | Delete
public function register( $name, $class ) {
[43] Fix | Delete
$this->formatters[ $name ] = new $class();
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function