@@ -240,7 +240,7 @@ |
||
| 240 | 240 | self::$notices['wp_version'] = array( |
| 241 | 241 | 'class' => 'error', |
| 242 | 242 | 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . $wp_version . '</span>' ), |
| 243 | - 'cap' => 'update_core', |
|
| 243 | + 'cap' => 'update_core', |
|
| 244 | 244 | 'dismiss' => 'wp_version', |
| 245 | 245 | ); |
| 246 | 246 | |
@@ -62,28 +62,28 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | - * When on the Add/Edit View screen, suggest most popular articles related to that |
|
| 66 | - * |
|
| 65 | + * When on the Add/Edit View screen, suggest most popular articles related to that |
|
| 66 | + * |
|
| 67 | 67 | * @param array $localization_data Data to be passed to the Support Port JS |
| 68 | 68 | * |
| 69 | 69 | * @return array |
| 70 | 70 | */ |
| 71 | 71 | function suggest_support_articles( $localization_data = array() ) { |
| 72 | 72 | |
| 73 | - if( ! gravityview()->request->is_view() ) { |
|
| 74 | - return $localization_data; |
|
| 75 | - } |
|
| 73 | + if( ! gravityview()->request->is_view() ) { |
|
| 74 | + return $localization_data; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | $localization_data['suggest'] = array( |
| 78 | - '57ef23539033602e61d4a560', |
|
| 79 | - '54c67bb9e4b0512429885513', |
|
| 80 | - '54c67bb9e4b0512429885512', |
|
| 81 | - '54c67bbbe4b07997ea3f3f6b', |
|
| 82 | - '54d1a33ae4b086c0c0964ce9', |
|
| 83 | - '57ef253c9033602e61d4a563', |
|
| 84 | - '552355bfe4b0221aadf2572b', |
|
| 85 | - '54c67bcde4b051242988553e', |
|
| 86 | - ); |
|
| 78 | + '57ef23539033602e61d4a560', |
|
| 79 | + '54c67bb9e4b0512429885513', |
|
| 80 | + '54c67bb9e4b0512429885512', |
|
| 81 | + '54c67bbbe4b07997ea3f3f6b', |
|
| 82 | + '54d1a33ae4b086c0c0964ce9', |
|
| 83 | + '57ef253c9033602e61d4a563', |
|
| 84 | + '552355bfe4b0221aadf2572b', |
|
| 85 | + '54c67bcde4b051242988553e', |
|
| 86 | + ); |
|
| 87 | 87 | |
| 88 | 88 | return $localization_data; |
| 89 | 89 | } |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | if( 'form_list' === GFForms::get_page() ) { |
| 231 | 231 | $priority = 790; |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | if( empty( $connected_views ) ) { |
| 235 | 235 | |
| 236 | - $menu_items['gravityview'] = array( |
|
| 236 | + $menu_items['gravityview'] = array( |
|
| 237 | 237 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
| 238 | 238 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
| 239 | 239 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | // If there were no items added, then let's create the parent menu |
| 265 | 265 | if( $sub_menu_items ) { |
| 266 | 266 | |
| 267 | - $sub_menu_items[] = array( |
|
| 268 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
| 269 | - 'link_class' => 'gv-create-view', |
|
| 270 | - 'icon' => '<i> + </i>', |
|
| 271 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
| 272 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
| 273 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
| 274 | - ); |
|
| 267 | + $sub_menu_items[] = array( |
|
| 268 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
| 269 | + 'link_class' => 'gv-create-view', |
|
| 270 | + 'icon' => '<i> + </i>', |
|
| 271 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
| 272 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
| 273 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
| 274 | + ); |
|
| 275 | 275 | |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -681,16 +681,16 @@ discard block |
||
| 681 | 681 | /** |
| 682 | 682 | * Render html for displaying available fields based on a Form ID |
| 683 | 683 | * |
| 684 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
| 684 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
| 685 | 685 | * |
| 686 | 686 | * @param int $form Gravity Forms Form ID (default: '') |
| 687 | 687 | * @param string $context (default: 'single') |
| 688 | - * |
|
| 688 | + * |
|
| 689 | 689 | * @return void |
| 690 | 690 | */ |
| 691 | 691 | function render_available_fields( $form = 0, $context = 'single' ) { |
| 692 | 692 | |
| 693 | - // Determine if form is a preset and convert it to an array with fields |
|
| 693 | + // Determine if form is a preset and convert it to an array with fields |
|
| 694 | 694 | $form = ( is_string( $form ) && preg_match( '/^preset_/', $form ) ) ? GravityView_Ajax::pre_get_form_fields( $form ) : $form; |
| 695 | 695 | |
| 696 | 696 | /** |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | |
| 703 | 703 | if ( ! is_array( $blacklist_field_types ) ) { |
| 704 | 704 | |
| 705 | - gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
| 705 | + gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
| 706 | 706 | |
| 707 | 707 | $blacklist_field_types = array(); |
| 708 | 708 | } |
@@ -840,12 +840,12 @@ discard block |
||
| 840 | 840 | /** |
| 841 | 841 | * @since 1.7.2 |
| 842 | 842 | */ |
| 843 | - 'other_entries' => array( |
|
| 844 | - 'label' => __('Other Entries', 'gravityview'), |
|
| 845 | - 'type' => 'other_entries', |
|
| 846 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
| 847 | - ), |
|
| 848 | - ); |
|
| 843 | + 'other_entries' => array( |
|
| 844 | + 'label' => __('Other Entries', 'gravityview'), |
|
| 845 | + 'type' => 'other_entries', |
|
| 846 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
| 847 | + ), |
|
| 848 | + ); |
|
| 849 | 849 | |
| 850 | 850 | if( 'single' !== $zone) { |
| 851 | 851 | |
@@ -1017,9 +1017,9 @@ discard block |
||
| 1017 | 1017 | |
| 1018 | 1018 | $joined_forms = gravityview_get_joined_forms( $post->ID ); |
| 1019 | 1019 | |
| 1020 | - foreach ( $joined_forms as $form ) { |
|
| 1021 | - $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
| 1022 | - } |
|
| 1020 | + foreach ( $joined_forms as $form ) { |
|
| 1021 | + $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
| 1022 | + } |
|
| 1023 | 1023 | } else { |
| 1024 | 1024 | $available_items[ $form ] = \GV\Widget::registered(); |
| 1025 | 1025 | } |
@@ -1047,9 +1047,9 @@ discard block |
||
| 1047 | 1047 | |
| 1048 | 1048 | if ( $form_id ) { |
| 1049 | 1049 | $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
| 1050 | - } else { |
|
| 1050 | + } else { |
|
| 1051 | 1051 | $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
| 1052 | - } |
|
| 1052 | + } |
|
| 1053 | 1053 | |
| 1054 | 1054 | if ( !$original_item ) { |
| 1055 | 1055 | 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 ) ) ); |
@@ -1101,7 +1101,7 @@ discard block |
||
| 1101 | 1101 | |
| 1102 | 1102 | /** |
| 1103 | 1103 | * Render the widget active areas |
| 1104 | - * @param string $template_id The current slug of the selected View template |
|
| 1104 | + * @param string $template_id The current slug of the selected View template |
|
| 1105 | 1105 | * @param string $zone Either 'header' or 'footer' |
| 1106 | 1106 | * @param string $post_id Current Post ID (view) |
| 1107 | 1107 | * @return string html |
@@ -1292,7 +1292,7 @@ discard block |
||
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | 1294 | // Add the GV font (with the Astronaut) |
| 1295 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
| 1295 | + wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
| 1296 | 1296 | wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version ); |
| 1297 | 1297 | |
| 1298 | 1298 | wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true ); |
@@ -1300,42 +1300,42 @@ discard block |
||
| 1300 | 1300 | if( GFForms::get_page() === 'form_list' ) { |
| 1301 | 1301 | wp_enqueue_style( 'gravityview_views_styles' ); |
| 1302 | 1302 | return; |
| 1303 | - } |
|
| 1303 | + } |
|
| 1304 | 1304 | |
| 1305 | 1305 | // Don't process any scripts below here if it's not a GravityView page. |
| 1306 | 1306 | if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
| 1307 | - return; |
|
| 1307 | + return; |
|
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1311 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
| 1312 | - |
|
| 1313 | - // Enqueue scripts |
|
| 1314 | - 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 ); |
|
| 1315 | - |
|
| 1316 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
| 1317 | - 'cookiepath' => COOKIEPATH, |
|
| 1318 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
| 1319 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1320 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1321 | - 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
| 1322 | - 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
| 1323 | - 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
| 1324 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1325 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1326 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1327 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1328 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1329 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1330 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1331 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1332 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
| 1333 | - )); |
|
| 1310 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1311 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
| 1312 | + |
|
| 1313 | + // Enqueue scripts |
|
| 1314 | + 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 ); |
|
| 1315 | + |
|
| 1316 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
| 1317 | + 'cookiepath' => COOKIEPATH, |
|
| 1318 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
| 1319 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1320 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1321 | + 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
| 1322 | + 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
| 1323 | + 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
| 1324 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1325 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1326 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1327 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1328 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1329 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1330 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1331 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1332 | + 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
| 1333 | + )); |
|
| 1334 | 1334 | |
| 1335 | 1335 | wp_enqueue_style( 'gravityview_views_styles' ); |
| 1336 | 1336 | |
| 1337 | - // Enqueue scripts needed for merge tags |
|
| 1338 | - self::enqueue_gravity_forms_scripts(); |
|
| 1337 | + // Enqueue scripts needed for merge tags |
|
| 1338 | + self::enqueue_gravity_forms_scripts(); |
|
| 1339 | 1339 | |
| 1340 | 1340 | // 2.5 changed how Merge Tags are enqueued |
| 1341 | 1341 | if ( is_callable( array( 'GFCommon', 'output_hooks_javascript') ) ) { |
@@ -1345,24 +1345,24 @@ discard block |
||
| 1345 | 1345 | |
| 1346 | 1346 | /** |
| 1347 | 1347 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
| 1348 | - * |
|
| 1349 | - * @since 1.0.5-beta |
|
| 1350 | - * |
|
| 1351 | - * @return void |
|
| 1348 | + * |
|
| 1349 | + * @since 1.0.5-beta |
|
| 1350 | + * |
|
| 1351 | + * @return void |
|
| 1352 | 1352 | */ |
| 1353 | 1353 | static function enqueue_gravity_forms_scripts() { |
| 1354 | 1354 | GFForms::register_scripts(); |
| 1355 | 1355 | |
| 1356 | 1356 | $scripts = array( |
| 1357 | - 'sack', |
|
| 1358 | - 'gform_gravityforms', |
|
| 1359 | - 'gform_forms', |
|
| 1360 | - 'gform_form_admin', |
|
| 1361 | - 'jquery-ui-autocomplete' |
|
| 1357 | + 'sack', |
|
| 1358 | + 'gform_gravityforms', |
|
| 1359 | + 'gform_forms', |
|
| 1360 | + 'gform_form_admin', |
|
| 1361 | + 'jquery-ui-autocomplete' |
|
| 1362 | 1362 | ); |
| 1363 | 1363 | |
| 1364 | 1364 | if ( wp_is_mobile() ) { |
| 1365 | - $scripts[] = 'jquery-touch-punch'; |
|
| 1365 | + $scripts[] = 'jquery-touch-punch'; |
|
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | 1368 | wp_enqueue_script( $scripts ); |
@@ -18,84 +18,84 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | class GravityView_Edit_Entry { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 21 | + /** |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | 24 | static $file; |
| 25 | 25 | |
| 26 | 26 | static $instance; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Component instances. |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - public $instances = array(); |
|
| 28 | + /** |
|
| 29 | + * Component instances. |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + public $instances = array(); |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | function __construct() { |
| 36 | 36 | |
| 37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
| 37 | + self::$file = plugin_dir_path( __FILE__ ); |
|
| 38 | 38 | |
| 39 | - if( is_admin() ) { |
|
| 40 | - $this->load_components( 'admin' ); |
|
| 41 | - } |
|
| 39 | + if( is_admin() ) { |
|
| 40 | + $this->load_components( 'admin' ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | $this->load_components( 'locking' ); |
| 44 | 44 | |
| 45 | - $this->load_components( 'render' ); |
|
| 45 | + $this->load_components( 'render' ); |
|
| 46 | 46 | |
| 47 | - // If GF User Registration Add-on exists |
|
| 48 | - $this->load_components( 'user-registration' ); |
|
| 47 | + // If GF User Registration Add-on exists |
|
| 48 | + $this->load_components( 'user-registration' ); |
|
| 49 | 49 | |
| 50 | - $this->add_hooks(); |
|
| 50 | + $this->add_hooks(); |
|
| 51 | 51 | |
| 52 | 52 | // Process hooks for addons that may or may not be present |
| 53 | 53 | $this->addon_specific_hooks(); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - static function getInstance() { |
|
| 57 | + static function getInstance() { |
|
| 58 | 58 | |
| 59 | - if( empty( self::$instance ) ) { |
|
| 60 | - self::$instance = new GravityView_Edit_Entry; |
|
| 61 | - } |
|
| 59 | + if( empty( self::$instance ) ) { |
|
| 60 | + self::$instance = new GravityView_Edit_Entry; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return self::$instance; |
|
| 64 | - } |
|
| 63 | + return self::$instance; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - private function load_components( $component ) { |
|
| 67 | + private function load_components( $component ) { |
|
| 68 | 68 | |
| 69 | - $dir = trailingslashit( self::$file ); |
|
| 69 | + $dir = trailingslashit( self::$file ); |
|
| 70 | 70 | |
| 71 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 72 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 71 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 72 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 73 | 73 | |
| 74 | - // Loads component and pass extension's instance so that component can |
|
| 75 | - // talk each other. |
|
| 76 | - require_once $filename; |
|
| 77 | - $this->instances[ $component ] = new $classname( $this ); |
|
| 78 | - $this->instances[ $component ]->load(); |
|
| 74 | + // Loads component and pass extension's instance so that component can |
|
| 75 | + // talk each other. |
|
| 76 | + require_once $filename; |
|
| 77 | + $this->instances[ $component ] = new $classname( $this ); |
|
| 78 | + $this->instances[ $component ]->load(); |
|
| 79 | 79 | |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - private function add_hooks() { |
|
| 82 | + private function add_hooks() { |
|
| 83 | 83 | |
| 84 | - // Add front-end access to Gravity Forms delete file action |
|
| 85 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 84 | + // Add front-end access to Gravity Forms delete file action |
|
| 85 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 86 | 86 | |
| 87 | - // Make sure this hook is run for non-admins |
|
| 88 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 87 | + // Make sure this hook is run for non-admins |
|
| 88 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 89 | 89 | |
| 90 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 90 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 91 | 91 | |
| 92 | - // add template path to check for field |
|
| 93 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 92 | + // add template path to check for field |
|
| 93 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 94 | 94 | |
| 95 | 95 | add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 ); |
| 96 | 96 | |
| 97 | 97 | add_filter( 'gravityview/api/reserved_query_args', array( $this, 'add_reserved_arg' ) ); |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Adds "edit" to the list of internal reserved query args |
@@ -166,74 +166,74 @@ discard block |
||
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * Include this extension templates path |
|
| 171 | - * @param array $file_paths List of template paths ordered |
|
| 172 | - */ |
|
| 173 | - public function add_template_path( $file_paths ) { |
|
| 174 | - |
|
| 175 | - // Index 100 is the default GravityView template path. |
|
| 176 | - $file_paths[ 110 ] = self::$file; |
|
| 177 | - |
|
| 178 | - return $file_paths; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * |
|
| 183 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 184 | - * |
|
| 185 | - * @param $view_id int GravityView view id |
|
| 186 | - * @param $form_id int Gravity Forms form id |
|
| 187 | - * @param $entry_id int Gravity Forms entry id |
|
| 188 | - * @return string |
|
| 189 | - */ |
|
| 190 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 191 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * The edit entry link creates a secure link with a nonce |
|
| 197 | - * |
|
| 198 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 199 | - * it formats the display of the edit form like it does in the backend, like |
|
| 200 | - * "You can edit this post from the post page" fields, for example. |
|
| 201 | - * |
|
| 202 | - * @param $entry array Gravity Forms entry object |
|
| 203 | - * @param $view_id int GravityView view id |
|
| 204 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 205 | - * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
| 206 | - * @return string |
|
| 207 | - */ |
|
| 208 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 209 | - |
|
| 210 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 211 | - |
|
| 212 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
| 213 | - |
|
| 214 | - $url = add_query_arg( array( |
|
| 215 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
| 216 | - ), $base ); |
|
| 217 | - |
|
| 218 | - if( $post_id ) { |
|
| 219 | - $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Allow passing params to dynamically populate entry with values |
|
| 224 | - * @since 1.9.2 |
|
| 225 | - */ |
|
| 226 | - if( !empty( $field_values ) ) { |
|
| 227 | - |
|
| 228 | - if( is_array( $field_values ) ) { |
|
| 229 | - // If already an array, no parse_str() needed |
|
| 230 | - $params = $field_values; |
|
| 231 | - } else { |
|
| 232 | - parse_str( $field_values, $params ); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - $url = add_query_arg( $params, $url ); |
|
| 236 | - } |
|
| 169 | + /** |
|
| 170 | + * Include this extension templates path |
|
| 171 | + * @param array $file_paths List of template paths ordered |
|
| 172 | + */ |
|
| 173 | + public function add_template_path( $file_paths ) { |
|
| 174 | + |
|
| 175 | + // Index 100 is the default GravityView template path. |
|
| 176 | + $file_paths[ 110 ] = self::$file; |
|
| 177 | + |
|
| 178 | + return $file_paths; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * |
|
| 183 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 184 | + * |
|
| 185 | + * @param $view_id int GravityView view id |
|
| 186 | + * @param $form_id int Gravity Forms form id |
|
| 187 | + * @param $entry_id int Gravity Forms entry id |
|
| 188 | + * @return string |
|
| 189 | + */ |
|
| 190 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 191 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The edit entry link creates a secure link with a nonce |
|
| 197 | + * |
|
| 198 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 199 | + * it formats the display of the edit form like it does in the backend, like |
|
| 200 | + * "You can edit this post from the post page" fields, for example. |
|
| 201 | + * |
|
| 202 | + * @param $entry array Gravity Forms entry object |
|
| 203 | + * @param $view_id int GravityView view id |
|
| 204 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 205 | + * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
| 206 | + * @return string |
|
| 207 | + */ |
|
| 208 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 209 | + |
|
| 210 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 211 | + |
|
| 212 | + $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
| 213 | + |
|
| 214 | + $url = add_query_arg( array( |
|
| 215 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
| 216 | + ), $base ); |
|
| 217 | + |
|
| 218 | + if( $post_id ) { |
|
| 219 | + $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * Allow passing params to dynamically populate entry with values |
|
| 224 | + * @since 1.9.2 |
|
| 225 | + */ |
|
| 226 | + if( !empty( $field_values ) ) { |
|
| 227 | + |
|
| 228 | + if( is_array( $field_values ) ) { |
|
| 229 | + // If already an array, no parse_str() needed |
|
| 230 | + $params = $field_values; |
|
| 231 | + } else { |
|
| 232 | + parse_str( $field_values, $params ); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + $url = add_query_arg( $params, $url ); |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | 238 | /** |
| 239 | 239 | * @filter `gravityview/edit/link` Filter the edit URL link. |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @param \GV\View $view The View. |
| 243 | 243 | */ |
| 244 | 244 | return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
| 245 | - } |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Edit mode doesn't allow certain field types. |
@@ -297,19 +297,19 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | |
| 300 | - /** |
|
| 301 | - * checks if user has permissions to edit a specific entry |
|
| 302 | - * |
|
| 303 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 304 | - * |
|
| 305 | - * @param array $entry Gravity Forms entry array |
|
| 306 | - * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
| 307 | - * @return bool |
|
| 308 | - */ |
|
| 309 | - public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
| 300 | + /** |
|
| 301 | + * checks if user has permissions to edit a specific entry |
|
| 302 | + * |
|
| 303 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 304 | + * |
|
| 305 | + * @param array $entry Gravity Forms entry array |
|
| 306 | + * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
| 307 | + * @return bool |
|
| 308 | + */ |
|
| 309 | + public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
| 310 | 310 | |
| 311 | - // No permission by default |
|
| 312 | - $user_can_edit = false; |
|
| 311 | + // No permission by default |
|
| 312 | + $user_can_edit = false; |
|
| 313 | 313 | |
| 314 | 314 | // get user_edit setting |
| 315 | 315 | if ( empty( $view ) ) { |
@@ -327,60 +327,60 @@ discard block |
||
| 327 | 327 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - // If they can edit any entries (as defined in Gravity Forms) |
|
| 331 | - // Or if they can edit other people's entries |
|
| 332 | - // Then we're good. |
|
| 333 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 330 | + // If they can edit any entries (as defined in Gravity Forms) |
|
| 331 | + // Or if they can edit other people's entries |
|
| 332 | + // Then we're good. |
|
| 333 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 334 | 334 | |
| 335 | - gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
| 335 | + gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
| 336 | 336 | |
| 337 | - $user_can_edit = true; |
|
| 337 | + $user_can_edit = true; |
|
| 338 | 338 | |
| 339 | - } else if( !isset( $entry['created_by'] ) ) { |
|
| 339 | + } else if( !isset( $entry['created_by'] ) ) { |
|
| 340 | 340 | |
| 341 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
| 341 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
| 342 | 342 | |
| 343 | - $user_can_edit = false; |
|
| 343 | + $user_can_edit = false; |
|
| 344 | 344 | |
| 345 | - } else { |
|
| 345 | + } else { |
|
| 346 | 346 | |
| 347 | - $current_user = wp_get_current_user(); |
|
| 347 | + $current_user = wp_get_current_user(); |
|
| 348 | 348 | |
| 349 | - // User edit is disabled |
|
| 350 | - if( empty( $user_edit ) ) { |
|
| 349 | + // User edit is disabled |
|
| 350 | + if( empty( $user_edit ) ) { |
|
| 351 | 351 | |
| 352 | - gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
| 352 | + gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
| 353 | 353 | |
| 354 | - $user_can_edit = false; |
|
| 355 | - } |
|
| 354 | + $user_can_edit = false; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 358 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 357 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 358 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 359 | 359 | |
| 360 | - gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
| 360 | + gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
| 361 | 361 | |
| 362 | - $user_can_edit = true; |
|
| 362 | + $user_can_edit = true; |
|
| 363 | 363 | |
| 364 | - } else if( ! is_user_logged_in() ) { |
|
| 364 | + } else if( ! is_user_logged_in() ) { |
|
| 365 | 365 | |
| 366 | - gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
| 366 | + gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
| 367 | 367 | |
| 368 | - $user_can_edit = false; // Here just for clarity |
|
| 369 | - } |
|
| 368 | + $user_can_edit = false; // Here just for clarity |
|
| 369 | + } |
|
| 370 | 370 | |
| 371 | - } |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 375 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 376 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 377 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 378 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 379 | - */ |
|
| 380 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 373 | + /** |
|
| 374 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 375 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 376 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 377 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 378 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 379 | + */ |
|
| 380 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 381 | 381 | |
| 382 | - return (bool) $user_can_edit; |
|
| 383 | - } |
|
| 382 | + return (bool) $user_can_edit; |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | 385 | |
| 386 | 386 | |