14 if ( ! defined(
'WPINC' ) ) {
37 self::$file = plugin_dir_path( __FILE__ );
59 if( empty( self::$instance ) ) {
63 return self::$instance;
69 $dir = trailingslashit( self::$file );
71 $filename = $dir .
'class-edit-entry-' . $component .
'.php';
72 $classname =
'GravityView_Edit_Entry_' . str_replace(
' ',
'_', ucwords( str_replace(
'-',
' ', $component ) ) );
76 require_once $filename;
77 $this->instances[ $component ] =
new $classname( $this );
78 $this->instances[ $component ]->load();
85 add_action(
'wp_ajax_nopriv_rg_delete_file', array( $this,
'delete_file') );
88 add_action(
'wp_ajax_rg_delete_file', array( $this,
'delete_file') );
90 add_filter(
'gravityview_blocklist_field_types', array( $this,
'modify_field_blocklist' ), 10, 2 );
93 add_filter(
'gravityview_template_paths', array( $this,
'add_template_path' ) );
95 add_filter(
'gravityview/field/is_visible', array( $this,
'maybe_not_visible' ), 10, 3 );
97 add_filter(
'gravityview/api/reserved_query_args', array( $this,
'add_reserved_arg' ) );
122 if( class_exists(
'GFSignature' ) && is_callable( array(
'GFSignature',
'get_instance' ) ) ) {
123 add_filter(
'gform_admin_pre_render', array( GFSignature::get_instance(),
'edit_lead_script'));
142 if (
'edit_link' !==
$field->ID ) {
146 if ( ! $view instanceof \
GV\View ) {
150 static $visibility_cache_for_view = array();
152 if ( ! is_null( $result = \
GV\Utils::get( $visibility_cache_for_view, $view->ID, null ) ) ) {
156 foreach ( $view->get_entries()->all() as
$entry ) {
157 if ( self::check_user_cap_edit_entry(
$entry->as_entry(), $view ) ) {
159 $visibility_cache_for_view[ $view->ID ] =
true;
164 $visibility_cache_for_view[ $view->ID ] =
false;
176 $file_paths[ 110 ] = self::$file;
214 $url = add_query_arg( array(
215 'edit' => wp_create_nonce( $nonce_key )
219 $url = add_query_arg( array(
'gvid' => $view_id ),
$url );
226 if( !empty( $field_values ) ) {
228 if( is_array( $field_values ) ) {
230 $params = $field_values;
232 parse_str( $field_values, $params );
235 $url = add_query_arg( $params,
$url );
248 return apply_filters(
'gravityview/edit/link',
$url,
$entry, \
GV\View::by_id( $view_id ), get_post( $view_id ) );
260 _deprecated_function( __METHOD__,
'2.14',
'GravityView_Edit_Entry::modify_field_blocklist()' );
276 if( empty( $context ) || $context !==
'edit' ) {
282 return array_merge( $fields, $add_fields );
295 _deprecated_function( __METHOD__,
'2.14',
'GravityView_Edit_Entry::get_field_blocklist()' );
326 $fields = apply_filters_deprecated(
'gravityview/edit_entry/field_blacklist', array( $fields,
$entry ),
'2.14',
'gravityview/edit_entry/field_blocklist' );
334 $fields = apply_filters(
'gravityview/edit_entry/field_blocklist', $fields,
$entry );
352 $user_can_edit =
false;
355 if ( empty( $view ) ) {
360 if ( $view instanceof \
GV\View ) {
373 if(
GVCommon::has_cap( array(
'gravityforms_edit_entries',
'gravityview_edit_others_entries' ),
$entry[
'id'] ) ) {
375 gravityview()->log->debug(
'User has ability to edit all entries.' );
377 $user_can_edit =
true;
379 }
else if( !isset(
$entry[
'created_by'] ) ) {
381 gravityview()->log->error(
'Entry `created_by` doesn\'t exist.');
383 $user_can_edit =
false;
387 $current_user = wp_get_current_user();
390 if( empty( $user_edit ) ) {
392 gravityview()->log->debug(
'User Edit is disabled. Returning false.' );
394 $user_can_edit =
false;
398 else if( is_user_logged_in() && intval( $current_user->ID ) === intval(
$entry[
'created_by'] ) ) {
400 gravityview()->log->debug(
'User {user_id} created the entry.', array(
'user_id', $current_user->ID ) );
402 $user_can_edit =
true;
404 }
else if( ! is_user_logged_in() ) {
406 gravityview()->log->debug(
'No user defined; edit entry requires logged in user' );
408 $user_can_edit =
false;
420 $user_can_edit = apply_filters(
'gravityview/edit_entry/user_can_edit_entry', $user_can_edit,
$entry,
$view_id );
422 return (
bool) $user_can_edit;
433 add_filter(
'user_has_cap',
function ( $caps ) {
434 $caps[
'gravityforms_delete_entries'] =
true;
440 GFForms::delete_file();
static get_edit_link( $entry, $view_id, $post_id=null, $field_values='')
The edit entry link creates a secure link with a nonce.
add_reserved_arg( $args)
Adds "edit" to the list of internal reserved query args.
delete_file()
Deletes a file.
static getInstance( $passed_post=NULL)
static get_template_setting( $post_id, $key)
Get the setting for a View.
static check_user_cap_edit_entry( $entry, $view=0)
checks if user has permissions to edit a specific entry
maybe_not_visible( $visible, $field, $view)
Hide the field or not.
modify_field_blacklist( $fields=array(), $context=NULL)
2.14 Use {
get_field_blocklist( $entry=array())
Returns array of field types that should not be displayed in Edit Entry.
add_template_path( $file_paths)
Include this extension templates path.
modify_field_blocklist( $fields=array(), $context=NULL)
Edit mode doesn't allow certain field types.
static get_nonce_key( $view_id, $form_id, $entry_id)
Return a well formatted nonce key according to GravityView Edit Entry protocol.
load_components( $component)
get_field_blacklist( $entry=array())
2.14 Use {
if(empty( $created_by)) $form_id
gravityview()
The main GravityView wrapper function.
gv_entry_link( $entry, $post_id=NULL)
addon_specific_hooks()
Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually becaus...
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()