diff --git a/composer.json b/composer.json index 345bbdefad5cc6595dc140e8c5313abaa22474f0..6a79cb8b9cb4beafebefa156376aceb5fd0e654b 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,6 @@ { "name": "wpdesk/wp-forms", + "description": "WP Forms", "authors": [ { "name": "Marcin", @@ -8,6 +9,10 @@ { "name": "Krzysiek", "email": "krzysiek@wpdesk.pl" + }, + { + "name": "Piotr Potrebka", + "email": "piotr.potrebka@wpdesk.pl" } ], "require": { @@ -31,6 +36,13 @@ }, "autoload-dev": { }, + "extra": { + "text-domain": "wp-forms", + "translations-folder": "lang", + "po-files": { + "pl_PL": "pl_PL.po" + } + }, "scripts": { "phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never", "phpunit-unit-fast": "phpunit --configuration phpunit-unit.xml --no-coverage", diff --git a/lang/pl_PL.mo b/lang/pl_PL.mo new file mode 100644 index 0000000000000000000000000000000000000000..f621cb5cbf4b151eecddd0e12ca29f4eee4f51c7 Binary files /dev/null and b/lang/pl_PL.mo differ diff --git a/lang/pl_PL.po b/lang/pl_PL.po new file mode 100644 index 0000000000000000000000000000000000000000..9fcc8e92b2a6dd2987c89caafb57e27db9785064 --- /dev/null +++ b/lang/pl_PL.po @@ -0,0 +1,44 @@ +msgid "" +msgstr "" +"Project-Id-Version: WP Forms\n" +"POT-Creation-Date: 2021-05-24 10:07+0200\n" +"PO-Revision-Date: 2021-05-24 10:07+0200\n" +"Last-Translator: Piotr Po <potreb@gmail.com>\n" +"Language-Team: Piotr Potrebka <piotr.potrebka@gmail.com>\n" +"Language: pl_PL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.3\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" +"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;" +"_nx_noop:3c,1,2;__ngettext_noop:1,2\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SearchPath-1: src\n" +"X-Poedit-SearchPathExcluded-0: *.js\n" +"X-Poedit-SearchPathExcluded-1: vendor\n" +"X-Poedit-SearchPathExcluded-2: vendor_prefixed\n" + +#: templates/input-image.php:24 +msgid "Set image" +msgstr "Wstaw obraz" + +#: templates/input-image.php:29 +msgid "Remove image" +msgstr "Usuń obraz" + +#: templates/input-image.php:50 +msgid "Select or Upload Media" +msgstr "Wybierz lub prześlij media" + +#: templates/input-image.php:52 +msgid "Use this media" +msgstr "Wybierz" + +#: templates/product-select.php:13 +msgid "Search for a product…" +msgstr "Szukaj produktu…" diff --git a/src/Field/ImageInputField.php b/src/Field/ImageInputField.php new file mode 100644 index 0000000000000000000000000000000000000000..dd4226c14e7e0a051c4ca077c3d870fde3643e91 --- /dev/null +++ b/src/Field/ImageInputField.php @@ -0,0 +1,19 @@ +<?php + +namespace WPDesk\Forms\Field; + +class ImageInputField extends \WPDesk\Forms\Field\BasicField { + + public function __construct() { + parent::__construct(); + $this->set_default_value( '' ); + $this->set_attribute( 'type', 'text' ); + } + + /** + * @return string + */ + public function get_template_name() { + return 'input-image'; + } +} diff --git a/templates/input-image.php b/templates/input-image.php new file mode 100644 index 0000000000000000000000000000000000000000..8b805c6d977cccdff1d187eaf0c802c83041cb3e --- /dev/null +++ b/templates/input-image.php @@ -0,0 +1,79 @@ +<?php +/** + * @var \WPDesk\Forms\Field $field + * @var string $name_prefix + * @var string $value + */ +?> +<?php +$media_container_id = 'media_' . sanitize_key( $field->get_id() ); +?> +<div class="media-input-wrapper" id="<?php echo $media_container_id; ?>"> + <input type="hidden" class="image-field-value" value="<?php echo \esc_html( $value ); ?>" + name="<?php echo \esc_attr( $name_prefix ) . '[' . \esc_attr( $field->get_name() ) . ']'; ?>" + id="<?php echo \esc_attr( $field->get_id() ); ?>"/> + <div class="custom-img-container"> + <?php if ( $value ) : ?> + <img src="<?php echo $value ?>" alt="" width="100"/> + <?php endif; ?> + </div> + <p class="hide-if-no-js"> + <a class="upload-custom-img <?php if ( $value ) { + echo 'hidden'; + } ?>" href="<?php echo $value ?>"> + <?php _e( 'Set image', 'wp-forms' ) ?> + </a> + <a class="delete-custom-img <?php if ( ! $value ) { + echo 'hidden'; + } ?>" href="#"> + <?php _e( 'Remove image', 'wp-forms' ) ?> + </a> + </p> +</div> +<script> + jQuery( function ( $ ) { + var frame, + metaBox = $( '#<?php echo $media_container_id; ?>' ), + addImgLink = metaBox.find( '.upload-custom-img' ), + delImgLink = metaBox.find( '.delete-custom-img' ), + imgContainer = metaBox.find( '.custom-img-container' ), + imgIdInput = metaBox.find( '.image-field-value' ); + + addImgLink.on( 'click', function ( event ) { + event.preventDefault(); + if ( frame ) { + frame.open(); + return; + } + + frame = wp.media( { + title: <?php _e( 'Select or Upload Media', 'wp-forms' ); ?>, + button: { + text: <?php _e( 'Use this media', 'wp-forms' ); ?> + }, + library: { + type: ['image'] + }, + multiple: false + } ); + + frame.on( 'select', function () { + var attachment = frame.state().get( 'selection' ).first().toJSON(); + imgContainer.append( '<img src="' + attachment.url + '" alt="" width="100" />' ); + imgIdInput.val( attachment.url ); + addImgLink.addClass( 'hidden' ); + delImgLink.removeClass( 'hidden' ); + } ); + frame.open(); + } ); + + delImgLink.on( 'click', function () { + imgContainer.html( '' ); + addImgLink.removeClass( 'hidden' ); + delImgLink.addClass( 'hidden' ); + imgIdInput.val( '' ); + return false; + } ); + + } ); +</script>