Skip to content

Commit

Permalink
Conditionally show the custom View name setting
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcasual committed May 8, 2024
1 parent 55b2ffe commit e63e77d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/ViewSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ public function add_settings_to_the_dashboards_view_tab( $settings ) {
$roles[ $role ] = $data['name'];
}

$wp_post = get_post( $_REQUEST['post'] ?? '' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$view_name = '';

if ( $wp_post instanceof WP_Post ) {
$view_name = $wp_post->post_title;
}

return array_merge(
$settings,
[
Expand All @@ -91,16 +84,17 @@ public function add_settings_to_the_dashboards_view_tab( $settings ) {
'value' => 0,
],
self::SETTINGS_PREFIX . '_custom_name' => [
'label' => esc_html__( 'Custom View Name', 'gk-gravityview-dashboard-views' ),
'desc' => strtr(
'label' => esc_html__( 'Custom View Name', 'gk-gravityview-dashboard-views' ),
'desc' => strtr(
esc_html__( 'Use this field to specify the View name as it will appear in the Dashboard.', 'gk-gravityview-dashboard-views' ),
[
'[url]' => '<a href="' . esc_url( GravityKitFoundation::settings()->get_plugin_settings_url( GravityViewPluginSettings::SETTINGS_PLUGIN_ID ) . '&s=3' ) . '">',
'[/url]' => '</a>',
]
),
'type' => 'text',
'value' => $view_name,
'requires' => self::SETTINGS_PREFIX . '_enable',
'type' => 'text',
'value' => get_the_title( $_REQUEST['post'] ?? '' ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
],
self::SETTINGS_PREFIX . '_user_roles' => [
'label' => esc_html__( 'Limit Access to User Role(s)', 'gk-gravityview-dashboard-views' ),
Expand Down Expand Up @@ -193,9 +187,9 @@ public function render_limit_access_to_user_roles_setting( $setting_key, $settin
$label = $settings[ $setting_key ]['label'] ?? '';
$description = $settings[ $setting_key ]['desc'] ?? '';
$placeholder = $settings[ $setting_key ]['placeholder'] ?? '';
$selected_roles = $settings_values[ $setting_key ] ?? [];
$requires = $settings[ $setting_key ]['requires'] ?? '';
$roles = $settings[ $setting_key ]['roles'] ?? [];
$selected_roles = $settings_values[ $setting_key ] ?? [];

?>
<tr style="vertical-align: top;" class="alternate">
Expand Down

0 comments on commit e63e77d

Please sign in to comment.