Skip to content

Commit

Permalink
Fix gruntfile
Browse files Browse the repository at this point in the history
  • Loading branch information
tlovett1 committed Dec 12, 2016
2 parents 153f1ed + 33b8790 commit 1766a15
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 31 deletions.
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -69,21 +69,33 @@ form is successfully filled out. Each notification contains the following config

* `[all_fields]` - Shows all your form fields
* `[ip_address]` - Shows the IP address of the submitter
* `[current_date_time]` - Shows the current date and time
* `[FIELD_SLUG]` - Each of your form fields can be inserted using their field slug.

* `"To" Email Addresses` - You can send each notification to as many emails as you want. Addresses have two types: `custom` and
`field`. `custom` allows you to specify a specific email (such as your own). `field` will pull the email address dynamically from a form field.
* `Reply To Email Address Type` - This allows you to set what email address is set as the notification email Reply To. `WordPress
Default` will use the default WordPress email address. `Custom Email` will allow you to manually type in an address. `Form Field` will allow you to choose an email field within the form to dynamically pull a email address.

* `Reply To Name Type` - This allows you to set the Reply To name in the notification email. `Custom Name`
will allow you to manually type in a name. `Form Field` will allow you to choose a name field within
the form to dynamically pull a name.

* `"From" Email Address Type` - This allows you to set what email address the notification is sent from. `WordPress
Default` will use the default WordPress email address. `Custom Email` will allow you to manually type in a from
address. `Form Field` will allow you to choose an email field within the form to dynamically pull a from email
address.

* `"From" Name Type` - This allows you to set what name the notification email is sent from. `Custom Name`
will allow you to manually type in a from name. `Form Field` will allow you to choose a name field within
the form to dynamically pull a from email name.
* `Email Subject Type` - This allows you to set what subject line is used on the notification email. `Default`
will use the CCF default subject. `Custom Subject` will allow you to manually type in an email subject.
`Form Field` will allow you to choose a field within the form to dynamically pull a subject line.

* `Include File Uploads` - If this is set to yes, file uploads will be sent in notification emails. This only applies if your
form has File Upload fields.

__Note:__ In order for form notification changes to take affect, you will need to save the form.

#### Post Creation
Expand Down
6 changes: 3 additions & 3 deletions assets/build/css/form-manager.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/build/css/form-manager.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/build/css/form-manager.min.css

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion assets/build/js/form-manager.js
Expand Up @@ -397,6 +397,7 @@
title: '',
content: '[all_fields]',
active: true,
includeUploads: true,
addresses: new wp.ccf.collections.FormNotificationAddresses(),
fromType: 'default',
fromAddress: '',
Expand Down Expand Up @@ -2000,6 +2001,9 @@
var emailNotificationActive = this.el.querySelectorAll( '.form-email-notification-active' )[0].value;
this.model.set( 'active', ( '1' === emailNotificationActive ) ? true : false );

var emailNotificationIncludeUploads = this.el.querySelectorAll( '.form-email-notification-include-uploads' )[0].value;
this.model.set( 'includeUploads', ( '1' === emailNotificationIncludeUploads ) ? true : false );

var emailNotificationFromType = this.el.querySelectorAll( '.form-email-notification-from-type' )[0].value;
this.model.set( 'fromType', emailNotificationFromType );

Expand Down Expand Up @@ -4456,4 +4460,4 @@

wp.ccf.createManager();

})( jQuery, Backbone, _, ccfSettings );
})( jQuery, Backbone, _, ccfSettings );
6 changes: 3 additions & 3 deletions assets/build/js/form-manager.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/js/manager/models.js
Expand Up @@ -128,6 +128,7 @@
title: '',
content: '[all_fields]',
active: true,
includeUploads: true,
addresses: new wp.ccf.collections.FormNotificationAddresses(),
fromType: 'default',
fromAddress: '',
Expand Down
3 changes: 3 additions & 0 deletions assets/js/manager/views.js
Expand Up @@ -733,6 +733,9 @@
var emailNotificationActive = this.el.querySelectorAll( '.form-email-notification-active' )[0].value;
this.model.set( 'active', ( '1' === emailNotificationActive ) ? true : false );

var emailNotificationIncludeUploads = this.el.querySelectorAll( '.form-email-notification-include-uploads' )[0].value;
this.model.set( 'includeUploads', ( '1' === emailNotificationIncludeUploads ) ? true : false );

var emailNotificationFromType = this.el.querySelectorAll( '.form-email-notification-from-type' )[0].value;
this.model.set( 'fromType', emailNotificationFromType );

Expand Down
6 changes: 3 additions & 3 deletions assets/scss/form-manager.scss
Expand Up @@ -60,7 +60,7 @@
left: 30px;
right: 30px;
bottom: 30px;
z-index: 160000;
z-index: 1600000;
overflow: hidden;
background-color: #fff;

Expand Down Expand Up @@ -248,7 +248,7 @@
font-size: 35px;
cursor: pointer;
color: #333;
z-index: 160001;
z-index: 1600001;
}

.main-menu {
Expand Down Expand Up @@ -876,7 +876,7 @@
left: 0px;
width: 100%;
height: 100%;
z-index: 159900;
z-index: 1599000;
opacity: 0.7;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
filter: alpha(opacity=70);
Expand Down
20 changes: 17 additions & 3 deletions classes/class-ccf-custom-contact-forms.php
Expand Up @@ -101,6 +101,18 @@ public function load_textdomain() {
load_plugin_textdomain( 'custom-contact-forms', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
}

/**
* Manually register rest scripts
*
* @since 7.8.3
*/
public function rest_register_scripts_manual() {
wp_register_script( 'wp-api', plugins_url( 'wp-api.js', __FILE__ ), array( 'jquery', 'backbone', 'underscore' ), '1.1', true );

$settings = array( 'root' => esc_url_raw( get_rest_url() ), 'nonce' => wp_create_nonce( 'wp_rest' ) );
wp_localize_script( 'wp-api', 'WP_API_Settings', $settings );
}

/**
* Right now we are including the JSON REST API (http://github.com/wp-api/wp-api) in the plugin itself
* since the API is not yet stable. Eventually, the API will be moved into WP and it will no longer need
Expand All @@ -117,19 +129,21 @@ public function manually_load_api() {

if ( ! empty( $_POST['checked'] ) ) {
foreach ( $_POST['checked'] as $plugin ) {
if ( preg_match( '#json-rest-api#i', $plugin ) ) {
if ( preg_match( '#(json-rest-api|wp-api|rest-api)#i', $plugin ) ) {
return;
}
}
} elseif ( ! empty( $_GET['plugin'] ) ) {
if ( preg_match( '#json-rest-api#i', $_GET['plugin'] ) ) {
if ( preg_match( '#(json-rest-api|wp-api|rest-api)#i', $_GET['plugin'] ) ) {
return;
}
}
}
}

if ( function_exists( 'create_initial_rest_routes' ) ) {
if ( function_exists( 'create_initial_rest_routes' ) || class_exists( 'WP_REST_Controller' ) ) {
add_action( 'wp_enqueue_scripts', array( $this, 'rest_register_scripts_manual' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'rest_register_scripts_manual' ) );
return;
}

Expand Down
13 changes: 11 additions & 2 deletions classes/class-ccf-form-cpt.php
Expand Up @@ -28,6 +28,7 @@ public function setup() {
add_filter( 'manage_edit-ccf_form_columns', array( $this, 'filter_columns' ) );
add_action( 'manage_ccf_form_posts_custom_column', array( $this, 'action_columns' ), 10, 2 );
add_action( 'admin_enqueue_scripts', array( $this, 'action_admin_enqueue_scripts' ), 9 );
add_action( 'customize_controls_enqueue_scripts', array( $this, 'action_admin_enqueue_scripts' ) );
add_action( 'edit_form_after_title', array( $this, 'action_edit_form_after_title' ) );
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
add_filter( 'post_row_actions', array( $this, 'filter_post_row_actions' ), 10, 2 );
Expand Down Expand Up @@ -475,9 +476,16 @@ public function action_admin_enqueue_scripts() {
}
wp_enqueue_style( 'ccf-admin', plugins_url( $admin_css_path, dirname( __FILE__ ) ), array(), CCF_VERSION );

global $pagenow;
global $pagenow, $wp_customize;

if ( ( 'post.php' === $pagenow && 'ccf_form' === get_post_type() ) || ( 'post-new.php' === $pagenow && isset( $_GET['post_type'] ) && 'ccf_form' === $_GET['post_type'] ) ) {
$is_edit_post = (
( 'post.php' === $pagenow && 'ccf_form' === get_post_type() )
||
( 'post-new.php' === $pagenow && isset( $_GET['post_type'] ) && 'ccf_form' === $_GET['post_type'] )
||
( ! empty( $wp_customize ) && isset( $wp_customize->posts ) )
);
if ( $is_edit_post ) {
wp_dequeue_script( 'autosave' );

add_thickbox();
Expand Down Expand Up @@ -592,6 +600,7 @@ public function setup_cpt() {
'exclude_from_search' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_customizer' => false,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'post',
Expand Down
16 changes: 14 additions & 2 deletions classes/class-ccf-form-handler.php
Expand Up @@ -727,11 +727,15 @@ function process_submission() {
$form_page = null;
}

$uploads = array();

foreach ( $file_ids as $file_id ) {
wp_update_post( array(
'ID' => $file_id,
'post_parent' => $submission_id,
) );

$uploads[] = get_attached_file( $file_id );
}

do_action( 'ccf_successful_submission', $submission_id, $form_id );
Expand Down Expand Up @@ -1077,6 +1081,8 @@ function process_submission() {
}
}

$include_uploads = $notification['includeUploads'];

foreach ( $notification['addresses'] as $address ) {

if ( ! empty( $address['email'] ) || ! empty( $address['field'] ) ) {
Expand Down Expand Up @@ -1106,9 +1112,15 @@ function process_submission() {
$notification_content = apply_filters( 'ccf_email_content', $message, $form_id, $email, $form_page, $notification );
$notification_headers = apply_filters( 'ccf_email_headers', $headers, $form_id, $email, $form_page, $notification );

do_action( 'ccf_send_notification', $email, $subject, $notification_content, $notification_headers, $notification );
if ( ! $include_uploads ) {
$uploads = array();
}

$uploads = apply_filters( 'ccf_email_uploads', $uploads, $headers, $form_id, $email, $form_page, $file_ids, $notification );

do_action( 'ccf_send_notification', $email, $subject, $notification_content, $notification_headers, $uploads, $notification );

wp_mail( $email, $subject, $notification_content, $notification_headers );
wp_mail( $email, $subject, $notification_content, $notification_headers, $uploads );
}
}
}
Expand Down
26 changes: 23 additions & 3 deletions classes/class-ccf-form-manager.php
Expand Up @@ -16,7 +16,9 @@ public function __construct() {}
public function setup() {
add_action( 'media_buttons', array( $this, 'action_media_buttons' ) );
add_action( 'admin_footer', array( $this, 'print_templates' ) );
add_action( 'admin_enqueue_scripts' , array( $this, 'action_admin_enqueue_scripts_css' ), 9 );
add_action( 'customize_controls_print_footer_scripts', array( $this, 'customize_controls_print_footer_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'action_admin_enqueue_scripts_css' ), 9 );
add_action( 'customize_controls_enqueue_scripts' , array( $this, 'action_admin_enqueue_scripts_css' ), 9 );
add_filter( 'mce_css', array( $this, 'filter_mce_css' ) );
}

Expand All @@ -42,6 +44,16 @@ public function filter_mce_css( $css ) {
return $css;
}

/**
* Print all Backbone templates for form manager in Customizer
*/
public function customize_controls_print_footer_scripts() {
global $wp_customize;
if ( isset( $wp_customize->posts ) ) {
$this->print_templates();
}
}

/**
* Print all Backbone templates for form manager
*
Expand Down Expand Up @@ -365,6 +377,14 @@ public function print_templates() {
<select name="email_notification_from_name_field" class="form-email-notification-from-name-field" id="ccf_form_email_notification_from_name_field">
</select>
</p>

<p>
<label for="ccf_form_email_notification_include_uploads"><?php esc_html_e( 'Include File Uploads:', 'custom-contact-forms' ); ?></label>
<select name="email_notification_include_uploads" class="form-email-notification-include-uploads" id="ccf_form_email_notification_include_uploads">
<option value="1"><?php esc_html_e( 'Yes', 'custom-contact-forms' ); ?></option>
<option value="0" <# if ( ! notification.includeUploads ) { #>selected<# } #>><?php esc_html_e( 'No', 'custom-contact-forms' ); ?></option>
</select>
</p>
</div>
</td>
<# } #>
Expand Down Expand Up @@ -2268,9 +2288,9 @@ public function action_media_buttons() {
* @since 6.0
*/
public function action_admin_enqueue_scripts_css() {
global $pagenow;
global $pagenow, $wp_customize;

if ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) {
if ( 'post.php' == $pagenow || 'post-new.php' == $pagenow || ( ! empty( $wp_customize ) && isset( $wp_customize->posts ) ) ) {
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
$js_manager_path = '/assets/build/js/form-manager.js';
$js_mce_path = '/assets/js/form-mce.js';
Expand Down
13 changes: 11 additions & 2 deletions classes/class-ccf-form-renderer.php
Expand Up @@ -149,8 +149,17 @@ public function shortcode( $atts ) {
* @return string
*/
public function get_rendered_form( $form_id ) {
$form = get_post( (int) $form_id );

if ( is_customize_preview() ) {
$form_query = new WP_Query( array(
'post__in' => array( $form_id ),
'post_type' => 'ccf_form',
'ignore_sticky_posts' => true,
'posts_per_page' => 1,
) );
$form = array_shift( $form_query->posts );
} else {
$form = get_post( $form_id );
}
if ( ! $form ) {
return '';
}
Expand Down
4 changes: 2 additions & 2 deletions custom-contact-forms.php
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: http://www.taylorlovett.com
* Description: Build beautiful custom forms and manage submissions the WordPress way. View live previews of your forms while you build them. Contact forms, subscription forms, payment forms, etc.
* Author: Taylor Lovett
* Version: 7.8.1
* Version: 7.8.3
* Text Domain: custom-contact-forms
* Domain Path: /languages
* Author URI: http://www.taylorlovett.com
Expand All @@ -15,7 +15,7 @@
*/


define( 'CCF_VERSION', '7.8.1' );
define( 'CCF_VERSION', '7.8.3' );

require_once( dirname( __FILE__ ) . '/classes/class-ccf-constants.php' );
require_once( dirname( __FILE__ ) . '/classes/class-ccf-custom-contact-forms.php' );
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -4,10 +4,10 @@
"grunt": "~0.4.2",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-sass": "~0.6.0",
"grunt-contrib-uglify": "0.2.0",
"grunt-contrib-watch": "0.5.3",
"grunt-contrib-qunit": "~0.4.0"
"grunt-contrib-qunit": "~0.4.0",
"grunt-contrib-jshint": "^1.1.0"
}
}
10 changes: 9 additions & 1 deletion readme.txt
Expand Up @@ -3,7 +3,7 @@ Contributors: tlovett1
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HR34W94MM53RQ
Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
Requires at least: 3.9
Tested up to: 4.5
Tested up to: 4.6
Stable tag: trunk
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -60,6 +60,14 @@ For full documentation, questions, feature requests, and support concerning the

== Changelog ==

= 7.8.3 =
* Fix WooCommerce conflict

= 7.8.2 =
* Add $submission to ccf_email_subject filter, correct "Invalid Date" issue with datepicker. Props (quayzar)[https://github.com/quayzar]
* Fix WooCommerce conflict
* Add support for Customize Posts plugin. Props (westonruter)[https://github.com/westonruter]

= 7.8.1 =
* Cache busy form submission URL
* Improve field choice UI
Expand Down
4 changes: 2 additions & 2 deletions wp-api/extras.php
Expand Up @@ -8,8 +8,8 @@
* @subpackage JSON API
*/

add_action( 'wp_enqueue_scripts', 'rest_register_scripts', -100 );
add_action( 'admin_enqueue_scripts', 'rest_register_scripts', -100 );
add_action( 'wp_enqueue_scripts', 'rest_register_scripts', 1000 );
add_action( 'admin_enqueue_scripts', 'rest_register_scripts', 1000 );

/**
* Registers REST API JavaScript helpers.
Expand Down

0 comments on commit 1766a15

Please sign in to comment.