Skip to content

Commit

Permalink
Fix conflict with Gravity Forms using id $_GET attr
Browse files Browse the repository at this point in the history
> Notice: Trying to access array offset on value of type null in /Users/zackkatz/Local Sites/gv/app/public/wp-content/plugins/gravityforms/common.php on line 5061

Also, on line 231, $view wasn't always set, so set backup to `gvid`
  • Loading branch information
zackkatz committed Nov 5, 2020
1 parent be0bf07 commit 59633e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion class-gravityview-admin-view-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function is_view() {
return false;
}

return \GV\View::by_id( \GV\Utils::_GET( 'id' ) );
return \GV\View::by_id( \GV\Utils::_GET( 'gvid' ) );
}

/**
Expand Down
20 changes: 11 additions & 9 deletions class-gravityview-admin-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function view_admin_action( $actions, $post ) {

$actions['adminview'] = sprintf(
'<a href="%s">%s</a>',
esc_url( add_query_arg( 'id', urlencode( $post->ID ), $action_link ) ),
esc_url( add_query_arg( 'gvid', urlencode( $post->ID ), $action_link ) ),
__( 'View in Admin', 'gravityview-adminview' )
);

Expand All @@ -207,7 +207,7 @@ public function add_submenu() {

if( 'adminview' !== \GV\Utils::_GET( 'page' ) ) {
return;
} elseif ( ! isset( $_GET['id'] ) ) {
} elseif ( ! isset( $_GET['gvid'] ) ) {
wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview' ) );
exit();
}
Expand Down Expand Up @@ -236,7 +236,7 @@ public function render_screen() {
</style>';

if ( ! $view = gravityview()->request->is_view() ) {
gravityview()->log->error( 'View cannot be displayed in the admin; View with ID #{view_id} could not be found.', array( 'view_id' => $view_id = \GV\Utils::_GET( 'id' ) ) );
gravityview()->log->error( 'View cannot be displayed in the admin; View with ID #{view_id} could not be found.', array( 'view_id' => $view_id = \GV\Utils::_GET( 'gvid' ) ) );

printf( '<h1>%s</h1>', sprintf( esc_html__( 'View #%s not found.', 'gravityview-admin' ), intval( $view_id ) ) );

Expand Down Expand Up @@ -282,6 +282,8 @@ public function render_screen() {
wp_print_styles();
}



/**
* Filter the entry permalink to lead to the Admin View page.
*
Expand All @@ -304,7 +306,7 @@ public function entry_permalink( $permalink, $entry, $view, $request ) {
$url = add_query_arg( array(
'post_type' => 'gravityview',
'page' => 'adminview',
'id' => $view->ID,
'gvid' => \GV\Utils::get( $view, 'ID', \GV\Utils::_GET( 'gvid' ) ),
'entry_id' => $entry->ID,
), $url );

Expand Down Expand Up @@ -334,7 +336,7 @@ public function search_action( $url ) {
$url = add_query_arg( array(
'post_type' => 'gravityview',
'page' => 'adminview',
'id' => $view->ID,
'gvid' => $view->ID,
), $url );

return $url;
Expand All @@ -360,7 +362,7 @@ public function search_fields() {
$args = array(
'post_type' => 'gravityview',
'page' => 'adminview',
'id' => $view->ID,
'gvid' => $view->ID,
);

foreach ( $args as $field => $value ) {
Expand Down Expand Up @@ -392,7 +394,7 @@ public function page_links_args( $args ) {
'pagenum' => '%#%',
'post_type' => 'gravityview',
'page' => 'adminview',
'id' => $view->ID,
'gvid' => $view->ID,
), $url );

return $args;
Expand Down Expand Up @@ -422,7 +424,7 @@ public function directory_link( $link, $context ) {
$url = add_query_arg( array(
'post_type' => 'gravityview',
'page' => 'adminview',
'id' => $view->ID,
'gvid' => $view->ID,
), $url );

return $url;
Expand Down Expand Up @@ -481,7 +483,7 @@ public function edit_entry_link( $url, $entry, $view ) {
$url = add_query_arg( array(
'post_type' => 'gravityview',
'page' => 'adminview',
'id' => $view->ID,
'gvid' => $view->ID,
'entry_id' => $entry['id'],
'edit' => wp_create_nonce( GravityView_Edit_Entry::get_nonce_key( $view->ID, $entry['form_id'], $entry['id'] ) ),
), $url );
Expand Down

0 comments on commit 59633e1

Please sign in to comment.