@@ -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 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | if( empty( $connected_views ) ) { |
| 169 | 169 | |
| 170 | - $menu_items['gravityview'] = array( |
|
| 170 | + $menu_items['gravityview'] = array( |
|
| 171 | 171 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
| 172 | 172 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
| 173 | 173 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | // If there were no items added, then let's create the parent menu |
| 199 | 199 | if( $sub_menu_items ) { |
| 200 | 200 | |
| 201 | - $sub_menu_items[] = array( |
|
| 202 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
| 203 | - 'link_class' => 'gv-create-view', |
|
| 204 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
| 205 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
| 206 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
| 207 | - ); |
|
| 201 | + $sub_menu_items[] = array( |
|
| 202 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
| 203 | + 'link_class' => 'gv-create-view', |
|
| 204 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
| 205 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
| 206 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
| 207 | + ); |
|
| 208 | 208 | |
| 209 | 209 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
| 210 | 210 | $sub_menu_items[] = array( |
@@ -587,12 +587,12 @@ discard block |
||
| 587 | 587 | * Render html for displaying available fields based on a Form ID |
| 588 | 588 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
| 589 | 589 | * |
| 590 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
| 590 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
| 591 | 591 | * @access public |
| 592 | - * |
|
| 592 | + * |
|
| 593 | 593 | * @param int $form Gravity Forms Form ID (default: '') |
| 594 | 594 | * @param string $context (default: 'single') |
| 595 | - * |
|
| 595 | + * |
|
| 596 | 596 | * @return void |
| 597 | 597 | */ |
| 598 | 598 | function render_available_fields( $form = 0, $context = 'single' ) { |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | if ( ! is_array( $blacklist_field_types ) ) { |
| 608 | 608 | |
| 609 | - gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
| 609 | + gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
| 610 | 610 | |
| 611 | 611 | $blacklist_field_types = array(); |
| 612 | 612 | } |
@@ -738,12 +738,12 @@ discard block |
||
| 738 | 738 | /** |
| 739 | 739 | * @since 1.7.2 |
| 740 | 740 | */ |
| 741 | - 'other_entries' => array( |
|
| 742 | - 'label' => __('Other Entries', 'gravityview'), |
|
| 743 | - 'type' => 'other_entries', |
|
| 744 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
| 745 | - ), |
|
| 746 | - ); |
|
| 741 | + 'other_entries' => array( |
|
| 742 | + 'label' => __('Other Entries', 'gravityview'), |
|
| 743 | + 'type' => 'other_entries', |
|
| 744 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
| 745 | + ), |
|
| 746 | + ); |
|
| 747 | 747 | |
| 748 | 748 | if( 'single' !== $zone) { |
| 749 | 749 | |
@@ -1084,59 +1084,59 @@ discard block |
||
| 1084 | 1084 | |
| 1085 | 1085 | // Don't process any scripts below here if it's not a GravityView page. |
| 1086 | 1086 | if( ! gravityview_is_admin_page( $hook, 'single' ) && ! $is_widgets_page ) { |
| 1087 | - return; |
|
| 1087 | + return; |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1091 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
| 1092 | - |
|
| 1093 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 1094 | - |
|
| 1095 | - //enqueue scripts |
|
| 1096 | - 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' ), GravityView_Plugin::version ); |
|
| 1097 | - |
|
| 1098 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
| 1099 | - 'cookiepath' => COOKIEPATH, |
|
| 1100 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
| 1101 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1102 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1103 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1104 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1105 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1106 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1107 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1108 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1109 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1110 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1111 | - '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' ), |
|
| 1112 | - )); |
|
| 1113 | - |
|
| 1114 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
| 1115 | - |
|
| 1116 | - // Enqueue scripts needed for merge tags |
|
| 1117 | - self::enqueue_gravity_forms_scripts(); |
|
| 1090 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1091 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
| 1092 | + |
|
| 1093 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 1094 | + |
|
| 1095 | + //enqueue scripts |
|
| 1096 | + 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' ), GravityView_Plugin::version ); |
|
| 1097 | + |
|
| 1098 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
| 1099 | + 'cookiepath' => COOKIEPATH, |
|
| 1100 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
| 1101 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1102 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1103 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1104 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1105 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1106 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1107 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1108 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1109 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1110 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1111 | + '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' ), |
|
| 1112 | + )); |
|
| 1113 | + |
|
| 1114 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
| 1115 | + |
|
| 1116 | + // Enqueue scripts needed for merge tags |
|
| 1117 | + self::enqueue_gravity_forms_scripts(); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | /** |
| 1121 | 1121 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
| 1122 | - * |
|
| 1123 | - * @since 1.0.5-beta |
|
| 1124 | - * |
|
| 1125 | - * @return void |
|
| 1122 | + * |
|
| 1123 | + * @since 1.0.5-beta |
|
| 1124 | + * |
|
| 1125 | + * @return void |
|
| 1126 | 1126 | */ |
| 1127 | 1127 | static function enqueue_gravity_forms_scripts() { |
| 1128 | 1128 | GFForms::register_scripts(); |
| 1129 | 1129 | |
| 1130 | 1130 | $scripts = array( |
| 1131 | - 'sack', |
|
| 1132 | - 'gform_gravityforms', |
|
| 1133 | - 'gform_forms', |
|
| 1134 | - 'gform_form_admin', |
|
| 1135 | - 'jquery-ui-autocomplete' |
|
| 1131 | + 'sack', |
|
| 1132 | + 'gform_gravityforms', |
|
| 1133 | + 'gform_forms', |
|
| 1134 | + 'gform_form_admin', |
|
| 1135 | + 'jquery-ui-autocomplete' |
|
| 1136 | 1136 | ); |
| 1137 | 1137 | |
| 1138 | 1138 | if ( wp_is_mobile() ) { |
| 1139 | - $scripts[] = 'jquery-touch-punch'; |
|
| 1139 | + $scripts[] = 'jquery-touch-punch'; |
|
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | 1142 | wp_enqueue_script( $scripts ); |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | // matching regex => the value is the method to call to replace the value. |
| 53 | 53 | $gv_modifiers = array( |
| 54 | 54 | 'maxwords:(\d+)' => 'modifier_maxwords', /** @see modifier_maxwords */ |
| 55 | - 'timestamp' => 'modifier_timestamp', /** @see modifier_timestamp */ |
|
| 55 | + 'timestamp' => 'modifier_timestamp', /** @see modifier_timestamp */ |
|
| 56 | 56 | 'explode' => 'modifier_explode', /** @see modifier_explode */ |
| 57 | 57 | |
| 58 | 58 | /** @see modifier_strings */ |
| 59 | 59 | 'urlencode' => 'modifier_strings', |
| 60 | 60 | 'wpautop' => 'modifier_strings', |
| 61 | - 'esc_html' => 'modifier_strings', |
|
| 62 | - 'sanitize_html_class' => 'modifier_strings', |
|
| 61 | + 'esc_html' => 'modifier_strings', |
|
| 62 | + 'sanitize_html_class' => 'modifier_strings', |
|
| 63 | 63 | 'sanitize_title' => 'modifier_strings', |
| 64 | 64 | 'strtolower' => 'modifier_strings', |
| 65 | 65 | 'strtoupper' => 'modifier_strings', |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | |
| 458 | 458 | $atts = array( |
| 459 | 459 | 'format' => self::get_format_from_modifiers( $exploded, false ), |
| 460 | - 'human' => in_array( 'human', $exploded ), // {date_created:human} |
|
| 460 | + 'human' => in_array( 'human', $exploded ), // {date_created:human} |
|
| 461 | 461 | 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
| 462 | 462 | 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
| 463 | 463 | 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
@@ -109,7 +109,7 @@ |
||
| 109 | 109 | $field_data = array( |
| 110 | 110 | 'label' => \GV\Utils::get( $edit_field, 'custom_label' ), |
| 111 | 111 | 'customLabel' => \GV\Utils::get( $edit_field, 'custom_label' ), |
| 112 | - 'content' => \GV\Utils::get( $edit_field, 'content' ), |
|
| 112 | + 'content' => \GV\Utils::get( $edit_field, 'content' ), |
|
| 113 | 113 | ); |
| 114 | 114 | |
| 115 | 115 | // Replace merge tags in the content |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | private function add_hooks() { |
| 38 | - /** @see \GV\Field::get_value_filters */ |
|
| 38 | + /** @see \GV\Field::get_value_filters */ |
|
| 39 | 39 | add_filter( "gravityview/field/{$this->name}/output", array( $this, 'get_content' ), 4, 2 ); |
| 40 | 40 | add_action( 'gravityview/template/after', array( $this, 'print_script'), 10, 1 ); |
| 41 | 41 | add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | public function get_content( $output, $template ) { |
| 77 | 77 | $entry = $template->entry; |
| 78 | 78 | |
| 79 | - $star_url = GFCommon::get_base_url() .'/images/star' . intval( $entry['is_starred'] ) .'.png'; |
|
| 79 | + $star_url = GFCommon::get_base_url() .'/images/star' . intval( $entry['is_starred'] ) .'.png'; |
|
| 80 | 80 | |
| 81 | 81 | $entry_id = ''; |
| 82 | 82 | |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * Add JS to the bottom of the View if there is a star field and user has `gravityview_edit_entries` cap |
| 97 | - * |
|
| 97 | + * |
|
| 98 | 98 | * @param \GV\Template_Context $context The template context |
| 99 | - * @since 2.0 |
|
| 100 | - * |
|
| 101 | - * @return void |
|
| 99 | + * @since 2.0 |
|
| 100 | + * |
|
| 101 | + * @return void |
|
| 102 | 102 | */ |
| 103 | 103 | public function print_script( $context ) { |
| 104 | 104 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | if ( ! GravityView_Roles_Capabilities::has_cap( 'gravityview_edit_entries' ) ) { |
| 110 | - return; |
|
| 110 | + return; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | ?> |
@@ -341,7 +341,7 @@ |
||
| 341 | 341 | */ |
| 342 | 342 | $content = apply_filters( 'gravityview/fields/fileupload/link_content', $content, $field_compat, $context ); |
| 343 | 343 | |
| 344 | - $content = gravityview_get_link( $link, $content, $link_atts ); |
|
| 344 | + $content = gravityview_get_link( $link, $content, $link_atts ); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | $output_arr[] = array( |
@@ -5,251 +5,251 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class GravityView_Change_Entry_Creator { |
| 7 | 7 | |
| 8 | - function __construct() { |
|
| 9 | - |
|
| 10 | - /** |
|
| 11 | - * @since 1.5.1 |
|
| 12 | - */ |
|
| 13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
| 14 | - |
|
| 15 | - // ONLY ADMIN FROM HERE ON. |
|
| 16 | - if( !is_admin() ) { return; } |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
| 20 | - * @since 1.7.4 |
|
| 21 | - * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
| 22 | - */ |
|
| 23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
| 24 | - return; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Use `init` to fix bbPress warning |
|
| 29 | - * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
| 30 | - */ |
|
| 31 | - add_action('init', array( $this, 'load'), 100 ); |
|
| 32 | - |
|
| 33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
| 34 | - |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * When an user is created using the User Registration add-on, assign the entry to them |
|
| 39 | - * |
|
| 40 | - * @since 1.5.1 |
|
| 41 | - * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
| 42 | - * @param int $user_id WordPress User ID |
|
| 43 | - * @param array $config User registration feed configuration |
|
| 44 | - * @param array $entry GF Entry array |
|
| 45 | - * @param string $password User password |
|
| 46 | - * @return void |
|
| 47 | - */ |
|
| 48 | - function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Disable assigning the new user to the entry by returning false. |
|
| 52 | - * @param int $user_id WordPress User ID |
|
| 53 | - * @param array $config User registration feed configuration |
|
| 54 | - * @param array $entry GF Entry array |
|
| 55 | - */ |
|
| 56 | - $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
| 57 | - |
|
| 58 | - // If filter returns false, do not process |
|
| 59 | - if( empty( $assign_to_lead ) ) { |
|
| 60 | - return; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
| 64 | - $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
| 65 | - |
|
| 66 | - if( empty( $result ) ) { |
|
| 67 | - $status = __('Error', 'gravityview'); |
|
| 68 | - } else { |
|
| 69 | - $status = __('Success', 'gravityview'); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
| 73 | - |
|
| 74 | - gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note', $note ) ); |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @filter `gravityview_disable_change_entry_creator_note` Disable adding a note when changing the entry creator |
|
| 78 | - * @since 1.21.5 |
|
| 79 | - * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
|
| 80 | - */ |
|
| 81 | - if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
| 82 | - return; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
| 8 | + function __construct() { |
|
| 9 | + |
|
| 10 | + /** |
|
| 11 | + * @since 1.5.1 |
|
| 12 | + */ |
|
| 13 | + add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
| 14 | + |
|
| 15 | + // ONLY ADMIN FROM HERE ON. |
|
| 16 | + if( !is_admin() ) { return; } |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
| 20 | + * @since 1.7.4 |
|
| 21 | + * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
| 22 | + */ |
|
| 23 | + if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
| 24 | + return; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Use `init` to fix bbPress warning |
|
| 29 | + * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
| 30 | + */ |
|
| 31 | + add_action('init', array( $this, 'load'), 100 ); |
|
| 32 | + |
|
| 33 | + add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
| 34 | + |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * When an user is created using the User Registration add-on, assign the entry to them |
|
| 39 | + * |
|
| 40 | + * @since 1.5.1 |
|
| 41 | + * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
| 42 | + * @param int $user_id WordPress User ID |
|
| 43 | + * @param array $config User registration feed configuration |
|
| 44 | + * @param array $entry GF Entry array |
|
| 45 | + * @param string $password User password |
|
| 46 | + * @return void |
|
| 47 | + */ |
|
| 48 | + function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Disable assigning the new user to the entry by returning false. |
|
| 52 | + * @param int $user_id WordPress User ID |
|
| 53 | + * @param array $config User registration feed configuration |
|
| 54 | + * @param array $entry GF Entry array |
|
| 55 | + */ |
|
| 56 | + $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
| 57 | + |
|
| 58 | + // If filter returns false, do not process |
|
| 59 | + if( empty( $assign_to_lead ) ) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
| 64 | + $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
| 65 | + |
|
| 66 | + if( empty( $result ) ) { |
|
| 67 | + $status = __('Error', 'gravityview'); |
|
| 68 | + } else { |
|
| 69 | + $status = __('Success', 'gravityview'); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
| 73 | + |
|
| 74 | + gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note', $note ) ); |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @filter `gravityview_disable_change_entry_creator_note` Disable adding a note when changing the entry creator |
|
| 78 | + * @since 1.21.5 |
|
| 79 | + * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
|
| 80 | + */ |
|
| 81 | + if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
| 82 | + return; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
| 86 | 86 | |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Disable previous functionality; use this one as the canonical. |
|
| 91 | - * @return void |
|
| 92 | - */ |
|
| 93 | - function prevent_conflicts() { |
|
| 89 | + /** |
|
| 90 | + * Disable previous functionality; use this one as the canonical. |
|
| 91 | + * @return void |
|
| 92 | + */ |
|
| 93 | + function prevent_conflicts() { |
|
| 94 | 94 | |
| 95 | - // Plugin that was provided here: |
|
| 96 | - // @link https://gravityview.co/support/documentation/201991205/ |
|
| 97 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
| 98 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
| 99 | - |
|
| 100 | - // Disable for Gravity Forms Add-ons 3.6.2 and lower |
|
| 101 | - if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
| 95 | + // Plugin that was provided here: |
|
| 96 | + // @link https://gravityview.co/support/documentation/201991205/ |
|
| 97 | + remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
| 98 | + remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
| 99 | + |
|
| 100 | + // Disable for Gravity Forms Add-ons 3.6.2 and lower |
|
| 101 | + if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
| 102 | 102 | |
| 103 | - $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
|
| 103 | + $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
|
| 104 | 104 | |
| 105 | - // Now, no validation is required in the methods; let's hook in. |
|
| 106 | - remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
| 107 | - |
|
| 108 | - remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10 ); |
|
| 109 | - |
|
| 110 | - remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @since 3.6.3 |
|
| 117 | - * @return void |
|
| 118 | - */ |
|
| 119 | - function load() { |
|
| 105 | + // Now, no validation is required in the methods; let's hook in. |
|
| 106 | + remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
| 107 | + |
|
| 108 | + remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10 ); |
|
| 109 | + |
|
| 110 | + remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @since 3.6.3 |
|
| 117 | + * @return void |
|
| 118 | + */ |
|
| 119 | + function load() { |
|
| 120 | 120 | |
| 121 | - // Does GF exist? |
|
| 122 | - if( !class_exists('GFCommon') ) { |
|
| 123 | - return; |
|
| 124 | - } |
|
| 121 | + // Does GF exist? |
|
| 122 | + if( !class_exists('GFCommon') ) { |
|
| 123 | + return; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - // Can the user edit entries? |
|
| 127 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
| 128 | - return; |
|
| 129 | - } |
|
| 126 | + // Can the user edit entries? |
|
| 127 | + if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
| 128 | + return; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - // If screen mode isn't set, then we're in the wrong place. |
|
| 132 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
| 133 | - return; |
|
| 134 | - } |
|
| 131 | + // If screen mode isn't set, then we're in the wrong place. |
|
| 132 | + if( empty( $_REQUEST['screen_mode'] ) ) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - // Now, no validation is required in the methods; let's hook in. |
|
| 137 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
| 136 | + // Now, no validation is required in the methods; let's hook in. |
|
| 137 | + add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
| 138 | 138 | |
| 139 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
| 139 | + add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
| 140 | 140 | |
| 141 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
| 141 | + add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
| 142 | 142 | |
| 143 | - } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
| 147 | - * @return void |
|
| 148 | - */ |
|
| 149 | - function set_screen_mode() { |
|
| 145 | + /** |
|
| 146 | + * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
| 147 | + * @return void |
|
| 148 | + */ |
|
| 149 | + function set_screen_mode() { |
|
| 150 | 150 | |
| 151 | - // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
| 152 | - if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
| 153 | - $_POST["screen_mode"] = 'edit'; |
|
| 154 | - } |
|
| 151 | + // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
| 152 | + if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
| 153 | + $_POST["screen_mode"] = 'edit'; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - } |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * When the entry creator is changed, add a note to the entry |
|
| 160 | - * @param array $form GF entry array |
|
| 161 | - * @param int $entry_id Entry ID |
|
| 162 | - * @return void |
|
| 163 | - */ |
|
| 164 | - function update_entry_creator($form, $entry_id) { |
|
| 165 | - global $current_user; |
|
| 158 | + /** |
|
| 159 | + * When the entry creator is changed, add a note to the entry |
|
| 160 | + * @param array $form GF entry array |
|
| 161 | + * @param int $entry_id Entry ID |
|
| 162 | + * @return void |
|
| 163 | + */ |
|
| 164 | + function update_entry_creator($form, $entry_id) { |
|
| 165 | + global $current_user; |
|
| 166 | 166 | |
| 167 | - // Update the entry |
|
| 168 | - $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
| 167 | + // Update the entry |
|
| 168 | + $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
| 169 | 169 | |
| 170 | - RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
| 170 | + RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
| 171 | 171 | |
| 172 | - // If the creator has changed, let's add a note about who it used to be. |
|
| 173 | - $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
|
| 172 | + // If the creator has changed, let's add a note about who it used to be. |
|
| 173 | + $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
|
| 174 | 174 | |
| 175 | - // If there's no owner and there didn't used to be, keep going |
|
| 176 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
| 177 | - return; |
|
| 178 | - } |
|
| 175 | + // If there's no owner and there didn't used to be, keep going |
|
| 176 | + if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
| 177 | + return; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // If the values have changed |
|
| 181 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
| 180 | + // If the values have changed |
|
| 181 | + if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
| 182 | 182 | |
| 183 | - $user_data = get_userdata($current_user->ID); |
|
| 183 | + $user_data = get_userdata($current_user->ID); |
|
| 184 | 184 | |
| 185 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
| 185 | + $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
| 186 | 186 | |
| 187 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
| 187 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
| 188 | 188 | |
| 189 | - if( !empty( $originally_created_by ) ) { |
|
| 190 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
| 191 | - $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
| 192 | - } |
|
| 189 | + if( !empty( $originally_created_by ) ) { |
|
| 190 | + $originally_created_by_user_data = get_userdata($originally_created_by); |
|
| 191 | + $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - if( !empty( $created_by ) ) { |
|
| 195 | - $created_by_user_data = get_userdata($created_by); |
|
| 196 | - $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
| 197 | - } |
|
| 194 | + if( !empty( $created_by ) ) { |
|
| 195 | + $created_by_user_data = get_userdata($created_by); |
|
| 196 | + $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
| 200 | - } |
|
| 199 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - /** |
|
| 205 | - * Output the select to change the entry creator |
|
| 206 | - * @param int $form_id GF Form ID |
|
| 207 | - * @param array $entry GF entry array |
|
| 208 | - * @return void |
|
| 209 | - */ |
|
| 210 | - function add_select($form_id, $entry ) { |
|
| 204 | + /** |
|
| 205 | + * Output the select to change the entry creator |
|
| 206 | + * @param int $form_id GF Form ID |
|
| 207 | + * @param array $entry GF entry array |
|
| 208 | + * @return void |
|
| 209 | + */ |
|
| 210 | + function add_select($form_id, $entry ) { |
|
| 211 | 211 | |
| 212 | - if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
| 213 | - return; |
|
| 214 | - } |
|
| 212 | + if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
| 213 | + return; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - $created_by_id = \GV\Utils::get( $entry, 'created_by' ); |
|
| 216 | + $created_by_id = \GV\Utils::get( $entry, 'created_by' ); |
|
| 217 | 217 | |
| 218 | - $users = GVCommon::get_users( 'change_entry_creator' ); |
|
| 218 | + $users = GVCommon::get_users( 'change_entry_creator' ); |
|
| 219 | 219 | |
| 220 | - $is_created_by_in_users = wp_list_filter( $users, array( 'ID' => $created_by_id ) ); |
|
| 220 | + $is_created_by_in_users = wp_list_filter( $users, array( 'ID' => $created_by_id ) ); |
|
| 221 | 221 | |
| 222 | - // Make sure that the entry creator is included in the users list. If not, add them. |
|
| 223 | - if ( ! empty( $created_by_id ) && empty( $is_created_by_in_users ) ) { |
|
| 222 | + // Make sure that the entry creator is included in the users list. If not, add them. |
|
| 223 | + if ( ! empty( $created_by_id ) && empty( $is_created_by_in_users ) ) { |
|
| 224 | 224 | |
| 225 | - if ( $created_by_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $created_by_id ) ) ) { |
|
| 226 | - $users = array_merge( $users, $created_by_user ); |
|
| 227 | - } |
|
| 228 | - } |
|
| 225 | + if ( $created_by_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $created_by_id ) ) ) { |
|
| 226 | + $users = array_merge( $users, $created_by_user ); |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - $output = '<label for="change_created_by">'; |
|
| 231 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
| 232 | - $output .= '</label>'; |
|
| 230 | + $output = '<label for="change_created_by">'; |
|
| 231 | + $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
| 232 | + $output .= '</label>'; |
|
| 233 | 233 | |
| 234 | - // If there are users who are not being shown, show a warning. |
|
| 235 | - // TODO: Use AJAX instead of <select> |
|
| 236 | - $count_users = count_users(); |
|
| 237 | - if( sizeof( $users ) < $count_users['total_users'] ) { |
|
| 238 | - $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
|
| 239 | - } |
|
| 234 | + // If there are users who are not being shown, show a warning. |
|
| 235 | + // TODO: Use AJAX instead of <select> |
|
| 236 | + $count_users = count_users(); |
|
| 237 | + if( sizeof( $users ) < $count_users['total_users'] ) { |
|
| 238 | + $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
|
| 242 | - $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
| 243 | - foreach($users as $user) { |
|
| 244 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
| 245 | - } |
|
| 246 | - $output .= '</select>'; |
|
| 247 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
| 241 | + $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
|
| 242 | + $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
| 243 | + foreach($users as $user) { |
|
| 244 | + $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
| 245 | + } |
|
| 246 | + $output .= '</select>'; |
|
| 247 | + $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
| 248 | 248 | |
| 249 | - unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
|
| 249 | + unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
|
| 250 | 250 | |
| 251 | - echo $output; |
|
| 252 | - } |
|
| 251 | + echo $output; |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | 254 | } |
| 255 | 255 | |
@@ -328,34 +328,34 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
| 331 | - * Get the fields for a specific context |
|
| 332 | - * |
|
| 333 | - * @since 1.19.2 |
|
| 334 | - * |
|
| 331 | + * Get the fields for a specific context |
|
| 332 | + * |
|
| 333 | + * @since 1.19.2 |
|
| 334 | + * |
|
| 335 | 335 | * @param string $context [Optional] "directory", "single", or "edit" |
| 336 | 336 | * |
| 337 | 337 | * @return array Array of GravityView field layout configurations |
| 338 | 338 | */ |
| 339 | 339 | public function getContextFields( $context = '' ) { |
| 340 | 340 | |
| 341 | - if( '' === $context ) { |
|
| 342 | - $context = $this->getContext(); |
|
| 343 | - } |
|
| 341 | + if( '' === $context ) { |
|
| 342 | + $context = $this->getContext(); |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | 345 | $fields = $this->getFields(); |
| 346 | 346 | |
| 347 | - foreach ( (array) $fields as $key => $context_fields ) { |
|
| 347 | + foreach ( (array) $fields as $key => $context_fields ) { |
|
| 348 | 348 | |
| 349 | - // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
|
| 350 | - $matches = explode( '_', $key ); |
|
| 349 | + // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
|
| 350 | + $matches = explode( '_', $key ); |
|
| 351 | 351 | |
| 352 | - if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 353 | - return $context_fields; |
|
| 354 | - } |
|
| 355 | - } |
|
| 352 | + if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 353 | + return $context_fields; |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | 357 | return array(); |
| 358 | - } |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | 360 | /** |
| 361 | 361 | * @param array $fields |
@@ -448,10 +448,10 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | public function getPaging() { |
| 450 | 450 | |
| 451 | - $default_params = array( |
|
| 452 | - 'offset' => 0, |
|
| 453 | - 'page_size' => 20, |
|
| 454 | - ); |
|
| 451 | + $default_params = array( |
|
| 452 | + 'offset' => 0, |
|
| 453 | + 'page_size' => 20, |
|
| 454 | + ); |
|
| 455 | 455 | |
| 456 | 456 | return wp_parse_args( $this->paging, $default_params ); |
| 457 | 457 | } |
@@ -508,10 +508,10 @@ discard block |
||
| 508 | 508 | public function getSorting() { |
| 509 | 509 | |
| 510 | 510 | $defaults_params = array( |
| 511 | - 'sort_field' => 'date_created', |
|
| 512 | - 'sort_direction' => 'ASC', |
|
| 513 | - 'is_numeric' => false, |
|
| 514 | - ); |
|
| 511 | + 'sort_field' => 'date_created', |
|
| 512 | + 'sort_direction' => 'ASC', |
|
| 513 | + 'is_numeric' => false, |
|
| 514 | + ); |
|
| 515 | 515 | |
| 516 | 516 | return wp_parse_args( $this->sorting, $defaults_params ); |
| 517 | 517 | } |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | */ |
| 838 | 838 | public function render_widget_hooks( $view_id_or_context ) { |
| 839 | 839 | |
| 840 | - /** |
|
| 840 | + /** |
|
| 841 | 841 | * @deprecated Numeric argument is deprecated. Pass a \GV\Template_Context instead. |
| 842 | 842 | */ |
| 843 | 843 | if ( is_numeric( $view_id_or_context ) ) { |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | if( 'gv_note_add' === $_POST['action'] ) { |
| 177 | 177 | |
| 178 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 179 | - do_action( 'gravityview_log_error', __METHOD__ . ': The user isnt allowed to add entry notes.' ); |
|
| 180 | - return; |
|
| 181 | - } |
|
| 178 | + if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 179 | + do_action( 'gravityview_log_error', __METHOD__ . ': The user isnt allowed to add entry notes.' ); |
|
| 180 | + return; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | $post = wp_unslash( $_POST ); |
| 184 | 184 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * Verify permissions. Check expected $_POST. Parse args, then send to process_delete_notes |
| 280 | 280 | * |
| 281 | - * @since 1.17 |
|
| 281 | + * @since 1.17 |
|
| 282 | 282 | * |
| 283 | 283 | * @see process_delete_notes |
| 284 | 284 | * |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | 'subject-label' => __( 'Subject', 'gravityview' ), |
| 432 | 432 | 'subject' => __( 'Email subject', 'gravityview' ), |
| 433 | 433 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
| 434 | - 'email-footer' => __( 'This note was sent from {url}', 'gravityview' ), |
|
| 434 | + 'email-footer' => __( 'This note was sent from {url}', 'gravityview' ), |
|
| 435 | 435 | 'also-email' => __( 'Also email this note to', 'gravityview' ), |
| 436 | 436 | 'error-add-note' => __( 'There was an error adding the note.', 'gravityview' ), |
| 437 | 437 | 'error-invalid' => __( 'The request was invalid. Refresh the page and try again.', 'gravityview' ), |
@@ -501,11 +501,11 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | if ( $context instanceof \GV\Template_Context ) { |
| 503 | 503 | |
| 504 | - ob_start(); |
|
| 505 | - $context->template->get_template_part( 'note', 'detail', true ); |
|
| 506 | - $note_detail_html = ob_get_clean(); |
|
| 504 | + ob_start(); |
|
| 505 | + $context->template->get_template_part( 'note', 'detail', true ); |
|
| 506 | + $note_detail_html = ob_get_clean(); |
|
| 507 | 507 | |
| 508 | - ob_start(); |
|
| 508 | + ob_start(); |
|
| 509 | 509 | $context->template->get_template_part( 'note', $note_row_template, true ); |
| 510 | 510 | $note_row = ob_get_clean(); |
| 511 | 511 | } else { |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | 'gv-note-to-custom' => '', |
| 762 | 762 | 'gv-note-subject' => '', |
| 763 | 763 | 'gv-note-content' => '', |
| 764 | - 'current-url' => '', |
|
| 764 | + 'current-url' => '', |
|
| 765 | 765 | ); |
| 766 | 766 | |
| 767 | 767 | $current_user = wp_get_current_user(); |
@@ -813,9 +813,9 @@ discard block |
||
| 813 | 813 | $message .= $this->get_email_footer( $email_footer, $is_html, $email_data ); |
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | - * @filter `gravityview/field/notes/wpautop_email` Should the message content have paragraphs added automatically, if using HTML message format |
|
| 816 | + * @filter `gravityview/field/notes/wpautop_email` Should the message content have paragraphs added automatically, if using HTML message format |
|
| 817 | 817 | * @since 1.18 |
| 818 | - * @param bool $wpautop_email True: Apply wpautop() to the email message if using; False: Leave as entered (Default: true) |
|
| 818 | + * @param bool $wpautop_email True: Apply wpautop() to the email message if using; False: Leave as entered (Default: true) |
|
| 819 | 819 | */ |
| 820 | 820 | $wpautop_email = apply_filters( 'gravityview/field/notes/wpautop_email', true ); |
| 821 | 821 | |
@@ -835,12 +835,12 @@ discard block |
||
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | /** |
| 838 | - * Get the footer for Entry Note emails |
|
| 839 | - * |
|
| 840 | - * `{url}` is replaced by the URL of the page where the note form was embedded |
|
| 841 | - * |
|
| 842 | - * @since 1.18 |
|
| 843 | - * @see GravityView_Field_Notes::strings The default value of $message_footer is set here, with the key 'email-footer' |
|
| 838 | + * Get the footer for Entry Note emails |
|
| 839 | + * |
|
| 840 | + * `{url}` is replaced by the URL of the page where the note form was embedded |
|
| 841 | + * |
|
| 842 | + * @since 1.18 |
|
| 843 | + * @see GravityView_Field_Notes::strings The default value of $message_footer is set here, with the key 'email-footer' |
|
| 844 | 844 | * |
| 845 | 845 | * @param string $email_footer The message footer value |
| 846 | 846 | * @param bool $is_html True: Email is being sent as HTML; False: sent as text |
@@ -849,10 +849,10 @@ discard block |
||
| 849 | 849 | */ |
| 850 | 850 | private function get_email_footer( $email_footer = '', $is_html = true, $email_data = array() ) { |
| 851 | 851 | |
| 852 | - $output = ''; |
|
| 852 | + $output = ''; |
|
| 853 | 853 | |
| 854 | 854 | if( ! empty( $email_footer ) ) { |
| 855 | - $url = \GV\Utils::get( $email_data, 'current-url' ); |
|
| 855 | + $url = \GV\Utils::get( $email_data, 'current-url' ); |
|
| 856 | 856 | $url = html_entity_decode( $url ); |
| 857 | 857 | $url = site_url( $url ); |
| 858 | 858 | |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
| 308 | - * @hack |
|
| 309 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 310 | - */ |
|
| 308 | + * @hack |
|
| 309 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 310 | + */ |
|
| 311 | 311 | if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
| 312 | - continue; |
|
| 313 | - } |
|
| 312 | + continue; |
|
| 313 | + } |
|
| 314 | 314 | $fields["{$input['id']}"] = array( |
| 315 | 315 | 'label' => \GV\Utils::get( $input, 'label' ), |
| 316 | 316 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
@@ -1349,7 +1349,7 @@ discard block |
||
| 1349 | 1349 | ), |
| 1350 | 1350 | ); |
| 1351 | 1351 | |
| 1352 | - $fields = $date_created + $fields; |
|
| 1352 | + $fields = $date_created + $fields; |
|
| 1353 | 1353 | |
| 1354 | 1354 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1355 | 1355 | |
@@ -1361,13 +1361,13 @@ discard block |
||
| 1361 | 1361 | } |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | - /** |
|
| 1365 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1366 | - * @since 1.12 |
|
| 1367 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1368 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1369 | - */ |
|
| 1370 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1364 | + /** |
|
| 1365 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1366 | + * @since 1.12 |
|
| 1367 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1368 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1369 | + */ |
|
| 1370 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1371 | 1371 | |
| 1372 | 1372 | return $fields; |
| 1373 | 1373 | } |
@@ -1659,26 +1659,26 @@ discard block |
||
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | 1661 | |
| 1662 | - /** |
|
| 1663 | - * Display updated/error notice |
|
| 1664 | - * |
|
| 1665 | - * @since 1.19.2 Added $cap and $object_id parameters |
|
| 1666 | - * |
|
| 1667 | - * @param string $notice text/HTML of notice |
|
| 1668 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1669 | - * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
| 1670 | - * |
|
| 1671 | - * @return string |
|
| 1672 | - */ |
|
| 1673 | - public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
| 1674 | - |
|
| 1675 | - // If $cap is defined, only show notice if user has capability |
|
| 1676 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1677 | - return ''; |
|
| 1678 | - } |
|
| 1679 | - |
|
| 1680 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1681 | - } |
|
| 1662 | + /** |
|
| 1663 | + * Display updated/error notice |
|
| 1664 | + * |
|
| 1665 | + * @since 1.19.2 Added $cap and $object_id parameters |
|
| 1666 | + * |
|
| 1667 | + * @param string $notice text/HTML of notice |
|
| 1668 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1669 | + * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
| 1670 | + * |
|
| 1671 | + * @return string |
|
| 1672 | + */ |
|
| 1673 | + public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
| 1674 | + |
|
| 1675 | + // If $cap is defined, only show notice if user has capability |
|
| 1676 | + if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1677 | + return ''; |
|
| 1678 | + } |
|
| 1679 | + |
|
| 1680 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1681 | + } |
|
| 1682 | 1682 | |
| 1683 | 1683 | /** |
| 1684 | 1684 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |