Skip to content

Commit

Permalink
Merge pull request #35 from michelegiorgi/development
Browse files Browse the repository at this point in the history
release v1.4
  • Loading branch information
michelegiorgi authored Sep 6, 2021
2 parents 0af15d6 + e36decf commit 6e13547
Show file tree
Hide file tree
Showing 28 changed files with 1,817 additions and 739 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# [![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)
[![Formality](https://formality.dev/download/logo-github-2.svg)](https://formality.dev)
# Formality ![license](https://img.shields.io/github/license/michelegiorgi/formality?color=%230A01B3&style=flat-square) ![license](https://img.shields.io/github/v/release/michelegiorgi/formality?color=%230A01B3&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 @@ -10,7 +11,7 @@ If you are not a developer, please download the latest release of the Formality

## Requirements

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

## Plugin setup

Expand Down
141 changes: 88 additions & 53 deletions admin/class-formality-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,68 +95,103 @@ public function link_website( $links, $file ) {
return $links;
}

public function welcome_notice() {
public function admin_header() {
global $pagenow, $typenow;
if ('edit.php' === $pagenow && strpos($typenow, 'formality_') !== false) {
if(strpos($typenow, 'formality_') !== false) {
global $wp_post_types;
$labels = $wp_post_types[$typenow]->labels;
?>
<div class="wrap wrap--formality">
<h1 class="wp-heading-inline"><a href="#"><i class="dashicons-formality-fo"></i></a><?php echo $labels->name; ?></h1>
<?php if ($typenow=='formality_form') { ?>
<?php $templates = get_option('formality_templates', 0); ?>
<?php $plugin_tools = new Formality_Tools( $this->formality, $this->version ); ?>
<a href="<?php echo admin_url('post-new.php?post_type='.$typenow); ?>" class="page-title-action"><?php echo $labels->add_new; ?></a>
<?php $welcome = get_option('formality_welcome'); ?>
<a class="formality-welcome-toggle <?php echo $welcome ? 'close' : 'open'; ?>" href="<?php echo $plugin_tools->toggle_panel_link_url(); ?>"><span><?php _e('Hide panel', 'formality'); ?></span><span><?php _e('Show panel', 'formality'); ?></span> <i class="dashicons-formality"></i></a>
<div class="welcome-panel<?php echo $welcome ? '' : ' hidden'; ?>">
<a class="welcome-panel-close formality-welcome-toggle" href="<?php echo $plugin_tools->toggle_panel_link_url(false); ?>"><?php _e('Hide panel', 'formality'); ?></a>
<div class="welcome-panel-content">
<h2><?php _e('Welcome to Formality!', 'formality'); ?></h2>
<p class="about-description"><?php _e('Everything is ready to start building your forms:', 'formality'); ?></p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<h3><?php _e('Get Started', 'formality'); ?></h3>
<?php $samplelink = !$templates ? '#TB_inline?&width=380&height=210&inlineId=formality-sample-thick" class="thickbox' : $plugin_tools->generate_sample_link_url(); ?>
<a class="button button-primary button-hero" href="<?php echo admin_url('post-new.php?post_type=formality_form'); ?>"><?php _e('Create your first form', 'formality'); ?></a>
<p><?php /* translators: %s: generate sample forms link */ echo sprintf( __('or <a href="%s">generate a couple of sample forms</a> to practice with', 'formality'), $samplelink); ?> <span class="badge"></span></p>
<p><?php /* translators: %s: import form link */ echo sprintf( __('or <a href="%s">import your forms</a> with the WordPress import tool', 'formality'), admin_url('admin.php?import=wordpress')); ?></p>
<?php if(!$templates) {?>
<?php add_thickbox(); ?>
<div id="formality-sample-thick" style="display:none;">
<p><?php _e('Our sample forms are made with a selection of the best Unsplash photos. To start using them, you first have to download these photos from Unsplash servers. Click the button below to start the sample forms generation, and the images download process in the background.', 'formality');?></p>
<a class="button button-primary" href="<?php echo $plugin_tools->generate_sample_link_url(); ?>"><?php _e( 'Generate sample forms and download background images', 'formality' ); ?></a>
<p>
<a target="_blank" rel="noopener noreferrer" href="https://unsplash.com/terms"><?php _e( 'Terms and conditions', 'formality' ); ?></a>&nbsp;
<a target="_blank" rel="noopener noreferrer" href="https://unsplash.com/license"><?php _e( 'License', 'formality' ); ?></a>
</p>
</div>
<?php } ?>
</div>
<div class="welcome-panel-column">
<h3><?php _e('Quick links', 'formality'); ?></h3>
<ul>
<li><a href="<?php echo admin_url('edit.php?post_type=formality_form'); ?>" class="welcome-icon welcome-edit-page"><?php _e('Manage your forms', 'formality'); ?></a></li>
<li><a href="<?php echo admin_url('edit.php?post_type=formality_result'); ?>" class="welcome-icon welcome-view-site"><?php _e('View or export your results', 'formality'); ?></a></li>
<li><a target="_blank" href="https://wordpress.org/support/plugin/formality" class="welcome-icon dashicons-warning"><?php _e('Request support or report a bug', 'formality'); ?></a></li>
<li><a target="_blank" href="https://formality.dev" class="welcome-icon welcome-learn-more"><?php _e('Learn more about Formality', 'formality'); ?></a></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h3><?php _e('Support us', 'formality'); ?></h3>
<p><?php /* translators: %s: donate link + 5 stars review link */ echo sprintf(__('If you enjoy using Formality, please consider <a href="%1$s">making a donation</a>, or rate this plugin with a <a href="%2$s">5 stars review</a> on the WordPress plugin directory. You can also subscribe to our newsletter (max once a month).', 'formality'), 'https://www.paypal.me/michelegiorgi/" target="_blank', 'https://wordpress.org/support/plugin/formality/reviews/?filter=5#new-post" target="_blank'); ?></p>
<form class="formality-newsletter" novalidate>
<input placeholder="<?php _e('Your email address', 'formality'); ?>" type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
<input type="submit" value="<?php _e('Subscribe', 'formality'); ?>" name="subscribe" id="mc-embedded-subscribe" class="button">
<br><label class="checkbox subfield" for="gdpr_33536"><input type="checkbox" id="gdpr_33536" name="gdpr[33536]" value="Y" class="av-checkbox "><small><?php /* translators: %s: privacy policy link */ echo sprintf( __('Accept our <a href="%s">privacy policy</a>.', 'formality'), 'https://www.iubenda.com/privacy-policy/87262067/legal" target="_blank'); ?></small></label>
<div class="formality-newsletter-result"></div>
</form>
<h1 class="wp-heading-inline">
<i></i>
<?php
if($pagenow == 'edit.php'){
$object = get_queried_object();
if($typenow == 'formality_result' && property_exists($object, 'term_id')) {
/* translators: %s: Results for <form name> */
echo sprintf(__('Results for %s', 'formality'), $object->name);
} else {
echo $labels->name;
}
} else {
echo $labels->singular_name . ' ' . get_the_ID();
}
?>
</h1>
<?php
$updated = true;
$update_plugins = get_site_transient('update_plugins');
if(!empty( $update_plugins->response )) {
$updates = array_keys($update_plugins->response);
foreach ($updates as $update) { if($update == 'formality/formality.php') { $updated = false; }}
}
echo '<span class="formality-header-version'. ($updated ? ' updated' : '') .'">' . $this->version . '</span>';
?>
<?php
if($pagenow == 'edit.php' && $typenow == 'formality_result' && isset($object)) {
if(property_exists($object, 'term_id')) {
$results = new Formality_Results( $this->formality, $this->version );
$results->export_panel(str_replace("form_","",$object->slug));
}
} else if ($pagenow == 'edit.php' && $typenow == 'formality_form') {
$templates = get_option('formality_templates', 0);
$plugin_tools = new Formality_Tools( $this->formality, $this->version );
$total = $GLOBALS['wp_query']->found_posts; ?>
<a href="<?php echo admin_url('post-new.php?post_type='.$typenow); ?>" class="page-title-action"><?php echo $labels->add_new; ?></a>
<?php $welcome = get_option('formality_welcome'); ?>
<a class="formality-welcome-toggle <?php echo $welcome ? 'close' : 'open'; ?>" href="<?php echo $plugin_tools->toggle_panel_link_url(); ?>"><span><?php _e('Hide panel', 'formality'); ?></span><span><?php _e('Show panel', 'formality'); ?></span></a>
<div class="welcome-panel<?php echo $welcome ? '' : ' hidden'; ?>">
<a class="welcome-panel-close formality-welcome-toggle" href="<?php echo $plugin_tools->toggle_panel_link_url(false); ?>"><?php _e('Hide panel', 'formality'); ?></a>
<div class="welcome-panel-content">
<h2><?php _e('Welcome to Formality!', 'formality'); ?></h2>
<p class="about-description"><?php _e('Everything is ready to start building your forms:', 'formality'); ?></p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<h3><?php _e('Get Started', 'formality'); ?></h3>
<?php $samplelink = !$templates ? '#TB_inline?&width=380&height=210&inlineId=formality-sample-thick" class="thickbox' : $plugin_tools->generate_sample_link_url(); ?>
<a class="button button-hero" href="<?php echo admin_url('post-new.php?post_type=formality_form'); ?>">
<strong><?php echo $total ? __('Add new form', 'formality') : __('Create your first form', 'formality'); ?></strong>
</a>
<p><?php /* translators: %s: generate sample forms link */ echo sprintf( __('or <a href="%s">generate a couple of sample forms</a> to practice with', 'formality'), $samplelink); ?></p>
<p><?php /* translators: %s: import form link */ echo sprintf( __('or <a href="%s">import your forms</a> with the WordPress import tool', 'formality'), admin_url('admin.php?import=wordpress')); ?></p>
<?php if(!$templates) {?>
<?php add_thickbox(); ?>
<div id="formality-sample-thick" style="display:none;">
<p><?php _e('Our sample forms are made with a selection of the best Unsplash photos. To start using them, you first have to download these photos from Unsplash servers. Click the button below to start the sample forms generation, and the images download process in the background.', 'formality');?></p>
<a class="button button-primary" href="<?php echo $plugin_tools->generate_sample_link_url(); ?>"><?php _e( 'Generate sample forms and download background images', 'formality' ); ?></a>
<p>
<a target="_blank" rel="noopener noreferrer" href="https://unsplash.com/terms"><?php _e( 'Terms and conditions', 'formality' ); ?></a>&nbsp;
<a target="_blank" rel="noopener noreferrer" href="https://unsplash.com/license"><?php _e( 'License', 'formality' ); ?></a>
</p>
</div>
<?php } ?>
</div>
<div class="welcome-panel-column">
<h3><?php _e('Quick links', 'formality'); ?></h3>
<ul>
<li><a href="<?php echo admin_url('edit.php?post_type=formality_form'); ?>" class="welcome-icon welcome-edit-page"><?php _e('Manage your forms', 'formality'); ?></a></li>
<li><a href="<?php echo admin_url('edit.php?post_type=formality_result'); ?>" class="welcome-icon welcome-view-site"><?php _e('View or export your results', 'formality'); ?></a> <span class="badge"></span></li>
<li><a target="_blank" href="https://wordpress.org/support/plugin/formality" class="welcome-icon dashicons-warning"><?php _e('Request support or report a bug', 'formality'); ?></a></li>
<li><a target="_blank" href="https://formality.dev" class="welcome-icon welcome-learn-more"><?php _e('Learn more about Formality', 'formality'); ?></a></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h3><?php _e('Support us', 'formality'); ?></h3>
<p><?php /* translators: %s: donate link + 5 stars review link */ echo sprintf(__('If you enjoy using Formality, please consider <a href="%1$s">making a donation</a>, or rate this plugin with a <a href="%2$s">5 stars review</a> on the WordPress plugin directory. You can also subscribe to our newsletter (max once a month).', 'formality'), 'https://www.paypal.me/michelegiorgi/" target="_blank', 'https://wordpress.org/support/plugin/formality/reviews/?filter=5#new-post" target="_blank'); ?></p>
<form class="formality-newsletter" novalidate>
<input placeholder="<?php _e('Your email address', 'formality'); ?>" type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
<input type="submit" value="<?php _e('Subscribe', 'formality'); ?>" name="subscribe" id="mc-embedded-subscribe" class="button">
<br><label class="checkbox subfield" for="gdpr_33536"><input type="checkbox" id="gdpr_33536" name="gdpr[33536]" value="Y" class="av-checkbox "><small><?php /* translators: %s: privacy policy link */ echo sprintf( __('Accept our <a href="%s">privacy policy</a>.', 'formality'), 'https://www.iubenda.com/privacy-policy/87262067/legal" target="_blank'); ?></small></label>
<div class="formality-newsletter-result"></div>
</form>
</div>
</div>
</div>
</div>
</div>

<?php } ?>
<?php if ((isset( $_GET['formality_task']) || isset( $_POST['formality_task'])) && get_option('formality_notice') ) {

<?php if ($pagenow == 'edit.php' && (isset( $_GET['formality_task']) || isset( $_POST['formality_task'])) && get_option('formality_notice') ) {
$notice = get_option('formality_notice');
echo '<div class="notice notice-'.$notice[0].' is-dismissible"><p>'.$notice[1].'</p></div>';
delete_option('formality_notice');
Expand Down
5 changes: 2 additions & 3 deletions admin/class-formality-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,8 @@ public function prevent_classic_editor($can_edit, $post) {
return $can_edit;
}

public function remove_editor_styles() {
global $current_screen;
if('formality_form' == $current_screen->post_type) {
public function remove_3rdparty_styles($screen) {
if(property_exists($screen, 'post_type') && 'formality_form' == $screen->post_type) {
remove_editor_styles();
}
}
Expand Down
4 changes: 2 additions & 2 deletions admin/class-formality-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function email_content_type(){
}

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";
$file_name = 'formality-notification.php';
$file_path = locate_template($file_name) ? locate_template($file_name) : plugin_dir_path(__DIR__) . "public/templates/" . $file_name;
$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'];
Expand Down
Loading

0 comments on commit 6e13547

Please sign in to comment.