File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Input.tar
BooleanSelect.php 0000644 00000001466 15154460022 0010002 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
defined( 'ABSPATH' ) || exit;
/**
* Class BooleanSelect
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*/
class BooleanSelect extends Select {
/**
* @return array
*/
public function get_options(): array {
return [
'' => __( 'Default', 'google-listings-and-ads' ),
'yes' => __( 'Yes', 'google-listings-and-ads' ),
'no' => __( 'No', 'google-listings-and-ads' ),
];
}
/**
* Return the data used for the input's view.
*
* @return array
*/
public function get_view_data(): array {
$view_data = parent::get_view_data();
if ( is_bool( $view_data['value'] ) ) {
$view_data['value'] = wc_bool_to_string( $view_data['value'] );
}
return $view_data;
}
}
DateTime.php 0000644 00000004266 15154460022 0006760 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
use DateTimeZone;
use Exception;
use WC_DateTime;
defined( 'ABSPATH' ) || exit;
/**
* Class DateTime
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*
* @since 1.5.0
*/
class DateTime extends Input {
/**
* DateTime constructor.
*/
public function __construct() {
parent::__construct( 'datetime', 'google-listings-and-ads/product-date-time-field' );
}
/**
* Return the data used for the input's view.
*
* @return array
*/
public function get_view_data(): array {
$view_data = parent::get_view_data();
if ( ! empty( $this->get_value() ) ) {
try {
// Display the time in site's local timezone.
$datetime = new WC_DateTime( $this->get_value(), new DateTimeZone( 'UTC' ) );
$datetime->setTimezone( new DateTimeZone( $this->get_local_tz_string() ) );
$view_data['value'] = $datetime->format( 'Y-m-d H:i:s' );
$view_data['date'] = $datetime->format( 'Y-m-d' );
$view_data['time'] = $datetime->format( 'H:i' );
} catch ( Exception $e ) {
do_action( 'woocommerce_gla_exception', $e, __METHOD__ );
$view_data['value'] = '';
$view_data['date'] = '';
$view_data['time'] = '';
}
}
return $view_data;
}
/**
* Set the form's data.
*
* @param mixed $data
*
* @return void
*/
public function set_data( $data ): void {
if ( is_array( $data ) ) {
if ( ! empty( $data['date'] ) ) {
$date = $data['date'] ?? '';
$time = $data['time'] ?? '';
$data = sprintf( '%s%s', $date, $time );
} else {
$data = '';
}
}
if ( ! empty( $data ) ) {
try {
// Store the time in UTC.
$datetime = new WC_DateTime( $data, new DateTimeZone( $this->get_local_tz_string() ) );
$datetime->setTimezone( new DateTimeZone( 'UTC' ) );
$data = (string) $datetime;
} catch ( Exception $e ) {
do_action( 'woocommerce_gla_exception', $e, __METHOD__ );
$data = '';
}
}
parent::set_data( $data );
}
/**
* Get site's local timezone string from WordPress settings.
*
* @return string
*/
protected function get_local_tz_string(): string {
return wp_timezone_string();
}
}
Form.php 0000644 00000011107 15154460022 0006157 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\ValidateInterface;
defined( 'ABSPATH' ) || exit;
/**
* Class Form
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*/
class Form implements FormInterface {
use ValidateInterface;
/**
* @var string
*/
protected $name = '';
/**
* @var mixed
*/
protected $data;
/**
* @var FormInterface[]
*/
protected $children = [];
/**
* @var FormInterface
*/
protected $parent;
/**
* @var bool
*/
protected $is_submitted = false;
/**
* Form constructor.
*
* @param mixed $data
*/
public function __construct( $data = null ) {
$this->set_data( $data );
}
/**
* @return string
*/
public function get_name(): string {
return $this->name;
}
/**
* @param string $name
*
* @return FormInterface
*/
public function set_name( string $name ): FormInterface {
$this->name = $name;
return $this;
}
/**
* @return FormInterface[]
*/
public function get_children(): array {
return $this->children;
}
/**
* Add a child form.
*
* @param FormInterface $form
*
* @return FormInterface
*
* @throws FormException If form is already submitted.
*/
public function add( FormInterface $form ): FormInterface {
if ( $this->is_submitted ) {
throw FormException::cannot_modify_submitted();
}
$this->children[ $form->get_name() ] = $form;
$form->set_parent( $this );
return $this;
}
/**
* Remove a child with the given name from the form's children.
*
* @param string $name
*
* @return FormInterface
*
* @throws FormException If form is already submitted.
*/
public function remove( string $name ): FormInterface {
if ( $this->is_submitted ) {
throw FormException::cannot_modify_submitted();
}
if ( isset( $this->children[ $name ] ) ) {
$this->children[ $name ]->set_parent( null );
unset( $this->children[ $name ] );
}
return $this;
}
/**
* Whether the form contains a child with the given name.
*
* @param string $name
*
* @return bool
*/
public function has( string $name ): bool {
return isset( $this->children[ $name ] );
}
/**
* @param FormInterface|null $form
*
* @return void
*/
public function set_parent( ?FormInterface $form ): void {
$this->parent = $form;
}
/**
* @return FormInterface|null
*/
public function get_parent(): ?FormInterface {
return $this->parent;
}
/**
* Return the form's data.
*
* @return mixed
*/
public function get_data() {
return $this->data;
}
/**
* Set the form's data.
*
* @param mixed $data
*
* @return void
*/
public function set_data( $data ): void {
if ( is_array( $data ) && ! empty( $this->children ) ) {
$this->data = $this->map_children_data( $data );
} else {
if ( is_string( $data ) ) {
$data = trim( $data );
}
$this->data = $data;
}
}
/**
* Maps the data to each child and returns the mapped data.
*
* @param array $data
*
* @return array
*/
protected function map_children_data( array $data ): array {
$children_data = [];
foreach ( $data as $key => $datum ) {
if ( isset( $this->children[ $key ] ) ) {
$this->children[ $key ]->set_data( $datum );
$children_data[ $key ] = $this->children[ $key ]->get_data();
}
}
return $children_data;
}
/**
* Submit the form.
*
* @param array $submitted_data
*/
public function submit( array $submitted_data = [] ): void {
// todo: add form validation
if ( ! $this->is_submitted ) {
$this->is_submitted = true;
$this->set_data( $submitted_data );
}
}
/**
* Return the data used for the form's view.
*
* @return array
*/
public function get_view_data(): array {
$view_data = [
'name' => $this->get_view_name(),
'is_root' => $this->is_root(),
'children' => [],
];
foreach ( $this->get_children() as $index => $form ) {
$view_data['children'][ $index ] = $form->get_view_data();
}
return $view_data;
}
/**
* Return the name used for the form's view.
*
* @return string
*/
public function get_view_name(): string {
return $this->is_root() ? sprintf( 'gla_%s', $this->get_name() ) : sprintf( '%s[%s]', $this->get_parent()->get_view_name(), $this->get_name() );
}
/**
* Whether this is the root form (i.e. has no parents).
*
* @return bool
*/
public function is_root(): bool {
return null === $this->parent;
}
/**
* Whether the form has been already submitted.
*
* @return bool
*/
public function is_submitted(): bool {
return $this->is_submitted;
}
}
FormException.php 0000644 00000001234 15154460022 0010036 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\GoogleListingsAndAdsException;
use Exception;
defined( 'ABSPATH' ) || exit;
/**
* Class FormException
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product
*/
class FormException extends Exception implements GoogleListingsAndAdsException {
/**
* Return a new instance of the exception when a submitted form is being modified.
*
* @return static
*/
public static function cannot_modify_submitted(): FormException {
return new static( 'You cannot modify a submitted form.' );
}
}
FormInterface.php 0000644 00000004170 15154460022 0010002 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
defined( 'ABSPATH' ) || exit;
/**
* Interface FormInterface
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*/
interface FormInterface {
/**
* Return the form's data.
*
* @return mixed
*/
public function get_data();
/**
* Set the form's data.
*
* @param mixed $data
*
* @return void
*/
public function set_data( $data ): void;
/**
* Return the form name.
*
* @return string
*/
public function get_name(): string;
/**
* Set the form's name.
*
* @param string $name
*
* @return FormInterface
*/
public function set_name( string $name ): FormInterface;
/**
* Submit the form.
*
* @param array $submitted_data
*
* @return void
*/
public function submit( array $submitted_data = [] ): void;
/**
* Return the data used for the form's view.
*
* @return array
*/
public function get_view_data(): array;
/**
* Return the name used for the form's view.
*
* @return string
*/
public function get_view_name(): string;
/**
* @return FormInterface[]
*/
public function get_children(): array;
/**
* Add a child form.
*
* @param FormInterface $form
*
* @return FormInterface
*/
public function add( FormInterface $form ): FormInterface;
/**
* Remove a child with the given name from the form's children.
*
* @param string $name
*
* @return FormInterface
*/
public function remove( string $name ): FormInterface;
/**
* Whether the form contains a child with the given name.
*
* @param string $name
*
* @return bool
*/
public function has( string $name ): bool;
/**
* @param FormInterface|null $form
*
* @return void
*/
public function set_parent( ?FormInterface $form ): void;
/**
* @return FormInterface|null
*/
public function get_parent(): ?FormInterface;
/**
* If this is the root form (i.e. has no parents)
*
* @return bool
*/
public function is_root(): bool;
/**
* Whether the form has been already submitted.
*
* @return bool
*/
public function is_submitted(): bool;
}
Input.php 0000644 00000012644 15154460022 0006362 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\PluginHelper;
defined( 'ABSPATH' ) || exit;
/**
* Class Input
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*/
class Input extends Form implements InputInterface {
use PluginHelper;
/**
* @var string
*/
protected $id;
/**
* @var string
*/
protected $type;
/**
* @var string
*/
protected $block_name;
/**
* @var array
*/
protected $block_attributes = [];
/**
* @var string
*/
protected $label;
/**
* @var string
*/
protected $description;
/**
* @var mixed
*/
protected $value;
/**
* @var bool
*/
protected $is_readonly = false;
/**
* @var bool
*/
protected $is_hidden = false;
/**
* Input constructor.
*
* @param string $type
* @param string $block_name The name of a generic product block in WooCommerce core or a custom block in this extension.
*/
public function __construct( string $type, string $block_name ) {
$this->type = $type;
$this->block_name = $block_name;
parent::__construct();
}
/**
* @return string|null
*/
public function get_id(): ?string {
return $this->id;
}
/**
* @return string
*/
public function get_type(): string {
return $this->type;
}
/**
* @return string|null
*/
public function get_label(): ?string {
return $this->label;
}
/**
* @return string|null
*/
public function get_description(): ?string {
return $this->description;
}
/**
* @return mixed
*/
public function get_value() {
return $this->get_data();
}
/**
* @param string|null $id
*
* @return InputInterface
*/
public function set_id( ?string $id ): InputInterface {
$this->id = $id;
return $this;
}
/**
* @param string|null $label
*
* @return InputInterface
*/
public function set_label( ?string $label ): InputInterface {
$this->label = $label;
return $this;
}
/**
* @param string|null $description
*
* @return InputInterface
*/
public function set_description( ?string $description ): InputInterface {
$this->description = $description;
return $this;
}
/**
* @param mixed $value
*
* @return InputInterface
*/
public function set_value( $value ): InputInterface {
$this->set_data( $value );
return $this;
}
/**
* @return bool
*/
public function is_readonly(): bool {
return $this->is_readonly;
}
/**
* @param bool $value
*
* @return InputInterface
*/
public function set_readonly( bool $value ): InputInterface {
$this->is_readonly = $value;
return $this;
}
/**
* @param bool $value
*
* @return InputInterface
*/
public function set_hidden( bool $value ): InputInterface {
$this->is_hidden = $value;
return $this;
}
/**
* @return bool
*/
public function is_hidden(): bool {
return $this->is_hidden;
}
/**
* Return the data used for the input's view.
*
* @return array
*/
public function get_view_data(): array {
$view_data = [
'id' => $this->get_view_id(),
'type' => $this->get_type(),
'label' => $this->get_label(),
'value' => $this->get_value(),
'description' => $this->get_description(),
'desc_tip' => true,
];
if ( $this->is_readonly ) {
$view_data['custom_attributes'] = [
'readonly' => 'readonly',
];
}
return array_merge( parent::get_view_data(), $view_data );
}
/**
* Return the id used for the input's view.
*
* @return string
*/
public function get_view_id(): string {
$parent = $this->get_parent();
if ( $parent instanceof InputInterface ) {
return sprintf( '%s_%s', $parent->get_view_id(), $this->get_id() );
} elseif ( $parent instanceof FormInterface ) {
return sprintf( '%s_%s', $parent->get_view_name(), $this->get_id() );
}
return sprintf( 'gla_%s', $this->get_name() );
}
/**
* Return the name of a generic product block in WooCommerce core or a custom block in this extension.
*
* @return string
*/
public function get_block_name(): string {
return $this->block_name;
}
/**
* Add or update a block attribute used for block config.
*
* @param string $key The attribute key defined in the corresponding block.json
* @param mixed $value The attribute value defined in the corresponding block.json
*
* @return InputInterface
*/
public function set_block_attribute( string $key, $value ): InputInterface {
$this->block_attributes[ $key ] = $value;
return $this;
}
/**
* Return the attributes of block config used for the input's view within the Product Block Editor.
*
* @return array
*/
public function get_block_attributes(): array {
$meta_key = $this->prefix_meta_key( $this->get_id() );
$block_attributes = array_merge(
[
'property' => "meta_data.{$meta_key}",
'label' => $this->get_label(),
'tooltip' => $this->get_description(),
],
$this->block_attributes
);
// Set boolean disabled property only if it's needed.
if ( $this->is_readonly() ) {
$block_attributes['disabled'] = true;
}
return $block_attributes;
}
/**
* Return the config used for the input's block within the Product Block Editor.
*
* @return array
*/
public function get_block_config(): array {
$id = $this->get_id();
return [
'id' => "google-listings-and-ads-product-attributes-{$id}",
'blockName' => $this->get_block_name(),
'attributes' => $this->get_block_attributes(),
];
}
}
InputInterface.php 0000644 00000004171 15154460022 0010177 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
defined( 'ABSPATH' ) || exit;
/**
* Interface InputInterface
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*/
interface InputInterface extends FormInterface {
/**
* @return string|null
*/
public function get_id(): ?string;
/**
* @param string|null $id
*
* @return InputInterface
*/
public function set_id( ?string $id ): InputInterface;
/**
* @return string
*/
public function get_type(): string;
/**
* @return string|null
*/
public function get_label(): ?string;
/**
* @param string|null $label
*
* @return InputInterface
*/
public function set_label( ?string $label ): InputInterface;
/**
* @return string|null
*/
public function get_description(): ?string;
/**
* @param string|null $description
*
* @return InputInterface
*/
public function set_description( ?string $description ): InputInterface;
/**
* @return mixed
*/
public function get_value();
/**
* @param mixed $value
*
* @return InputInterface
*/
public function set_value( $value ): InputInterface;
/**
* Return the id used for the input's view.
*
* @return string
*/
public function get_view_id(): string;
/**
* Return the name of a generic product block in WooCommerce core or a custom block in this extension.
*
* @return string
*/
public function get_block_name(): string;
/**
* Add or update a block attribute used for block config.
*
* @param string $key The attribute key defined in the corresponding block.json
* @param mixed $value The attribute value defined in the corresponding block.json
*
* @return InputInterface
*/
public function set_block_attribute( string $key, $value ): InputInterface;
/**
* Return the attributes of block config used for the input's view within the Product Block Editor.
*
* @return array
*/
public function get_block_attributes(): array;
/**
* Return the block config used for the input's view within the Product Block Editor.
*
* @return array
*/
public function get_block_config(): array;
}
Integer.php 0000644 00000001253 15154460022 0006652 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
defined( 'ABSPATH' ) || exit;
/**
* Class Integer
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*/
class Integer extends Input {
/**
* Integer constructor.
*/
public function __construct() {
// Ideally, it should use the 'woocommerce/product-number-field' block
// but the block doesn't support integer validation. Therefore, it uses
// the text field block to work around it.
parent::__construct( 'integer', 'woocommerce/product-text-field' );
$this->set_block_attribute(
'pattern',
[
'value' => '0|[1-9]\d*',
]
);
}
}
Select.php 0000644 00000002666 15154460022 0006505 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
defined( 'ABSPATH' ) || exit;
/**
* Class Select
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*/
class Select extends Input {
/**
* @var array
*/
protected $options = [];
/**
* Select constructor.
*/
public function __construct() {
parent::__construct( 'select', 'google-listings-and-ads/product-select-field' );
}
/**
* @return array
*/
public function get_options(): array {
return $this->options;
}
/**
* @param array $options
*
* @return $this
*/
public function set_options( array $options ): Select {
$this->options = $options;
return $this;
}
/**
* Return the data used for the input's view.
*
* @return array
*/
public function get_view_data(): array {
$view_data = parent::get_view_data();
$view_data['options'] = $this->get_options();
// add custom class
$view_data['class'] = 'select short';
return $view_data;
}
/**
* Return the attributes of block config used for the input's view within the Product Block Editor.
*
* @return array
*/
public function get_block_attributes(): array {
$options = [];
foreach ( $this->get_options() as $key => $value ) {
$options[] = [
'label' => $value,
'value' => $key,
];
}
$this->set_block_attribute( 'options', $options );
return parent::get_block_attributes();
}
}
SelectWithTextInput.php 0000644 00000010500 15154460022 0011210 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
defined( 'ABSPATH' ) || exit;
/**
* Class Select
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*/
class SelectWithTextInput extends Input {
public const CUSTOM_INPUT_KEY = '_gla_custom_value';
public const SELECT_INPUT_KEY = '_gla_select';
/**
* SelectWithTextInput constructor.
*/
public function __construct() {
$select_input = ( new Select() )->set_id( self::SELECT_INPUT_KEY )
->set_name( self::SELECT_INPUT_KEY );
$this->add( $select_input );
$custom_input = ( new Text() )->set_id( self::CUSTOM_INPUT_KEY )
->set_label( __( 'Enter your value', 'google-listings-and-ads' ) )
->set_name( self::CUSTOM_INPUT_KEY );
$this->add( $custom_input );
parent::__construct( 'select-with-text-input', 'google-listings-and-ads/product-select-with-text-field' );
}
/**
* @return array
*/
public function get_options(): array {
return $this->get_select_input()->get_options();
}
/**
* @param array $options
*
* @return $this
*/
public function set_options( array $options ): SelectWithTextInput {
$this->get_select_input()->set_options( $options );
return $this;
}
/**
* @param string|null $label
*
* @return InputInterface
*/
public function set_label( ?string $label ): InputInterface {
$this->get_select_input()->set_label( $label );
return parent::set_label( $label );
}
/**
* @param string|null $description
*
* @return InputInterface
*/
public function set_description( ?string $description ): InputInterface {
$this->get_select_input()->set_description( $description );
return parent::set_description( $description );
}
/**
* @return Select
*/
protected function get_select_input(): Select {
return $this->children[ self::SELECT_INPUT_KEY ];
}
/**
* @return Text
*/
protected function get_custom_input(): Text {
return $this->children[ self::CUSTOM_INPUT_KEY ];
}
/**
* Return the data used for the input's view.
*
* @return array
*/
public function get_view_data(): array {
$view_data = parent::get_view_data();
$select_input = $view_data['children'][ self::SELECT_INPUT_KEY ];
$custom_input = $view_data['children'][ self::CUSTOM_INPUT_KEY ];
// add custom classes
$view_data['gla_wrapper_class'] = $view_data['gla_wrapper_class'] ?? '';
$view_data['gla_wrapper_class'] .= ' select-with-text-input';
$custom_input['wrapper_class'] = 'custom-input';
// add custom value option
$select_input['options'][ self::CUSTOM_INPUT_KEY ] = __( 'Enter a custom value', 'google-listings-and-ads' );
if ( $this->is_readonly ) {
$select_input['custom_attributes'] = [
'disabled' => 'disabled',
];
$custom_input['custom_attributes'] = [
'readonly' => 'readonly',
];
}
$view_data['children'][ self::CUSTOM_INPUT_KEY ] = $custom_input;
$view_data['children'][ self::SELECT_INPUT_KEY ] = $select_input;
return $view_data;
}
/**
* Set the form's data.
*
* @param mixed $data
*
* @return void
*/
public function set_data( $data ): void {
if ( empty( $data ) ) {
$this->get_select_input()->set_data( null );
$this->get_custom_input()->set_data( null );
return;
}
$select_value = is_array( $data ) ? $data[ self::SELECT_INPUT_KEY ] ?? '' : $data;
$custom_value = is_array( $data ) ? $data[ self::CUSTOM_INPUT_KEY ] ?? '' : $data;
if ( ! isset( $this->get_options()[ $select_value ] ) ) {
$this->get_select_input()->set_data( self::CUSTOM_INPUT_KEY );
$this->get_custom_input()->set_data( $custom_value );
$this->data = $custom_value;
} else {
$this->get_select_input()->set_data( $select_value );
$this->data = $select_value;
}
}
/**
* Return the attributes of block config used for the input's view within the Product Block Editor.
*
* @return array
*/
public function get_block_attributes(): array {
$options = [];
foreach ( $this->get_options() as $key => $value ) {
$options[] = [
'label' => $value,
'value' => $key,
];
}
$options[] = [
'label' => __( 'Enter a custom value', 'google-listings-and-ads' ),
'value' => self::CUSTOM_INPUT_KEY,
];
$this->set_block_attribute( 'options', $options );
$this->set_block_attribute( 'customInputValue', self::CUSTOM_INPUT_KEY );
return parent::get_block_attributes();
}
}
Text.php 0000644 00000000606 15154460022 0006202 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input;
defined( 'ABSPATH' ) || exit;
/**
* Class Text
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input
*/
class Text extends Input {
/**
* Text constructor.
*/
public function __construct() {
parent::__construct( 'text', 'woocommerce/product-text-field' );
}
}
AdultInput.php 0000644 00000001267 15155650676 0007374 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\BooleanSelect;
defined( 'ABSPATH' ) || exit;
/**
* Class Adult
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class AdultInput extends BooleanSelect {
/**
* AdultInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Adult content', 'google-listings-and-ads' ) );
$this->set_description( __( 'Whether the product contains nudity or sexually suggestive content', 'google-listings-and-ads' ) );
}
}
AgeGroupInput.php 0000644 00000001211 15155650676 0010021 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Select;
defined( 'ABSPATH' ) || exit;
/**
* Class AgeGroup
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class AgeGroupInput extends Select {
/**
* AgeGroupInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Age Group', 'google-listings-and-ads' ) );
$this->set_description( __( 'Target age group of the item.', 'google-listings-and-ads' ) );
}
}
AttributeInputInterface.php 0000644 00000001433 15155650676 0012102 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
defined( 'ABSPATH' ) || exit;
/**
* Class AttributeInputInterface
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input
*
* @since 1.5.0
*/
interface AttributeInputInterface {
/**
* Returns a name for the attribute input.
*
* @return string
*/
public static function get_name(): string;
/**
* Returns a short description for the attribute input.
*
* @return string
*/
public static function get_description(): string;
/**
* Returns the input class used for the attribute input.
*
* Must be an instance of `InputInterface`.
*
* @return string
*/
public static function get_input_type(): string;
}
AvailabilityDateInput.php 0000644 00000001426 15155650676 0011530 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\DateTime;
defined( 'ABSPATH' ) || exit;
/**
* Class AvailabilityDate
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class AvailabilityDateInput extends DateTime {
/**
* AvailabilityDateInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Availability Date', 'google-listings-and-ads' ) );
$this->set_description( __( 'The date a preordered or backordered product becomes available for delivery. Required if product availability is preorder or backorder', 'google-listings-and-ads' ) );
}
}
BrandInput.php 0000644 00000001160 15155650676 0007341 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Text;
defined( 'ABSPATH' ) || exit;
/**
* Class Brand
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class BrandInput extends Text {
/**
* BrandInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Brand', 'google-listings-and-ads' ) );
$this->set_description( __( 'Brand of the product.', 'google-listings-and-ads' ) );
}
}
ColorInput.php 0000644 00000001160 15155650676 0007371 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Text;
defined( 'ABSPATH' ) || exit;
/**
* Class Color
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class ColorInput extends Text {
/**
* ColorInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Color', 'google-listings-and-ads' ) );
$this->set_description( __( 'Color of the product.', 'google-listings-and-ads' ) );
}
}
ConditionInput.php 0000644 00000001216 15155650676 0010243 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Select;
defined( 'ABSPATH' ) || exit;
/**
* Class Condition
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class ConditionInput extends Select {
/**
* ConditionInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Condition', 'google-listings-and-ads' ) );
$this->set_description( __( 'Condition or state of the item.', 'google-listings-and-ads' ) );
}
}
GTINInput.php 0000644 00000003125 15155650676 0007057 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Text;
use Automattic\WooCommerce\GoogleListingsAndAds\HelperTraits\GTINMigrationUtilities;
defined( 'ABSPATH' ) || exit;
/**
* Class GTIN
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class GTINInput extends Text {
use GTINMigrationUtilities;
/**
* GTINInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Global Trade Item Number (GTIN)', 'google-listings-and-ads' ) );
$this->set_description( __( 'Global Trade Item Number (GTIN) for your item. These identifiers include UPC (in North America), EAN (in Europe), JAN (in Japan), and ISBN (for books)', 'google-listings-and-ads' ) );
$this->set_field_visibility();
}
/**
* Controls the inputs visibility based on the WooCommerce version and the
* initial version of Google for WooCommerce at the time of installation.
*
* @since 2.9.0
* @return void
*/
public function set_field_visibility(): void {
if ( $this->is_gtin_available_in_core() ) {
// For versions after the GTIN changes are published. Hide the GTIN field from G4W tab. Otherwise, set as readonly.
if ( $this->should_hide_gtin() ) {
$this->set_hidden( true );
} else {
$this->set_readonly( true );
$this->set_description( __( 'The Global Trade Item Number (GTIN) for your item can now be entered on the "Inventory" tab', 'google-listings-and-ads' ) );
}
}
}
}
GenderInput.php 0000644 00000001221 15155650676 0007515 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Select;
defined( 'ABSPATH' ) || exit;
/**
* Class Gender
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class GenderInput extends Select {
/**
* GenderInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Gender', 'google-listings-and-ads' ) );
$this->set_description( __( 'The gender for which your product is intended.', 'google-listings-and-ads' ) );
}
}
IsBundleInput.php 0000644 00000001377 15155650676 0010032 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\BooleanSelect;
defined( 'ABSPATH' ) || exit;
/**
* Class IsBundle
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class IsBundleInput extends BooleanSelect {
/**
* IsBundleInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Is Bundle?', 'google-listings-and-ads' ) );
$this->set_description( __( 'Whether the item is a bundle of products. A bundle is a custom grouping of different products sold by a merchant for a single price.', 'google-listings-and-ads' ) );
}
}
MPNInput.php 0000644 00000001254 15155650676 0006751 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Text;
defined( 'ABSPATH' ) || exit;
/**
* Class MPN
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class MPNInput extends Text {
/**
* MPNInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Manufacturer Part Number (MPN)', 'google-listings-and-ads' ) );
$this->set_description( __( 'This code uniquely identifies the product to its manufacturer.', 'google-listings-and-ads' ) );
}
}
MaterialInput.php 0000644 00000001216 15155650676 0010053 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Text;
defined( 'ABSPATH' ) || exit;
/**
* Class Material
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class MaterialInput extends Text {
/**
* MaterialInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Material', 'google-listings-and-ads' ) );
$this->set_description( __( 'The material of which the item is made.', 'google-listings-and-ads' ) );
}
}
MultipackInput.php 0000644 00000001500 15155650676 0010242 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Integer;
defined( 'ABSPATH' ) || exit;
/**
* Class Multipack
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class MultipackInput extends Integer {
/**
* MultipackInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Multipack', 'google-listings-and-ads' ) );
$this->set_description( __( 'The number of identical products in a multipack. Use this attribute to indicate that you\'ve grouped multiple identical products for sale as one item.', 'google-listings-and-ads' ) );
$this->set_block_attribute( 'min', [ 'value' => 0 ] );
}
}
PatternInput.php 0000644 00000001211 15155650676 0007725 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Text;
defined( 'ABSPATH' ) || exit;
/**
* Class Pattern
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class PatternInput extends Text {
/**
* PatternInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Pattern', 'google-listings-and-ads' ) );
$this->set_description( __( 'The item\'s pattern (e.g. polka dots).', 'google-listings-and-ads' ) );
}
}
SizeInput.php 0000644 00000001153 15155650676 0007227 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Text;
defined( 'ABSPATH' ) || exit;
/**
* Class Size
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class SizeInput extends Text {
/**
* SizeInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Size', 'google-listings-and-ads' ) );
$this->set_description( __( 'Size of the product.', 'google-listings-and-ads' ) );
}
}
SizeSystemInput.php 0000644 00000001271 15155650676 0010435 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Select;
defined( 'ABSPATH' ) || exit;
/**
* Class SizeSystem
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class SizeSystemInput extends Select {
/**
* SizeSystemInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Size system', 'google-listings-and-ads' ) );
$this->set_description( __( 'System in which the size is specified. Recommended for apparel items.', 'google-listings-and-ads' ) );
}
}
SizeTypeInput.php 0000644 00000001237 15155650676 0010074 0 ustar 00 <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Input\Select;
defined( 'ABSPATH' ) || exit;
/**
* Class SizeType
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes
*
* @since 1.5.0
*/
class SizeTypeInput extends Select {
/**
* SizeTypeInput constructor.
*/
public function __construct() {
parent::__construct();
$this->set_label( __( 'Size type', 'google-listings-and-ads' ) );
$this->set_description( __( 'The cut of the item. Recommended for apparel items.', 'google-listings-and-ads' ) );
}
}