Passed
Push — master ( 9e37cd...7382ee )
by Brian
09:54
created

wpinv_select_callback()   B

Complexity

Conditions 9
Paths 32

Size

Total Lines 35
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 9
eloc 30
c 1
b 0
f 0
nc 32
nop 1
dl 0
loc 35
rs 8.0555
1
<?php
2
/**
3
 * Contains settings related functions
4
 *
5
 * @package Invoicing
6
 * @since   1.0.0
7
 */
8
9
defined( 'ABSPATH' ) || exit;
10
11
/**
12
 * Retrieves all default settings.
13
 * 
14
 * @return array
15
 */
16
function wpinv_get_settings() {
17
    $defaults = array();
18
19
    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
20
21
        foreach ( array_values( $tab_settings ) as $section_settings ) {
22
23
            foreach ( $section_settings as $key => $setting ) {
24
                if ( isset( $setting['std'] ) ) {
25
                    $defaults[ $key ] = $setting['std'];
26
                }
27
            }
28
29
        }
30
31
    }
32
33
    return $defaults;
34
35
}
36
37
/**
38
 * Retrieves all settings.
39
 * 
40
 * @return array
41
 */
42
function wpinv_get_options() {
43
    global $wpinv_options;
44
45
    // Try fetching the saved options.
46
    if ( ! is_array( $wpinv_options ) ) {
47
        $wpinv_options = get_option( 'wpinv_settings' );
48
    }
49
50
    // If that fails, don't fetch the default settings to prevent a loop.
51
    if ( ! is_array( $wpinv_options ) ) {
52
        $wpinv_options = array();
53
    }
54
55
    return $wpinv_options;
56
}
57
58
/**
59
 * Retrieves a single setting.
60
 * 
61
 * @param string $key the setting key.
62
 * @param mixed $default The default value to use if the setting has not been set.
63
 * @return mixed
64
 */
65
function wpinv_get_option( $key = '', $default = false ) {
66
67
    $options = wpinv_get_options();
68
    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
70
71
    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
72
}
73
74
/**
75
 * Updates all settings.
76
 * 
77
 * @param array $options the new options.
78
 * @return bool
79
 */
80
function wpinv_update_options( $options ) {
81
    global $wpinv_options;
82
83
    // update the option.
84
    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
85
        $wpinv_options = $options;
86
        return true;
87
    }
88
89
    return false;
90
}
91
92
/**
93
 * Updates a single setting.
94
 * 
95
 * @param string $key the setting key.
96
 * @param mixed $value The setting value.
97
 * @return bool
98
 */
99
function wpinv_update_option( $key = '', $value = false ) {
100
101
    // If no key, exit.
102
    if ( empty( $key ) ) {
103
        return false;
104
    }
105
106
    // Maybe delete the option instead.
107
    if ( is_null( $value ) ) {
108
        return wpinv_delete_option( $key );
109
    }
110
111
    // Prepare the new options.
112
    $options         = wpinv_get_options();
113
    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
114
115
    // Save the new options.
116
    return wpinv_update_options( $options );
117
118
}
119
120
/**
121
 * Deletes a single setting.
122
 * 
123
 * @param string $key the setting key.
124
 * @return bool
125
 */
126
function wpinv_delete_option( $key = '' ) {
127
128
    // If no key, exit
129
    if ( empty( $key ) ) {
130
        return false;
131
    }
132
133
    $options = wpinv_get_options();
134
135
    if ( isset( $options[ $key ] ) ) {
136
        unset( $options[ $key ] );
137
        return wpinv_update_options( $options );
138
    }
139
140
    return true;
141
142
}
143
144
/**
145
 * Register settings after admin inits.
146
 * 
147
 */
148
function wpinv_register_settings() {
149
150
    // Loop through all tabs.
151
    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
152
153
        // In each tab, loop through sections.
154
        foreach ( $sections as $section => $settings ) {
155
156
            // Check for backwards compatibility
157
            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
159
                $section = 'main';
160
                $settings = $sections;
161
            }
162
163
            // Register the setting section.
164
            add_settings_section(
165
                'wpinv_settings_' . $tab . '_' . $section,
166
                __return_null(),
0 ignored issues
show
Bug introduced by
Are you sure the usage of __return_null() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
167
                '__return_false',
168
                'wpinv_settings_' . $tab . '_' . $section
169
            );
170
171
            foreach ( $settings as $option ) {
172
                if ( ! empty( $option['id'] ) ) {
173
                    wpinv_register_settings_option( $tab, $section, $option );
174
                }
175
            }
176
177
        }
178
    }
179
180
    // Creates our settings in the options table.
181
    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
0 ignored issues
show
Bug introduced by
'wpinv_settings_sanitize' of type string is incompatible with the type array expected by parameter $args of register_setting(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

181
    register_setting( 'wpinv_settings', 'wpinv_settings', /** @scrutinizer ignore-type */ 'wpinv_settings_sanitize' );
Loading history...
182
}
183
add_action( 'admin_init', 'wpinv_register_settings' );
184
185
/**
186
 * Register a single settings option.
187
 * 
188
 * @param string $tab
189
 * @param string $section
190
 * @param string $option
191
 * 
192
 */
193
function wpinv_register_settings_option( $tab, $section, $option ) {
194
195
    $name    = isset( $option['name'] ) ? $option['name'] : '';
196
    $cb      = "wpinv_{$option['type']}_callback";
197
    $section = "wpinv_settings_{$tab}_$section";
198
199
	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
		$tip   = wpinv_clean( $option['desc'] );
201
		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
		unset( $option['desc'] );
203
	}
204
205
    // Loop through all tabs.
206
    add_settings_field(
207
        'wpinv_settings[' . $option['id'] . ']',
208
        $name,
209
        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
210
        $section,
211
        $section,
212
        array(
213
            'section'     => $section,
214
            'id'          => isset( $option['id'] )          ? $option['id']          : uniqid( 'wpinv-' ),
215
            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
216
            'name'        => $name,
217
            'size'        => isset( $option['size'] )        ? $option['size']        : null,
218
            'options'     => isset( $option['options'] )     ? $option['options']     : '',
219
            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
220
            'std'         => isset( $option['std'] )         ? $option['std']         : '',
221
            'min'         => isset( $option['min'] )         ? $option['min']         : 0,
222
            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
223
            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
224
            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
225
            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
226
            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
227
            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228
            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229
            'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
			'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
231
			'class'       => isset( $option['class'] )     ? $option['class']         : '',
232
			'style'       => isset( $option['style'] )     ? $option['style']         : '',
233
            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
234
            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
235
        )
236
    );
237
238
}
239
240
/**
241
 * Returns an array of all registered settings.
242
 * 
243
 * @return array
244
 */
245
function wpinv_get_registered_settings() {
246
	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
247
}
248
249
/**
250
 * Returns an array of all integration settings.
251
 * 
252
 * @return array
253
 */
254
function getpaid_get_integration_settings() {
255
    return apply_filters( 'getpaid_integration_settings', array() );
256
}
257
258
/**
259
 * Sanitizes settings before they are saved.
260
 * 
261
 * @return array
262
 */
263
function wpinv_settings_sanitize( $input = array() ) {
264
265
	$wpinv_options = wpinv_get_options();
266
	$raw_referrer  = wp_get_raw_referer();
267
268
    if ( empty( $raw_referrer ) ) {
269
        return $input;
270
    }
271
272
    wp_parse_str( $raw_referrer, $referrer );
273
274
	if ( empty( $referrer['tab'] ) ) {
275
        return $input;
276
	}
277
278
    $settings = wpinv_get_registered_settings();
279
    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
280
    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
281
282
    $input = $input ? $input : array();
283
    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
284
    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
285
286
    // Loop through each setting being saved and pass it through a sanitization filter
287
    foreach ( $input as $key => $value ) {
288
289
        // Get the setting type (checkbox, select, etc)
290
        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
291
292
        if ( $type ) {
293
            // Field type specific filter
294
            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
295
        }
296
297
        // General filter
298
		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
299
300
		// Key specific filter.
301
		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
302
    }
303
304
    // Loop through the whitelist and unset any that are empty for the tab being saved
305
    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
306
    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
307
308
    $found_settings   = array_merge( $main_settings, $section_settings );
309
310
    if ( ! empty( $found_settings ) ) {
311
        foreach ( $found_settings as $key => $value ) {
312
313
            // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
314
            if ( is_numeric( $key ) ) {
315
                $key = $value['id'];
316
            }
317
318
            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
319
                unset( $wpinv_options[ $key ] );
320
            }
321
        }
322
    }
323
324
    // Merge our new settings with the existing
325
    $output = array_merge( $wpinv_options, $input );
326
327
    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
328
329
    return $output;
330
}
331
332
function wpinv_settings_sanitize_misc_accounting( $input ) {
333
334
    if ( ! wpinv_current_user_can_manage_invoicing() ) {
335
        return $input;
336
    }
337
338
    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
339
        // Shows an admin notice about upgrading previous order numbers
340
        getpaid_session()->set( 'upgrade_sequential', '1' );
341
    }
342
343
    return $input;
344
}
345
add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
346
347
function wpinv_settings_sanitize_tax_rates( $input ) {
348
    if( ! wpinv_current_user_can_manage_invoicing() ) {
349
        return $input;
350
    }
351
352
    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
353
    $tax_rates = array();
354
355
    foreach ( $new_rates as $rate ) {
356
357
		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
358
		$rate['name']    = sanitize_text_field( $rate['name'] );
359
		$rate['state']   = sanitize_text_field( $rate['state'] );
360
		$rate['country'] = sanitize_text_field( $rate['country'] );
361
		$rate['global']  = empty( $rate['state'] );
362
		$tax_rates[]     = $rate;
363
364
	}
365
366
    update_option( 'wpinv_tax_rates', $tax_rates );
367
368
    return $input;
369
}
370
add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
371
372
function wpinv_sanitize_text_field( $input ) {
373
    return trim( $input );
374
}
375
add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
376
377
function wpinv_get_settings_tabs() {
378
    $tabs             = array();
379
    $tabs['general']  = __( 'General', 'invoicing' );
380
    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
381
    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
382
	$tabs['emails']   = __( 'Emails', 'invoicing' );
383
384
	if ( count( getpaid_get_integration_settings() ) > 0 ) {
385
		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
386
	}
387
388
    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
389
    $tabs['misc']     = __( 'Misc', 'invoicing' );
390
    $tabs['tools']    = __( 'Tools', 'invoicing' );
391
392
    return apply_filters( 'wpinv_settings_tabs', $tabs );
393
}
394
395
function wpinv_get_settings_tab_sections( $tab = false ) {
396
    $tabs     = false;
397
    $sections = wpinv_get_registered_settings_sections();
398
399
    if( $tab && ! empty( $sections[ $tab ] ) ) {
400
        $tabs = $sections[ $tab ];
401
    }
402
403
    return $tabs;
404
}
405
406
function wpinv_get_registered_settings_sections() {
407
    static $sections = false;
408
409
    if ( false !== $sections ) {
410
        return $sections;
411
    }
412
413
    $sections = array(
414
        'general' => apply_filters( 'wpinv_settings_sections_general', array(
415
            'main' => __( 'General Settings', 'invoicing' ),
416
            'currency_section' => __( 'Currency Settings', 'invoicing' ),
417
            'labels' => __( 'Label Texts', 'invoicing' ),
418
        ) ),
419
        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
420
            'main' => __( 'Gateway Settings', 'invoicing' ),
421
        ) ),
422
        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
423
            'main'  => __( 'Tax Settings', 'invoicing' ),
424
			'rates' => __( 'Tax Rates', 'invoicing' ),
425
			'vat'   => __( 'EU VAT Settings', 'invoicing' )
426
        ) ),
427
        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
428
            'main' => __( 'Email Settings', 'invoicing' ),
429
		) ),
430
431
		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
432
433
        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
434
            'main' => __( 'Privacy policy', 'invoicing' ),
435
        ) ),
436
        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
437
            'main' => __( 'Miscellaneous', 'invoicing' ),
438
            'custom-css' => __( 'Custom CSS', 'invoicing' ),
439
        ) ),
440
        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
441
            'main' => __( 'Diagnostic Tools', 'invoicing' ),
442
        ) ),
443
    );
444
445
    $sections = apply_filters( 'wpinv_settings_sections', $sections );
446
447
    return $sections;
448
}
449
450
function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
451
	$pages_options = array();
452
453
	if( $default_label !== NULL && $default_label !== false ) {
454
		$pages_options = array( '' => $default_label ); // Blank option
455
	}
456
457
	$pages = get_pages();
458
	if ( $pages ) {
459
		foreach ( $pages as $page ) {
460
			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
461
            $pages_options[ $page->ID ] = $title;
462
		}
463
	}
464
465
	return $pages_options;
466
}
467
468
function wpinv_header_callback( $args ) {
469
	if ( !empty( $args['desc'] ) ) {
470
        echo $args['desc'];
471
    }
472
}
473
474
function wpinv_hidden_callback( $args ) {
475
	global $wpinv_options;
476
477
	if ( isset( $args['set_value'] ) ) {
478
		$value = $args['set_value'];
479
	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
480
		$value = $wpinv_options[ $args['id'] ];
481
	} else {
482
		$value = isset( $args['std'] ) ? $args['std'] : '';
483
	}
484
485
	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
486
		$args['readonly'] = true;
487
		$value = isset( $args['std'] ) ? $args['std'] : '';
488
		$name  = '';
489
	} else {
490
		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
491
	}
492
493
	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
494
    
495
	echo $html;
496
}
497
498
/**
499
 * Displays a checkbox settings callback.
500
 */
501
function wpinv_checkbox_callback( $args ) {
502
503
	$std = isset( $args['std'] ) ? $args['std'] : '';
504
	$std = wpinv_get_option( $args['id'], $std );
505
	$id  = esc_attr( $args['id'] );
506
507
	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
508
	?>
509
		<fieldset>
510
			<label>
511
				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
512
				<?php echo wp_kses_post( $args['desc'] ); ?>
513
			</label>
514
		</fieldset>
515
	<?php
516
}
517
518
function wpinv_multicheck_callback( $args ) {
519
	
520
	global $wpinv_options;
521
522
	$sanitize_id = wpinv_sanitize_key( $args['id'] );
523
	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
524
525
	if ( ! empty( $args['options'] ) ) {
526
527
		$std     = isset( $args['std'] ) ? $args['std'] : array();
528
		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
529
530
		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
531
        foreach( $args['options'] as $key => $option ):
532
			$sanitize_key = wpinv_sanitize_key( $key );
533
			if ( in_array( $sanitize_key, $value ) ) { 
534
				$enabled = $sanitize_key;
535
			} else { 
536
				$enabled = NULL; 
537
			}
538
			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
539
			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
540
		endforeach;
541
		echo '</div>';
542
		echo '<p class="description">' . $args['desc'] . '</p>';
543
	}
544
}
545
546
function wpinv_payment_icons_callback( $args ) {
547
	global $wpinv_options;
548
    
549
    $sanitize_id = wpinv_sanitize_key( $args['id'] );
550
551
	if ( ! empty( $args['options'] ) ) {
552
		foreach( $args['options'] as $key => $option ) {
553
            $sanitize_key = wpinv_sanitize_key( $key );
554
            
555
			if( isset( $wpinv_options[$args['id']][$key] ) ) {
556
				$enabled = $option;
557
			} else {
558
				$enabled = NULL;
559
			}
560
561
			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
562
563
				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
564
565
				if ( wpinv_string_is_image_url( $key ) ) {
566
					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
567
				} else {
568
					$card = strtolower( str_replace( ' ', '', $option ) );
569
570
					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
571
						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
572
					} else {
573
						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string expected by parameter $template_path of wpinv_locate_template(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

573
						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', /** @scrutinizer ignore-type */ false );
Loading history...
574
						$content_dir = WP_CONTENT_DIR;
575
576
						if ( function_exists( 'wp_normalize_path' ) ) {
577
							// Replaces backslashes with forward slashes for Windows systems
578
							$image = wp_normalize_path( $image );
579
							$content_dir = wp_normalize_path( $content_dir );
580
						}
581
582
						$image = str_replace( $content_dir, content_url(), $image );
583
					}
584
585
					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
586
				}
587
			echo $option . '</label>';
588
		}
589
		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
590
	}
591
}
592
593
/**
594
 * Displays a radio settings field.
595
 */
596
function wpinv_radio_callback( $args ) {
597
598
	$std = isset( $args['std'] ) ? $args['std'] : '';
599
	$std = wpinv_get_option( $args['id'], $std );
600
	?>
601
		<fieldset>
602
			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
603
				<?php foreach( $args['options'] as $key => $option ) : ?>
604
					<li>
605
						<label>
606
							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
607
							<?php echo wp_kses_post( $option ); ?>
608
						</label>
609
					</li>
610
				<?php endforeach; ?>
611
			</ul>
612
		</fieldset>
613
	<?php
614
	getpaid_settings_description_callback( $args );
615
}
616
617
/**
618
 * Displays a description if available.
619
 */
620
function getpaid_settings_description_callback( $args ) {
621
622
	if ( ! empty( $args['desc'] ) ) {
623
		$description = wp_kses_post( $args['desc'] );
624
		echo "<p class='description'>$description</p>";
625
	}
626
627
}
628
629
/**
630
 * Displays a list of available gateways.
631
 */
632
function wpinv_gateways_callback() {
633
634
	?>
635
		</td>
636
	</tr>
637
	<tr class="bsui">
638
    	<td colspan="2" class="p-0">
639
			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
640
641
	<?php
642
}
643
644
function wpinv_gateway_select_callback($args) {
645
	global $wpinv_options;
646
    
647
    $sanitize_id = wpinv_sanitize_key( $args['id'] );
648
    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
649
650
	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
651
652
	foreach ( $args['options'] as $key => $option ) :
653
		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
654
            $selected = selected( $key, $args['selected'], false );
655
        } else {
656
            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
657
        }
658
		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
659
	endforeach;
660
661
	echo '</select>';
662
	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
663
}
664
665
/**
666
 * Generates attributes.
667
 * 
668
 * @param array $args
669
 * @return string
670
 */
671
function wpinv_settings_attrs_helper( $args ) {
672
673
	$value        = isset( $args['std'] ) ? $args['std'] : '';
674
	$id           = esc_attr( $args['id'] );
675
	$placeholder  = esc_attr( $args['placeholder'] );
676
677
	if ( ! empty( $args['faux'] ) ) {
678
		$args['readonly'] = true;
679
		$name             = '';
680
	} else {
681
		$value  = wpinv_get_option( $args['id'], $value );
682
		$name   = "wpinv_settings[$id]";
683
	}
684
685
	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
686
	$class    = esc_attr( $args['class'] );
687
	$style    = esc_attr( $args['style'] );
688
	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
689
690
	$onchange = '';
691
    if ( ! empty( $args['onchange'] ) ) {
692
        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
693
	}
694
695
	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
696
}
697
698
/**
699
 * Displays a text input settings callback.
700
 */
701
function wpinv_text_callback( $args ) {
702
703
	$desc = wp_kses_post( $args['desc'] );
704
	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
705
	$attr = wpinv_settings_attrs_helper( $args );
706
707
	?>
708
		<label style="width: 100%;">
709
			<input type="text" <?php echo $attr; ?>>
710
			<?php echo $desc; ?>
711
		</label>
712
	<?php
713
714
}
715
716
/**
717
 * Displays a number input settings callback.
718
 */
719
function wpinv_number_callback( $args ) {
720
721
	$desc = wp_kses_post( $args['desc'] );
722
	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
723
	$attr = wpinv_settings_attrs_helper( $args );
724
	$max  = intval( $args['max'] );
725
	$min  = intval( $args['min'] );
726
	$step = floatval( $args['step'] );
727
728
	?>
729
		<label style="width: 100%;">
730
			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
731
			<?php echo $desc; ?>
732
		</label>
733
	<?php
734
735
}
736
737
function wpinv_textarea_callback( $args ) {
738
	global $wpinv_options;
739
    
740
    $sanitize_id = wpinv_sanitize_key( $args['id'] );
741
742
	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
743
		$value = $wpinv_options[ $args['id'] ];
744
	} else {
745
		$value = isset( $args['std'] ) ? $args['std'] : '';
746
	}
747
    
748
    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
749
    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
750
751
	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
752
	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
753
754
	echo $html;
755
}
756
757
function wpinv_password_callback( $args ) {
758
	global $wpinv_options;
759
    
760
    $sanitize_id = wpinv_sanitize_key( $args['id'] );
761
762
	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
763
		$value = $wpinv_options[ $args['id'] ];
764
	} else {
765
		$value = isset( $args['std'] ) ? $args['std'] : '';
766
	}
767
768
	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
769
	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
770
	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
771
772
	echo $html;
773
}
774
775
function wpinv_missing_callback($args) {
776
	printf(
777
		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
778
		'<strong>' . $args['id'] . '</strong>'
779
	);
780
}
781
782
/**
783
 * Displays a number input settings callback.
784
 */
785
function wpinv_select_callback( $args ) {
786
787
	$desc   = wp_kses_post( $args['desc'] );
788
	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
789
	$attr   = wpinv_settings_attrs_helper( $args );
790
	$value  = isset( $args['std'] ) ? $args['std'] : '';
791
	$value  = wpinv_get_option( $args['id'], $value );
792
	$rand   = uniqid( 'random_id' );
793
794
	?>
795
		<label style="width: 100%;">
796
			<select <?php echo $attr; ?>>
797
				<?php foreach ( $args['options'] as $option => $name ) : ?>
798
					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
0 ignored issues
show
Bug introduced by
Are you sure wpinv_clean($name) of type array|string can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

798
					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo /** @scrutinizer ignore-type */ wpinv_clean( $name ); ?></option>
Loading history...
799
				<?php endforeach;?>
800
			</select>
801
802
			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
803
				<a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ) ?></a>
0 ignored issues
show
Bug introduced by
$value of type string is incompatible with the type WP_Post|integer expected by parameter $id of get_edit_post_link(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

803
				<a href="<?php echo get_edit_post_link( /** @scrutinizer ignore-type */ $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ) ?></a>
Loading history...
804
			<?php endif; ?>
805
806
			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
807
				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ) ?></a>
808
				<div id='<?php echo $rand; ?>' style='display:none;'>
809
					<div>
810
						<h3><?php _e( 'Original Content', 'invoicing' ) ?></h3>
811
						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea>
812
						<h3><?php _e( 'Current Content', 'invoicing' ) ?></h3>
813
						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea>
814
					</div>
815
				</div>
816
			<?php endif; ?>
817
818
			<?php echo $desc; ?>
819
		</label>
820
	<?php
821
822
}
823
824
function wpinv_color_select_callback( $args ) {
825
	global $wpinv_options;
826
    
827
    $sanitize_id = wpinv_sanitize_key( $args['id'] );
828
829
	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
830
		$value = $wpinv_options[ $args['id'] ];
831
	} else {
832
		$value = isset( $args['std'] ) ? $args['std'] : '';
833
	}
834
835
	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
836
837
	foreach ( $args['options'] as $option => $color ) {
838
		$selected = selected( $option, $value, false );
839
		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
840
	}
841
842
	$html .= '</select>';
843
	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
844
845
	echo $html;
846
}
847
848
function wpinv_rich_editor_callback( $args ) {
849
	global $wpinv_options, $wp_version;
850
    
851
    $sanitize_id = wpinv_sanitize_key( $args['id'] );
852
853
	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
854
		$value = $wpinv_options[ $args['id'] ];
855
856
		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
857
			$value = isset( $args['std'] ) ? $args['std'] : '';
858
		}
859
	} else {
860
		$value = isset( $args['std'] ) ? $args['std'] : '';
861
	}
862
863
	$rows = isset( $args['size'] ) ? $args['size'] : 20;
864
865
	$html = '<div class="getpaid-settings-editor-input">';
866
	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
867
		ob_start();
868
		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
869
		$html .= ob_get_clean();
870
	} else {
871
		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
872
	}
873
874
	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
875
876
	echo $html;
877
}
878
879
function wpinv_upload_callback( $args ) {
880
	global $wpinv_options;
881
    
882
    $sanitize_id = wpinv_sanitize_key( $args['id'] );
883
884
	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
		$value = $wpinv_options[$args['id']];
886
	} else {
887
		$value = isset($args['std']) ? $args['std'] : '';
888
	}
889
890
	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
891
	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
892
	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
893
	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
894
895
	echo $html;
896
}
897
898
function wpinv_color_callback( $args ) {
899
	global $wpinv_options;
900
    
901
    $sanitize_id = wpinv_sanitize_key( $args['id'] );
902
903
	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
904
		$value = $wpinv_options[ $args['id'] ];
905
	} else {
906
		$value = isset( $args['std'] ) ? $args['std'] : '';
907
	}
908
909
	$default = isset( $args['std'] ) ? $args['std'] : '';
910
911
	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
912
	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
913
914
	echo $html;
915
}
916
917
function wpinv_country_states_callback($args) {
918
	global $wpinv_options;
919
    
920
    $sanitize_id = wpinv_sanitize_key( $args['id'] );
921
922
	if ( isset( $args['placeholder'] ) ) {
923
		$placeholder = $args['placeholder'];
924
	} else {
925
		$placeholder = '';
926
	}
927
928
	$states = wpinv_get_country_states();
929
930
	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
931
	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
932
933
	foreach ( $states as $option => $name ) {
934
		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
935
		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
936
	}
937
938
	$html .= '</select>';
939
	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
940
941
	echo $html;
942
}
943
944
/**
945
 * Displays the tax rates edit table.
946
 */
947
function wpinv_tax_rates_callback() {
948
	
949
	?>
950
		</td>
951
	</tr>
952
	<tr class="bsui">
953
    	<td colspan="2" class="p-0">
954
			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
955
956
	<?php
957
958
}
959
960
/**
961
 * Displays a tax rate' edit row.
962
 */
963
function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
964
	ob_start();
965
966
	$key                      = sanitize_key( $key );
967
	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
968
	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
969
970
	if ( $echo ) {
971
		echo ob_get_clean();
972
	} else {
973
		return ob_get_clean(); 
974
	}
975
976
}
977
978
979
function wpinv_tools_callback($args) {
980
    ob_start(); ?>
981
    </td><tr>
982
    <td colspan="2" class="wpinv_tools_tdbox">
983
    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
984
    <?php do_action( 'wpinv_tools_before' ); ?>
985
    <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
986
        <thead>
987
            <tr>
988
                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
989
                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
990
                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
991
            </tr>
992
        </thead>
993
994
        <tbody>
995
			<tr>
996
                <td><?php _e( 'Check Pages', 'invoicing' );?></td>
997
                <td>
998
                    <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
999
                </td>
1000
                <td>
1001
					<a href="<?php
1002
						echo esc_url(
1003
							wp_nonce_url(
1004
								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1005
								'getpaid-nonce',
1006
								'getpaid-nonce'
1007
							)
1008
						);
1009
					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1010
                </td>
1011
            </tr>
1012
			<tr>
1013
                <td><?php _e( 'Create Database Tables', 'invoicing' );?></td>
1014
                <td>
1015
                    <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
1016
                </td>
1017
                <td>
1018
					<a href="<?php
1019
						echo esc_url(
1020
							wp_nonce_url(
1021
								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1022
								'getpaid-nonce',
1023
								'getpaid-nonce'
1024
							)
1025
						);
1026
					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1027
                </td>
1028
            </tr>
1029
			<tr>
1030
                <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td>
1031
                <td>
1032
                    <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
1033
                </td>
1034
                <td>
1035
					<a href="<?php
1036
						echo esc_url(
1037
							wp_nonce_url(
1038
								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1039
								'getpaid-nonce',
1040
								'getpaid-nonce'
1041
							)
1042
						);
1043
					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1044
                </td>
1045
            </tr>
1046
1047
			<tr>
1048
                <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td>
1049
                <td>
1050
                    <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1051
                </td>
1052
                <td>
1053
					<a href="<?php
1054
						echo esc_url(
1055
							wp_nonce_url(
1056
								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1057
								'getpaid-nonce',
1058
								'getpaid-nonce'
1059
							)
1060
						);
1061
					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1062
                </td>
1063
            </tr>
1064
1065
			<?php do_action( 'wpinv_tools_row' ); ?>
1066
        </tbody>
1067
    </table>
1068
    <?php do_action( 'wpinv_tools_after' ); ?>
1069
    <?php
1070
    echo ob_get_clean();
1071
}
1072
1073
1074
function wpinv_descriptive_text_callback( $args ) {
1075
	echo wp_kses_post( $args['desc'] );
1076
}
1077
1078
function wpinv_raw_html_callback( $args ) {
1079
	echo $args['desc'];
1080
}
1081
1082
function wpinv_hook_callback( $args ) {
1083
	do_action( 'wpinv_' . $args['id'], $args );
1084
}
1085
1086
function wpinv_set_settings_cap() {
1087
	return wpinv_get_capability();
1088
}
1089
add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1090
1091
function wpinv_settings_sanitize_input( $value, $key ) {
1092
1093
    if ( $key == 'tax_rate' ) {
1094
        $value = wpinv_sanitize_amount( $value );
1095
        $value = absint( min( $value, 99 ) );
1096
    }
1097
1098
    return $value;
1099
}
1100
add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1101
1102
function wpinv_on_update_settings( $old_value, $value, $option ) {
1103
    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1104
    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1105
    
1106
    if ( $old != $new ) {
1107
        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1108
    }
1109
}
1110
add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1111
1112
/**
1113
 * Returns the merge tags help text.
1114
 *
1115
 * @since    2.1.8
1116
 * 
1117
 * @return string
1118
 */
1119
function wpinv_get_merge_tags_help_text( $subscription = false ) {
1120
1121
	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1122
	$link = sprintf(
1123
		'<strong><a href="%s" target="_blank">%s</a></strong>',
1124
		$url,
1125
		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1126
	);
1127
1128
	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1129
1130
	return "$description $link";
1131
1132
}
1133