@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | // Enqueue code editor and settings for manipulating HTML. |
47 | 47 | add_action('admin_enqueue_scripts', function() { |
48 | 48 | |
49 | - $settings = wp_enqueue_code_editor( array( 'type' => 'text/html' ) ); |
|
49 | + $settings = wp_enqueue_code_editor( array( 'type' => 'text/html' ) ); |
|
50 | 50 | }); |
51 | 51 | |
52 | 52 | // @todo check if this hook is needed.. |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * When on the Add/Edit View screen, suggest most popular articles related to that |
|
72 | - * |
|
71 | + * When on the Add/Edit View screen, suggest most popular articles related to that |
|
72 | + * |
|
73 | 73 | * @param array $localization_data Data to be passed to the Support Port JS |
74 | 74 | * |
75 | 75 | * @return array |
76 | 76 | */ |
77 | 77 | function suggest_support_articles( $localization_data = array() ) { |
78 | 78 | |
79 | - if( ! gravityview()->request->is_view() ) { |
|
80 | - return $localization_data; |
|
81 | - } |
|
79 | + if( ! gravityview()->request->is_view() ) { |
|
80 | + return $localization_data; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | $localization_data['suggest'] = array( |
84 | - '57ef23539033602e61d4a560', |
|
85 | - '54c67bb9e4b0512429885513', |
|
86 | - '54c67bb9e4b0512429885512', |
|
87 | - '54c67bbbe4b07997ea3f3f6b', |
|
88 | - '54d1a33ae4b086c0c0964ce9', |
|
89 | - '57ef253c9033602e61d4a563', |
|
90 | - '552355bfe4b0221aadf2572b', |
|
91 | - '54c67bcde4b051242988553e', |
|
92 | - ); |
|
84 | + '57ef23539033602e61d4a560', |
|
85 | + '54c67bb9e4b0512429885513', |
|
86 | + '54c67bb9e4b0512429885512', |
|
87 | + '54c67bbbe4b07997ea3f3f6b', |
|
88 | + '54d1a33ae4b086c0c0964ce9', |
|
89 | + '57ef253c9033602e61d4a563', |
|
90 | + '552355bfe4b0221aadf2572b', |
|
91 | + '54c67bcde4b051242988553e', |
|
92 | + ); |
|
93 | 93 | |
94 | 94 | return $localization_data; |
95 | 95 | } |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | |
236 | 236 | if( 'form_list' === GFForms::get_page() ) { |
237 | 237 | $priority = 790; |
238 | - } |
|
238 | + } |
|
239 | 239 | |
240 | 240 | if( empty( $connected_views ) ) { |
241 | 241 | |
242 | - $menu_items['gravityview'] = array( |
|
242 | + $menu_items['gravityview'] = array( |
|
243 | 243 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
244 | 244 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', // Only appears in GF pre-2.5 |
245 | 245 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -271,13 +271,13 @@ discard block |
||
271 | 271 | // If there were no items added, then let's create the parent menu |
272 | 272 | if( $sub_menu_items ) { |
273 | 273 | |
274 | - $sub_menu_items[] = array( |
|
275 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
276 | - 'icon' => '<span class="dashicons dashicons-plus"></span>', |
|
277 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
278 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
279 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
280 | - ); |
|
274 | + $sub_menu_items[] = array( |
|
275 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
276 | + 'icon' => '<span class="dashicons dashicons-plus"></span>', |
|
277 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
278 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
279 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
280 | + ); |
|
281 | 281 | |
282 | 282 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
283 | 283 | $sub_menu_items[] = array( |
@@ -659,16 +659,16 @@ discard block |
||
659 | 659 | /** |
660 | 660 | * Render html for displaying available fields based on a Form ID |
661 | 661 | * |
662 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
662 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
663 | 663 | * |
664 | 664 | * @param int $form Gravity Forms Form ID (default: '') |
665 | 665 | * @param string $context (default: 'single') |
666 | - * |
|
666 | + * |
|
667 | 667 | * @return void |
668 | 668 | */ |
669 | 669 | function render_available_fields( $form = 0, $context = 'single' ) { |
670 | 670 | |
671 | - // Determine if form is a preset and convert it to an array with fields |
|
671 | + // Determine if form is a preset and convert it to an array with fields |
|
672 | 672 | $form = ( is_string( $form ) && preg_match( '/^preset_/', $form ) ) ? GravityView_Ajax::pre_get_form_fields( $form ) : $form; |
673 | 673 | |
674 | 674 | /** |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | |
681 | 681 | if ( ! is_array( $blacklist_field_types ) ) { |
682 | 682 | |
683 | - gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
683 | + gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
684 | 684 | |
685 | 685 | $blacklist_field_types = array(); |
686 | 686 | } |
@@ -936,9 +936,9 @@ discard block |
||
936 | 936 | |
937 | 937 | $joined_forms = gravityview_get_joined_forms( $post->ID ); |
938 | 938 | |
939 | - foreach ( $joined_forms as $form ) { |
|
940 | - $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
941 | - } |
|
939 | + foreach ( $joined_forms as $form ) { |
|
940 | + $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
941 | + } |
|
942 | 942 | } else { |
943 | 943 | $available_items[ $form ] = \GV\Widget::registered(); |
944 | 944 | } |
@@ -977,9 +977,9 @@ discard block |
||
977 | 977 | |
978 | 978 | if ( $form_id ) { |
979 | 979 | $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
980 | - } else { |
|
980 | + } else { |
|
981 | 981 | $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
982 | - } |
|
982 | + } |
|
983 | 983 | |
984 | 984 | if ( !$original_item ) { |
985 | 985 | gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | // Add the GV font (with the Astronaut) |
1232 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1232 | + wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1233 | 1233 | wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version ); |
1234 | 1234 | |
1235 | 1235 | wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true ); |
@@ -1237,43 +1237,43 @@ discard block |
||
1237 | 1237 | if( GFForms::get_page() === 'form_list' ) { |
1238 | 1238 | wp_enqueue_style( 'gravityview_views_styles' ); |
1239 | 1239 | return; |
1240 | - } |
|
1240 | + } |
|
1241 | 1241 | |
1242 | 1242 | // Don't process any scripts below here if it's not a GravityView page. |
1243 | 1243 | if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
1244 | - return; |
|
1244 | + return; |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1248 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1249 | - |
|
1250 | - // Enqueue scripts |
|
1251 | - wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
|
1252 | - |
|
1253 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1254 | - 'cookiepath' => COOKIEPATH, |
|
1255 | - 'admin_cookiepath' => ADMIN_COOKIE_PATH, |
|
1256 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1257 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1258 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1259 | - 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1260 | - 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1261 | - 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1262 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
1263 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1264 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1265 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1266 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1267 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1268 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1269 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1270 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone?', 'gravityview' ), |
|
1271 | - )); |
|
1247 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1248 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1249 | + |
|
1250 | + // Enqueue scripts |
|
1251 | + wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
|
1252 | + |
|
1253 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1254 | + 'cookiepath' => COOKIEPATH, |
|
1255 | + 'admin_cookiepath' => ADMIN_COOKIE_PATH, |
|
1256 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1257 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1258 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1259 | + 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
1260 | + 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
1261 | + 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
1262 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
1263 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1264 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1265 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1266 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1267 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1268 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1269 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1270 | + 'remove_all_fields' => __( 'Would you like to remove all fields in this zone?', 'gravityview' ), |
|
1271 | + )); |
|
1272 | 1272 | |
1273 | 1273 | wp_enqueue_style( 'gravityview_views_styles' ); |
1274 | 1274 | |
1275 | - // Enqueue scripts needed for merge tags |
|
1276 | - self::enqueue_gravity_forms_scripts(); |
|
1275 | + // Enqueue scripts needed for merge tags |
|
1276 | + self::enqueue_gravity_forms_scripts(); |
|
1277 | 1277 | |
1278 | 1278 | // 2.5 changed how Merge Tags are enqueued |
1279 | 1279 | if ( is_callable( array( 'GFCommon', 'output_hooks_javascript') ) ) { |
@@ -1283,24 +1283,24 @@ discard block |
||
1283 | 1283 | |
1284 | 1284 | /** |
1285 | 1285 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
1286 | - * |
|
1287 | - * @since 1.0.5-beta |
|
1288 | - * |
|
1289 | - * @return void |
|
1286 | + * |
|
1287 | + * @since 1.0.5-beta |
|
1288 | + * |
|
1289 | + * @return void |
|
1290 | 1290 | */ |
1291 | 1291 | static function enqueue_gravity_forms_scripts() { |
1292 | 1292 | GFForms::register_scripts(); |
1293 | 1293 | |
1294 | 1294 | $scripts = array( |
1295 | - 'sack', |
|
1296 | - 'gform_gravityforms', |
|
1297 | - 'gform_forms', |
|
1298 | - 'gform_form_admin', |
|
1299 | - 'jquery-ui-autocomplete' |
|
1295 | + 'sack', |
|
1296 | + 'gform_gravityforms', |
|
1297 | + 'gform_forms', |
|
1298 | + 'gform_form_admin', |
|
1299 | + 'jquery-ui-autocomplete' |
|
1300 | 1300 | ); |
1301 | 1301 | |
1302 | 1302 | if ( wp_is_mobile() ) { |
1303 | - $scripts[] = 'jquery-touch-punch'; |
|
1303 | + $scripts[] = 'jquery-touch-punch'; |
|
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | wp_enqueue_script( $scripts ); |
@@ -45,13 +45,13 @@ |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | $field_options['link_phone'] = array( |
48 | - 'type' => 'checkbox', |
|
49 | - 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
|
50 | - 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview'), |
|
51 | - 'value' => true, |
|
52 | - 'group' => 'display', |
|
53 | - 'priority' => 100, |
|
54 | - ); |
|
48 | + 'type' => 'checkbox', |
|
49 | + 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
|
50 | + 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview'), |
|
51 | + 'value' => true, |
|
52 | + 'group' => 'display', |
|
53 | + 'priority' => 100, |
|
54 | + ); |
|
55 | 55 | |
56 | 56 | return $field_options; |
57 | 57 | } |
@@ -10,42 +10,42 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | if ( ! defined( 'WPINC' ) ) { |
13 | - die; |
|
13 | + die; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | |
17 | 17 | class GravityView_Edit_Entry_Admin { |
18 | 18 | |
19 | - protected $loader; |
|
19 | + protected $loader; |
|
20 | 20 | |
21 | - function __construct( GravityView_Edit_Entry $loader ) { |
|
22 | - $this->loader = $loader; |
|
23 | - } |
|
21 | + function __construct( GravityView_Edit_Entry $loader ) { |
|
22 | + $this->loader = $loader; |
|
23 | + } |
|
24 | 24 | |
25 | - function load() { |
|
25 | + function load() { |
|
26 | 26 | |
27 | - if( !is_admin() ) { |
|
28 | - return; |
|
29 | - } |
|
27 | + if( !is_admin() ) { |
|
28 | + return; |
|
29 | + } |
|
30 | 30 | |
31 | - // Add Edit Link as a default field, outside those set in the Gravity Form form |
|
32 | - add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
|
31 | + // Add Edit Link as a default field, outside those set in the Gravity Form form |
|
32 | + add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
|
33 | 33 | |
34 | - // For the Edit Entry Link, you don't want visible to all users. |
|
35 | - add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); |
|
34 | + // For the Edit Entry Link, you don't want visible to all users. |
|
35 | + add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); |
|
36 | 36 | |
37 | - // Modify the field options based on the name of the field type |
|
38 | - add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 ); |
|
37 | + // Modify the field options based on the name of the field type |
|
38 | + add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 ); |
|
39 | 39 | |
40 | - // add tooltips |
|
41 | - add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
40 | + // add tooltips |
|
41 | + add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
42 | 42 | |
43 | - // custom fields' options for zone EDIT |
|
44 | - add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 ); |
|
43 | + // custom fields' options for zone EDIT |
|
44 | + add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 ); |
|
45 | 45 | |
46 | - // Add Edit Entry settings to View Settings |
|
47 | - add_action( 'gravityview/metaboxes/edit_entry', array( $this, 'view_settings_metabox' ) ); |
|
48 | - } |
|
46 | + // Add Edit Entry settings to View Settings |
|
47 | + add_action( 'gravityview/metaboxes/edit_entry', array( $this, 'view_settings_metabox' ) ); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Render Edit Entry View metabox settings |
@@ -69,101 +69,101 @@ discard block |
||
69 | 69 | GravityView_Render_Settings::render_setting_row( 'edit_redirect_url', $current_settings ); |
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * Add Edit Link as a default field, outside those set in the Gravity Form form |
|
74 | - * @param array $entry_default_fields Existing fields |
|
75 | - * @param string|array $form form_ID or form object |
|
76 | - * @param string $zone Either 'single', 'directory', 'header', 'footer' |
|
77 | - */ |
|
78 | - function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
|
79 | - |
|
80 | - if( $zone !== 'edit' ) { |
|
81 | - |
|
82 | - $entry_default_fields['edit_link'] = array( |
|
83 | - 'label' => __('Link to Edit Entry', 'gravityview'), |
|
84 | - 'type' => 'edit_link', |
|
85 | - 'desc' => __('A link to edit the entry. Visible based on View settings.', 'gravityview'), |
|
86 | - 'icon' => 'dashicons-welcome-write-blog', |
|
87 | - ); |
|
88 | - |
|
89 | - } |
|
90 | - |
|
91 | - return $entry_default_fields; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Change wording for the Edit context to read Entry Creator |
|
96 | - * |
|
97 | - * @param array $visibility_caps Array of capabilities to display in field dropdown. |
|
98 | - * @param string $field_type Type of field options to render (`field` or `widget`) |
|
99 | - * @param string $template_id Table slug |
|
100 | - * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
|
101 | - * @param string $context What context are we in? Example: `single` or `directory` |
|
102 | - * @param string $input_type (textarea, list, select, etc.) |
|
103 | - * @return array Array of field options with `label`, `value`, `type`, `default` keys |
|
104 | - */ |
|
105 | - function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
106 | - |
|
107 | - $caps = $visibility_caps; |
|
108 | - |
|
109 | - // If we're configuring fields in the edit context, we want a limited selection |
|
110 | - if( $context === 'edit' ) { |
|
111 | - |
|
112 | - // Remove other built-in caps. |
|
113 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
114 | - |
|
115 | - $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); |
|
116 | - } |
|
117 | - |
|
118 | - return $caps; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Add "Edit Link Text" setting to the edit_link field settings |
|
123 | - * |
|
124 | - * @param array $field_options |
|
125 | - * @param string $template_id |
|
126 | - * @param string $field_id |
|
127 | - * @param string $context |
|
128 | - * @param string $input_type |
|
129 | - * |
|
130 | - * @return array $field_options, with "Edit Link Text" field option |
|
131 | - */ |
|
132 | - function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
|
133 | - |
|
134 | - // Always a link, never a filter |
|
135 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
136 | - |
|
137 | - // Edit Entry link should only appear to visitors capable of editing entries |
|
138 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
139 | - |
|
140 | - $add_option['edit_link'] = array( |
|
141 | - 'type' => 'text', |
|
142 | - 'label' => __( 'Edit Link Text', 'gravityview' ), |
|
143 | - 'desc' => NULL, |
|
144 | - 'value' => __('Edit Entry', 'gravityview'), |
|
145 | - 'merge_tags' => true, |
|
146 | - ); |
|
147 | - |
|
148 | - return array_merge( $add_option, $field_options ); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * Add tooltips |
|
153 | - * @param array $tooltips Existing tooltips |
|
154 | - * @return array Modified tooltips |
|
155 | - */ |
|
156 | - function tooltips( $tooltips ) { |
|
157 | - |
|
158 | - $return = $tooltips; |
|
159 | - |
|
160 | - $return['allow_edit_cap'] = array( |
|
161 | - 'title' => __('Limiting Edit Access', 'gravityview'), |
|
162 | - 'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), |
|
163 | - ); |
|
164 | - |
|
165 | - return $return; |
|
166 | - } |
|
72 | + /** |
|
73 | + * Add Edit Link as a default field, outside those set in the Gravity Form form |
|
74 | + * @param array $entry_default_fields Existing fields |
|
75 | + * @param string|array $form form_ID or form object |
|
76 | + * @param string $zone Either 'single', 'directory', 'header', 'footer' |
|
77 | + */ |
|
78 | + function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
|
79 | + |
|
80 | + if( $zone !== 'edit' ) { |
|
81 | + |
|
82 | + $entry_default_fields['edit_link'] = array( |
|
83 | + 'label' => __('Link to Edit Entry', 'gravityview'), |
|
84 | + 'type' => 'edit_link', |
|
85 | + 'desc' => __('A link to edit the entry. Visible based on View settings.', 'gravityview'), |
|
86 | + 'icon' => 'dashicons-welcome-write-blog', |
|
87 | + ); |
|
88 | + |
|
89 | + } |
|
90 | + |
|
91 | + return $entry_default_fields; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Change wording for the Edit context to read Entry Creator |
|
96 | + * |
|
97 | + * @param array $visibility_caps Array of capabilities to display in field dropdown. |
|
98 | + * @param string $field_type Type of field options to render (`field` or `widget`) |
|
99 | + * @param string $template_id Table slug |
|
100 | + * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
|
101 | + * @param string $context What context are we in? Example: `single` or `directory` |
|
102 | + * @param string $input_type (textarea, list, select, etc.) |
|
103 | + * @return array Array of field options with `label`, `value`, `type`, `default` keys |
|
104 | + */ |
|
105 | + function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
106 | + |
|
107 | + $caps = $visibility_caps; |
|
108 | + |
|
109 | + // If we're configuring fields in the edit context, we want a limited selection |
|
110 | + if( $context === 'edit' ) { |
|
111 | + |
|
112 | + // Remove other built-in caps. |
|
113 | + unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
114 | + |
|
115 | + $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); |
|
116 | + } |
|
117 | + |
|
118 | + return $caps; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Add "Edit Link Text" setting to the edit_link field settings |
|
123 | + * |
|
124 | + * @param array $field_options |
|
125 | + * @param string $template_id |
|
126 | + * @param string $field_id |
|
127 | + * @param string $context |
|
128 | + * @param string $input_type |
|
129 | + * |
|
130 | + * @return array $field_options, with "Edit Link Text" field option |
|
131 | + */ |
|
132 | + function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
|
133 | + |
|
134 | + // Always a link, never a filter |
|
135 | + unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
136 | + |
|
137 | + // Edit Entry link should only appear to visitors capable of editing entries |
|
138 | + unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
139 | + |
|
140 | + $add_option['edit_link'] = array( |
|
141 | + 'type' => 'text', |
|
142 | + 'label' => __( 'Edit Link Text', 'gravityview' ), |
|
143 | + 'desc' => NULL, |
|
144 | + 'value' => __('Edit Entry', 'gravityview'), |
|
145 | + 'merge_tags' => true, |
|
146 | + ); |
|
147 | + |
|
148 | + return array_merge( $add_option, $field_options ); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * Add tooltips |
|
153 | + * @param array $tooltips Existing tooltips |
|
154 | + * @return array Modified tooltips |
|
155 | + */ |
|
156 | + function tooltips( $tooltips ) { |
|
157 | + |
|
158 | + $return = $tooltips; |
|
159 | + |
|
160 | + $return['allow_edit_cap'] = array( |
|
161 | + 'title' => __('Limiting Edit Access', 'gravityview'), |
|
162 | + 'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), |
|
163 | + ); |
|
164 | + |
|
165 | + return $return; |
|
166 | + } |
|
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Add "Edit Link Text" setting to the edit_link field settings |
@@ -179,28 +179,28 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
181 | 181 | |
182 | - // We only want to modify the settings for the edit context |
|
183 | - if( 'edit' !== $context ) { |
|
184 | - return $field_options; |
|
185 | - } |
|
186 | - |
|
187 | - // Entry field is only for logged in users |
|
188 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
189 | - |
|
190 | - $add_options = array( |
|
191 | - 'allow_edit_cap' => array( |
|
192 | - 'type' => 'select', |
|
193 | - 'label' => __( 'Make field editable to:', 'gravityview' ), |
|
194 | - 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
|
195 | - 'tooltip' => 'allow_edit_cap', |
|
196 | - 'class' => 'widefat', |
|
197 | - 'value' => 'read', // Default: entry creator |
|
198 | - 'group' => 'visibility', |
|
199 | - ), |
|
200 | - ); |
|
201 | - |
|
202 | - return array_merge( $field_options, $add_options ); |
|
203 | - } |
|
182 | + // We only want to modify the settings for the edit context |
|
183 | + if( 'edit' !== $context ) { |
|
184 | + return $field_options; |
|
185 | + } |
|
186 | + |
|
187 | + // Entry field is only for logged in users |
|
188 | + unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
189 | + |
|
190 | + $add_options = array( |
|
191 | + 'allow_edit_cap' => array( |
|
192 | + 'type' => 'select', |
|
193 | + 'label' => __( 'Make field editable to:', 'gravityview' ), |
|
194 | + 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
|
195 | + 'tooltip' => 'allow_edit_cap', |
|
196 | + 'class' => 'widefat', |
|
197 | + 'value' => 'read', // Default: entry creator |
|
198 | + 'group' => 'visibility', |
|
199 | + ), |
|
200 | + ); |
|
201 | + |
|
202 | + return array_merge( $field_options, $add_options ); |
|
203 | + } |
|
204 | 204 | |
205 | 205 | |
206 | 206 | } // end class |