Skip to content

Commit

Permalink
Merge pull request #31 from michelegiorgi/development
Browse files Browse the repository at this point in the history
release 1.3.4
  • Loading branch information
michelegiorgi authored Jul 2, 2021
2 parents a51df06 + f8fa7fc commit 5e15d77
Show file tree
Hide file tree
Showing 14 changed files with 3,154 additions and 3,315 deletions.
8 changes: 3 additions & 5 deletions admin/class-formality-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@ public function block_categories($categories, $post) {
);
}

public function filter_blocks($allowed_block_types, $post) {
if( !is_object($post) ) { $post = get_post(); }
if ( $post->post_type == 'formality_form' ) {
return $this->get_allowed('blocks');
}
public function filter_blocks($allowed_block_types, $editorcontext) {
$post = property_exists($editorcontext, 'post') ? $editorcontext->post : $editorcontext;
if ( $post->post_type == 'formality_form' ) { return $this->get_allowed('blocks'); }
return $allowed_block_types;
}

Expand Down
24 changes: 11 additions & 13 deletions admin/class-formality-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function email_send($to, $data) {
$render = new Formality_Results($this->formality, $this->version);
$fields = $render->result_data($data['result_id'], false);
$message = $this->email_content($fields, $data);
$subject = __("New result for", "formality") . ' ' . $data['form_title'];
$subject = __("New result for", "formality") . ' ' . $data['form_title'] . ' (' . $data['result_id'] . ')';

add_filter( 'wp_mail_content_type', [$this, 'email_content_type']);
add_filter( 'wp_mail_from_name', [$this, 'sender_name']);
Expand All @@ -45,18 +45,16 @@ public function email_content_type(){
return "text/html";
}

public function email_content($fields, $data){
$content = "";
$response = wp_remote_get(plugin_dir_url(__DIR__) . "public/templates/notification.html");
if ( is_array( $response ) && ! is_wp_error( $response ) ) {
$template = $response['body'];
$link = '<a href="' . get_admin_url() . 'post.php?post=' .$data['result_id']. '&action=edit">' . __('View this result', 'formality') . '</a> ' . __('in your admin dashboard', 'formality') . '<br>';
$link .= '<a href="' . get_admin_url() . 'post.php?post=' .$data['form_id']. '&action=edit">' . __('View all results', 'formality') . '</a> ' . __('for', 'formality') . ' ' . $data['form_title'] . '<br><br>';
$link .= 'Made with <strong>Formality</strong>';
$fields = __("New result for", "formality") . '<h2 style="margin:0">' . $data['form_title'] . '</h2><br><br>' . $fields . '<br>';
$content = str_replace('%%DATA%%', $fields, $template);
$content = str_replace('%%LINK%%', $link, $content);
}
public function email_content($content="", $data){
$file_name = 'notification-formality.php';
$file_path = locate_template($file_name) ? locate_template($file_name) : plugin_dir_path(__DIR__) . "public/templates/notification.php";
$result_link = get_admin_url() . 'post.php?post=' .$data['result_id']. '&action=edit';
$results_link = get_admin_url() . 'post.php?post=' .$data['form_id']. '&action=edit';
$title = $data['form_title'];
ob_start();
include($file_path);
$content = ob_get_contents();
ob_end_clean();
return $content;
}

Expand Down
12 changes: 7 additions & 5 deletions admin/class-formality-results.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ public function field($result_id, $block, $index) {
}
$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>';
if($fieldvalue) {
$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 . '">' . __('Download', 'formality') . '</a>';
}
}
} else {
$fieldvalue = nl2br($fieldvalue);
Expand Down
7 changes: 6 additions & 1 deletion assets/styles/admin/editor_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
pointer-events: none;
}
}
&__content-area {
background: none !important;
> div {
background: none !important;
}
}
.editor-styles-wrapper {
background: transparent;
color: var(--formality_col1);
Expand Down Expand Up @@ -367,7 +373,6 @@
}
}
.block-list-appender__toggle {
background: none;
width: 100%;
margin: 0;
height: auto;
Expand Down
19 changes: 10 additions & 9 deletions assets/styles/public/components/_fields.scss
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,8 @@
&--upload {
.formality__input {
cursor: pointer;
min-height: 7.5rem;
padding-bottom: 0.75em;
min-height: 7em;
input {
width: 0.1px;
height: 0.1px;
Expand All @@ -971,19 +972,19 @@
p {
width: 100%;
margin-top: 0;
margin-bottom: 0.75rem;
margin-bottom: 0.75em;
display: flex;
&:before {
content: "cloud_upload";
font-family: 'Material Icons';
font-size: 1em;
margin-right: 0.5rem;
margin-right: 0.5em;
white-space: nowrap;
}
}
span {
width: 50%;
font-size: 1rem;
font-size: 0.9em;
strong {
display: block;
max-height: 2.8em;
Expand All @@ -1000,7 +1001,7 @@
position: relative;
line-height: 1;
flex-shrink: 0;
margin-left: 0.5rem;
margin-left: 0.5em;
&:after {
font-family: 'Material Icons';
content: "check_circle";
Expand All @@ -1023,9 +1024,9 @@
i {
flex-shrink: 0;
display: inline-block;
width: 4rem;
height: 4rem;
margin-right: 1rem;
width: 4em;
height: 4em;
margin-right: 1em;
background-position: center center;
background-size: cover;
flex-shrink: 0;
Expand All @@ -1049,7 +1050,7 @@
top: 50%;
transform: translate(-50%, -50%);
position: absolute;
font-size: 1.6rem;
font-size: 1.6em;
white-space: nowrap;
}
&[style] {
Expand Down
4 changes: 2 additions & 2 deletions formality.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Formality
* Plugin URI: https://formality.dev
* Description: Forms made simple (and cute). Designless, multistep, conversational, secure, all-in-one WordPress forms plugin.
* Version: 1.3.3
* Version: 1.3.4
* Author: Michele Giorgi
* Author URI: https://giorgi.io
* License: GPLv3
Expand Down Expand Up @@ -51,7 +51,7 @@
/**
* Currently plugin version.
*/
define( 'FORMALITY_VERSION', '1.3.3' );
define( 'FORMALITY_VERSION', '1.3.4' );
define( 'FORMALITY_PATH', plugin_dir_path( __FILE__ ));

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/class-formality.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Formality {
*/
public function __construct() {

$this->version = defined( 'FORMALITY_VERSION' ) ? FORMALITY_VERSION : '1.3.3';
$this->version = defined( 'FORMALITY_VERSION' ) ? FORMALITY_VERSION : '1.3.4';
$this->formality = 'formality';
$this->fse = version_compare( $GLOBALS['wp_version'], '5.7.9', '>' );

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Formality",
"version": "1.3.3",
"version": "1.3.4",
"author": "Michele Giorgi <[email protected]>",
"homepage": "https://giorgi.io",
"private": true,
Expand Down Expand Up @@ -56,7 +56,8 @@
"sass-loader": "^9.0.3",
"stylelint": "^13.6.1",
"stylelint-config-standard": "^20.0.0",
"vue-template-compiler": "^2.6.12"
"vue-template-compiler": "^2.6.12",
"laravel-mix-banner": "^0.1.4"
},
"dependencies": {
"clone-deep": "^4.0.1",
Expand Down
12 changes: 0 additions & 12 deletions public/templates/notification.html

This file was deleted.

44 changes: 44 additions & 0 deletions public/templates/notification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Formality email notification template
* You can override this by putting a notification-formality.php file inside your active theme's directory.
* Don't forget to use basic html tags and inline css rules.
*
* Some inherited variables that you can easily use:
* $title - Your form title
* $content - Html table with all form data
* $result_link - Direct link to this result in your admin dashboard
* $results_link - Direct link to all results for this form
*
* @link https://formality.dev
* @since 1.3.4
* @package Formality
* @subpackage Formality/public
* @author Michele Giorgi <[email protected]>
* @license GPL-3.0+
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Formality email template</title>
</head>
<body>
<div style="font-family: sans-serif;">
<?php _e("New result for", "formality"); ?>
<h2 style="margin: 0; font-family: sans-serif;"><?php echo $title; ?></h2>
<br><br>
<?php echo $content; ?>
<br><br>
<a style="font-family: sans-serif;" href="<?php echo $result_link; ?>"><?php _e('View this result', 'formality'); ?></a>
<?php _e('in your admin dashboard', 'formality'); ?>
<br>
<a style="font-family: sans-serif;" href="<?php echo $results_link; ?>"><?php _e('View all results', 'formality'); ?></a>
<?php _e('for', 'formality'); ?> <?php echo $title; ?>
<br><br>
<?php _e("Made with", "formality"); ?> <a href="https://formality.dev" style="color:inherit; font-family: sans-serif"><strong>Formality</strong></a>
</div>
</body>
</html>
10 changes: 9 additions & 1 deletion public/templates/single.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?php
/**
* The template for displaying single formality form
* Formality standalone form template
* You can override this by putting a single-formality.php file inside your active theme's directory.
*
* @link https://formality.dev
* @since 1.0
* @package Formality
* @subpackage Formality/public
* @author Michele Giorgi <[email protected]>
* @license GPL-3.0+
*/
?>
<!DOCTYPE html>
Expand Down
14 changes: 11 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: michelegiorgi
Donate link: https://www.paypal.me/michelegiorgi/
Tags: form, conversational, multistep, design form, gutenberg, block editor
Requires at least: 5.6
Tested up to: 5.7
Stable tag: 1.3.3
Tested up to: 5.8
Stable tag: 1.3.4
Requires PHP: 7.0
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
Expand Down Expand Up @@ -41,7 +41,7 @@ You can extend Formality plugin functionality with its custom hooks. Formality h

= Translations =

Formality is now available in 3 languages. You can now choose between English, Italian and Indonesian (Thanks to [Kharis Sulistiyono](https://profiles.wordpress.org/kharisblank/)). You can help translating Formality to your language on [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/formality)
Formality is now available in 5 languages. You can now choose between English, Italian, Indonesian, Czech and Swedish (Thanks to WordPress Community). You can help translating Formality to your language on [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/formality)

== Installation ==

Expand All @@ -61,6 +61,14 @@ You will find **Formality** menu in your WordPress admin screen.

== Changelog ==

= 1.3.4 =
Release Date: Jul 2nd, 2021

* Add email notification template
* Gutenberg 10.9+ compatibility
* WordPress 5.8 FSE compatibility
* Minor file upload UI fixes

= 1.3.3 =
Release Date: Jun 13th, 2021

Expand Down
14 changes: 12 additions & 2 deletions webpack.mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ Mix.manifest.refresh = _ => void 0
const mix = require('laravel-mix');
const devUrl = 'formality.local';
require('laravel-mix-copy-watched');
require('laravel-mix-banner');

mix
.setPublicPath('./dist')
.browserSync(devUrl);

mix
.sass('assets/styles/public.scss', 'styles/formality-public.css')
.sass('assets/styles/admin.scss', 'styles/formality-admin.css')
.sass('assets/styles/admin.scss', 'styles/formality-admin.css');

mix
.js('assets/scripts/public.js', 'scripts/formality-public.js')
.js('assets/scripts/editor.js', 'scripts/formality-editor.js')
.js('assets/scripts/admin.js', 'scripts/formality-admin.js')
.banner({ banner: 'Formality v1.3.4' });

mix
.copyWatched('assets/images/admin/**', 'dist/images/admin')
Expand All @@ -39,7 +41,15 @@ mix
.autoload({ jquery: ['$', 'window.jQuery'] })
.options({
processCssUrls: false,
terser: { extractComments: false }
terser: {
terserOptions: {
mangle: { reserved: ['__'] },
output: {
comments ({}, { value }) { return value.startsWith("! Formality v") }
}
},
extractComments: false
}
})
.sourceMaps(false, 'source-map')
.version();
Loading

0 comments on commit 5e15d77

Please sign in to comment.