Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make approval link text filterable #2031

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions includes/class-gravityview-entry-approval-merge-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,35 @@ protected function replace_merge_tag( $matches = array(), $text = '', $form = ar
continue;
}

$link_url = $this->get_link_url( $token, $expiration_seconds, $privacy );

$anchor_text = GravityView_Entry_Approval_Status::get_action( $action . 'd' );

$link = sprintf( '<a href="%s">%s</a>', esc_url_raw( $link_url ), esc_html( $anchor_text ) );

$text = str_replace( $full_tag, $link, $text );
$approval_link = $this->get_link_url( $token, $expiration_seconds, $privacy );

$approval_link_text = GravityView_Entry_Approval_Status::get_action( $action . 'd' );

$approval_link_params = [
'url' => $approval_link,
'text' => $approval_link_text,
'form_id' => (int) $form['id'],
'action' => $action,
'atts' => []
];

/**
* Modifies entry approval link parameters.
*
* @filter `gk/gravityview/entry/approval-link/params`
*
* @since TBD
*
* @param array{url: string, text: string, form_id: int, action: string, atts: array} $approval_link_params
*/
$approval_link_params = wp_parse_args(
apply_filters( 'gk/gravityview/entry/approval-link/params', $approval_link_params ),
$approval_link_params
);

$approval_link = gravityview_get_link( esc_html( $approval_link_params['url'] ), esc_html( $approval_link_params['text'] ), $approval_link_params['atts'] );

$text = str_replace( $full_tag, $approval_link, $text );
}

return $text;
Expand Down
5 changes: 5 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Beautifully display your Gravity Forms entries. Learn more on [gravitykit.com](h

== Changelog ==

= develop =

__Developer Updates:__
* `gk/gravityview/entry/approval-link/params` filter to modify entry approval link parameters.

= 2.22 on April 16, 2024 =

This release introduces [support for search modifiers](https://docs.gravitykit.com/article/995-gravityview-search-modifiers) and [range-based searching for numeric fields](https://docs.gravitykit.com/article/996-number-range-search), enables easy duplication and precise insertion of View fields and widgets, and resolves critical issues with Yoast SEO and LifterLMS. [Read the announcement](https://www.gravitykit.com/gravityview-2-22/) for more details.
Expand Down