From d0ac246a28047accb0975e524d8c23d46872e172 Mon Sep 17 00:00:00 2001 From: Jake Snyder Date: Tue, 24 Feb 2015 16:52:42 -0600 Subject: [PATCH] Final 1.2.17 update --- README.md | 12 +-- gravityforms-update-post.php | 187 ++++++++++++++++++----------------- readme.txt | 55 ++++------- 3 files changed, 121 insertions(+), 133 deletions(-) diff --git a/README.md b/README.md index b4a0798..8655dab 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,14 @@ http://wordpress.org/plugins/gravity-forms-post-updates/ * * * -## Installation +-> **Requires PHP 5.3 or greater** <- -This add-on can be treated as both a WP plugin and a theme include. +* * * -### Install as Plugin +## Installation -1. Copy the folder into your plugins folder -2. Activate the plugin via the Plugins admin page +1. Install plugin either via the WordPress.org plugin directory, or by uploading the files to your server. +2. Activate the plugin via the Plugins admin page. ## Features @@ -314,4 +314,4 @@ add_filter('gform_update_post/public_edit', 'custom_gform_update_post_public_edi { return 'edit_posts'; } -``` +``` \ No newline at end of file diff --git a/gravityforms-update-post.php b/gravityforms-update-post.php index 47e4e5f..e842d61 100644 --- a/gravityforms-update-post.php +++ b/gravityforms-update-post.php @@ -1,31 +1,24 @@ choices) ) + if ( version_compare(GFCommon::$version, '1.9') >= 0 ) { - foreach ( $field->choices as &$choice ) + if ( isset($field->choices) ) { - $choice['isSelected'] = ( in_array($choice['value'], $value) ) ? true : ''; + foreach ( $field->choices as &$choice ) { + $choice['isSelected'] = ( in_array($choice['value'], $value) ) ? true : ''; + } } } + else + { + if ( isset($field['choices']) ) + { + foreach ( $field['choices'] as &$choice ) { + $choice['isSelected'] = ( in_array($choice['value'], $value) ) ? true : ''; + } + } + } + #add_filter( 'gform_field_value_' . $field['inputName'], function($value) use($value) { return $value; } ); break; @@ -998,13 +989,25 @@ public static function populate_element( $field, $field_type, $value ) $value = (! is_array($value) ) ? array($value) : $value; - if ( isset($field->choices) ) + if ( version_compare(GFCommon::$version, '1.9') >= 0 ) { - foreach ( $field->choices as &$choice ) + if ( isset($field->choices) ) { - $choice['isSelected'] = ( in_array($choice['value'], $value) ) ? true : ''; + foreach ( $field->choices as &$choice ) { + $choice['isSelected'] = ( in_array($choice['value'], $value) ) ? true : ''; + } + } + } + else + { + if ( isset($field['choices']) ) + { + foreach ( $field['choices'] as &$choice ) { + $choice['isSelected'] = ( in_array($choice['value'], $value) ) ? true : ''; + } } } + break; default: @@ -1023,7 +1026,7 @@ public static function populate_element( $field, $field_type, $value ) /** * Return value for taxonomy fields * - * @author Jake Snyder + * @author ekaj * @return value */ public static function return_category_field_value( $value, $field ) @@ -1040,7 +1043,7 @@ public static function return_taxonomy_field_value( $value, $field ) * * While nice, custom post types plugin only adds taxonomies on intead of updating the whole set, so you can't ever remove them. This wipes them out and then they can be added through the custom post types plugin. * - * @author Jake Snyder + * @author ekaj * @return void */ public static function delete_custom_taxonomy_save( $entry, $form ) @@ -1067,9 +1070,8 @@ public static function delete_custom_taxonomy_save( $entry, $form ) * Adds the support for unique custom fields which clean up the database. This does force a new post_meta entry every save though. * This is forced because GF uses "add_post_meta" instead of "update_post_meta". * - * @author Kevin Miller - * @author Jake Snyder - * @date 22/08/13 + * @author p51labs + * @author ekaj * @type action */ public static function gform_post_data( $post_data, $form ) @@ -1118,7 +1120,7 @@ public static function gform_post_data( $post_data, $form ) /** * Test if an image already exists, for validation on required fields * - * @author Jake Snyder + * @author ekaj * @since 0.6.4 * @return void */ @@ -1140,8 +1142,7 @@ public static function required_upload_field_validation( $result, $value, $form, * * Check permissions for current user that they are allowed to edit the post/page. * - * @author Jake Snyder - * @date 22/08/13 + * @author ekaj * @return void */ public static function current_user_can( $post_id=false ) @@ -1199,8 +1200,8 @@ public static function current_user_can( $post_id=false ) * * This function adds the checkbox. * - * @author Kevin Miller - * @author Jake Snyder + * @author p51labs + * @author ekaj * @type action * @return void */ @@ -1226,8 +1227,8 @@ public static function gform_field_standard_settings( $position, $form_id ) * * Adds the js for the checkbox. * - * @author Kevin Miller - * @author Jake Snyder + * @author p51labs + * @author ekaj * @type action * @return void */ @@ -1268,8 +1269,8 @@ public static function gform_editor_js() * * This function adds the tooltip for the checkbox. * - * @author Kevin Miller - * @author Jake Snyder + * @author p51labs + * @author ekaj * @type filter * @return void */ diff --git a/readme.txt b/readme.txt index 9d2602f..7d6d004 100644 --- a/readme.txt +++ b/readme.txt @@ -4,40 +4,29 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=jacob Tags: gravity forms, update posts, frontend, front end Requires at least: 3.6.1 Tested up to: 4.1.1 -Stable tag: 1.2.16 +Stable tag: 1.2.17 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Allows you to use Gravity Forms to update any post on the front end. + == Description == -Requires PHP 5.2. +**Requires PHP 5.3 or greater** Allows you to use Gravity Forms to update any post on the front end. If you use the "Gravity Forms + Custom Post Types", you can even update custom post types and use custom taxonomies. -This started as an update to the Gravity Forms Update Post plugin developed by p51labs here. -It has evolved into a completely rewritten plugin that streamlines the system, adds some new support for more fields, and adds more interfaces and filters. - -= Compatibility = - -Here is how it does NOT really support the original version: - -* All of the delete functionality has been removed. It didn't have anything to do with Gravity Forms, so I thought it should be in a separate plugin or users can manually add it. It seemed like it complicated things in a way that distracted from the main function of the plugin. And I wasn't getting a lot of feedback that users were using it. -* You can NOT just send a URL get variable and have a form populate with existing content and be editable. I wanted another layer to that. So you have to include a nonce as well, however, there is a built in function for creating edit links to make up for that. += Features = -So it isn't very compatible. Plain and simple, you will have to change something to start using this plugin if you were using the original, but I don't think it will be very hard and I did keep the original query variable that was used before. - -= New Features = - -* Supports custom field file uploading and deletion with thumbnails or mime type icons for existing items. -* Fixed a bugs on multi selects and checkboxes. -* Fixed bug on Categories. -* Completely removed the ability to delete posts. -* There are some filters to customize things now. -* Adds non-query-var template method to setup a form. -* Adds a really basic shortcode to setup a form (UPDATE: This is still supported, but it is better to use the addition, below, to the gravityform shortcode). -* Adds an additional attribute to the gravityform shortcode: "update" +* Supports custom field file uploading and deletion with thumbnails or mime type icons for existing items. +* Fixed a bugs on multi selects and checkboxes. +* Fixed bug on Categories. +* Completely removed the ability to delete posts. +* There are some filters to customize things now. +* Adds non-query-var template method to setup a form. +* Adds a really basic shortcode to setup a form (UPDATE: This is still supported, but it is better to use the addition, below, to the gravityform shortcode). +* Adds an additional attribute to the gravityform shortcode: "update" = SHORTCODE = @@ -101,18 +90,9 @@ You can use the action to force a form show a specific post: == Installation == -This add-on can be treated as both a WP plugin and a theme include. - -= Install as Plugin = +* Install plugin either via the WordPress.org plugin directory, or by uploading the files to your server. +* Activate the plugin via the Plugins admin page. -* Copy the folder into your plugins folder -* Activate the plugin via the Plugins admin page - -= Include within theme = - -* Copy the folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory -* Edit your functions.php file and add the code below (Make sure the path is correct to include the gravityforms-update-post.php file) -* `include_once('gravityforms-update-post/gravityforms-update-post.php');` == Frequently Asked Questions == @@ -124,10 +104,16 @@ Tags really only work with a single line text field, checkbox and multiselect cu Image fields are only supported if they are the "Featured Image". Otherwise you have to use a Custom Field and choose "File Upload" under File Type. If it is not one of these two types, we can't track it for updating. += What does this error mean: syntax error, unexpected T_FUNCTION?! = + +It usually means you are running PHP 5.2.x on your server. I know WordPress supports 5.2.4, but it is highly recommended to run at least 5.4, and this plugin simply doesn't support older than 5.3. We tried a little bit, but we could not get anonymous functions to work in a format that was compatible with 5.2, and, honestly, we really don't want to spend a lot more time on it, because 5.2 is so old, and you should upgrade. We did try though... + + == Screenshots == 1. A form on the front end. This just demonstrates the image/file capabilities. + == Changelog == ## 1.2.16 - 2015-02-18 @@ -274,6 +260,7 @@ Image fields are only supported if they are the "Featured Image". Otherwise you - Removed error output from unlink when a file doesn't exist. Stopped the default thumbnail on post images, so post image thumbs only show up when there is an actual image. + == Upgrade Notice == = 1.0 =