1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Give Settings Page/Tab |
4
|
|
|
* |
5
|
|
|
* @package Give |
6
|
|
|
* @subpackage Classes/Give_Settings_Import |
7
|
|
|
* @copyright Copyright (c) 2016, WordImpress |
8
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
9
|
|
|
* @since 1.8 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
13
|
|
|
exit; // Exit if accessed directly |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
if ( ! class_exists( 'Give_Settings_Import' ) ) { |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Give_Settings_Import. |
20
|
|
|
* |
21
|
|
|
* Add a submenu page in give tools menu called Import donations which import the donations from the CSV files. |
22
|
|
|
* |
23
|
|
|
* @since 1.8.13 |
24
|
|
|
*/ |
25
|
|
|
class Give_Settings_Import extends Give_Settings_Page { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Importing donation per page. |
29
|
|
|
* |
30
|
|
|
* @since 1.8.13 |
31
|
|
|
* |
32
|
|
|
* @var int |
33
|
|
|
*/ |
34
|
|
|
public static $per_page = 5; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Constructor. |
38
|
|
|
*/ |
39
|
|
|
public function __construct() { |
40
|
|
|
$this->id = 'import'; |
41
|
|
|
$this->label = __( 'Import', 'give' ); |
42
|
|
|
|
43
|
|
|
// Add Import tab in submenu. |
44
|
|
|
add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
45
|
|
|
|
46
|
|
|
// Will display html of the import donation. |
47
|
|
|
add_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field' ), 10, 2 ); |
48
|
|
|
|
49
|
|
|
// Will call the function that generated the hook called 'give_admin_field_tools_import'. |
50
|
|
|
add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
51
|
|
|
|
52
|
|
|
// Do not use main form for this tab. |
53
|
|
|
if ( give_get_current_setting_tab() === $this->id ) { |
54
|
|
|
add_action( "give-tools_open_form", '__return_empty_string' ); |
|
|
|
|
55
|
|
|
add_action( "give-tools_close_form", '__return_empty_string' ); |
|
|
|
|
56
|
|
|
|
57
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/import/class-give-import-donations.php'; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get settings array. |
64
|
|
|
* |
65
|
|
|
* @since 1.8.13 |
66
|
|
|
* @return array |
67
|
|
|
*/ |
68
|
|
|
public function get_settings() { |
69
|
|
|
// Hide save button. |
70
|
|
|
$GLOBALS['give_hide_save_button'] = true; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Filter the settings. |
74
|
|
|
* |
75
|
|
|
* @since 1.8.13 |
76
|
|
|
* |
77
|
|
|
* @param array $settings |
78
|
|
|
*/ |
79
|
|
|
$settings = apply_filters( |
80
|
|
|
'give_get_settings_' . $this->id, |
81
|
|
|
array( |
82
|
|
|
array( |
83
|
|
|
'id' => 'give_tools_import', |
84
|
|
|
'type' => 'title', |
85
|
|
|
'table_html' => false |
|
|
|
|
86
|
|
|
), |
87
|
|
|
array( |
88
|
|
|
'id' => 'import', |
89
|
|
|
'name' => __( 'Import', 'give' ), |
90
|
|
|
'type' => 'tools_import', |
91
|
|
|
), |
92
|
|
|
array( |
93
|
|
|
'name' => esc_html__( 'Import Docs Link', 'give' ), |
94
|
|
|
'id' => 'import_docs_link', |
95
|
|
|
'url' => esc_url( 'http://docs.givewp.com/tools-importer' ), |
96
|
|
|
'title' => __( 'Import Tab', 'give' ), |
97
|
|
|
'type' => 'give_docs_link', |
98
|
|
|
), |
99
|
|
|
array( |
100
|
|
|
'id' => 'give_tools_import', |
101
|
|
|
'type' => 'sectionend', |
102
|
|
|
'table_html' => false |
|
|
|
|
103
|
|
|
) |
|
|
|
|
104
|
|
|
) |
105
|
|
|
); |
106
|
|
|
|
107
|
|
|
// Output. |
108
|
|
|
return $settings; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Render report import field |
113
|
|
|
* |
114
|
|
|
* @since 1.8.13 |
115
|
|
|
* @access public |
116
|
|
|
* |
117
|
|
|
* @param $field |
118
|
|
|
* @param $option_value |
119
|
|
|
*/ |
120
|
|
|
public static function render_import_field( $field, $option_value ) { |
121
|
|
|
include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-imports.php'; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
return new Give_Settings_Import(); |
126
|
|
|
|
PHP provides two ways to mark string literals. Either with single quotes
'literal'
or with double quotes"literal"
. The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (
\'
) and the backslash (\\
). Every other character is displayed as is.Double quoted string literals may contain other variables or more complex escape sequences.
will print an indented:
Single is Value
If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.
For more information on PHP string literals and available escape sequences see the PHP core documentation.