HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/filters.tar
block-list-block.js000064400000004720151551050520010237 0ustar00/**
 * External dependencies
 */
import { Component } from '@wordpress/element';
import { createHigherOrderComponent } from '@wordpress/compose';
import { getBlockType } from '@wordpress/blocks';
import { addFilter } from '@wordpress/hooks';

/**
 * withDefaultAttributes HOC for editor.BlockListBlock.
 *
 * @param  object BlockListBlock The BlockListBlock element.
 */
const withDefaultAttributes = createHigherOrderComponent(
	( BlockListBlock ) => {
		class WrappedComponent extends Component {
			mounted = false;

			componentDidMount() {
				const { block, setAttributes } = this.props;

				if ( block.name.startsWith( 'woocommerce/' ) ) {
					setAttributes( this.getAttributesWithDefaults() );
				}
			}

			componentDidUpdate() {
				if (
					this.props.block.name.startsWith( 'woocommerce/' ) &&
					! this.mounted
				) {
					this.mounted = true;
				}
			}

			getAttributesWithDefaults() {
				const blockType = getBlockType( this.props.block.name );
				let attributes = this.props.attributes;

				if (
					! this.mounted &&
					this.props.block.name.startsWith( 'woocommerce/' ) &&
					typeof blockType.attributes !== 'undefined' &&
					typeof blockType.defaults !== 'undefined'
				) {
					attributes = Object.assign(
						{},
						this.props.attributes || {}
					);
					Object.keys( blockType.attributes ).map( ( key ) => {
						if (
							typeof attributes[ key ] === 'undefined' &&
							typeof blockType.defaults[ key ] !== 'undefined'
						) {
							attributes[ key ] = blockType.defaults[ key ];
						}
						return key;
					} );
				}
				return attributes;
			}

			render() {
				return (
					<BlockListBlock
						{ ...this.props }
						attributes={ this.getAttributesWithDefaults() }
					/>
				);
			}
		}
		return WrappedComponent;
	},
	'withDefaultAttributes'
);

/**
 * Hook into `editor.BlockListBlock` to set default attributes (if blocks
 * define them separately) when a block is inserted.
 *
 * This is a workaround for Gutenberg which does not save "default" attributes
 * to the post, which means if defaults change, all existing blocks change too.
 *
 * See https://github.com/WordPress/gutenberg/issues/7342
 *
 * To use this, the block name needs a `woocommerce/` prefix, and as well
 * as defining `attributes` during block registration, you must also declare an
 * array called `defaults`. Defaults should be omitted from `attributes`.
 */
addFilter(
	'editor.BlockListBlock',
	'woocommerce-blocks/block-list-block',
	withDefaultAttributes
);
exclude-draft-status-from-analytics.js000064400000002104151551050530014075 0ustar00/**
 * External dependencies
 */
import { addFilter } from '@wordpress/hooks';

addFilter(
	'woocommerce_admin_analytics_settings',
	'woocommerce-blocks/exclude-draft-status-from-analytics',
	( settings ) => {
		const removeCheckoutDraft = ( optionsGroup ) => {
			if ( optionsGroup.key === 'customStatuses' ) {
				return {
					...optionsGroup,
					options: optionsGroup.options.filter(
						( option ) => option.value !== 'checkout-draft'
					),
				};
			}
			return optionsGroup;
		};

		const actionableStatusesOptions =
			settings.woocommerce_actionable_order_statuses.options.map(
				removeCheckoutDraft
			);
		const excludedStatusesOptions =
			settings.woocommerce_excluded_report_order_statuses.options.map(
				removeCheckoutDraft
			);

		return {
			...settings,
			woocommerce_actionable_order_statuses: {
				...settings.woocommerce_actionable_order_statuses,
				options: actionableStatusesOptions,
			},
			woocommerce_excluded_report_order_statuses: {
				...settings.woocommerce_excluded_report_order_statuses,
				options: excludedStatusesOptions,
			},
		};
	}
);
get-block-attributes.js000064400000002744151551050530011144 0ustar00/**
 * External dependencies
 */
import { addFilter } from '@wordpress/hooks';

/**
 * Adjust attributes on load to set defaults so default attributes get saved.
 *
 * @param {Object} blockAttributes Original block attributes.
 * @param {Object} blockType       Block type settings.
 *
 * @return {Object} Filtered block attributes.
 */
const setBlockAttributeDefaults = ( blockAttributes, blockType ) => {
	if ( blockType.name.startsWith( 'woocommerce/' ) ) {
		Object.keys( blockType.attributes ).map( ( key ) => {
			if (
				typeof blockAttributes[ key ] === 'undefined' &&
				typeof blockType.defaults !== 'undefined' &&
				typeof blockType.defaults[ key ] !== 'undefined'
			) {
				blockAttributes[ key ] = blockType.defaults[ key ];
			}
			return key;
		} );
	}
	return blockAttributes;
};

/**
 * Hook into `blocks.getBlockAttributes` to set default attributes (if blocks
 * define them separately) when a block is loaded.
 *
 * This is a workaround for Gutenberg which does not save "default" attributes
 * to the post, which means if defaults change, all existing blocks change too.
 *
 * See https://github.com/WordPress/gutenberg/issues/7342
 *
 * To use this, the block name needs a `woocommerce/` prefix, and as well
 * as defining `attributes` during block registration, you must also declare an
 * array called `defaults`. Defaults should be omitted from `attributes`.
 */
addFilter(
	'blocks.getBlockAttributes',
	'woocommerce-blocks/get-block-attributes',
	setBlockAttributeDefaults
);