GravityView  2.5
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Private Member Functions
GravityView_Duplicate_Entry Class Reference

Public Member Functions

 __construct ()
 
 add_available_field ( $available_fields=array())
 Add Duplicate Entry Link to the Add Field dialog. More...
 
 add_default_field ( $entry_default_fields, $form=array(), $zone='')
 Add Edit Link as a default field, outside those set in the Gravity Form form. More...
 
 add_template_path ( $file_paths)
 Include this extension templates path. More...
 
 display_message ( $current_view_id=0)
 After processing duplicate entry, the user will be redirected to the referring View or embedded post/page. More...
 
 duplicate_link_field_options ( $field_options, $template_id, $field_id, $context, $input_type)
 Add "Duplicate Link Text" setting to the edit_link field settings. More...
 
 modify_visibility_caps ( $visibility_caps=array(), $template_id='', $field_id='', $context='', $input_type='')
 Change wording for the Edit context to read Entry Creator. More...
 
 process_duplicate ()
 Handle the duplication request, if $_GET['action'] is set to "duplicate". More...
 
 set_entry ( $entry)
 Make sure there's an entry. More...
 
 verify_nonce ()
 Is the current nonce valid for editing the entry? More...
 

Static Public Member Functions

static check_user_cap_duplicate_entry ( $entry, $field, $view_id)
 checks if user has permissions to view the link or duplicate a specific entry More...
 
static get_confirm_dialog ()
 Get the onclick attribute for the confirm dialogs that warns users before they duplicate an entry. More...
 
static get_duplicate_link ( $entry, $view_id, $post_id=null)
 Generate a nonce link with the base URL of the current View embed. More...
 
static get_nonce_key ( $entry_id)
 Generate a consistent nonce key based on the Entry ID. More...
 
static getInstance ()
 Return the instantiated class object. More...
 

Data Fields

 $entry
 
 $view_id
 

Static Public Attributes

static $file
 
static $instance
 

Private Member Functions

 add_hooks ()
 
 duplicate_entry ( $entry)
 Duplicate the entry. More...
 
 user_can_duplicate_entry ( $entry=array(), $view_id=null)
 Check if the user can edit the entry. More...
 

Detailed Description

Since
2.5

Definition at line 22 of file class-duplicate-entry.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Definition at line 41 of file class-duplicate-entry.php.

References add_hooks().

Member Function Documentation

◆ add_available_field()

add_available_field (   $available_fields = array())

Add Duplicate Entry Link to the Add Field dialog.

Since
2.5
Parameters
array$available_fields
Returns
array Fields with duplicate_link added

Definition at line 177 of file class-duplicate-entry.php.

◆ add_default_field()

add_default_field (   $entry_default_fields,
  $form = array(),
  $zone = '' 
)

Add Edit Link as a default field, outside those set in the Gravity Form form.

Since
2.5
Parameters
array$entry_default_fieldsExisting fields
string | array$formform_ID or form object
string$zoneEither 'single', 'directory', 'edit', 'header', 'footer'
Returns
array $entry_default_fields, with duplicate_link added. Won't be added if in Edit Entry context.

Definition at line 155 of file class-duplicate-entry.php.

◆ add_hooks()

add_hooks ( )
private
Since
2.5

Definition at line 50 of file class-duplicate-entry.php.

Referenced by __construct().

◆ add_template_path()

add_template_path (   $file_paths)

Include this extension templates path.

Since
2.5
Parameters
array$file_pathsList of template paths ordered
Returns
array File paths, with duplicate field path added at index 117

Definition at line 92 of file class-duplicate-entry.php.

◆ check_user_cap_duplicate_entry()

static check_user_cap_duplicate_entry (   $entry,
  $field,
  $view_id 
)
static

checks if user has permissions to view the link or duplicate a specific entry

Since
2.5
Parameters
array$entryGravity Forms entry array
array$fieldField settings (optional)
int$view_idPass a View ID to check caps against. If not set, check against current View (
Returns
bool

Definition at line 583 of file class-duplicate-entry.php.

References $field, gravityview(), and GVCommon\has_cap().

◆ display_message()

display_message (   $current_view_id = 0)

After processing duplicate entry, the user will be redirected to the referring View or embedded post/page.

Display a message on redirection.

If success, there will be status URL parameters status=>success If an error, there will be status and message URL parameters status=>error&message=example

Since
2.5
Parameters
int$current_view_idThe ID of the View being rendered
Returns
void
Runs Filter:
gravityview/duplicate-entry/message Modify the Duplicate Entry messages. Allows HTML; will not be further sanitized.
Since
2.5
Parameters
string$messageMessage to be displayed, sanitized using esc_attr()
string$statusMessage status (error or success)
string$message_from_urlThe original error message, if any, without the "There was an error duplicating the entry:" prefix

Definition at line 672 of file class-duplicate-entry.php.

References $class, Utils\_GET(), and getInstance().

◆ duplicate_entry()

duplicate_entry (   $entry)
private

Duplicate the entry.

Done after all the checks in self::process_duplicate.

Since
2.5
Parameters
array$entryThe entry to be duplicated
Returns
WP_Error|boolean
Runs Filter:
gravityview/entry/duplicate/details Modify the new entry details before it's created.
Since
2.5
Parameters
[in,out]array$rowThe entry details
array$entryThe original entry
Runs Filter:
gravityview/entry/duplicate/meta Modify the new entry meta details.
Parameters
[in,out]array$dulicate_metaThe duplicate meta. Use/add meta_key, meta_value, item_index.
array$duplicate_entryThe duplicated entry
array$entryThe original entry
Runs Actions:
gravityview/entry/duplicated Triggered when an entry is duplicated
Since
2.5
Parameters
array$duplicated_entryThe duplicated entry
array$entryThe original entry

Definition at line 388 of file class-duplicate-entry.php.

References Utils\_SERVER(), GV\get(), and gravityview().

Referenced by process_duplicate().

◆ duplicate_link_field_options()

duplicate_link_field_options (   $field_options,
  $template_id,
  $field_id,
  $context,
  $input_type 
)

Add "Duplicate Link Text" setting to the edit_link field settings.

Since
2.5
Parameters
array$field_options[description]
[type]$template_id [description]
[type]$field_id [description]
[type]$context [description]
[type]$input_type [description]
Returns
array [description]

Definition at line 114 of file class-duplicate-entry.php.

References $field_id, and GravityView_Render_Settings\get_cap_choices().

◆ get_confirm_dialog()

static get_confirm_dialog ( )
static

Get the onclick attribute for the confirm dialogs that warns users before they duplicate an entry.

Since
2.5
Returns
string HTML onclick attribute
Runs Filter:
gravityview/duplicate-entry/confirm-text Modify the Duplicate Entry Javascript confirmation text
Parameters
string$confirmDefault: "Are you sure you want to duplicate this entry?"

Definition at line 522 of file class-duplicate-entry.php.

◆ get_duplicate_link()

static get_duplicate_link (   $entry,
  $view_id,
  $post_id = null 
)
static

Generate a nonce link with the base URL of the current View embed.

We don't want to link to the single entry, because when duplicated, there would be nothing to return to.

Since
2.5
Parameters
array$entryGravity Forms entry array
int$view_idThe View id. Not optional since 2.0
int$post_idID of the current post/page being embedded on, if any
Returns
string|null If directory link is valid, the URL to process the duplicate request. Otherwise, NULL.

Definition at line 260 of file class-duplicate-entry.php.

References GravityView_API\directory_link(), and gravityview().

◆ get_nonce_key()

static get_nonce_key (   $entry_id)
static

Generate a consistent nonce key based on the Entry ID.

Since
2.5
Parameters
int$entry_idEntry ID
Returns
string Key used to validate request

Definition at line 242 of file class-duplicate-entry.php.

◆ getInstance()

static getInstance ( )
static

Return the instantiated class object.

Since
2.5
Returns
GravityView_Duplicate_Entry

Definition at line 74 of file class-duplicate-entry.php.

Referenced by display_message().

◆ modify_visibility_caps()

modify_visibility_caps (   $visibility_caps = array(),
  $template_id = '',
  $field_id = '',
  $context = '',
  $input_type = '' 
)

Change wording for the Edit context to read Entry Creator.

Since
2.5
Parameters
array$visibility_capsArray of capabilities to display in field dropdown.
string$field_typeType of field options to render (field or widget)
string$template_idTable slug
float | string$field_idGF Field ID - Example: 3, 5.2, entry_link, created_by
string$contextWhat context are we in? Example: single or directory
string$input_type(textarea, list, select, etc.)
Returns
array Array of field options with label, value, type, default keys

Definition at line 204 of file class-duplicate-entry.php.

References $field_id.

◆ process_duplicate()

process_duplicate ( )

Handle the duplication request, if $_GET['action'] is set to "duplicate".

  1. Check referrer validity
  2. Make sure there's an entry with the slug of $_GET['entry_id']
  3. If so, attempt to duplicate the entry. If not, set the error status
  4. Remove action=duplicate from the URL
  5. Redirect to the page using wp_safe_redirect()
Since
2.5

wp_safe_redirect()

Returns
void|string $url URL during tests instead of redirect.

Definition at line 295 of file class-duplicate-entry.php.

References $entry_slug, duplicate_entry(), gravityview(), gravityview_get_entry(), and user_can_duplicate_entry().

◆ set_entry()

set_entry (   $entry)

Make sure there's an entry.

Since
2.5
Parameters
array$entryCurrent entry array
Returns
void

Definition at line 229 of file class-duplicate-entry.php.

References $entry.

◆ user_can_duplicate_entry()

user_can_duplicate_entry (   $entry = array(),
  $view_id = null 
)
private

Check if the user can edit the entry.

  • Is the nonce valid?
  • Does the user have the right caps for the entry
  • Is the entry in the trash?
Since
2.5
Parameters
array$entryGravity Forms entry array
int$view_idID of the View being rendered
Returns
boolean|WP_Error True: can edit form. WP_Error: nope.

Definition at line 549 of file class-duplicate-entry.php.

References gravityview().

Referenced by process_duplicate().

◆ verify_nonce()

verify_nonce ( )

Is the current nonce valid for editing the entry?

Since
2.5
Returns
boolean
Runs Filter:
gravityview/duplicate-entry/verify_nonce Override Duplicate Entry nonce validation. Return true to declare nonce valid.
Since
2.5
See also
wp_verify_nonce()
Parameters
int | boolean$validFalse if invalid; 1 or 2 when nonce was generated
string$nonce_keyName of nonce action used in wp_verify_nonce. $_GET['duplicate'] holds the nonce value itself. Default: duplicate_{entry_id}

Definition at line 492 of file class-duplicate-entry.php.

Field Documentation

◆ $entry

$entry

Definition at line 37 of file class-duplicate-entry.php.

Referenced by set_entry().

◆ $file

$file
static

Definition at line 27 of file class-duplicate-entry.php.

◆ $instance

$instance
static

Definition at line 32 of file class-duplicate-entry.php.

◆ $view_id

$view_id

Definition at line 39 of file class-duplicate-entry.php.


The documentation for this class was generated from the following file: