@@ -227,7 +227,7 @@ |
||
| 227 | 227 | */ |
| 228 | 228 | $content = apply_filters( 'gravityview/fields/fileupload/link_content', $content, $gravityview_view->getCurrentField() ); |
| 229 | 229 | |
| 230 | - $content = gravityview_get_link( $link, $content, $link_atts ); |
|
| 230 | + $content = gravityview_get_link( $link, $content, $link_atts ); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | $output_arr[] = array( |
@@ -21,13 +21,13 @@ |
||
| 21 | 21 | 'tooltip' => __( 'Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gravityview' ), |
| 22 | 22 | ); |
| 23 | 23 | |
| 24 | - $field_options['make_clickable'] = array( |
|
| 25 | - 'type' => 'checkbox', |
|
| 26 | - 'merge_tags' => false, |
|
| 27 | - 'value' => 0, |
|
| 28 | - 'label' => __( 'Convert text URLs to HTML links', 'gravityview' ), |
|
| 29 | - 'tooltip' => __( 'Converts URI, www, FTP, and email addresses in HTML links', 'gravityview' ), |
|
| 30 | - ); |
|
| 24 | + $field_options['make_clickable'] = array( |
|
| 25 | + 'type' => 'checkbox', |
|
| 26 | + 'merge_tags' => false, |
|
| 27 | + 'value' => 0, |
|
| 28 | + 'label' => __( 'Convert text URLs to HTML links', 'gravityview' ), |
|
| 29 | + 'tooltip' => __( 'Converts URI, www, FTP, and email addresses in HTML links', 'gravityview' ), |
|
| 30 | + ); |
|
| 31 | 31 | |
| 32 | 32 | return $field_options; |
| 33 | 33 | } |
@@ -255,7 +255,6 @@ |
||
| 255 | 255 | * Get the default date format for a field based on the field ID and the time format setting |
| 256 | 256 | * |
| 257 | 257 | * @since 1.14 |
| 258 | - |
|
| 259 | 258 | * @param string $time_format The time format ("12" or "24"). Default: "12" {@since 1.14} |
| 260 | 259 | * @param int $field_id The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14} |
| 261 | 260 | * |
@@ -10,159 +10,159 @@ discard block |
||
| 10 | 10 | * |
| 11 | 11 | * @var string |
| 12 | 12 | */ |
| 13 | - protected $name; |
|
| 13 | + protected $name; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Field settings |
| 17 | 17 | * |
| 18 | 18 | * @var array |
| 19 | 19 | */ |
| 20 | - protected $field; |
|
| 20 | + protected $field; |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Field current value |
| 24 | 24 | * |
| 25 | 25 | * @var mixed |
| 26 | 26 | */ |
| 27 | - protected $value; |
|
| 28 | - |
|
| 29 | - function __construct( $name = '', $field = array(), $curr_value = NULL ) { |
|
| 30 | - |
|
| 31 | - $this->name = $name; |
|
| 32 | - |
|
| 33 | - $defaults = self::get_field_defaults(); |
|
| 34 | - |
|
| 35 | - // Backward compatibility |
|
| 36 | - if( !empty( $field['choices'] ) ) { |
|
| 37 | - $field['options'] = $field['choices']; |
|
| 38 | - unset( $field['choices'] ); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - $this->field = wp_parse_args( $field, $defaults ); |
|
| 42 | - |
|
| 43 | - $this->value = is_null( $curr_value ) ? $this->field['value'] : $curr_value; |
|
| 44 | - |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Returns the default details for a field option |
|
| 49 | - * |
|
| 50 | - * - default // default option value, in case nothing is defined (@deprecated) |
|
| 51 | - * - desc // option description |
|
| 52 | - * - value // the option default value |
|
| 53 | - * - label // the option label |
|
| 54 | - * - left_label // In case of checkboxes, left label will appear on the left of the checkbox |
|
| 55 | - * - id // the field id |
|
| 56 | - * - type // the option type ( text, checkbox, select, ... ) |
|
| 57 | - * - options // when type is select, define the select options ('choices' is @deprecated) |
|
| 58 | - * - merge_tags // if the option supports merge tags feature |
|
| 59 | - * - class // (new) define extra classes for the field |
|
| 60 | - * - tooltip // |
|
| 61 | - * |
|
| 62 | - * @return array |
|
| 63 | - */ |
|
| 64 | - public static function get_field_defaults() { |
|
| 65 | - return array( |
|
| 66 | - 'desc' => '', |
|
| 67 | - 'value' => NULL, |
|
| 68 | - 'label' => '', |
|
| 69 | - 'left_label' => NULL, |
|
| 70 | - 'id' => NULL, |
|
| 71 | - 'type' => 'text', |
|
| 72 | - 'options' => NULL, |
|
| 73 | - 'merge_tags' => true, |
|
| 74 | - 'class' => '', |
|
| 75 | - 'tooltip' => NULL |
|
| 76 | - ); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - function get_tooltip() { |
|
| 81 | - if( !function_exists('gform_tooltip') ) { |
|
| 82 | - return NULL; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - return !empty( $this->field['tooltip'] ) ? ' '.gform_tooltip( $this->field['tooltip'] , false, true ) : NULL; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Build input id based on the name |
|
| 90 | - * @return string |
|
| 91 | - */ |
|
| 92 | - function get_field_id() { |
|
| 93 | - if( isset( $this->field['id'] ) ) { |
|
| 94 | - return esc_attr( $this->field['id'] ); |
|
| 95 | - } |
|
| 96 | - return esc_attr( sanitize_html_class( $this->name ) ); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Retrieve field label |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function get_field_label() { |
|
| 104 | - return esc_html( trim( $this->field['label'] ) ); |
|
| 105 | - } |
|
| 27 | + protected $value; |
|
| 28 | + |
|
| 29 | + function __construct( $name = '', $field = array(), $curr_value = NULL ) { |
|
| 30 | + |
|
| 31 | + $this->name = $name; |
|
| 32 | + |
|
| 33 | + $defaults = self::get_field_defaults(); |
|
| 34 | + |
|
| 35 | + // Backward compatibility |
|
| 36 | + if( !empty( $field['choices'] ) ) { |
|
| 37 | + $field['options'] = $field['choices']; |
|
| 38 | + unset( $field['choices'] ); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + $this->field = wp_parse_args( $field, $defaults ); |
|
| 42 | + |
|
| 43 | + $this->value = is_null( $curr_value ) ? $this->field['value'] : $curr_value; |
|
| 44 | + |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Returns the default details for a field option |
|
| 49 | + * |
|
| 50 | + * - default // default option value, in case nothing is defined (@deprecated) |
|
| 51 | + * - desc // option description |
|
| 52 | + * - value // the option default value |
|
| 53 | + * - label // the option label |
|
| 54 | + * - left_label // In case of checkboxes, left label will appear on the left of the checkbox |
|
| 55 | + * - id // the field id |
|
| 56 | + * - type // the option type ( text, checkbox, select, ... ) |
|
| 57 | + * - options // when type is select, define the select options ('choices' is @deprecated) |
|
| 58 | + * - merge_tags // if the option supports merge tags feature |
|
| 59 | + * - class // (new) define extra classes for the field |
|
| 60 | + * - tooltip // |
|
| 61 | + * |
|
| 62 | + * @return array |
|
| 63 | + */ |
|
| 64 | + public static function get_field_defaults() { |
|
| 65 | + return array( |
|
| 66 | + 'desc' => '', |
|
| 67 | + 'value' => NULL, |
|
| 68 | + 'label' => '', |
|
| 69 | + 'left_label' => NULL, |
|
| 70 | + 'id' => NULL, |
|
| 71 | + 'type' => 'text', |
|
| 72 | + 'options' => NULL, |
|
| 73 | + 'merge_tags' => true, |
|
| 74 | + 'class' => '', |
|
| 75 | + 'tooltip' => NULL |
|
| 76 | + ); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + function get_tooltip() { |
|
| 81 | + if( !function_exists('gform_tooltip') ) { |
|
| 82 | + return NULL; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + return !empty( $this->field['tooltip'] ) ? ' '.gform_tooltip( $this->field['tooltip'] , false, true ) : NULL; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Build input id based on the name |
|
| 90 | + * @return string |
|
| 91 | + */ |
|
| 92 | + function get_field_id() { |
|
| 93 | + if( isset( $this->field['id'] ) ) { |
|
| 94 | + return esc_attr( $this->field['id'] ); |
|
| 95 | + } |
|
| 96 | + return esc_attr( sanitize_html_class( $this->name ) ); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Retrieve field label |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function get_field_label() { |
|
| 104 | + return esc_html( trim( $this->field['label'] ) ); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Retrieve field left label |
| 109 | - * |
|
| 110 | - * @since 1.7 |
|
| 111 | - * |
|
| 109 | + * |
|
| 110 | + * @since 1.7 |
|
| 111 | + * |
|
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | 114 | function get_field_left_label() { |
| 115 | 115 | return ! empty( $this->field['left_label'] ) ? esc_html( trim( $this->field['left_label'] ) ) : NULL; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Retrieve field label class |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - function get_label_class() { |
|
| 123 | - return 'gv-label-'. sanitize_html_class( $this->field['type'] ); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Retrieve field description |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - function get_field_desc() { |
|
| 132 | - return !empty( $this->field['desc'] ) ? '<span class="howto">'. $this->field['desc'] .'</span>' : ''; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Verify if field should have merge tags |
|
| 138 | - * @return boolean |
|
| 139 | - */ |
|
| 140 | - function show_merge_tags() { |
|
| 141 | - // Show the merge tags if the field is a list view |
|
| 142 | - $is_list = preg_match( '/_list-/ism', $this->name ); |
|
| 143 | - // Or is a single entry view |
|
| 144 | - $is_single = preg_match( '/single_/ism', $this->name ); |
|
| 145 | - |
|
| 146 | - return ( $is_single || $is_list ); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * important! Override this class |
|
| 153 | - * outputs the field option html |
|
| 154 | - */ |
|
| 155 | - function render_option() { |
|
| 156 | - // to replace on each field |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * important! Override this class if needed |
|
| 161 | - * outputs the field setting html |
|
| 162 | - */ |
|
| 163 | - function render_setting( $override_input = NULL ) { |
|
| 164 | - |
|
| 165 | - if( !empty( $this->field['full_width'] ) ) { ?> |
|
| 118 | + /** |
|
| 119 | + * Retrieve field label class |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + function get_label_class() { |
|
| 123 | + return 'gv-label-'. sanitize_html_class( $this->field['type'] ); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Retrieve field description |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + function get_field_desc() { |
|
| 132 | + return !empty( $this->field['desc'] ) ? '<span class="howto">'. $this->field['desc'] .'</span>' : ''; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Verify if field should have merge tags |
|
| 138 | + * @return boolean |
|
| 139 | + */ |
|
| 140 | + function show_merge_tags() { |
|
| 141 | + // Show the merge tags if the field is a list view |
|
| 142 | + $is_list = preg_match( '/_list-/ism', $this->name ); |
|
| 143 | + // Or is a single entry view |
|
| 144 | + $is_single = preg_match( '/single_/ism', $this->name ); |
|
| 145 | + |
|
| 146 | + return ( $is_single || $is_list ); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * important! Override this class |
|
| 153 | + * outputs the field option html |
|
| 154 | + */ |
|
| 155 | + function render_option() { |
|
| 156 | + // to replace on each field |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * important! Override this class if needed |
|
| 161 | + * outputs the field setting html |
|
| 162 | + */ |
|
| 163 | + function render_setting( $override_input = NULL ) { |
|
| 164 | + |
|
| 165 | + if( !empty( $this->field['full_width'] ) ) { ?> |
|
| 166 | 166 | <th scope="row" colspan="2"> |
| 167 | 167 | <div> |
| 168 | 168 | <label for="<?php echo $this->get_field_id(); ?>"> |
@@ -182,14 +182,14 @@ discard block |
||
| 182 | 182 | </td> |
| 183 | 183 | <?php } |
| 184 | 184 | |
| 185 | - } |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * important! Override this class |
|
| 189 | - * outputs the input html part |
|
| 190 | - */ |
|
| 191 | - function render_input( $override_input ) { |
|
| 192 | - echo ''; |
|
| 193 | - } |
|
| 187 | + /** |
|
| 188 | + * important! Override this class |
|
| 189 | + * outputs the input html part |
|
| 190 | + */ |
|
| 191 | + function render_input( $override_input ) { |
|
| 192 | + echo ''; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | 195 | } |
@@ -386,14 +386,14 @@ |
||
| 386 | 386 | $curr_start = esc_attr( rgget( 'gv_start' ) ); |
| 387 | 387 | $curr_end = esc_attr( rgget( 'gv_end' ) ); |
| 388 | 388 | |
| 389 | - /** |
|
| 390 | - * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
| 391 | - * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
| 392 | - * @since 1.12 |
|
| 393 | - * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
| 394 | - * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
| 395 | - */ |
|
| 396 | - $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
| 389 | + /** |
|
| 390 | + * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
| 391 | + * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
| 392 | + * @since 1.12 |
|
| 393 | + * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
| 394 | + * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
| 395 | + */ |
|
| 396 | + $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
| 397 | 397 | |
| 398 | 398 | |
| 399 | 399 | /** |
@@ -18,80 +18,80 @@ 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 | |
| 44 | - $this->load_components( 'render' ); |
|
| 44 | + $this->load_components( 'render' ); |
|
| 45 | 45 | |
| 46 | - // If GF User Registration Add-on exists |
|
| 47 | - $this->load_components( 'user-registration' ); |
|
| 46 | + // If GF User Registration Add-on exists |
|
| 47 | + $this->load_components( 'user-registration' ); |
|
| 48 | 48 | |
| 49 | - $this->add_hooks(); |
|
| 49 | + $this->add_hooks(); |
|
| 50 | 50 | |
| 51 | 51 | // Process hooks for addons that may or may not be present |
| 52 | 52 | $this->addon_specific_hooks(); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - static function getInstance() { |
|
| 56 | + static function getInstance() { |
|
| 57 | 57 | |
| 58 | - if( empty( self::$instance ) ) { |
|
| 59 | - self::$instance = new GravityView_Edit_Entry; |
|
| 60 | - } |
|
| 58 | + if( empty( self::$instance ) ) { |
|
| 59 | + self::$instance = new GravityView_Edit_Entry; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return self::$instance; |
|
| 63 | - } |
|
| 62 | + return self::$instance; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | - private function load_components( $component ) { |
|
| 66 | + private function load_components( $component ) { |
|
| 67 | 67 | |
| 68 | - $dir = trailingslashit( self::$file ); |
|
| 68 | + $dir = trailingslashit( self::$file ); |
|
| 69 | 69 | |
| 70 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 71 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 70 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 71 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 72 | 72 | |
| 73 | - // Loads component and pass extension's instance so that component can |
|
| 74 | - // talk each other. |
|
| 75 | - require_once $filename; |
|
| 76 | - $this->instances[ $component ] = new $classname( $this ); |
|
| 77 | - $this->instances[ $component ]->load(); |
|
| 73 | + // Loads component and pass extension's instance so that component can |
|
| 74 | + // talk each other. |
|
| 75 | + require_once $filename; |
|
| 76 | + $this->instances[ $component ] = new $classname( $this ); |
|
| 77 | + $this->instances[ $component ]->load(); |
|
| 78 | 78 | |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - private function add_hooks() { |
|
| 81 | + private function add_hooks() { |
|
| 82 | 82 | |
| 83 | - // Add front-end access to Gravity Forms delete file action |
|
| 84 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 83 | + // Add front-end access to Gravity Forms delete file action |
|
| 84 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 85 | 85 | |
| 86 | - // Make sure this hook is run for non-admins |
|
| 87 | - add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 86 | + // Make sure this hook is run for non-admins |
|
| 87 | + add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
| 88 | 88 | |
| 89 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 89 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 90 | 90 | |
| 91 | - // add template path to check for field |
|
| 92 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 91 | + // add template path to check for field |
|
| 92 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 93 | 93 | |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin |
@@ -105,75 +105,75 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Include this extension templates path |
|
| 110 | - * @param array $file_paths List of template paths ordered |
|
| 111 | - */ |
|
| 112 | - public function add_template_path( $file_paths ) { |
|
| 113 | - |
|
| 114 | - // Index 100 is the default GravityView template path. |
|
| 115 | - $file_paths[ 110 ] = self::$file; |
|
| 116 | - |
|
| 117 | - return $file_paths; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * |
|
| 122 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 123 | - * |
|
| 124 | - * @param $view_id int GravityView view id |
|
| 125 | - * @param $form_id int Gravity Forms form id |
|
| 126 | - * @param $entry_id int Gravity Forms entry id |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 129 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 130 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * The edit entry link creates a secure link with a nonce |
|
| 136 | - * |
|
| 137 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 138 | - * it formats the display of the edit form like it does in the backend, like |
|
| 139 | - * "You can edit this post from the post page" fields, for example. |
|
| 140 | - * |
|
| 141 | - * @param $entry array Gravity Forms entry object |
|
| 142 | - * @param $view_id int GravityView view id |
|
| 143 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 144 | - * @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/ } |
|
| 145 | - * @return string |
|
| 146 | - */ |
|
| 147 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 148 | - |
|
| 149 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 150 | - |
|
| 151 | - $base = gv_entry_link( $entry, $post_id ); |
|
| 152 | - |
|
| 153 | - $url = add_query_arg( array( |
|
| 154 | - 'page' => 'gf_entries', // Needed for GFForms::get_page() |
|
| 155 | - 'view' => 'entry', // Needed for GFForms::get_page() |
|
| 156 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
| 157 | - ), $base ); |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Allow passing params to dynamically populate entry with values |
|
| 161 | - * @since 1.9.2 |
|
| 162 | - */ |
|
| 163 | - if( !empty( $field_values ) ) { |
|
| 164 | - |
|
| 165 | - if( is_array( $field_values ) ) { |
|
| 166 | - // If already an array, no parse_str() needed |
|
| 167 | - $params = $field_values; |
|
| 168 | - } else { |
|
| 169 | - parse_str( $field_values, $params ); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - $url = add_query_arg( $params, $url ); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - return $url; |
|
| 176 | - } |
|
| 108 | + /** |
|
| 109 | + * Include this extension templates path |
|
| 110 | + * @param array $file_paths List of template paths ordered |
|
| 111 | + */ |
|
| 112 | + public function add_template_path( $file_paths ) { |
|
| 113 | + |
|
| 114 | + // Index 100 is the default GravityView template path. |
|
| 115 | + $file_paths[ 110 ] = self::$file; |
|
| 116 | + |
|
| 117 | + return $file_paths; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * |
|
| 122 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 123 | + * |
|
| 124 | + * @param $view_id int GravityView view id |
|
| 125 | + * @param $form_id int Gravity Forms form id |
|
| 126 | + * @param $entry_id int Gravity Forms entry id |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 130 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * The edit entry link creates a secure link with a nonce |
|
| 136 | + * |
|
| 137 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 138 | + * it formats the display of the edit form like it does in the backend, like |
|
| 139 | + * "You can edit this post from the post page" fields, for example. |
|
| 140 | + * |
|
| 141 | + * @param $entry array Gravity Forms entry object |
|
| 142 | + * @param $view_id int GravityView view id |
|
| 143 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 144 | + * @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/ } |
|
| 145 | + * @return string |
|
| 146 | + */ |
|
| 147 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 148 | + |
|
| 149 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 150 | + |
|
| 151 | + $base = gv_entry_link( $entry, $post_id ); |
|
| 152 | + |
|
| 153 | + $url = add_query_arg( array( |
|
| 154 | + 'page' => 'gf_entries', // Needed for GFForms::get_page() |
|
| 155 | + 'view' => 'entry', // Needed for GFForms::get_page() |
|
| 156 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
| 157 | + ), $base ); |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Allow passing params to dynamically populate entry with values |
|
| 161 | + * @since 1.9.2 |
|
| 162 | + */ |
|
| 163 | + if( !empty( $field_values ) ) { |
|
| 164 | + |
|
| 165 | + if( is_array( $field_values ) ) { |
|
| 166 | + // If already an array, no parse_str() needed |
|
| 167 | + $params = $field_values; |
|
| 168 | + } else { |
|
| 169 | + parse_str( $field_values, $params ); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + $url = add_query_arg( $params, $url ); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + return $url; |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -209,81 +209,81 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
| 212 | - /** |
|
| 213 | - * checks if user has permissions to edit a specific entry |
|
| 214 | - * |
|
| 215 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 216 | - * |
|
| 217 | - * @param array $entry Gravity Forms entry array |
|
| 218 | - * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
| 219 | - * @return bool |
|
| 220 | - */ |
|
| 221 | - public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
| 212 | + /** |
|
| 213 | + * checks if user has permissions to edit a specific entry |
|
| 214 | + * |
|
| 215 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 216 | + * |
|
| 217 | + * @param array $entry Gravity Forms entry array |
|
| 218 | + * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
| 219 | + * @return bool |
|
| 220 | + */ |
|
| 221 | + public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
| 222 | 222 | |
| 223 | - // No permission by default |
|
| 224 | - $user_can_edit = false; |
|
| 223 | + // No permission by default |
|
| 224 | + $user_can_edit = false; |
|
| 225 | 225 | |
| 226 | - // If they can edit any entries (as defined in Gravity Forms) |
|
| 227 | - // Or if they can edit other people's entries |
|
| 228 | - // Then we're good. |
|
| 229 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 226 | + // If they can edit any entries (as defined in Gravity Forms) |
|
| 227 | + // Or if they can edit other people's entries |
|
| 228 | + // Then we're good. |
|
| 229 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 230 | 230 | |
| 231 | - do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
| 231 | + do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
| 232 | 232 | |
| 233 | - $user_can_edit = true; |
|
| 233 | + $user_can_edit = true; |
|
| 234 | 234 | |
| 235 | - } else if( !isset( $entry['created_by'] ) ) { |
|
| 235 | + } else if( !isset( $entry['created_by'] ) ) { |
|
| 236 | 236 | |
| 237 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
| 237 | + do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
| 238 | 238 | |
| 239 | - $user_can_edit = false; |
|
| 239 | + $user_can_edit = false; |
|
| 240 | 240 | |
| 241 | - } else { |
|
| 241 | + } else { |
|
| 242 | 242 | |
| 243 | - // get user_edit setting |
|
| 244 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
| 245 | - // if View ID not specified or is the current view |
|
| 246 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
| 247 | - } else { |
|
| 248 | - // in case is specified and not the current view |
|
| 249 | - $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
| 250 | - } |
|
| 243 | + // get user_edit setting |
|
| 244 | + if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
| 245 | + // if View ID not specified or is the current view |
|
| 246 | + $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
| 247 | + } else { |
|
| 248 | + // in case is specified and not the current view |
|
| 249 | + $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - $current_user = wp_get_current_user(); |
|
| 252 | + $current_user = wp_get_current_user(); |
|
| 253 | 253 | |
| 254 | - // User edit is disabled |
|
| 255 | - if( empty( $user_edit ) ) { |
|
| 254 | + // User edit is disabled |
|
| 255 | + if( empty( $user_edit ) ) { |
|
| 256 | 256 | |
| 257 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
| 257 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
| 258 | 258 | |
| 259 | - $user_can_edit = false; |
|
| 260 | - } |
|
| 259 | + $user_can_edit = false; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 263 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 262 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 263 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 264 | 264 | |
| 265 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
| 265 | + do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
| 266 | 266 | |
| 267 | - $user_can_edit = true; |
|
| 267 | + $user_can_edit = true; |
|
| 268 | 268 | |
| 269 | - } else if( ! is_user_logged_in() ) { |
|
| 269 | + } else if( ! is_user_logged_in() ) { |
|
| 270 | 270 | |
| 271 | - do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
| 272 | - } |
|
| 271 | + do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 278 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 279 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 280 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 281 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 282 | - */ |
|
| 283 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 276 | + /** |
|
| 277 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 278 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 279 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 280 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 281 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 282 | + */ |
|
| 283 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 284 | 284 | |
| 285 | - return (bool)$user_can_edit; |
|
| 286 | - } |
|
| 285 | + return (bool)$user_can_edit; |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | 288 | |
| 289 | 289 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | self::getInstance()->set_entry( $entry ); |
| 230 | 230 | |
| 231 | - $base = GravityView_API::directory_link( $post_id, true ); |
|
| 231 | + $base = GravityView_API::directory_link( $post_id, true ); |
|
| 232 | 232 | |
| 233 | 233 | if( empty( $base ) ) { |
| 234 | 234 | do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id ); |
@@ -238,13 +238,13 @@ discard block |
||
| 238 | 238 | // Use the slug instead of the ID for consistent security |
| 239 | 239 | $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
| 240 | 240 | |
| 241 | - $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; |
|
| 241 | + $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; |
|
| 242 | 242 | |
| 243 | 243 | $actionurl = add_query_arg( array( |
| 244 | 244 | 'action' => 'delete', |
| 245 | 245 | 'entry_id' => $entry_slug, |
| 246 | 246 | 'gvid' => $view_id, |
| 247 | - 'view_id' => $view_id, |
|
| 247 | + 'view_id' => $view_id, |
|
| 248 | 248 | ), $base ); |
| 249 | 249 | |
| 250 | 250 | $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | * @action `gravityview/delete-entry/deleted` Triggered when an entry is deleted |
| 416 | 416 | * @since 1.16.4 |
| 417 | 417 | * @param int $entry_id ID of the Gravity Forms entry |
| 418 | - */ |
|
| 418 | + */ |
|
| 419 | 419 | do_action( 'gravityview/delete-entry/deleted', $entry_id ); |
| 420 | 420 | } |
| 421 | 421 | |
@@ -255,7 +255,6 @@ |
||
| 255 | 255 | * Get the default date format for a field based on the field ID and the time format setting |
| 256 | 256 | * |
| 257 | 257 | * @since 1.14 |
| 258 | - |
|
| 259 | 258 | * @param string $time_format The time format ("12" or "24"). Default: "12" {@since 1.14} |
| 260 | 259 | * @param int $field_id The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14} |
| 261 | 260 | * |
@@ -40,11 +40,11 @@ |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $field_options['link_phone'] = array( |
| 43 | - 'type' => 'checkbox', |
|
| 44 | - 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
|
| 45 | - 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview'), |
|
| 46 | - 'value' => true, |
|
| 47 | - ); |
|
| 43 | + 'type' => 'checkbox', |
|
| 44 | + 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
|
| 45 | + 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview'), |
|
| 46 | + 'value' => true, |
|
| 47 | + ); |
|
| 48 | 48 | |
| 49 | 49 | return $field_options; |
| 50 | 50 | } |