| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | * @since 1.15 | 
| 29 | 29 | * @param bool|false $mixed | 
| 30 | 30 | * | 
| 31 | - * @return bool | |
| 31 | + * @return boolean|null | |
| 32 | 32 | */ | 
| 33 | 33 |  	private function _exit( $mixed = NULL ) { | 
| 34 | 34 | |
| @@ -200,7 +200,7 @@ discard block | ||
| 200 | 200 | * Import Gravity Form XML or JSON | 
| 201 | 201 | * | 
| 202 | 202 | * @param string $xml_or_json_path Path to form XML or JSON file | 
| 203 | - * @return int|bool Imported form ID or false | |
| 203 | + * @return false|string Imported form ID or false | |
| 204 | 204 | */ | 
| 205 | 205 |  	function import_form( $xml_or_json_path = '' ) { | 
| 206 | 206 | |
| @@ -136,7 +136,7 @@ discard block | ||
| 136 | 136 | |
| 137 | 137 | // template areas | 
| 138 | 138 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); | 
| 139 | - $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); | |
| 139 | + $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); | |
| 140 | 140 | |
| 141 | 141 | // widget areas | 
| 142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); | 
| @@ -328,40 +328,40 @@ discard block | ||
| 328 | 328 | // load file | 
| 329 | 329 | $xmlstr = file_get_contents( $form_file ); | 
| 330 | 330 | |
| 331 | - $options = array( | |
| 332 | -            "page" => array("unserialize_as_array" => true), | |
| 333 | -            "form"=> array("unserialize_as_array" => true), | |
| 334 | -            "field"=> array("unserialize_as_array" => true), | |
| 335 | -            "rule"=> array("unserialize_as_array" => true), | |
| 336 | -            "choice"=> array("unserialize_as_array" => true), | |
| 337 | -            "input"=> array("unserialize_as_array" => true), | |
| 338 | -            "routing_item"=> array("unserialize_as_array" => true), | |
| 339 | -            "creditCard"=> array("unserialize_as_array" => true), | |
| 340 | -            "routin"=> array("unserialize_as_array" => true), | |
| 341 | -            "confirmation" => array("unserialize_as_array" => true), | |
| 342 | -            "notification" => array("unserialize_as_array" => true) | |
| 343 | - ); | |
| 331 | + $options = array( | |
| 332 | +			"page" => array("unserialize_as_array" => true), | |
| 333 | +			"form"=> array("unserialize_as_array" => true), | |
| 334 | +			"field"=> array("unserialize_as_array" => true), | |
| 335 | +			"rule"=> array("unserialize_as_array" => true), | |
| 336 | +			"choice"=> array("unserialize_as_array" => true), | |
| 337 | +			"input"=> array("unserialize_as_array" => true), | |
| 338 | +			"routing_item"=> array("unserialize_as_array" => true), | |
| 339 | +			"creditCard"=> array("unserialize_as_array" => true), | |
| 340 | +			"routin"=> array("unserialize_as_array" => true), | |
| 341 | +			"confirmation" => array("unserialize_as_array" => true), | |
| 342 | +			"notification" => array("unserialize_as_array" => true) | |
| 343 | + ); | |
| 344 | 344 | |
| 345 | 345 | $xml = new RGXML($options); | 
| 346 | - $forms = $xml->unserialize($xmlstr); | |
| 346 | + $forms = $xml->unserialize($xmlstr); | |
| 347 | 347 | |
| 348 | -        if( !$forms ) { | |
| 349 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); | |
| 350 | - return false; | |
| 351 | - } | |
| 348 | +		if( !$forms ) { | |
| 349 | + do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); | |
| 350 | + return false; | |
| 351 | + } | |
| 352 | 352 | |
| 353 | -        if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { | |
| 354 | - $form = $forms[0]; | |
| 355 | - } | |
| 353 | +		if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { | |
| 354 | + $form = $forms[0]; | |
| 355 | + } | |
| 356 | 356 | |
| 357 | -        if( empty( $form ) ) { | |
| 358 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); | |
| 359 | - return false; | |
| 360 | - } | |
| 357 | +		if( empty( $form ) ) { | |
| 358 | + do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); | |
| 359 | + return false; | |
| 360 | + } | |
| 361 | 361 | |
| 362 | - do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); | |
| 362 | + do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); | |
| 363 | 363 | |
| 364 | - return $form; | |
| 364 | + return $form; | |
| 365 | 365 | |
| 366 | 366 | } | 
| 367 | 367 | |
| @@ -195,7 +195,7 @@ | ||
| 195 | 195 | * | 
| 196 | 196 | * @since 1.6 | 
| 197 | 197 | * | 
| 198 | - * @param int $new_view_id The ID of the newly created View | |
| 198 | + * @param int $new_id The ID of the newly created View | |
| 199 | 199 | * @param WP_Post $post The View that was just cloned | 
| 200 | 200 | * | 
| 201 | 201 | * @return void | 
| @@ -116,7 +116,7 @@ | ||
| 116 | 116 | |
| 117 | 117 | /** | 
| 118 | 118 | * @since 1.12 | 
| 119 | - * @return bool | |
| 119 | + * @return boolean|null | |
| 120 | 120 | */ | 
| 121 | 121 |  	private function add_fallback_shortcode() { | 
| 122 | 122 | |
| @@ -204,7 +204,7 @@ | ||
| 204 | 204 | self::$notices['wp_version'] = array( | 
| 205 | 205 | 'class' => 'error', | 
| 206 | 206 | 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ), | 
| 207 | - 'cap' => 'update_core', | |
| 207 | + 'cap' => 'update_core', | |
| 208 | 208 | 'dismiss' => 'wp_version', | 
| 209 | 209 | ); | 
| 210 | 210 | |
| @@ -221,7 +221,6 @@ discard block | ||
| 221 | 221 | * | 
| 222 | 222 | * @since 1.15 | 
| 223 | 223 | * | 
| 224 | - * @param string|null $content Content inside shortcode, if defined | |
| 225 | 224 | * | 
| 226 | 225 | * @return string|boolean If URL is fetched, the URL to the entry link. If not found, returns false. | 
| 227 | 226 | */ | 
| @@ -316,7 +315,7 @@ discard block | ||
| 316 | 315 | * | 
| 317 | 316 | * @since 1.15 | 
| 318 | 317 | * | 
| 319 | - * @param string $href URL | |
| 318 | + * @param string|null $url | |
| 320 | 319 | */ | 
| 321 | 320 |  	private function maybe_add_field_values_query_args( $url ) { | 
| 322 | 321 | |
| @@ -278,7 +278,7 @@ | ||
| 278 | 278 | |
| 279 | 279 | /** | 
| 280 | 280 | * Add a notice to be displayed in the admin. | 
| 281 | - * @param array $notice Array with `class` and `message` keys. The message is not escaped. | |
| 281 | + * @param string $notice Array with `class` and `message` keys. The message is not escaped. | |
| 282 | 282 | */ | 
| 283 | 283 |  	public static function add_notice( $notice = array() ) { | 
| 284 | 284 | |
| @@ -244,13 +244,13 @@ | ||
| 244 | 244 | $this->_remote_update_url, | 
| 245 | 245 | $this->_path, | 
| 246 | 246 | array( | 
| 247 | - 'version' => $this->_version, // current version number | |
| 248 | - 'license' => $license['license'], | |
| 249 | - 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url | |
| 250 | - 'item_name' => $this->_title, // name of this plugin | |
| 251 | - 'author' => strip_tags( $this->_author ) // author of this plugin | |
| 252 | - ) | |
| 253 | - ); | |
| 247 | + 'version' => $this->_version, // current version number | |
| 248 | + 'license' => $license['license'], | |
| 249 | + 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url | |
| 250 | + 'item_name' => $this->_title, // name of this plugin | |
| 251 | + 'author' => strip_tags( $this->_author ) // author of this plugin | |
| 252 | + ) | |
| 253 | + ); | |
| 254 | 254 | } | 
| 255 | 255 | |
| 256 | 256 | /** | 
| @@ -67,7 +67,6 @@ | ||
| 67 | 67 | * | 
| 68 | 68 | * @since 1.15 | 
| 69 | 69 | * | 
| 70 | - * @param array $allcaps An array of all the user's capabilities. | |
| 71 | 70 | * @param array $caps Actual capabilities for meta capability. | 
| 72 | 71 | * @param array $args Optional parameters passed to has_cap(), typically object ID. | 
| 73 | 72 | * @param WP_User|null $user The user object, in WordPress 3.7.0 or higher | 
| @@ -56,7 +56,7 @@ discard block | ||
| 56 | 56 | add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); | 
| 57 | 57 | add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); | 
| 58 | 58 | add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); | 
| 59 | - add_action( 'admin_init', array( $this, 'add_caps') ); | |
| 59 | + add_action( 'admin_init', array( $this, 'add_caps') ); | |
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | 62 | |
| @@ -360,7 +360,6 @@ discard block | ||
| 360 | 360 | * Add Gravity Forms and GravityView's "full access" caps when any other caps are checked against. | 
| 361 | 361 | * | 
| 362 | 362 | * @since 1.15 | 
| 363 | - | |
| 364 | 363 | * @param array $caps_to_check | 
| 365 | 364 | * | 
| 366 | 365 | * @return array | 
| @@ -37,6 +37,9 @@ discard block | ||
| 37 | 37 | public $active_areas; | 
| 38 | 38 | |
| 39 | 39 | |
| 40 | + /** | |
| 41 | + * @param string $id | |
| 42 | + */ | |
| 40 | 43 |  	function __construct( $id, $settings = array(), $field_options = array(), $areas = array() ) { | 
| 41 | 44 | |
| 42 | 45 |  		if ( empty( $id ) ) { | 
| @@ -144,6 +147,9 @@ discard block | ||
| 144 | 147 | return $areas; | 
| 145 | 148 | } | 
| 146 | 149 | |
| 150 | + /** | |
| 151 | + * @param string $context | |
| 152 | + */ | |
| 147 | 153 |  	public function get_active_areas( $context ) { | 
| 148 | 154 |  		if ( isset( $this->active_areas[ $context ] ) ) { | 
| 149 | 155 | return $this->active_areas[ $context ]; | 
| @@ -156,8 +162,8 @@ discard block | ||
| 156 | 162 | /** | 
| 157 | 163 | * Assign template specific field options | 
| 158 | 164 | * | 
| 159 | - * @param array $options (default: array()) | |
| 160 | - * @param string $template (default: '') | |
| 165 | + * @param array $field_options (default: array()) | |
| 166 | + * @param string $template_id (default: '') | |
| 161 | 167 | * @param string $field_id key for the field | 
| 162 | 168 | * @param string|array $context Context for the field; `directory` or `single` for example. | 
| 163 | 169 | * | 
| @@ -170,7 +170,6 @@ | ||
| 170 | 170 | * | 
| 171 | 171 | * @since 1.5.1 | 
| 172 | 172 | * @param array $visibility_caps Array of capabilities to display in field dropdown. | 
| 173 | - * @param string $field_type Type of field options to render (`field` or `widget`) | |
| 174 | 173 | * @param string $template_id Table slug | 
| 175 | 174 | * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` | 
| 176 | 175 | * @param string $context What context are we in? Example: `single` or `directory` | 
| @@ -234,7 +234,7 @@ discard block | ||
| 234 | 234 | |
| 235 | 235 | self::getInstance()->set_entry( $entry ); | 
| 236 | 236 | |
| 237 | - $base = GravityView_API::directory_link( $post_id, true ); | |
| 237 | + $base = GravityView_API::directory_link( $post_id, true ); | |
| 238 | 238 | |
| 239 | 239 |  		if( empty( $base ) ) { | 
| 240 | 240 | do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id ); | 
| @@ -244,13 +244,13 @@ discard block | ||
| 244 | 244 | // Use the slug instead of the ID for consistent security | 
| 245 | 245 | $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); | 
| 246 | 246 | |
| 247 | - $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; | |
| 247 | + $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; | |
| 248 | 248 | |
| 249 | 249 | $actionurl = add_query_arg( array( | 
| 250 | 250 | 'action' => 'delete', | 
| 251 | 251 | 'entry_id' => $entry_slug, | 
| 252 | 252 | 'gvid' => $view_id, | 
| 253 | - 'view_id' => $view_id, | |
| 253 | + 'view_id' => $view_id, | |
| 254 | 254 | ), $base ); | 
| 255 | 255 | |
| 256 | 256 | $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); | 
| @@ -424,7 +424,7 @@ discard block | ||
| 424 | 424 | * @since 1.16.4 | 
| 425 | 425 | * @param int $entry_id ID of the Gravity Forms entry | 
| 426 | 426 | * @param array $entry Deleted entry array | 
| 427 | - */ | |
| 427 | + */ | |
| 428 | 428 | do_action( 'gravityview/delete-entry/deleted', $entry_id, $entry ); | 
| 429 | 429 | } | 
| 430 | 430 | |
| @@ -69,7 +69,6 @@ | ||
| 69 | 69 | * Change wording for the Edit context to read Entry Creator | 
| 70 | 70 | * | 
| 71 | 71 | * @param array $visibility_caps Array of capabilities to display in field dropdown. | 
| 72 | - * @param string $field_type Type of field options to render (`field` or `widget`) | |
| 73 | 72 | * @param string $template_id Table slug | 
| 74 | 73 | * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` | 
| 75 | 74 | * @param string $context What context are we in? Example: `single` or `directory` | 
| @@ -10,175 +10,175 @@ | ||
| 10 | 10 | */ | 
| 11 | 11 | |
| 12 | 12 |  if ( ! defined( 'WPINC' ) ) { | 
| 13 | - die; | |
| 13 | + die; | |
| 14 | 14 | } | 
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 |  class GravityView_Edit_Entry_Admin { | 
| 18 | 18 | |
| 19 | - protected $loader; | |
| 19 | + protected $loader; | |
| 20 | 20 | |
| 21 | -    function __construct( GravityView_Edit_Entry $loader ) { | |
| 22 | - $this->loader = $loader; | |
| 23 | - } | |
| 21 | +	function __construct( GravityView_Edit_Entry $loader ) { | |
| 22 | + $this->loader = $loader; | |
| 23 | + } | |
| 24 | 24 | |
| 25 | -    function load() { | |
| 26 | - | |
| 27 | -        if( !is_admin() ) { | |
| 28 | - return; | |
| 29 | - } | |
| 30 | - | |
| 31 | - // Add Edit Link as a default field, outside those set in the Gravity Form form | |
| 32 | - add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); | |
| 33 | - | |
| 34 | - // For the Edit Entry Link, you don't want visible to all users. | |
| 35 | - add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); | |
| 25 | +	function load() { | |
| 26 | + | |
| 27 | +		if( !is_admin() ) { | |
| 28 | + return; | |
| 29 | + } | |
| 30 | + | |
| 31 | + // Add Edit Link as a default field, outside those set in the Gravity Form form | |
| 32 | + add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); | |
| 33 | + | |
| 34 | + // For the Edit Entry Link, you don't want visible to all users. | |
| 35 | + add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); | |
| 36 | 36 | |
| 37 | - // Modify the field options based on the name of the field type | |
| 38 | - add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 ); | |
| 37 | + // Modify the field options based on the name of the field type | |
| 38 | + add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 ); | |
| 39 | 39 | |
| 40 | - // add tooltips | |
| 41 | - add_filter( 'gravityview_tooltips', array( $this, 'tooltips') ); | |
| 42 | - | |
| 43 | - // custom fields' options for zone EDIT | |
| 44 | - add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 ); | |
| 45 | - } | |
| 46 | - | |
| 47 | - /** | |
| 48 | - * Add Edit Link as a default field, outside those set in the Gravity Form form | |
| 49 | - * @param array $entry_default_fields Existing fields | |
| 50 | - * @param string|array $form form_ID or form object | |
| 51 | - * @param string $zone Either 'single', 'directory', 'header', 'footer' | |
| 52 | - */ | |
| 53 | -    function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { | |
| 54 | - | |
| 55 | -        if( $zone !== 'edit' ) { | |
| 56 | - | |
| 57 | - $entry_default_fields['edit_link'] = array( | |
| 58 | -                'label' => __('Edit Entry', 'gravityview'), | |
| 59 | - 'type' => 'edit_link', | |
| 60 | -                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'), | |
| 61 | - ); | |
| 62 | - | |
| 63 | - } | |
| 64 | - | |
| 65 | - return $entry_default_fields; | |
| 66 | - } | |
| 67 | - | |
| 68 | - /** | |
| 69 | - * Change wording for the Edit context to read Entry Creator | |
| 70 | - * | |
| 71 | - * @param array $visibility_caps Array of capabilities to display in field dropdown. | |
| 72 | - * @param string $field_type Type of field options to render (`field` or `widget`) | |
| 73 | - * @param string $template_id Table slug | |
| 74 | - * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` | |
| 75 | - * @param string $context What context are we in? Example: `single` or `directory` | |
| 76 | - * @param string $input_type (textarea, list, select, etc.) | |
| 77 | - * @return array Array of field options with `label`, `value`, `type`, `default` keys | |
| 78 | - */ | |
| 79 | -    function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) { | |
| 80 | - | |
| 81 | - $caps = $visibility_caps; | |
| 82 | - | |
| 83 | - // If we're configuring fields in the edit context, we want a limited selection | |
| 84 | -        if( $context === 'edit' ) { | |
| 85 | - | |
| 86 | - // Remove other built-in caps. | |
| 87 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); | |
| 88 | - | |
| 89 | -            $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); | |
| 90 | - } | |
| 91 | - | |
| 92 | - return $caps; | |
| 93 | - } | |
| 94 | - | |
| 95 | - /** | |
| 96 | - * Add "Edit Link Text" setting to the edit_link field settings | |
| 97 | - * @param [type] $field_options [description] | |
| 98 | - * @param [type] $template_id [description] | |
| 99 | - * @param [type] $field_id [description] | |
| 100 | - * @param [type] $context [description] | |
| 101 | - * @param [type] $input_type [description] | |
| 102 | - * @return [type] [description] | |
| 103 | - */ | |
| 104 | -    function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { | |
| 105 | - | |
| 106 | - // Always a link, never a filter | |
| 107 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); | |
| 108 | - | |
| 109 | - // Edit Entry link should only appear to visitors capable of editing entries | |
| 110 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); | |
| 111 | - | |
| 112 | - $add_option['edit_link'] = array( | |
| 113 | - 'type' => 'text', | |
| 114 | - 'label' => __( 'Edit Link Text', 'gravityview' ), | |
| 115 | - 'desc' => NULL, | |
| 116 | -            'value' => __('Edit Entry', 'gravityview'), | |
| 117 | - 'merge_tags' => true, | |
| 118 | - ); | |
| 119 | - | |
| 120 | - return array_merge( $add_option, $field_options ); | |
| 121 | - } | |
| 122 | - | |
| 123 | - /** | |
| 124 | - * Add tooltips | |
| 125 | - * @param array $tooltips Existing tooltips | |
| 126 | - * @return array Modified tooltips | |
| 127 | - */ | |
| 128 | -    function tooltips( $tooltips ) { | |
| 129 | - | |
| 130 | - $return = $tooltips; | |
| 131 | - | |
| 132 | - $return['allow_edit_cap'] = array( | |
| 133 | -            'title' => __('Limiting Edit Access', 'gravityview'), | |
| 134 | -            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), | |
| 135 | - ); | |
| 136 | - | |
| 137 | - return $return; | |
| 138 | - } | |
| 139 | - | |
| 140 | - /** | |
| 141 | - * Manipulate the fields' options for the EDIT ENTRY screen | |
| 142 | - * @param [type] $field_options [description] | |
| 143 | - * @param [type] $template_id [description] | |
| 144 | - * @param [type] $field_id [description] | |
| 145 | - * @param [type] $context [description] | |
| 146 | - * @param [type] $input_type [description] | |
| 147 | - * @return [type] [description] | |
| 148 | - */ | |
| 149 | -    function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { | |
| 150 | - | |
| 151 | - // We only want to modify the settings for the edit context | |
| 152 | -        if( 'edit' !== $context ) { | |
| 153 | - | |
| 154 | - /** | |
| 155 | - * @since 1.8.4 | |
| 156 | - */ | |
| 157 | - $field_options['new_window'] = array( | |
| 158 | - 'type' => 'checkbox', | |
| 159 | - 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), | |
| 160 | - 'value' => false, | |
| 161 | - ); | |
| 162 | - | |
| 163 | - return $field_options; | |
| 164 | - } | |
| 165 | - | |
| 166 | - // Entry field is only for logged in users | |
| 167 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); | |
| 168 | - | |
| 169 | - $add_options = array( | |
| 170 | - 'allow_edit_cap' => array( | |
| 171 | - 'type' => 'select', | |
| 172 | - 'label' => __( 'Make field editable to:', 'gravityview' ), | |
| 173 | - 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), | |
| 174 | - 'tooltip' => 'allow_edit_cap', | |
| 175 | - 'class' => 'widefat', | |
| 176 | - 'value' => 'read', // Default: entry creator | |
| 177 | - ), | |
| 178 | - ); | |
| 179 | - | |
| 180 | - return array_merge( $field_options, $add_options ); | |
| 181 | - } | |
| 40 | + // add tooltips | |
| 41 | + add_filter( 'gravityview_tooltips', array( $this, 'tooltips') ); | |
| 42 | + | |
| 43 | + // custom fields' options for zone EDIT | |
| 44 | + add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 ); | |
| 45 | + } | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Add Edit Link as a default field, outside those set in the Gravity Form form | |
| 49 | + * @param array $entry_default_fields Existing fields | |
| 50 | + * @param string|array $form form_ID or form object | |
| 51 | + * @param string $zone Either 'single', 'directory', 'header', 'footer' | |
| 52 | + */ | |
| 53 | +	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { | |
| 54 | + | |
| 55 | +		if( $zone !== 'edit' ) { | |
| 56 | + | |
| 57 | + $entry_default_fields['edit_link'] = array( | |
| 58 | +				'label' => __('Edit Entry', 'gravityview'), | |
| 59 | + 'type' => 'edit_link', | |
| 60 | +				'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'), | |
| 61 | + ); | |
| 62 | + | |
| 63 | + } | |
| 64 | + | |
| 65 | + return $entry_default_fields; | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Change wording for the Edit context to read Entry Creator | |
| 70 | + * | |
| 71 | + * @param array $visibility_caps Array of capabilities to display in field dropdown. | |
| 72 | + * @param string $field_type Type of field options to render (`field` or `widget`) | |
| 73 | + * @param string $template_id Table slug | |
| 74 | + * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` | |
| 75 | + * @param string $context What context are we in? Example: `single` or `directory` | |
| 76 | + * @param string $input_type (textarea, list, select, etc.) | |
| 77 | + * @return array Array of field options with `label`, `value`, `type`, `default` keys | |
| 78 | + */ | |
| 79 | +	function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) { | |
| 80 | + | |
| 81 | + $caps = $visibility_caps; | |
| 82 | + | |
| 83 | + // If we're configuring fields in the edit context, we want a limited selection | |
| 84 | +		if( $context === 'edit' ) { | |
| 85 | + | |
| 86 | + // Remove other built-in caps. | |
| 87 | + unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); | |
| 88 | + | |
| 89 | +			$caps['read'] = _x('Entry Creator','User capability', 'gravityview'); | |
| 90 | + } | |
| 91 | + | |
| 92 | + return $caps; | |
| 93 | + } | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * Add "Edit Link Text" setting to the edit_link field settings | |
| 97 | + * @param [type] $field_options [description] | |
| 98 | + * @param [type] $template_id [description] | |
| 99 | + * @param [type] $field_id [description] | |
| 100 | + * @param [type] $context [description] | |
| 101 | + * @param [type] $input_type [description] | |
| 102 | + * @return [type] [description] | |
| 103 | + */ | |
| 104 | +	function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { | |
| 105 | + | |
| 106 | + // Always a link, never a filter | |
| 107 | + unset( $field_options['show_as_link'], $field_options['search_filter'] ); | |
| 108 | + | |
| 109 | + // Edit Entry link should only appear to visitors capable of editing entries | |
| 110 | + unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); | |
| 111 | + | |
| 112 | + $add_option['edit_link'] = array( | |
| 113 | + 'type' => 'text', | |
| 114 | + 'label' => __( 'Edit Link Text', 'gravityview' ), | |
| 115 | + 'desc' => NULL, | |
| 116 | +			'value' => __('Edit Entry', 'gravityview'), | |
| 117 | + 'merge_tags' => true, | |
| 118 | + ); | |
| 119 | + | |
| 120 | + return array_merge( $add_option, $field_options ); | |
| 121 | + } | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * Add tooltips | |
| 125 | + * @param array $tooltips Existing tooltips | |
| 126 | + * @return array Modified tooltips | |
| 127 | + */ | |
| 128 | +	function tooltips( $tooltips ) { | |
| 129 | + | |
| 130 | + $return = $tooltips; | |
| 131 | + | |
| 132 | + $return['allow_edit_cap'] = array( | |
| 133 | +			'title' => __('Limiting Edit Access', 'gravityview'), | |
| 134 | +			'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), | |
| 135 | + ); | |
| 136 | + | |
| 137 | + return $return; | |
| 138 | + } | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * Manipulate the fields' options for the EDIT ENTRY screen | |
| 142 | + * @param [type] $field_options [description] | |
| 143 | + * @param [type] $template_id [description] | |
| 144 | + * @param [type] $field_id [description] | |
| 145 | + * @param [type] $context [description] | |
| 146 | + * @param [type] $input_type [description] | |
| 147 | + * @return [type] [description] | |
| 148 | + */ | |
| 149 | +	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { | |
| 150 | + | |
| 151 | + // We only want to modify the settings for the edit context | |
| 152 | +		if( 'edit' !== $context ) { | |
| 153 | + | |
| 154 | + /** | |
| 155 | + * @since 1.8.4 | |
| 156 | + */ | |
| 157 | + $field_options['new_window'] = array( | |
| 158 | + 'type' => 'checkbox', | |
| 159 | + 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), | |
| 160 | + 'value' => false, | |
| 161 | + ); | |
| 162 | + | |
| 163 | + return $field_options; | |
| 164 | + } | |
| 165 | + | |
| 166 | + // Entry field is only for logged in users | |
| 167 | + unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); | |
| 168 | + | |
| 169 | + $add_options = array( | |
| 170 | + 'allow_edit_cap' => array( | |
| 171 | + 'type' => 'select', | |
| 172 | + 'label' => __( 'Make field editable to:', 'gravityview' ), | |
| 173 | + 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), | |
| 174 | + 'tooltip' => 'allow_edit_cap', | |
| 175 | + 'class' => 'widefat', | |
| 176 | + 'value' => 'read', // Default: entry creator | |
| 177 | + ), | |
| 178 | + ); | |
| 179 | + | |
| 180 | + return array_merge( $field_options, $add_options ); | |
| 181 | + } | |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | } // end class | 
| 185 | 185 | \ No newline at end of file |