Skip to content

Commit

Permalink
Merge pull request #14 from michelegiorgi/development
Browse files Browse the repository at this point in the history
release 1.3
  • Loading branch information
michelegiorgi authored Apr 5, 2021
2 parents 8087302 + f10fad1 commit e759eaf
Show file tree
Hide file tree
Showing 69 changed files with 2,010 additions and 1,465 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[![Formality](https://formality.dev/download/mark-repo-final.svg)](https://formality.dev)

# Formality ![license](https://img.shields.io/github/license/michelegiorgi/formality?color=%231B4DDB&style=flat-square) ![license](https://img.shields.io/github/v/release/michelegiorgi/formality?color=%231B4DDB&style=flat-square)
# [![Formality](https://formality.dev/download/logo-github.svg)](https://formality.dev) ![license](https://img.shields.io/github/license/michelegiorgi/formality?color=%231B4DDB&style=flat-square) ![license](https://img.shields.io/github/v/release/michelegiorgi/formality?color=%231B4DDB&style=flat-square)

**[New plugin website](https://formality.dev)**  |  [Wordpress.org page](https://wordpress.org/plugins/formality)  |  [Donate link](https://www.paypal.me/michelegiorgi/)
Designless, multistep, conversational, secure, all-in-one WordPress forms plugin.
Expand All @@ -12,7 +10,7 @@ If you are not a developer, please download the latest release of the Formality

## Requirements

* [WordPress](https://wordpress.org/) >= 5.5
* [WordPress](https://wordpress.org/) >= 5.6

## Plugin setup

Expand Down
2 changes: 1 addition & 1 deletion admin/class-formality-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* The admin-specific functionality of the plugin.
*
* @link https://formality.dev
* @since 1.0.0
* @since 1.0
* @package Formality
* @subpackage Formality/admin
* @author Michele Giorgi <[email protected]>
Expand Down
18 changes: 15 additions & 3 deletions admin/class-formality-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* The editor-specific functionality of the plugin.
*
* @link https://formality.dev
* @since 1.0.0
* @since 1.0
* @package Formality
* @subpackage Formality/admin
* @author Michele Giorgi <[email protected]>
Expand Down Expand Up @@ -41,17 +41,28 @@ public function register_blocks() {

public function enqueue_scripts() {
$upload = wp_upload_dir();
$formats = array();
$mimes = get_allowed_mime_types();
$maxsize = wp_max_upload_size() / 1048576;
if(!empty($mimes)) {
foreach ($mimes as $type => $mime) {
$multiple = explode("|", $type);
foreach ($multiple as $single) {
$formats[] = $single;
}
}
}
wp_enqueue_script( $this->formality . "-editor", plugin_dir_url(__DIR__) . 'dist/scripts/formality-editor.js', array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'wp-plugins', 'wp-edit-post' ), $this->version, false );

wp_localize_script( $this->formality . "-editor", 'formality', array(
'plugin_url' => str_replace('admin/', '', plugin_dir_url( __FILE__ )),
'templates_url' => $upload['baseurl'] . '/formality/templates',
'templates_count' => get_option('formality_templates', 0),
'admin_url' => get_admin_url(),
'api' => esc_url_raw(rest_url()),
'nonce' => wp_create_nonce('wp_rest'),
'upload_formats' => $formats,
'upload_max' => $maxsize
));

wp_set_script_translations( $this->formality . "-editor", 'formality', plugin_dir_path( __DIR__ ) . 'languages' );
}

Expand Down Expand Up @@ -122,6 +133,7 @@ public function get_allowed( $type = 'blocks' ) {
'formality/switch',
'formality/multiple',
'formality/rating',
'formality/upload',
'formality/step',
'formality/message',
'formality/media',
Expand Down
2 changes: 1 addition & 1 deletion admin/class-formality-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Build and send notifications.
*
* @link https://formality.dev
* @since 1.0.0
* @since 1.0
* @package Formality
* @subpackage Formality/admin
* @author Michele Giorgi <[email protected]>
Expand Down
10 changes: 9 additions & 1 deletion admin/class-formality-results.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Results functions.
*
* @link https://formality.dev
* @since 1.0.0
* @since 1.0
* @package Formality
* @subpackage Formality/admin
* @author Michele Giorgi <[email protected]>
Expand Down Expand Up @@ -124,13 +124,21 @@ public function result_data($result_id = 0, $echo = true) {
public function field($result_id, $block, $index) {
if(!isset($block["attrs"]['exclude'])) {
$fieldname = "field_" . $block["attrs"]["uid"];
$type = str_replace("formality/","",$block['blockName']);
$fieldvalue = get_post_meta( $result_id, $fieldname, true );
if(is_array($fieldvalue)) {
$values = "";
foreach($fieldvalue as $subvalue){
$values .= $subvalue . '<br>';
}
$fieldvalue = $values;
} else if($type=="upload") {
$ext = pathinfo($fieldvalue, PATHINFO_EXTENSION);
if(in_array($ext, array('gif', 'png', 'bmp', 'jpg', 'jpeg', 'svg'))) {
$fieldvalue = '<a target="_blank" href="' . $fieldvalue . '"><img style="max-width:100%; height:auto;" src="' . $fieldvalue . '" alt="" /></a>';
} else {
$fieldvalue = '<a target="_blank" href="' . $fieldvalue . '">' . $fieldvalue . '</a>';
}
} else {
$fieldvalue = nl2br($fieldvalue);
}
Expand Down
2 changes: 1 addition & 1 deletion admin/class-formality-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Helper functions and tools of the plugin.
*
* @link https://formality.dev
* @since 1.0.0
* @since 1.0
* @package Formality
* @subpackage Formality/admin
* @author Michele Giorgi <[email protected]>
Expand Down
Binary file added assets/images/admin/block-preview-upload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/source/blockpreview.sketch
Binary file not shown.
3 changes: 2 additions & 1 deletion assets/scripts/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import './editor/blocks/select.js';
import './editor/blocks/multiple.js';
import './editor/blocks/switch.js';
import './editor/blocks/rating.js';
import './editor/blocks/upload.js';

import './editor/blocks/step.js';
import './editor/blocks/message.js';
import './editor/blocks/media.js';

import './editor/blocks/widget.js';
import './editor/blocks/widget.js';
8 changes: 4 additions & 4 deletions assets/scripts/editor/blocks/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
mainOptions,
advancedPanel,
hasRules,
inlineName,
} from '../utility/blocks.js'

const { __ } = wp.i18n;
Expand Down Expand Up @@ -80,13 +81,12 @@ registerBlockType( blockName, {
<div
className={ "formality__field formality__field--email" + ( focus ? ' formality__field--focus' : '' ) + ( required ? ' formality__field--required' : '' ) + ( value ? ' formality__field--filled' : '' ) }
>
<label
<div
className="formality__label"
htmlFor={ uid }
>
{ name ? name : __('Field name', 'formality') }
{ inlineName(props) }
<Icon icon={ hasRules(rules) ? "hidden" : "" } />
</label>
</div>
<div
className="formality__input"
>
Expand Down
8 changes: 4 additions & 4 deletions assets/scripts/editor/blocks/multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
mainOptions,
advancedPanel,
hasRules,
inlineName,
} from '../utility/blocks.js'

import { iconMultiple as blockicon } from '../utility/icons.js'
Expand Down Expand Up @@ -162,13 +163,12 @@ registerBlockType( blockName, {
<div
className={ "formality__field formality__field--multiple" + ( focus ? ' formality__field--focus' : '' ) + ( required ? ' formality__field--required' : '' ) + ( value ? ' formality__field--filled' : '' ) }
>
<label
<div
className="formality__label"
htmlFor={ uid }
>
{ name ? name : __('Field name', 'formality') }
{ inlineName(props) }
<Icon icon={ hasRules(rules) ? "hidden" : "" } />
</label>
</div>
<div
className="formality__input"
data-placeholder={ placeholder ? placeholder : __('Select your choice', 'formality') }
Expand Down
8 changes: 4 additions & 4 deletions assets/scripts/editor/blocks/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
mainOptions,
advancedPanel,
hasRules,
inlineName,
} from '../utility/blocks.js'

const { __ } = wp.i18n;
Expand Down Expand Up @@ -108,13 +109,12 @@ registerBlockType( blockName, {
<div
className={ "formality__field formality__field--text" + ( focus ? ' formality__field--focus' : '' ) + ( required ? ' formality__field--required' : '' ) + ( value ? ' formality__field--filled' : '' ) }
>
<label
<div
className="formality__label"
htmlFor={ uid }
>
{ name ? name : __('Field name', 'formality') }
{ inlineName(props) }
<Icon icon={ hasRules(rules) ? "hidden" : "" } />
</label>
</div>
<div
className="formality__input"
>
Expand Down
8 changes: 4 additions & 4 deletions assets/scripts/editor/blocks/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
mainOptions,
advancedPanel,
hasRules,
inlineName,
} from '../utility/blocks.js'

const { __ } = wp.i18n;
Expand Down Expand Up @@ -121,13 +122,12 @@ registerBlockType( blockName, {
<div
className={ "formality__field formality__field--rating" + ( focus ? ' formality__field--focus' : '' ) + ( required ? ' formality__field--required' : '' ) + ( value ? ' formality__field--filled' : '' ) }
>
<label
<div
className="formality__label"
htmlFor={ uid }
>
{ name ? name : __('Field name', 'formality') }
{ inlineName(props) }
<Icon icon={ hasRules(rules) ? "hidden" : "" } />
</label>
</div>
<div
className="formality__input"
>
Expand Down
10 changes: 5 additions & 5 deletions assets/scripts/editor/blocks/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
mainOptions,
advancedPanel,
hasRules,
inlineName,
} from '../utility/blocks.js'

import { iconSelect as blockicon } from '../utility/icons.js'
Expand Down Expand Up @@ -119,13 +120,12 @@ registerBlockType( blockName, {
<div
className={ "formality__field formality__field--select" + ( focus ? ' formality__field--focus' : '' ) + ( required ? ' formality__field--required' : '' ) + ( value ? ' formality__field--filled' : '' ) }
>
<label
<div
className="formality__label"
htmlFor={ uid }
>
{ name ? name : __('Field name', 'formality') }
{ inlineName(props) }
<Icon icon={ hasRules(rules) ? "hidden" : "" } />
</label>
</div>
<div
className="formality__input"
>
Expand All @@ -141,7 +141,7 @@ registerBlockType( blockName, {
value=""
>{ value ? value : (placeholder ? placeholder : __('Select your choice', 'formality')) }</option>
</select>
<div className="formality__input__status" data-placeholder={ placeholder ? placeholder : __('Type your answer here', 'formality') }/>
<div className="formality__input__status" data-placeholder={ placeholder ? placeholder : __('Select your choice', 'formality') }/>
</div>
</div>,
])
Expand Down
8 changes: 4 additions & 4 deletions assets/scripts/editor/blocks/switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
mainOptions,
advancedPanel,
hasRules,
inlineName,
} from '../utility/blocks.js'

const { __ } = wp.i18n;
Expand Down Expand Up @@ -92,13 +93,12 @@ registerBlockType( blockName, {
<div
className={ "formality__field formality__field--switch" + ( focus ? ' formality__field--focus' : '' ) + ( required ? ' formality__field--required' : '' ) + ( value ? ' formality__field--filled' : '' ) }
>
<label
<div
className="formality__label"
htmlFor={ uid }
>
{ name ? name : __('Field name', 'formality') }
{ inlineName(props) }
<Icon icon={ hasRules(rules) ? "hidden" : "" } />
</label>
</div>
<div
className="formality__input"
>
Expand Down
9 changes: 5 additions & 4 deletions assets/scripts/editor/blocks/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
mainOptions,
advancedPanel,
hasRules,
inlineName,
} from '../utility/blocks.js'

const { __ } = wp.i18n;
Expand Down Expand Up @@ -80,17 +81,17 @@ registerBlockType( blockName, {
<div
className={ "formality__field formality__field--text" + ( focus ? ' formality__field--focus' : '' ) + ( required ? ' formality__field--required' : '' ) + ( value ? ' formality__field--filled' : '' ) }
>
<label
<div
className="formality__label"
htmlFor={ uid }
>
{ name ? name : __('Field name', 'formality') }
{ inlineName(props) }
<Icon icon={ hasRules(rules) ? "hidden" : "" } />
</label>
</div>
<div
className="formality__input"
>
<input
tabindex={ "-1" }
type="text"
id={ uid }
name={ uid }
Expand Down
8 changes: 4 additions & 4 deletions assets/scripts/editor/blocks/textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
mainOptions,
advancedPanel,
hasRules,
inlineName,
} from '../utility/blocks.js'

const { __ } = wp.i18n;
Expand Down Expand Up @@ -102,13 +103,12 @@ registerBlockType( blockName, {
<div
className={ "formality__field formality__field--textarea" + ( focus ? ' formality__field--focus' : '' ) + ( required ? ' formality__field--required' : '' ) + ( value ? ' formality__field--filled' : '' ) }
>
<label
<div
className="formality__label"
htmlFor={ uid }
>
{ name ? name : __('Field name', 'formality') }
{ inlineName(props) }
<Icon icon={ hasRules(rules) ? "hidden" : "" } />
</label>
</div>
<div
className="formality__input"
>
Expand Down
Loading

0 comments on commit e759eaf

Please sign in to comment.