Version Description
- Create forms, fields, choices, and submissions under the proper user.
Download this release
Release Info
| Developer | tlovett1 |
| Plugin | |
| Version | 6.0.2 |
| Comparing to | |
| See all releases | |
Code changes from version 6.0.1 to 6.0.2
- bower.json +0 -1
- classes/class-ccf-api.php +8 -29
- classes/class-ccf-form-handler.php +0 -1
- custom-contact-forms.php +1 -1
- readme.txt +4 -1
- vendor/wp-api/wp-api/lib/class-wp-json-posts.php +4 -0
bower.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
{
|
| 2 |
"name": "custom-contact-forms",
|
| 3 |
-
"version": "6.0",
|
| 4 |
"homepage": "https://github.com/tlovett1/custom-contact-forms",
|
| 5 |
"authors": [
|
| 6 |
"Taylor Lovett <tlovett88@gmail.com>"
|
| 1 |
{
|
| 2 |
"name": "custom-contact-forms",
|
|
|
|
| 3 |
"homepage": "https://github.com/tlovett1/custom-contact-forms",
|
| 4 |
"authors": [
|
| 5 |
"Taylor Lovett <tlovett88@gmail.com>"
|
classes/class-ccf-api.php
CHANGED
|
@@ -321,6 +321,10 @@ class CCF_API extends WP_JSON_Posts {
|
|
| 321 |
public function create_form( $data ) {
|
| 322 |
unset( $data['ID'] );
|
| 323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
$result = $this->insert_post( $data );
|
| 325 |
if ( $result instanceof WP_Error ) {
|
| 326 |
return $result;
|
|
@@ -380,7 +384,6 @@ class CCF_API extends WP_JSON_Posts {
|
|
| 380 |
if ( empty( $choice['ID'] ) ) {
|
| 381 |
$args = array(
|
| 382 |
'post_title' => $choice['label'] . '-' . (int) $field_id,
|
| 383 |
-
'post_author' => 1,
|
| 384 |
'post_status' => 'publish',
|
| 385 |
'post_parent' => $field_id,
|
| 386 |
'post_type' => 'ccf_choice',
|
|
@@ -434,7 +437,6 @@ class CCF_API extends WP_JSON_Posts {
|
|
| 434 |
if ( empty( $field['ID'] ) ) {
|
| 435 |
$args = array(
|
| 436 |
'post_title' => $field['slug'] . '-' . (int) $form_id,
|
| 437 |
-
'post_author' => 1,
|
| 438 |
'post_status' => 'publish',
|
| 439 |
'post_parent' => $form_id,
|
| 440 |
'post_type' => 'ccf_field',
|
|
@@ -574,6 +576,10 @@ class CCF_API extends WP_JSON_Posts {
|
|
| 574 |
return new WP_Error( 'json_invalid_ccf_form', esc_html__( 'Invalid form.', 'custom-contact-forms' ), array( 'status' => 404 ) );
|
| 575 |
}
|
| 576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
$result = $this->insert_post( $data );
|
| 578 |
if ( $result instanceof WP_Error ) {
|
| 579 |
return $result;
|
|
@@ -652,31 +658,4 @@ class CCF_API extends WP_JSON_Posts {
|
|
| 652 |
return array( 'message' => esc_html__( 'Deleted post', 'custom-contact-forms' ) );
|
| 653 |
}
|
| 654 |
}
|
| 655 |
-
|
| 656 |
-
/**
|
| 657 |
-
* Prepare a form for output
|
| 658 |
-
*
|
| 659 |
-
* @param array $post
|
| 660 |
-
* @param string $context
|
| 661 |
-
* @since 6.0
|
| 662 |
-
* @return array
|
| 663 |
-
*/
|
| 664 |
-
/*protected function prepare_form( $post, $context = 'edit' ) {
|
| 665 |
-
$_post = parent::prepare_post( $post, $context );
|
| 666 |
-
|
| 667 |
-
// Override entity meta keys with the correct links
|
| 668 |
-
$_post['meta'] = array(
|
| 669 |
-
'links' => array(
|
| 670 |
-
'self' => json_url( '/ccf/forms/' . $post['ID'] ),
|
| 671 |
-
'author' => json_url( '/users/' . $post['post_author'] ),
|
| 672 |
-
'collection' => json_url( '/ccf/forms' ),
|
| 673 |
-
),
|
| 674 |
-
);
|
| 675 |
-
|
| 676 |
-
if ( ! empty( $post['post_parent'] ) ) {
|
| 677 |
-
$_post['meta']['links']['up'] = json_url( '/ccf/forms/' . $post['ID'] );
|
| 678 |
-
}
|
| 679 |
-
|
| 680 |
-
return apply_filters( "json_prepare_ccf_form", $_post, $post, $context );
|
| 681 |
-
}*/
|
| 682 |
}
|
| 321 |
public function create_form( $data ) {
|
| 322 |
unset( $data['ID'] );
|
| 323 |
|
| 324 |
+
if ( isset( $data['author'] ) ) {
|
| 325 |
+
unset( $data['author'] );
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
$result = $this->insert_post( $data );
|
| 329 |
if ( $result instanceof WP_Error ) {
|
| 330 |
return $result;
|
| 384 |
if ( empty( $choice['ID'] ) ) {
|
| 385 |
$args = array(
|
| 386 |
'post_title' => $choice['label'] . '-' . (int) $field_id,
|
|
|
|
| 387 |
'post_status' => 'publish',
|
| 388 |
'post_parent' => $field_id,
|
| 389 |
'post_type' => 'ccf_choice',
|
| 437 |
if ( empty( $field['ID'] ) ) {
|
| 438 |
$args = array(
|
| 439 |
'post_title' => $field['slug'] . '-' . (int) $form_id,
|
|
|
|
| 440 |
'post_status' => 'publish',
|
| 441 |
'post_parent' => $form_id,
|
| 442 |
'post_type' => 'ccf_field',
|
| 576 |
return new WP_Error( 'json_invalid_ccf_form', esc_html__( 'Invalid form.', 'custom-contact-forms' ), array( 'status' => 404 ) );
|
| 577 |
}
|
| 578 |
|
| 579 |
+
if ( isset( $data['author'] ) ) {
|
| 580 |
+
unset( $data['author'] );
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
$result = $this->insert_post( $data );
|
| 584 |
if ( $result instanceof WP_Error ) {
|
| 585 |
return $result;
|
| 658 |
return array( 'message' => esc_html__( 'Deleted post', 'custom-contact-forms' ) );
|
| 659 |
}
|
| 660 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 661 |
}
|
classes/class-ccf-form-handler.php
CHANGED
|
@@ -496,7 +496,6 @@ class CCF_Form_Handler {
|
|
| 496 |
'post_status' => 'publish',
|
| 497 |
'post_type' => 'ccf_submission',
|
| 498 |
'post_parent' => $form_id,
|
| 499 |
-
'post_author' => 1,
|
| 500 |
'post_title' => 'Form Submission ' . $form_id,
|
| 501 |
));
|
| 502 |
|
| 496 |
'post_status' => 'publish',
|
| 497 |
'post_type' => 'ccf_submission',
|
| 498 |
'post_parent' => $form_id,
|
|
|
|
| 499 |
'post_title' => 'Form Submission ' . $form_id,
|
| 500 |
));
|
| 501 |
|
custom-contact-forms.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
* Plugin URI: http://www.taylorlovett.com
|
| 5 |
* Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
|
| 6 |
* Author: Taylor Lovett
|
| 7 |
-
* Version: 6.0.
|
| 8 |
* Author URI: http://www.taylorlovett.com
|
| 9 |
*/
|
| 10 |
|
| 4 |
* Plugin URI: http://www.taylorlovett.com
|
| 5 |
* Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
|
| 6 |
* Author: Taylor Lovett
|
| 7 |
+
* Version: 6.0.2
|
| 8 |
* Author URI: http://www.taylorlovett.com
|
| 9 |
*/
|
| 10 |
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: http://www.taylorlovett.com
|
|
| 4 |
Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
|
| 5 |
Requires at least: 3.9
|
| 6 |
Tested up to: 4.1
|
| 7 |
-
Stable tag: 6.0.
|
| 8 |
|
| 9 |
Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
|
| 10 |
|
|
@@ -34,6 +34,9 @@ For questions, feature requests, and support concerning the Custom Contact Forms
|
|
| 34 |
|
| 35 |
= Changelog ==
|
| 36 |
|
|
|
|
|
|
|
|
|
|
| 37 |
= 6.0.1 =
|
| 38 |
* Properly flush permalinks on activation
|
| 39 |
* Warn user if pretty permalinks is not enabled.
|
| 4 |
Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
|
| 5 |
Requires at least: 3.9
|
| 6 |
Tested up to: 4.1
|
| 7 |
+
Stable tag: 6.0.2
|
| 8 |
|
| 9 |
Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
|
| 10 |
|
| 34 |
|
| 35 |
= Changelog ==
|
| 36 |
|
| 37 |
+
= 6.0.2 =
|
| 38 |
+
* Create forms, fields, choices, and submissions under the proper user.
|
| 39 |
+
|
| 40 |
= 6.0.1 =
|
| 41 |
* Properly flush permalinks on activation
|
| 42 |
* Warn user if pretty permalinks is not enabled.
|
vendor/wp-api/wp-api/lib/class-wp-json-posts.php
CHANGED
|
@@ -837,6 +837,8 @@ class WP_JSON_Posts {
|
|
| 837 |
$post['post_name'] = $data['name'];
|
| 838 |
}
|
| 839 |
|
|
|
|
|
|
|
| 840 |
// Author
|
| 841 |
if ( ! empty( $data['author'] ) ) {
|
| 842 |
// Allow passing an author object
|
|
@@ -849,6 +851,8 @@ class WP_JSON_Posts {
|
|
| 849 |
$data['author'] = (int) $data['author'];
|
| 850 |
}
|
| 851 |
|
|
|
|
|
|
|
| 852 |
// Only check edit others' posts if we are another user
|
| 853 |
if ( $data['author'] !== get_current_user_id() ) {
|
| 854 |
if ( ! json_check_post_permission( $post, 'edit_others_posts' ) ) {
|
| 837 |
$post['post_name'] = $data['name'];
|
| 838 |
}
|
| 839 |
|
| 840 |
+
var_dump( $data['author']);
|
| 841 |
+
|
| 842 |
// Author
|
| 843 |
if ( ! empty( $data['author'] ) ) {
|
| 844 |
// Allow passing an author object
|
| 851 |
$data['author'] = (int) $data['author'];
|
| 852 |
}
|
| 853 |
|
| 854 |
+
var_dump( $data['author']);
|
| 855 |
+
|
| 856 |
// Only check edit others' posts if we are another user
|
| 857 |
if ( $data['author'] !== get_current_user_id() ) {
|
| 858 |
if ( ! json_check_post_permission( $post, 'edit_others_posts' ) ) {
|
