File manager - Edit - /home/aresglob/public_html/wp/wp-includes/images/smilies/safe-svg.tar
Back
block.json 0000644 00000002033 15105162063 0006526 0 ustar 00 { "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "title": "Safe SVG", "description": "Display the SVG icon", "textdomain": "safe-svg", "name": "safe-svg/svg-icon", "category": "design", "attributes": { "svgURL": { "type": "string", "default": "" }, "type": { "type": "string", "default": "full" }, "alignment": { "type": "string" }, "imageID": { "type": "number", "default": 0 }, "imageWidth": { "type": "number" }, "imageHeight": { "type": "number" }, "dimensionWidth": { "type": "number" }, "dimensionHeight": { "type": "number" }, "imageSizes": { "type": "object" } }, "supports": { "html": false, "color": { "text": true, "background": true }, "spacing": { "margin": true, "padding": true } }, "editorScript": "file:../../../dist/safe-svg-block.js", "style": "file:../../../dist/safe-svg-block-frontend.css" } frontend.js 0000644 00000000143 15105162063 0006716 0 ustar 00 /* global safe-svg_personalizer_params */ /* eslint-disable camelcase */ import './frontend.scss'; save.js 0000644 00000000176 15105162063 0006043 0 ustar 00 /** * @return string Dynamic SVG icon block HTML. */ const SafeSVGBlockSave = () => null; export default SafeSVGBlockSave; index.js 0000644 00000004531 15105162063 0006213 0 ustar 00 /** * SafeSvg Icon Block */ /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { registerBlockType } from '@wordpress/blocks'; /** * Internal dependencies */ import edit from './edit'; import save from './save'; import block from './block.json'; /* Uncomment for CSS overrides in the admin */ import './frontend.scss'; /** * Register block */ registerBlockType( block.name, { title: __( 'Inline SVG', 'safe-svg' ), description: __( 'Display an SVG icon', 'safe-svg' ), edit, save, icon: { src: <svg xmlns='http://www.w3.org/2000/svg' width='800' height='800' viewBox='0 0 512 512'><path fill='currentColor' fillRule='evenodd' d='M321.838 42.667H87.171v234.666h42.667v-192h174.293l81.707 81.707v110.293h42.667v-128L321.838 42.667ZM85.333 441.734l4.17-24.65c14.68 6.163 27.126 9.244 37.337 9.244 6.645 0 11.54-1.631 14.68-4.894 2.72-2.84 4.079-6.313 4.079-10.422 0-3.685-1.33-6.555-3.988-8.61-2.658-2.053-9.213-5.225-19.665-9.515-7.734-3.202-13.186-5.588-16.358-7.16-3.172-1.57-6.087-3.352-8.745-5.346-7.552-5.619-11.328-13.715-11.328-24.287 0-9.123 2.477-17.129 7.43-24.016 7.613-10.694 20.12-16.04 37.52-16.04 12.566 0 26.22 2.325 40.962 6.977l-5.8 23.563c-8.7-3.202-15.24-5.317-19.62-6.344-4.38-1.027-8.957-1.54-13.73-1.54-5.437 0-9.576 1.208-12.416 3.625-2.96 2.597-4.44 5.89-4.44 9.878 0 3.443 1.253 6.147 3.76 8.11 2.508 1.964 8.535 4.91 18.08 8.837 9.486 3.927 15.77 6.66 18.85 8.201a55.772 55.772 0 0 1 8.7 5.392c7.432 5.68 11.147 14.35 11.147 26.01 0 13.775-4.682 24.197-14.047 31.265-7.975 5.982-19.152 8.972-33.53 8.972-14.984 0-29.333-2.417-43.048-7.25Zm146.722 4.985L183.39 318.303h30.087l21.388 57.637c5.437 14.682 9.515 26.765 12.234 36.25 4.169-13.291 8.126-24.982 11.872-35.071l22.022-58.816h28.637l-48.665 128.416h-28.91ZM429.8 374.853v65.522c-7.37 2.477-12.567 4.108-15.588 4.894-9.364 2.477-19.424 3.715-30.178 3.715-21.146 0-37.247-5.317-48.303-15.95-12.264-11.72-18.397-28.063-18.397-49.028 0-24.106 7.613-42.292 22.838-54.556 11.056-8.942 25.979-13.413 44.769-13.413 16.07 0 31.024 2.93 44.859 8.79l-9.878 22.567c-6.525-3.263-12.235-5.544-17.128-6.843-4.894-1.299-10.271-1.948-16.132-1.948-14.016 0-24.347 4.561-30.993 13.684-5.619 7.734-8.428 17.914-8.428 30.54 0 15.165 4.229 26.584 12.687 34.257 6.767 6.163 15.165 9.244 25.194 9.244 5.86 0 11.419-.997 16.675-2.99v-25.829h-22.113v-22.656H429.8Z'></path></svg> } } ); edit.js 0000644 00000015041 15105162063 0006027 0 ustar 00 /* eslint-disable no-unused-vars */ /** * External dependencies */ import PropTypes from 'prop-types'; import { ReactSVG } from 'react-svg' import classnames from 'classnames'; /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { Placeholder, PanelBody, } from '@wordpress/components'; import { useBlockProps, BlockControls, AlignmentToolbar, InspectorControls, __experimentalImageSizeControl as ImageSizeControl, MediaReplaceFlow, MediaPlaceholder, getColorClassName, } from '@wordpress/block-editor'; /** * Edit component. * See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit * * @param {Object} props The block props. * @param {Object} props.attributes Block attributes. * @param {Object} props.attributes.svgURL SVG URL. * @param {boolean} props.attributes.alignment Alignment of the SVG. * @param {string} props.className Class name for the block. * @param {Function} props.setAttributes Sets the value for block attributes. * @return {Function} Render the edit screen */ const SafeSvgBlockEdit = ({ attributes, setAttributes }) => { const { contentPostType, svgURL, type, imageID, imageSizes, alignment, imageWidth, imageHeight, dimensionWidth, dimensionHeight, textColor, } = attributes; const blockProps = useBlockProps( { className: 'wp-block-safe-svg-svg-icon safe-svg-cover', style: { textAlign: alignment, } } ); const { className, style, ...containerBlockProps } = blockProps; // Remove text alignment so we can apply to the parent container. delete style.textAlign; containerBlockProps.style = { textAlign: alignment }; // Remove core background & text color classes, so we can add our own. const newClassName = className.replace(/has-[\w-]*-color|has-background/g, '').trim(); containerBlockProps.className = newClassName; // Add the width and height to enforce dimensions and to keep parity with the frontend. style.width = `${dimensionWidth}px`; style.height = `${dimensionHeight}px`; const ALLOWED_MEDIA_TYPES = ['image/svg+xml']; const onSelectImage = media => { if (!media.sizes && !media.media_details?.sizes) { return; } if (media.media_details) { media.sizes = media.media_details.sizes; } const newURL = media.sizes.full.url ?? media.sizes.full.source_url; setAttributes({ imageSizes: { full: media.sizes.full, medium: media.sizes.medium, thumbnail: media.sizes.thumbnail, }, imageWidth: media.sizes.full.width, imageHeight: media.sizes.full.height, dimensionWidth: media.sizes.full.width, dimensionHeight: media.sizes.full.height, imageID: media.id, svgURL: newURL, type: 'full', }); }; const onError = (message) => { console.log(__(`Something went wrong, please try again. Message: ${message}`, 'safe-svg')); } const onChange = (dimensionSizes) => { if (!dimensionSizes.width && !dimensionSizes.height) { dimensionSizes.width = parseInt(imageSizes[type].width); dimensionSizes.height = parseInt(imageSizes[type].height); } setAttributes({ dimensionWidth: dimensionSizes.width ?? dimensionWidth, dimensionHeight: dimensionSizes.height ?? dimensionHeight, }) } const onChangeImage = (newSizeSlug) => { const newUrl = imageSizes[newSizeSlug].url ?? imageSizes[newSizeSlug].source_url; if (!newUrl) { return null; } let newWidth = parseInt(imageSizes[newSizeSlug].width); let newHeight = parseInt(imageSizes[newSizeSlug].height); if ('full' !== newSizeSlug) { if (imageSizes[newSizeSlug].width >= imageSizes[newSizeSlug].height) { newHeight = imageSizes[newSizeSlug].height * imageSizes['full'].height / imageSizes['full'].width; } else { newWidth = imageSizes[newSizeSlug].width * imageSizes['full'].width / imageSizes['full'].height; } } setAttributes({ svgURL: newUrl, imageWidth: newWidth, imageHeight: newHeight, dimensionWidth: newWidth, dimensionHeight: newHeight, type: newSizeSlug }) } const imageSizeOptions = [ { value: 'full', label: __('Full Size', 'safe-svg') }, { value: 'medium', label: __('Medium', 'safe-svg') }, { value: 'thumbnail', label: __('Thumbnail', 'safe-svg') }, ]; return ( <> {svgURL && <> <InspectorControls> <PanelBody title={__( 'Image settings', 'safe-svg' )} > <ImageSizeControl width={dimensionWidth} height={dimensionHeight} imageWidth={imageWidth} imageHeight={imageHeight} imageSizeOptions={imageSizeOptions} slug={type} onChange={onChange} onChangeImage={onChangeImage} /> </PanelBody> </InspectorControls> <BlockControls> <AlignmentToolbar value={alignment} onChange={(newVal) => setAttributes({ alignment: newVal })} /> </BlockControls> <BlockControls> <MediaReplaceFlow mediaId={imageID} mediaURL={svgURL} allowedTypes={ALLOWED_MEDIA_TYPES} accept={ALLOWED_MEDIA_TYPES} onSelect={onSelectImage} onError={onError} /> </BlockControls> </> } {!svgURL && <MediaPlaceholder onSelect={onSelectImage} allowedTypes={ALLOWED_MEDIA_TYPES} accept={ALLOWED_MEDIA_TYPES} value={imageID} labels={{ title: __('Inline SVG', 'safe-svg'), instructions: __('Upload an SVG or pick one from your media library.', 'safe-svg') }} /> } {svgURL && <div {...containerBlockProps}> <div style={style} className={classnames( 'safe-svg-inside', getColorClassName('color', textColor) || '' )} > <ReactSVG src={svgURL} beforeInjection={(svg) => { svg.setAttribute('style', `width: ${dimensionWidth}px; height: ${dimensionHeight}px;`); }} /> </div> </div> } {contentPostType && ( <Placeholder label={__('SafeSvg', 'safe-svg')} > <p> {__( 'Please select the SVG icon.', 'safe-svg' )} </p> </Placeholder> )} </> ); }; // Set the propTypes SafeSvgBlockEdit.propTypes = { attributes: PropTypes.shape({ svgURL: PropTypes.string, alignment: PropTypes.string, imageID: PropTypes.number, imageWidth: PropTypes.number, imageHeight: PropTypes.number, dimensionWidth: PropTypes.number, dimensionHeight: PropTypes.number, imageSizes: PropTypes.object, }).isRequired, className: PropTypes.string, clientId: PropTypes.string, setAttributes: PropTypes.func.isRequired, }; export default SafeSvgBlockEdit; register.php 0000644 00000010571 15105162063 0007104 0 ustar 00 <?php /** * SafeSvg Block setup * * @package SafeSvg\Blocks\SafeSvgBlock */ namespace SafeSvg\Blocks\SafeSvgBlock; /** * Register the block */ function register() { $n = function( $function ) { return __NAMESPACE__ . "\\$function"; }; // Register the block. \register_block_type_from_metadata( SAFE_SVG_PLUGIN_DIR . '/includes/blocks/safe-svg', [ 'render_callback' => $n( 'render_block_callback' ), ] ); } /** * Render callback method for the block. * * @param array $attributes The blocks attributes * * @return string|\WP_Post[] The rendered block markup. */ function render_block_callback( $attributes ) { // If image is not an SVG return empty string. if ( 'image/svg+xml' !== get_post_mime_type( $attributes['imageID'] ) ) { return ''; } // If we couldn't get the contents of the file, empty string again. if ( ! $contents = file_get_contents( get_attached_file( $attributes['imageID'] ) ) ) { // phpcs:ignore return ''; } /** * The wrapper class name. * * Allows a user to adjust the inline svg wrapper class name. * * @param string The class name. * * @since 2.1.0 */ $class_name = apply_filters( 'safe_svg_inline_class', 'safe-svg-inline' ); /** * The wrapper markup. * * Allows a user to adjust the inline svg wrapper markup. * * @param string The current wrapper markup. * @param string $contents The SVG contents. * @param string $class_name The wrapper class name. * @param int $attachment_id The ID of the attachment. * * @since 2.1.0 */ return apply_filters( 'safe_svg_inline_markup', sprintf( '<div class="wp-block-safe-svg-svg-icon safe-svg-cover" style="text-align: %1$s;"> <div class="safe-svg-inside %2$s%3$s" style="width: %4$spx; height: %5$spx; background-color: var(--wp--preset--color--%6$s); color: var(--wp--preset--color--%7$s); padding-top: %8$s; padding-right: %9$s; padding-bottom: %10$s; padding-left: %11$s; margin-top: %12$s; margin-right: %13$s; margin-bottom: %14$s; margin-left: %15$s;">%16$s</div> </div>', isset( $attributes['alignment'] ) ? esc_attr( $attributes['alignment'] ) : 'left', esc_attr( $class_name ), isset( $attributes['className'] ) ? ' ' . esc_attr( $attributes['className'] ) : '', isset( $attributes['dimensionWidth'] ) ? esc_attr( $attributes['dimensionWidth'] ) : '', isset( $attributes['dimensionHeight'] ) ? esc_attr( $attributes['dimensionHeight'] ) : '', isset( $attributes['backgroundColor'] ) ? esc_attr( $attributes['backgroundColor'] ) : '', isset( $attributes['textColor'] ) ? esc_attr( $attributes['textColor'] ) : '', isset( $attributes['style']['spacing']['padding']['top'] ) ? esc_attr( convert_to_css_variable( $attributes['style']['spacing']['padding']['top'] ) ) : '', isset( $attributes['style']['spacing']['padding']['right'] ) ? esc_attr( convert_to_css_variable( $attributes['style']['spacing']['padding']['right'] ) ) : '', isset( $attributes['style']['spacing']['padding']['bottom'] ) ? esc_attr( convert_to_css_variable( $attributes['style']['spacing']['padding']['bottom'] ) ) : '', isset( $attributes['style']['spacing']['padding']['left'] ) ? esc_attr( convert_to_css_variable( $attributes['style']['spacing']['padding']['left'] ) ) : '', isset( $attributes['style']['spacing']['margin']['top'] ) ? esc_attr( convert_to_css_variable( $attributes['style']['spacing']['margin']['top'] ) ) : '', isset( $attributes['style']['spacing']['margin']['right'] ) ? esc_attr( convert_to_css_variable( $attributes['style']['spacing']['margin']['right'] ) ) : '', isset( $attributes['style']['spacing']['margin']['bottom'] ) ? esc_attr( convert_to_css_variable( $attributes['style']['spacing']['margin']['bottom'] ) ) : '', isset( $attributes['style']['spacing']['margin']['left'] ) ? esc_attr( convert_to_css_variable( $attributes['style']['spacing']['margin']['left'] ) ) : '', $contents ), $contents, $class_name, $attributes['imageID'] ); } /** * Converts a given value to a CSS variable if it starts with 'var:'. * * @param string $value The value to be converted. * @return string The converted value or the original value if it doesn't start with 'var:'. */ function convert_to_css_variable( $value ) { if ( strpos( $value, 'var:' ) === 0 ) { $parts = explode( '|', $value ); if ( count( $parts ) === 3 ) { return 'var(--wp--preset--' . $parts[1] . '--' . $parts[2] . ')'; } } return $value; } frontend.scss 0000644 00000000415 15105162063 0007257 0 ustar 00 .safe-svg-cover { text-align: center; .safe-svg-inside { display: inline-block; max-width: 100%; } svg { fill: currentColor; height: 100%; max-height: 100%; max-width: 100%; width: 100%; } } languages/safe-svg.pot 0000644 00000002050 15106173747 0010761 0 ustar 00 # Copyright (C) 2015 Safe SVG # This file is distributed under the same license as the Safe SVG package. msgid "" msgstr "" "Project-Id-Version: Safe SVG 1.0.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/safe-svg\n" "POT-Creation-Date: 2015-07-04 12:31:03+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" #: safe-svg.php:66 msgid "" "Sorry, this file couldn't be sanitized so for security reasons wasn't " "uploaded" msgstr "" #. Plugin Name of the plugin/theme msgid "Safe SVG" msgstr "" #. Plugin URI of the plugin/theme msgid "https://wordpress.org/plugins/safe-svg/" msgstr "" #. Description of the plugin/theme msgid "" "Allows SVG uploads into Wordpress and sanitizes the SVG before saving it" msgstr "" #. Author of the plugin/theme msgid "Daryll Doyle" msgstr "" #. Author URI of the plugin/theme msgid "http://enshrined.co.uk" msgstr "" dist/safe-svg-block.css 0000644 00000000304 15106173747 0011034 0 ustar 00 .safe-svg-cover{text-align:center}.safe-svg-cover .safe-svg-inside{display:inline-block;max-width:100%}.safe-svg-cover svg{fill:currentColor;height:100%;max-height:100%;max-width:100%;width:100%} dist/safe-svg-block-frontend-rtl.css 0000644 00000000304 15106173747 0013450 0 ustar 00
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings