@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_tools_recount_stats_display() { |
24 | 24 | |
25 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
25 | + if ( ! current_user_can('manage_give_settings')) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @since 1.5 |
33 | 33 | */ |
34 | - do_action( 'give_tools_recount_stats_before' ); |
|
34 | + do_action('give_tools_recount_stats_before'); |
|
35 | 35 | ?> |
36 | 36 | <div id="poststuff"> |
37 | 37 | <div class="postbox"> |
38 | 38 | |
39 | - <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2> |
|
39 | + <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2> |
|
40 | 40 | |
41 | 41 | <div class="inside recount-stats-controls"> |
42 | - <p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
42 | + <p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p> |
|
43 | 43 | <form method="post" id="give-tools-recount-form" class="give-export-form"> |
44 | 44 | |
45 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
45 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
46 | 46 | |
47 | 47 | <select name="give-export-class" id="recount-stats-type"> |
48 | - <option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option> |
|
49 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
50 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option> |
|
51 | - <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option> |
|
52 | - <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
53 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Transactions', 'give' ); ?></option> |
|
54 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option> |
|
48 | + <option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option> |
|
49 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
50 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option> |
|
51 | + <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option> |
|
52 | + <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option> |
|
53 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Transactions', 'give'); ?></option> |
|
54 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option> |
|
55 | 55 | <?php |
56 | 56 | /** |
57 | 57 | * Fires in the recount stats selectbox. |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @since 1.5 |
62 | 62 | */ |
63 | - do_action( 'give_recount_tool_options' ); |
|
63 | + do_action('give_recount_tool_options'); |
|
64 | 64 | ?> |
65 | 65 | </select> |
66 | 66 | |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | <?php |
69 | 69 | $args = array( |
70 | 70 | 'name' => 'form_id', |
71 | - 'number' => - 1, |
|
71 | + 'number' => -1, |
|
72 | 72 | 'chosen' => true, |
73 | 73 | ); |
74 | - echo Give()->html->forms_dropdown( $args ); |
|
74 | + echo Give()->html->forms_dropdown($args); |
|
75 | 75 | ?> |
76 | 76 | </span> |
77 | 77 | |
78 | - <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
78 | + <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/> |
|
79 | 79 | |
80 | 80 | <br/> |
81 | 81 | |
82 | 82 | <span class="give-recount-stats-descriptions"> |
83 | - <span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
84 | - <span id="recount-form"><?php esc_html_e( 'Recalculates the donation and income stats for a specific form.', 'give' ); ?></span> |
|
85 | - <span id="recount-all"><?php esc_html_e( 'Recalculates the earnings and sales stats for all forms.', 'give' ); ?></span> |
|
86 | - <span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
83 | + <span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
84 | + <span id="recount-form"><?php esc_html_e('Recalculates the donation and income stats for a specific form.', 'give'); ?></span> |
|
85 | + <span id="recount-all"><?php esc_html_e('Recalculates the earnings and sales stats for all forms.', 'give'); ?></span> |
|
86 | + <span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
87 | 87 | <?php |
88 | 88 | /** |
89 | 89 | * Fires in the recount stats description area. |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @since 1.5 |
94 | 94 | */ |
95 | - do_action( 'give_recount_tool_descriptions' ); |
|
95 | + do_action('give_recount_tool_descriptions'); |
|
96 | 96 | ?> |
97 | - <span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give' ); ?></span> |
|
98 | - <span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span> |
|
97 | + <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give'); ?></span> |
|
98 | + <span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span> |
|
99 | 99 | </span> |
100 | 100 | |
101 | 101 | <span class="spinner"></span> |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @since 1.5 |
111 | 111 | */ |
112 | - do_action( 'give_tools_recount_forms' ); |
|
112 | + do_action('give_tools_recount_forms'); |
|
113 | 113 | ?> |
114 | 114 | </div><!-- .inside --> |
115 | 115 | </div><!-- .postbox --> |
@@ -120,5 +120,5 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @since 1.5 |
122 | 122 | */ |
123 | - do_action( 'give_tools_recount_stats_after' ); |
|
123 | + do_action('give_tools_recount_stats_after'); |
|
124 | 124 | } |
125 | 125 | \ No newline at end of file |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_API' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_API')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_API. |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'api'; |
46 | - $this->label = esc_html__( 'API', 'give' ); |
|
46 | + $this->label = esc_html__('API', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param array $pages Lst of pages. |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function add_settings_page( $pages ) { |
|
60 | - $pages[ $this->id ] = $this->label; |
|
59 | + public function add_settings_page($pages) { |
|
60 | + $pages[$this->id] = $this->label; |
|
61 | 61 | |
62 | 62 | return $pages; |
63 | 63 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $GLOBALS['give_hide_save_button'] = true; |
74 | 74 | |
75 | 75 | // Get settings. |
76 | - $settings = apply_filters( 'give_settings_system', array( |
|
76 | + $settings = apply_filters('give_settings_system', array( |
|
77 | 77 | array( |
78 | 78 | 'id' => 'give_tools_api', |
79 | 79 | 'type' => 'title', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ), |
82 | 82 | array( |
83 | 83 | 'id' => 'api', |
84 | - 'name' => esc_html__( 'API', 'give' ), |
|
84 | + 'name' => esc_html__('API', 'give'), |
|
85 | 85 | 'type' => 'api', |
86 | 86 | ), |
87 | 87 | array( |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @since 1.8 |
98 | 98 | * @param array $settings |
99 | 99 | */ |
100 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
100 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
101 | 101 | |
102 | 102 | // Output. |
103 | 103 | return $settings; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function output() { |
113 | 113 | $settings = $this->get_settings(); |
114 | 114 | |
115 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
115 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Data' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Data')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Data. |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'data'; |
46 | - $this->label = esc_html__( 'Data', 'give' ); |
|
46 | + $this->label = esc_html__('Data', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | |
51 | 51 | // Do not use main form for this tab. |
52 | - if( give_get_current_setting_tab() === $this->id ) { |
|
53 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
54 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
52 | + if (give_get_current_setting_tab() === $this->id) { |
|
53 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
54 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param array $pages Lst of pages. |
63 | 63 | * @return array |
64 | 64 | */ |
65 | - public function add_settings_page( $pages ) { |
|
66 | - $pages[ $this->id ] = $this->label; |
|
65 | + public function add_settings_page($pages) { |
|
66 | + $pages[$this->id] = $this->label; |
|
67 | 67 | |
68 | 68 | return $pages; |
69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $GLOBALS['give_hide_save_button'] = true; |
80 | 80 | |
81 | 81 | // Get settings. |
82 | - $settings = apply_filters( 'give_settings_system', array( |
|
82 | + $settings = apply_filters('give_settings_system', array( |
|
83 | 83 | array( |
84 | 84 | 'id' => 'give_tools_tools', |
85 | 85 | 'type' => 'title', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ), |
88 | 88 | array( |
89 | 89 | 'id' => 'api', |
90 | - 'name' => esc_html__( 'Tools', 'give' ), |
|
90 | + 'name' => esc_html__('Tools', 'give'), |
|
91 | 91 | 'type' => 'data', |
92 | 92 | ), |
93 | 93 | array( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @since 1.8 |
104 | 104 | * @param array $settings |
105 | 105 | */ |
106 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
106 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
107 | 107 | |
108 | 108 | // Output. |
109 | 109 | return $settings; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function output() { |
119 | 119 | $settings = $this->get_settings(); |
120 | 120 | |
121 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
121 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __setup_hooks() { |
45 | 45 | // Create the log post type |
46 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
46 | + add_action('init', array($this, 'register_post_type'), 1); |
|
47 | 47 | |
48 | 48 | // Create types taxonomy and default types |
49 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
49 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
50 | 50 | |
51 | - add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache') ); |
|
52 | - add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache') ); |
|
53 | - add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache') ); |
|
54 | - add_action( 'give_delete_log_cache', array( $this, 'delete_cache') ); |
|
51 | + add_action('save_post_give_payment', array($this, 'background_process_delete_cache')); |
|
52 | + add_action('save_post_give_forms', array($this, 'background_process_delete_cache')); |
|
53 | + add_action('save_post_give_log', array($this, 'background_process_delete_cache')); |
|
54 | + add_action('give_delete_log_cache', array($this, 'delete_cache')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function register_post_type() { |
68 | 68 | /* Logs post type */ |
69 | 69 | $log_args = array( |
70 | - 'labels' => array( 'name' => esc_html__( 'Logs', 'give' ) ), |
|
70 | + 'labels' => array('name' => esc_html__('Logs', 'give')), |
|
71 | 71 | 'public' => false, |
72 | 72 | 'exclude_from_search' => true, |
73 | 73 | 'publicly_queryable' => false, |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | 'query_var' => false, |
76 | 76 | 'rewrite' => false, |
77 | 77 | 'capability_type' => 'post', |
78 | - 'supports' => array( 'title', 'editor' ), |
|
78 | + 'supports' => array('title', 'editor'), |
|
79 | 79 | 'can_export' => true, |
80 | 80 | ); |
81 | 81 | |
82 | - register_post_type( 'give_log', $log_args ); |
|
82 | + register_post_type('give_log', $log_args); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @return void |
94 | 94 | */ |
95 | 95 | public function register_taxonomy() { |
96 | - register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) ); |
|
96 | + register_taxonomy('give_log_type', 'give_log', array('public' => false)); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'api_request', |
114 | 114 | ); |
115 | 115 | |
116 | - return apply_filters( 'give_log_types', $terms ); |
|
116 | + return apply_filters('give_log_types', $terms); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return bool Whether log type is valid. |
130 | 130 | */ |
131 | - public function valid_type( $type ) { |
|
132 | - return in_array( $type, $this->log_types() ); |
|
131 | + public function valid_type($type) { |
|
132 | + return in_array($type, $this->log_types()); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return int Log ID. |
150 | 150 | */ |
151 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
151 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
152 | 152 | $log_data = array( |
153 | 153 | 'post_title' => $title, |
154 | 154 | 'post_content' => $message, |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'log_type' => $type, |
157 | 157 | ); |
158 | 158 | |
159 | - return $this->insert_log( $log_data ); |
|
159 | + return $this->insert_log($log_data); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return array An array of the connected logs. |
175 | 175 | */ |
176 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
177 | - return $this->get_connected_logs( array( |
|
176 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
177 | + return $this->get_connected_logs(array( |
|
178 | 178 | 'post_parent' => $object_id, |
179 | 179 | 'paged' => $paged, |
180 | 180 | 'log_type' => $type, |
181 | - ) ); |
|
181 | + )); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return int The ID of the newly created log item. |
194 | 194 | */ |
195 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
195 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
196 | 196 | $defaults = array( |
197 | 197 | 'post_type' => 'give_log', |
198 | 198 | 'post_status' => 'publish', |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | 'log_type' => false, |
202 | 202 | ); |
203 | 203 | |
204 | - $args = wp_parse_args( $log_data, $defaults ); |
|
204 | + $args = wp_parse_args($log_data, $defaults); |
|
205 | 205 | |
206 | 206 | /** |
207 | 207 | * Fires before inserting log entry. |
@@ -211,20 +211,20 @@ discard block |
||
211 | 211 | * @param array $log_data Log entry data. |
212 | 212 | * @param array $log_meta Log entry meta. |
213 | 213 | */ |
214 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
214 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
215 | 215 | |
216 | 216 | // Store the log entry |
217 | - $log_id = wp_insert_post( $args ); |
|
217 | + $log_id = wp_insert_post($args); |
|
218 | 218 | |
219 | 219 | // Set the log type, if any |
220 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
221 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
220 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
221 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | // Set log meta, if any |
225 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
226 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
227 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
225 | + if ($log_id && ! empty($log_meta)) { |
|
226 | + foreach ((array) $log_meta as $key => $meta) { |
|
227 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param array $log_data Log entry data. |
238 | 238 | * @param array $log_meta Log entry meta. |
239 | 239 | */ |
240 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
240 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
241 | 241 | |
242 | 242 | return $log_id; |
243 | 243 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return bool|null True if successful, false otherwise. |
255 | 255 | */ |
256 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
256 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Fires before updating log entry. |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param array $log_data Log entry data. |
264 | 264 | * @param array $log_meta Log entry meta. |
265 | 265 | */ |
266 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
266 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
267 | 267 | |
268 | 268 | $defaults = array( |
269 | 269 | 'post_type' => 'give_log', |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | 'post_parent' => 0, |
272 | 272 | ); |
273 | 273 | |
274 | - $args = wp_parse_args( $log_data, $defaults ); |
|
274 | + $args = wp_parse_args($log_data, $defaults); |
|
275 | 275 | |
276 | 276 | // Store the log entry |
277 | - $log_id = wp_update_post( $args ); |
|
277 | + $log_id = wp_update_post($args); |
|
278 | 278 | |
279 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
280 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
281 | - if ( ! empty( $meta ) ) { |
|
282 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
279 | + if ($log_id && ! empty($log_meta)) { |
|
280 | + foreach ((array) $log_meta as $key => $meta) { |
|
281 | + if ( ! empty($meta)) { |
|
282 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param array $log_data Log entry data. |
294 | 294 | * @param array $log_meta Log entry meta. |
295 | 295 | */ |
296 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
296 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -308,19 +308,19 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return array|false Array if logs were found, false otherwise. |
310 | 310 | */ |
311 | - public function get_connected_logs( $args = array() ) { |
|
311 | + public function get_connected_logs($args = array()) { |
|
312 | 312 | |
313 | 313 | $defaults = array( |
314 | 314 | 'post_type' => 'give_log', |
315 | 315 | 'posts_per_page' => 20, |
316 | 316 | 'post_status' => 'publish', |
317 | - 'paged' => get_query_var( 'paged' ), |
|
317 | + 'paged' => get_query_var('paged'), |
|
318 | 318 | 'log_type' => false, |
319 | 319 | ); |
320 | 320 | |
321 | - $query_args = wp_parse_args( $args, $defaults ); |
|
321 | + $query_args = wp_parse_args($args, $defaults); |
|
322 | 322 | |
323 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
323 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
324 | 324 | $query_args['tax_query'] = array( |
325 | 325 | array( |
326 | 326 | 'taxonomy' => 'give_log_type', |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | ); |
331 | 331 | } |
332 | 332 | |
333 | - $logs = get_posts( $query_args ); |
|
333 | + $logs = get_posts($query_args); |
|
334 | 334 | |
335 | - if ( $logs ) { |
|
335 | + if ($logs) { |
|
336 | 336 | return $logs; |
337 | 337 | } |
338 | 338 | |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return int Log count. |
357 | 357 | */ |
358 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
358 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
359 | 359 | |
360 | 360 | $query_args = array( |
361 | 361 | 'post_parent' => $object_id, |
362 | 362 | 'post_type' => 'give_log', |
363 | - 'posts_per_page' => - 1, |
|
363 | + 'posts_per_page' => -1, |
|
364 | 364 | 'post_status' => 'publish', |
365 | 365 | 'fields' => 'ids', |
366 | 366 | ); |
367 | 367 | |
368 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
368 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
369 | 369 | $query_args['tax_query'] = array( |
370 | 370 | array( |
371 | 371 | 'taxonomy' => 'give_log_type', |
@@ -375,25 +375,25 @@ discard block |
||
375 | 375 | ); |
376 | 376 | } |
377 | 377 | |
378 | - if ( ! empty( $meta_query ) ) { |
|
378 | + if ( ! empty($meta_query)) { |
|
379 | 379 | $query_args['meta_query'] = $meta_query; |
380 | 380 | } |
381 | 381 | |
382 | - if ( ! empty( $date_query ) ) { |
|
382 | + if ( ! empty($date_query)) { |
|
383 | 383 | $query_args['date_query'] = $date_query; |
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | // Get cache key for current query. |
388 | - $cache_key = give_get_cache_key( 'get_log_count', $query_args ); |
|
388 | + $cache_key = give_get_cache_key('get_log_count', $query_args); |
|
389 | 389 | |
390 | 390 | // check if cache already exist or not. |
391 | - if( ! ( $logs_count = get_option( $cache_key ) ) ) { |
|
392 | - $logs = new WP_Query( $query_args ); |
|
391 | + if ( ! ($logs_count = get_option($cache_key))) { |
|
392 | + $logs = new WP_Query($query_args); |
|
393 | 393 | $logs_count = (int) $logs->post_count; |
394 | 394 | |
395 | 395 | // Cache results. |
396 | - add_option( $cache_key, $logs_count, '', 'no' ); |
|
396 | + add_option($cache_key, $logs_count, '', 'no'); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | return $logs_count; |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return void |
415 | 415 | */ |
416 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
416 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
417 | 417 | $query_args = array( |
418 | 418 | 'post_parent' => $object_id, |
419 | 419 | 'post_type' => 'give_log', |
420 | - 'posts_per_page' => - 1, |
|
420 | + 'posts_per_page' => -1, |
|
421 | 421 | 'post_status' => 'publish', |
422 | 422 | 'fields' => 'ids', |
423 | 423 | ); |
424 | 424 | |
425 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
425 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
426 | 426 | $query_args['tax_query'] = array( |
427 | 427 | array( |
428 | 428 | 'taxonomy' => 'give_log_type', |
@@ -432,15 +432,15 @@ discard block |
||
432 | 432 | ); |
433 | 433 | } |
434 | 434 | |
435 | - if ( ! empty( $meta_query ) ) { |
|
435 | + if ( ! empty($meta_query)) { |
|
436 | 436 | $query_args['meta_query'] = $meta_query; |
437 | 437 | } |
438 | 438 | |
439 | - $logs = get_posts( $query_args ); |
|
439 | + $logs = get_posts($query_args); |
|
440 | 440 | |
441 | - if ( $logs ) { |
|
442 | - foreach ( $logs as $log ) { |
|
443 | - wp_delete_post( $log, true ); |
|
441 | + if ($logs) { |
|
442 | + foreach ($logs as $log) { |
|
443 | + wp_delete_post($log, true); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @param int $post_id |
455 | 455 | */ |
456 | - public function background_process_delete_cache( $post_id ) { |
|
457 | - wp_schedule_single_event( time(), 'give_delete_log_cache' ); |
|
456 | + public function background_process_delete_cache($post_id) { |
|
457 | + wp_schedule_single_event(time(), 'give_delete_log_cache'); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | ); |
477 | 477 | |
478 | 478 | // Bailout. |
479 | - if( empty( $cache_option_names ) ) { |
|
479 | + if (empty($cache_option_names)) { |
|
480 | 480 | return false; |
481 | 481 | } |
482 | 482 | |
483 | 483 | |
484 | 484 | // Delete log cache. |
485 | - foreach ( $cache_option_names as $option_name ) { |
|
486 | - delete_option( $option_name['option_name'] ); |
|
485 | + foreach ($cache_option_names as $option_name) { |
|
486 | + delete_option($option_name['option_name']); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return int ID of the new log entry. |
508 | 508 | */ |
509 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
509 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
510 | 510 | /* @var Give_Logging $give_logs */ |
511 | 511 | global $give_logs; |
512 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
512 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
513 | 513 | |
514 | 514 | return $log; |
515 | 515 | } |
@@ -463,7 +463,7 @@ |
||
463 | 463 | * @since 1.7 |
464 | 464 | * @access public |
465 | 465 | * |
466 | - * @return bool |
|
466 | + * @return false|null |
|
467 | 467 | */ |
468 | 468 | public function delete_cache() { |
469 | 469 | global $wpdb; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string $default_price |
69 | 69 | */ |
70 | -function give_get_default_multilevel_amount( $form_id ) { |
|
70 | +function give_get_default_multilevel_amount($form_id) { |
|
71 | 71 | $default_price = '1.00'; |
72 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
72 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
73 | 73 | |
74 | - foreach ( $prices as $price ) { |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | |
76 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
76 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
77 | 77 | $default_price = $price['_give_amount']; |
78 | 78 | } |
79 | 79 | |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | * @return string $default_price |
95 | 95 | * @since 1.0 |
96 | 96 | */ |
97 | -function give_get_default_form_amount( $form_id ) { |
|
97 | +function give_get_default_form_amount($form_id) { |
|
98 | 98 | |
99 | - if ( give_has_variable_prices( $form_id ) ) { |
|
99 | + if (give_has_variable_prices($form_id)) { |
|
100 | 100 | |
101 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
101 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
102 | 102 | |
103 | 103 | } else { |
104 | 104 | |
105 | - $default_amount = get_post_meta( $form_id, '_give_set_price', true ); |
|
105 | + $default_amount = get_post_meta($form_id, '_give_set_price', true); |
|
106 | 106 | |
107 | 107 | } |
108 | 108 | |
109 | - return apply_filters( 'give_default_form_amount', $default_amount ); |
|
109 | + return apply_filters('give_default_form_amount', $default_amount); |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool |
126 | 126 | */ |
127 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
127 | +function give_is_custom_price_mode($form_id = 0) { |
|
128 | 128 | |
129 | - if ( empty( $form_id ) ) { |
|
129 | + if (empty($form_id)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - $form = new Give_Donate_Form( $form_id ); |
|
133 | + $form = new Give_Donate_Form($form_id); |
|
134 | 134 | |
135 | 135 | return $form->is_custom_price_mode(); |
136 | 136 | } |
137 | 137 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function add_roles() { |
52 | - add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array( |
|
52 | + add_role('give_manager', esc_html__('Give Manager', 'give'), array( |
|
53 | 53 | 'read' => true, |
54 | 54 | 'edit_posts' => true, |
55 | 55 | 'delete_posts' => true, |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | 'publish_posts' => true, |
79 | 79 | 'read_private_pages' => true, |
80 | 80 | 'read_private_posts' => true |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | - add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array( |
|
83 | + add_role('give_accountant', esc_html__('Give Accountant', 'give'), array( |
|
84 | 84 | 'read' => true, |
85 | 85 | 'edit_posts' => false, |
86 | 86 | 'delete_posts' => false |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | - add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array( |
|
89 | + add_role('give_worker', esc_html__('Give Worker', 'give'), array( |
|
90 | 90 | 'read' => true, |
91 | 91 | 'edit_posts' => false, |
92 | 92 | 'upload_files' => true, |
93 | 93 | 'delete_posts' => false |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -110,38 +110,38 @@ discard block |
||
110 | 110 | public function add_caps() { |
111 | 111 | global $wp_roles; |
112 | 112 | |
113 | - if ( class_exists( 'WP_Roles' ) ) { |
|
114 | - if ( ! isset( $wp_roles ) ) { |
|
113 | + if (class_exists('WP_Roles')) { |
|
114 | + if ( ! isset($wp_roles)) { |
|
115 | 115 | $wp_roles = new WP_Roles(); |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - if ( is_object( $wp_roles ) ) { |
|
120 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
121 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
122 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
123 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
119 | + if (is_object($wp_roles)) { |
|
120 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
121 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
122 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
123 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
124 | 124 | |
125 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
126 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
127 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
125 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
126 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
127 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
128 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
129 | 129 | |
130 | 130 | // Add the main post type capabilities. |
131 | 131 | $capabilities = $this->get_core_caps(); |
132 | - foreach ( $capabilities as $cap_group ) { |
|
133 | - foreach ( $cap_group as $cap ) { |
|
134 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
135 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
136 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
132 | + foreach ($capabilities as $cap_group) { |
|
133 | + foreach ($cap_group as $cap) { |
|
134 | + $wp_roles->add_cap('administrator', $cap); |
|
135 | + $wp_roles->add_cap('give_manager', $cap); |
|
136 | + $wp_roles->add_cap('give_worker', $cap); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
141 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
142 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
143 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
144 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
140 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
141 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
142 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
143 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
144 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | } |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | public function get_core_caps() { |
160 | 160 | $capabilities = array(); |
161 | 161 | |
162 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
162 | + $capability_types = array('give_form', 'give_payment'); |
|
163 | 163 | |
164 | - foreach ( $capability_types as $capability_type ) { |
|
165 | - $capabilities[ $capability_type ] = array( |
|
164 | + foreach ($capability_types as $capability_type) { |
|
165 | + $capabilities[$capability_type] = array( |
|
166 | 166 | // Post type. |
167 | 167 | "edit_{$capability_type}", |
168 | 168 | "read_{$capability_type}", |
@@ -208,22 +208,22 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return array $caps Meta capabilities. |
210 | 210 | */ |
211 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
211 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
212 | 212 | |
213 | - switch ( $cap ) { |
|
213 | + switch ($cap) { |
|
214 | 214 | |
215 | 215 | case 'view_give_form_stats' : |
216 | 216 | |
217 | - if ( empty( $args[0] ) ) { |
|
217 | + if (empty($args[0])) { |
|
218 | 218 | break; |
219 | 219 | } |
220 | 220 | |
221 | - $form = get_post( $args[0] ); |
|
222 | - if ( empty( $form ) ) { |
|
221 | + $form = get_post($args[0]); |
|
222 | + if (empty($form)) { |
|
223 | 223 | break; |
224 | 224 | } |
225 | 225 | |
226 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
226 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
227 | 227 | $caps = array(); |
228 | 228 | } |
229 | 229 | |
@@ -250,41 +250,41 @@ discard block |
||
250 | 250 | |
251 | 251 | global $wp_roles; |
252 | 252 | |
253 | - if ( class_exists( 'WP_Roles' ) ) { |
|
254 | - if ( ! isset( $wp_roles ) ) { |
|
253 | + if (class_exists('WP_Roles')) { |
|
254 | + if ( ! isset($wp_roles)) { |
|
255 | 255 | $wp_roles = new WP_Roles(); |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if ( is_object( $wp_roles ) ) { |
|
259 | + if (is_object($wp_roles)) { |
|
260 | 260 | // Give Manager Capabilities. |
261 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
262 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
263 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
264 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
261 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
262 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
263 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
264 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
265 | 265 | |
266 | 266 | // Site Administrator Capabilities. |
267 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
268 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
269 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
270 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
267 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
268 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
269 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
270 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
271 | 271 | |
272 | 272 | // Remove the Main Post Type Capabilities. |
273 | 273 | $capabilities = $this->get_core_caps(); |
274 | 274 | |
275 | - foreach ( $capabilities as $cap_group ) { |
|
276 | - foreach ( $cap_group as $cap ) { |
|
277 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
278 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
279 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
275 | + foreach ($capabilities as $cap_group) { |
|
276 | + foreach ($cap_group as $cap) { |
|
277 | + $wp_roles->remove_cap('give_manager', $cap); |
|
278 | + $wp_roles->remove_cap('administrator', $cap); |
|
279 | + $wp_roles->remove_cap('give_worker', $cap); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | 283 | /** Give Accountant Capabilities */ |
284 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
285 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
286 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
287 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
284 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
285 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
286 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
287 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
288 | 288 | |
289 | 289 | } |
290 | 290 | } |
@@ -1283,7 +1283,7 @@ |
||
1283 | 1283 | * |
1284 | 1284 | * @param $field |
1285 | 1285 | * |
1286 | - * @return string |
|
1286 | + * @return integer |
|
1287 | 1287 | */ |
1288 | 1288 | function _give_set_field_give_id_default_value( $field ) { |
1289 | 1289 | return 0; |
@@ -645,20 +645,20 @@ |
||
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
648 | - * Output the documentation link. |
|
649 | - * |
|
650 | - * @since 1.8 |
|
651 | - * @param array $field { |
|
652 | - * Optional. Array of customizable link attributes. |
|
653 | - * |
|
654 | - * @type string $name Name of input field. Default ''. |
|
655 | - * @type string $type Type of input field. Default 'text'. |
|
656 | - * @type string $url Value to be passed as a link. Default 'https://givewp.com/documentation'. |
|
657 | - * @type string $title Value to be passed as text of link. Default 'Documentation'. |
|
658 | - * @type array $attributes List of attributes of input field. Default array(). |
|
659 | - * for example: 'attributes' => array( 'placeholder' => '*****', 'class' => '****' ) |
|
660 | - * } |
|
661 | - * @return void |
|
648 | + * Output the documentation link. |
|
649 | + * |
|
650 | + * @since 1.8 |
|
651 | + * @param array $field { |
|
652 | + * Optional. Array of customizable link attributes. |
|
653 | + * |
|
654 | + * @type string $name Name of input field. Default ''. |
|
655 | + * @type string $type Type of input field. Default 'text'. |
|
656 | + * @type string $url Value to be passed as a link. Default 'https://givewp.com/documentation'. |
|
657 | + * @type string $title Value to be passed as text of link. Default 'Documentation'. |
|
658 | + * @type array $attributes List of attributes of input field. Default array(). |
|
659 | + * for example: 'attributes' => array( 'placeholder' => '*****', 'class' => '****' ) |
|
660 | + * } |
|
661 | + * @return void |
|
662 | 662 | */ |
663 | 663 | |
664 | 664 | function give_docs_link($field) { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; // Exit if accessed directly |
13 | 13 | } |
14 | 14 | |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool|string |
24 | 24 | */ |
25 | -function give_is_field_callback_exist( $field ) { |
|
26 | - return ( give_get_field_callback( $field ) ? true : false ); |
|
25 | +function give_is_field_callback_exist($field) { |
|
26 | + return (give_get_field_callback($field) ? true : false); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return bool|string |
37 | 37 | */ |
38 | -function give_get_field_callback( $field ) { |
|
38 | +function give_get_field_callback($field) { |
|
39 | 39 | $func_name_prefix = 'give'; |
40 | 40 | $func_name = ''; |
41 | 41 | |
42 | 42 | // Set callback function on basis of cmb2 field name. |
43 | - switch ( $field['type'] ) { |
|
43 | + switch ($field['type']) { |
|
44 | 44 | case 'radio_inline': |
45 | 45 | $func_name = "{$func_name_prefix}_radio"; |
46 | 46 | break; |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | default: |
78 | 78 | |
79 | 79 | if ( |
80 | - array_key_exists( 'callback', $field ) |
|
81 | - && ! empty( $field['callback'] ) |
|
80 | + array_key_exists('callback', $field) |
|
81 | + && ! empty($field['callback']) |
|
82 | 82 | ) { |
83 | 83 | $func_name = $field['callback']; |
84 | 84 | } else { |
@@ -91,15 +91,15 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @since 1.8 |
93 | 93 | */ |
94 | - $func_name = apply_filters( 'give_get_field_callback', $func_name, $field ); |
|
94 | + $func_name = apply_filters('give_get_field_callback', $func_name, $field); |
|
95 | 95 | |
96 | 96 | // Exit if not any function exist. |
97 | 97 | // Check if render callback exist or not. |
98 | - if ( empty( $func_name ) ) { |
|
98 | + if (empty($func_name)) { |
|
99 | 99 | return false; |
100 | - } elseif ( is_string( $func_name ) && ! function_exists( "$func_name" ) ) { |
|
100 | + } elseif (is_string($func_name) && ! function_exists("$func_name")) { |
|
101 | 101 | return false; |
102 | - } elseif ( is_array( $func_name ) && ! method_exists( $func_name[0], "$func_name[1]" ) ) { |
|
102 | + } elseif (is_array($func_name) && ! method_exists($func_name[0], "$func_name[1]")) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
@@ -115,36 +115,36 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return bool |
117 | 117 | */ |
118 | -function give_render_field( $field ) { |
|
118 | +function give_render_field($field) { |
|
119 | 119 | |
120 | 120 | // Check if render callback exist or not. |
121 | - if ( ! ( $func_name = give_get_field_callback( $field ) ) ) { |
|
121 | + if ( ! ($func_name = give_get_field_callback($field))) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | |
125 | 125 | // CMB2 compatibility: Push all classes to attributes's class key |
126 | - if ( empty( $field['class'] ) ) { |
|
126 | + if (empty($field['class'])) { |
|
127 | 127 | $field['class'] = ''; |
128 | 128 | } |
129 | 129 | |
130 | - if ( empty( $field['attributes']['class'] ) ) { |
|
130 | + if (empty($field['attributes']['class'])) { |
|
131 | 131 | $field['attributes']['class'] = ''; |
132 | 132 | } |
133 | 133 | |
134 | - $field['attributes']['class'] = trim( "give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}" ); |
|
135 | - unset( $field['class'] ); |
|
134 | + $field['attributes']['class'] = trim("give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}"); |
|
135 | + unset($field['class']); |
|
136 | 136 | |
137 | 137 | |
138 | 138 | // CMB2 compatibility: Set wrapper class if any. |
139 | - if ( ! empty( $field['row_classes'] ) ) { |
|
139 | + if ( ! empty($field['row_classes'])) { |
|
140 | 140 | $field['wrapper_class'] = $field['row_classes']; |
141 | - unset( $field['row_classes'] ); |
|
141 | + unset($field['row_classes']); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | // Set field params on basis of cmb2 field name. |
145 | - switch ( $field['type'] ) { |
|
145 | + switch ($field['type']) { |
|
146 | 146 | case 'radio_inline': |
147 | - if ( empty( $field['wrapper_class'] ) ) { |
|
147 | + if (empty($field['wrapper_class'])) { |
|
148 | 148 | $field['wrapper_class'] = ''; |
149 | 149 | } |
150 | 150 | $field['wrapper_class'] .= ' give-inline-radio-fields'; |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | case 'text-small' : |
158 | 158 | case 'text_small' : |
159 | 159 | // CMB2 compatibility: Set field type to text. |
160 | - $field['type'] = isset( $field['attributes']['type'] ) ? $field['attributes']['type'] : 'text'; |
|
160 | + $field['type'] = isset($field['attributes']['type']) ? $field['attributes']['type'] : 'text'; |
|
161 | 161 | |
162 | 162 | // CMB2 compatibility: Set data type to price. |
163 | 163 | if ( |
164 | - empty( $field['data_type'] ) |
|
165 | - && ! empty( $field['attributes']['class'] ) |
|
164 | + empty($field['data_type']) |
|
165 | + && ! empty($field['attributes']['class']) |
|
166 | 166 | && ( |
167 | - false !== strpos( $field['attributes']['class'], 'money' ) |
|
168 | - || false !== strpos( $field['attributes']['class'], 'amount' ) |
|
167 | + false !== strpos($field['attributes']['class'], 'money') |
|
168 | + || false !== strpos($field['attributes']['class'], 'amount') |
|
169 | 169 | ) |
170 | 170 | ) { |
171 | 171 | $field['data_type'] = 'decimal'; |
@@ -184,22 +184,22 @@ discard block |
||
184 | 184 | case 'give_default_radio_inline': |
185 | 185 | $field['type'] = 'radio'; |
186 | 186 | $field['options'] = array( |
187 | - 'default' => __( 'Default' ), |
|
187 | + 'default' => __('Default'), |
|
188 | 188 | ); |
189 | 189 | break; |
190 | 190 | } |
191 | 191 | |
192 | 192 | // CMB2 compatibility: Add support to define field description by desc & description param. |
193 | 193 | // We encourage you to use description param. |
194 | - $field['description'] = ( ! empty( $field['description'] ) |
|
194 | + $field['description'] = ( ! empty($field['description']) |
|
195 | 195 | ? $field['description'] |
196 | - : ( ! empty( $field['desc'] ) ? $field['desc'] : '' ) ); |
|
196 | + : ( ! empty($field['desc']) ? $field['desc'] : '')); |
|
197 | 197 | |
198 | 198 | // Call render function. |
199 | - if ( is_array( $func_name ) ) { |
|
200 | - $func_name[0]->$func_name[1]( $field ); |
|
199 | + if (is_array($func_name)) { |
|
200 | + $func_name[0]->$func_name[1]($field); |
|
201 | 201 | } else { |
202 | - $func_name( $field ); |
|
202 | + $func_name($field); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | return true; |
@@ -227,29 +227,29 @@ discard block |
||
227 | 227 | * } |
228 | 228 | * @return void |
229 | 229 | */ |
230 | -function give_text_input( $field ) { |
|
230 | +function give_text_input($field) { |
|
231 | 231 | global $thepostid, $post; |
232 | 232 | |
233 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
234 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
235 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
236 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
237 | - $field['type'] = isset( $field['type'] ) ? $field['type'] : 'text'; |
|
233 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
234 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
235 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
236 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
237 | + $field['type'] = isset($field['type']) ? $field['type'] : 'text'; |
|
238 | 238 | $field['before_field'] = ''; |
239 | 239 | $field['after_field'] = ''; |
240 | - $data_type = empty( $field['data_type'] ) ? '' : $field['data_type']; |
|
240 | + $data_type = empty($field['data_type']) ? '' : $field['data_type']; |
|
241 | 241 | |
242 | - switch ( $data_type ) { |
|
242 | + switch ($data_type) { |
|
243 | 243 | case 'price' : |
244 | - $field['value'] = ( ! empty( $field['value'] ) ? give_format_amount( $field['value'] ) : $field['value'] ); |
|
244 | + $field['value'] = ( ! empty($field['value']) ? give_format_amount($field['value']) : $field['value']); |
|
245 | 245 | |
246 | - $field['before_field'] = ! empty( $field['before_field'] ) ? $field['before_field'] : ( give_get_option( 'currency_position', 'before' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' ); |
|
247 | - $field['after_field'] = ! empty( $field['after_field'] ) ? $field['after_field'] : ( give_get_option( 'currency_position', 'before' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' ); |
|
246 | + $field['before_field'] = ! empty($field['before_field']) ? $field['before_field'] : (give_get_option('currency_position', 'before') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : ''); |
|
247 | + $field['after_field'] = ! empty($field['after_field']) ? $field['after_field'] : (give_get_option('currency_position', 'before') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : ''); |
|
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'decimal' : |
251 | 251 | $field['attributes']['class'] .= ' give_input_decimal'; |
252 | - $field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( $field['value'] ) : $field['value'] ); |
|
252 | + $field['value'] = ( ! empty($field['value']) ? give_format_decimal($field['value']) : $field['value']); |
|
253 | 253 | break; |
254 | 254 | |
255 | 255 | default : |
@@ -257,20 +257,20 @@ discard block |
||
257 | 257 | } |
258 | 258 | |
259 | 259 | ?> |
260 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
261 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
260 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
261 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
262 | 262 | <?php echo $field['before_field']; ?> |
263 | 263 | <input |
264 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
265 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
266 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
267 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
268 | - value="<?php echo esc_attr( $field['value'] ); ?>" |
|
269 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
264 | + type="<?php echo esc_attr($field['type']); ?>" |
|
265 | + style="<?php echo esc_attr($field['style']); ?>" |
|
266 | + name="<?php echo give_get_field_name($field); ?>" |
|
267 | + id="<?php echo esc_attr($field['id']); ?>" |
|
268 | + value="<?php echo esc_attr($field['value']); ?>" |
|
269 | + <?php echo give_get_custom_attributes($field); ?> |
|
270 | 270 | /> |
271 | 271 | <?php echo $field['after_field']; ?> |
272 | 272 | <?php |
273 | - echo give_get_field_description( $field ); |
|
273 | + echo give_get_field_description($field); |
|
274 | 274 | echo '</p>'; |
275 | 275 | } |
276 | 276 | |
@@ -290,29 +290,29 @@ discard block |
||
290 | 290 | * } |
291 | 291 | * @return void |
292 | 292 | */ |
293 | -function give_hidden_input( $field ) { |
|
293 | +function give_hidden_input($field) { |
|
294 | 294 | global $thepostid, $post; |
295 | 295 | |
296 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
297 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
296 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
297 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
298 | 298 | |
299 | 299 | // Custom attribute handling |
300 | 300 | $custom_attributes = array(); |
301 | 301 | |
302 | - if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) { |
|
302 | + if ( ! empty($field['attributes']) && is_array($field['attributes'])) { |
|
303 | 303 | |
304 | - foreach ( $field['attributes'] as $attribute => $value ) { |
|
305 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; |
|
304 | + foreach ($field['attributes'] as $attribute => $value) { |
|
305 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"'; |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | ?> |
309 | 309 | |
310 | 310 | <input |
311 | 311 | type="hidden" |
312 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
313 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
314 | - value="<?php echo esc_attr( $field['value'] ); ?>" |
|
315 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
312 | + name="<?php echo give_get_field_name($field); ?>" |
|
313 | + id="<?php echo esc_attr($field['id']); ?>" |
|
314 | + value="<?php echo esc_attr($field['value']); ?>" |
|
315 | + <?php echo give_get_custom_attributes($field); ?> |
|
316 | 316 | /> |
317 | 317 | <?php |
318 | 318 | } |
@@ -336,27 +336,27 @@ discard block |
||
336 | 336 | * } |
337 | 337 | * @return void |
338 | 338 | */ |
339 | -function give_textarea_input( $field ) { |
|
339 | +function give_textarea_input($field) { |
|
340 | 340 | global $thepostid, $post; |
341 | 341 | |
342 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
343 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
344 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
345 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
342 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
343 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
344 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
345 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
346 | 346 | |
347 | 347 | ?> |
348 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
349 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
348 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
349 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
350 | 350 | <textarea |
351 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
352 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
353 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
351 | + style="<?php echo esc_attr($field['style']); ?>" |
|
352 | + name="<?php echo give_get_field_name($field); ?>" |
|
353 | + id="<?php echo esc_attr($field['id']); ?>" |
|
354 | 354 | rows="10" |
355 | 355 | cols="20" |
356 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
357 | - ><?php echo esc_textarea( $field['value'] ); ?></textarea> |
|
356 | + <?php echo give_get_custom_attributes($field); ?> |
|
357 | + ><?php echo esc_textarea($field['value']); ?></textarea> |
|
358 | 358 | <?php |
359 | - echo give_get_field_description( $field ); |
|
359 | + echo give_get_field_description($field); |
|
360 | 360 | echo '</p>'; |
361 | 361 | } |
362 | 362 | |
@@ -378,24 +378,24 @@ discard block |
||
378 | 378 | * } |
379 | 379 | * @return void |
380 | 380 | */ |
381 | -function give_wysiwyg( $field ) { |
|
381 | +function give_wysiwyg($field) { |
|
382 | 382 | global $thepostid, $post; |
383 | 383 | |
384 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
385 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
386 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
387 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
388 | - $field['unique_field_id'] = give_get_field_name( $field ); |
|
384 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
385 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
386 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
387 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
388 | + $field['unique_field_id'] = give_get_field_name($field); |
|
389 | 389 | $editor_attributes = array( |
390 | - 'textarea_name' => isset( $field['repeatable_field_id'] ) ? $field['repeatable_field_id'] : $field['id'], |
|
390 | + 'textarea_name' => isset($field['repeatable_field_id']) ? $field['repeatable_field_id'] : $field['id'], |
|
391 | 391 | 'textarea_rows' => '10', |
392 | - 'editor_css' => esc_attr( $field['style'] ), |
|
392 | + 'editor_css' => esc_attr($field['style']), |
|
393 | 393 | 'editor_class' => $field['attributes']['class'] |
394 | 394 | ); |
395 | - $data_wp_editor = ' data-wp-editor="'. base64_encode( json_encode( array( $field['value'], $field['unique_field_id'],$editor_attributes ) ) ) .'"'; |
|
396 | - $data_wp_editor = isset( $field['repeatable_field_id'] ) ? $data_wp_editor : ''; |
|
395 | + $data_wp_editor = ' data-wp-editor="'.base64_encode(json_encode(array($field['value'], $field['unique_field_id'], $editor_attributes))).'"'; |
|
396 | + $data_wp_editor = isset($field['repeatable_field_id']) ? $data_wp_editor : ''; |
|
397 | 397 | |
398 | - echo '<div class="give-field-wrap ' . $field['unique_field_id'] . '_field ' . esc_attr( $field['wrapper_class'] ) . '"'.$data_wp_editor.'><label for="' . $field['unique_field_id'] . '">' . wp_kses_post( $field['name'] ) . '</label>'; |
|
398 | + echo '<div class="give-field-wrap '.$field['unique_field_id'].'_field '.esc_attr($field['wrapper_class']).'"'.$data_wp_editor.'><label for="'.$field['unique_field_id'].'">'.wp_kses_post($field['name']).'</label>'; |
|
399 | 399 | |
400 | 400 | wp_editor( |
401 | 401 | $field['value'], |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $editor_attributes |
404 | 404 | ); |
405 | 405 | |
406 | - echo give_get_field_description( $field ); |
|
406 | + echo give_get_field_description($field); |
|
407 | 407 | echo '</div>'; |
408 | 408 | } |
409 | 409 | |
@@ -426,29 +426,29 @@ discard block |
||
426 | 426 | * } |
427 | 427 | * @return void |
428 | 428 | */ |
429 | -function give_checkbox( $field ) { |
|
429 | +function give_checkbox($field) { |
|
430 | 430 | global $thepostid, $post; |
431 | 431 | |
432 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
433 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
434 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
435 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
436 | - $field['cbvalue'] = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'on'; |
|
437 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
432 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
433 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
434 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
435 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
436 | + $field['cbvalue'] = isset($field['cbvalue']) ? $field['cbvalue'] : 'on'; |
|
437 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
438 | 438 | ?> |
439 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
440 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
439 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
440 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
441 | 441 | <input |
442 | 442 | type="checkbox" |
443 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
444 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
445 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
446 | - value="<?php echo esc_attr( $field['cbvalue'] ); ?>" |
|
447 | - <?php echo checked( $field['value'], $field['cbvalue'], false ); ?> |
|
448 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
443 | + style="<?php echo esc_attr($field['style']); ?>" |
|
444 | + name="<?php echo give_get_field_name($field); ?>" |
|
445 | + id="<?php echo esc_attr($field['id']); ?>" |
|
446 | + value="<?php echo esc_attr($field['cbvalue']); ?>" |
|
447 | + <?php echo checked($field['value'], $field['cbvalue'], false); ?> |
|
448 | + <?php echo give_get_custom_attributes($field); ?> |
|
449 | 449 | /> |
450 | 450 | <?php |
451 | - echo give_get_field_description( $field ); |
|
451 | + echo give_get_field_description($field); |
|
452 | 452 | echo '</p>'; |
453 | 453 | } |
454 | 454 | |
@@ -472,29 +472,29 @@ discard block |
||
472 | 472 | * } |
473 | 473 | * @return void |
474 | 474 | */ |
475 | -function give_select( $field ) { |
|
475 | +function give_select($field) { |
|
476 | 476 | global $thepostid, $post; |
477 | 477 | |
478 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
479 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
480 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
481 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
482 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
478 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
479 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
480 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
481 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
482 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
483 | 483 | ?> |
484 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
485 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
484 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
485 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
486 | 486 | <select |
487 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
488 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
489 | - style="<?php echo esc_attr( $field['style'] ) ?>" |
|
490 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
487 | + id="<?php echo esc_attr($field['id']); ?>" |
|
488 | + name="<?php echo give_get_field_name($field); ?>" |
|
489 | + style="<?php echo esc_attr($field['style']) ?>" |
|
490 | + <?php echo give_get_custom_attributes($field); ?> |
|
491 | 491 | > |
492 | 492 | <?php |
493 | - foreach ( $field['options'] as $key => $value ) { |
|
494 | - echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>'; |
|
493 | + foreach ($field['options'] as $key => $value) { |
|
494 | + echo '<option value="'.esc_attr($key).'" '.selected(esc_attr($field['value']), esc_attr($key), false).'>'.esc_html($value).'</option>'; |
|
495 | 495 | } |
496 | 496 | echo '</select>'; |
497 | - echo give_get_field_description( $field ); |
|
497 | + echo give_get_field_description($field); |
|
498 | 498 | echo '</p>'; |
499 | 499 | } |
500 | 500 | |
@@ -518,32 +518,32 @@ discard block |
||
518 | 518 | * } |
519 | 519 | * @return void |
520 | 520 | */ |
521 | -function give_radio( $field ) { |
|
521 | +function give_radio($field) { |
|
522 | 522 | global $thepostid, $post; |
523 | 523 | |
524 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
525 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
526 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
527 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
528 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
524 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
525 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
526 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
527 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
528 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
529 | 529 | |
530 | - echo '<fieldset class="give-field-wrap ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><span class="give-field-label">' . wp_kses_post( $field['name'] ) . '</span><legend class="screen-reader-text">' . wp_kses_post( $field['name'] ) . '</legend><ul class="give-radios">'; |
|
530 | + echo '<fieldset class="give-field-wrap '.esc_attr($field['id']).'_field '.esc_attr($field['wrapper_class']).'"><span class="give-field-label">'.wp_kses_post($field['name']).'</span><legend class="screen-reader-text">'.wp_kses_post($field['name']).'</legend><ul class="give-radios">'; |
|
531 | 531 | |
532 | - foreach ( $field['options'] as $key => $value ) { |
|
532 | + foreach ($field['options'] as $key => $value) { |
|
533 | 533 | |
534 | 534 | echo '<li><label><input |
535 | - name="' . give_get_field_name( $field ) . '" |
|
536 | - value="' . esc_attr( $key ) . '" |
|
535 | + name="' . give_get_field_name($field).'" |
|
536 | + value="' . esc_attr($key).'" |
|
537 | 537 | type="radio" |
538 | - style="' . esc_attr( $field['style'] ) . '" |
|
539 | - ' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' ' |
|
540 | - . give_get_custom_attributes( $field ) . ' |
|
541 | - /> ' . esc_html( $value ) . '</label> |
|
538 | + style="' . esc_attr($field['style']).'" |
|
539 | + ' . checked(esc_attr($field['value']), esc_attr($key), false).' ' |
|
540 | + . give_get_custom_attributes($field).' |
|
541 | + /> ' . esc_html($value).'</label> |
|
542 | 542 | </li>'; |
543 | 543 | } |
544 | 544 | echo '</ul>'; |
545 | 545 | |
546 | - echo give_get_field_description( $field ); |
|
546 | + echo give_get_field_description($field); |
|
547 | 547 | echo '</fieldset>'; |
548 | 548 | } |
549 | 549 | |
@@ -565,27 +565,27 @@ discard block |
||
565 | 565 | * } |
566 | 566 | * @return void |
567 | 567 | */ |
568 | -function give_colorpicker( $field ) { |
|
568 | +function give_colorpicker($field) { |
|
569 | 569 | global $thepostid, $post; |
570 | 570 | |
571 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
572 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
573 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
574 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
575 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
571 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
572 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
573 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
574 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
575 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
576 | 576 | $field['type'] = 'text'; |
577 | 577 | ?> |
578 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
579 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
578 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
579 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
580 | 580 | <input |
581 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
582 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
583 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
584 | - id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr( $field['value'] ); ?>" |
|
585 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
581 | + type="<?php echo esc_attr($field['type']); ?>" |
|
582 | + style="<?php echo esc_attr($field['style']); ?>" |
|
583 | + name="<?php echo give_get_field_name($field); ?>" |
|
584 | + id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr($field['value']); ?>" |
|
585 | + <?php echo give_get_custom_attributes($field); ?> |
|
586 | 586 | /> |
587 | 587 | <?php |
588 | - echo give_get_field_description( $field ); |
|
588 | + echo give_get_field_description($field); |
|
589 | 589 | echo '</p>'; |
590 | 590 | } |
591 | 591 | |
@@ -598,32 +598,32 @@ discard block |
||
598 | 598 | * @param array $field |
599 | 599 | * |
600 | 600 | */ |
601 | -function give_media( $field ) { |
|
601 | +function give_media($field) { |
|
602 | 602 | global $thepostid, $post; |
603 | 603 | |
604 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
605 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
606 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
607 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
608 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
604 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
605 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
606 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
607 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
608 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
609 | 609 | $field['type'] = 'text'; |
610 | 610 | $field['attributes']['class'] = "{$field['attributes']['class']} give-text-medium"; |
611 | 611 | |
612 | 612 | // Allow developer to save attachment ID or attachment url as metadata. |
613 | - $field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url'; |
|
613 | + $field['fvalue'] = isset($field['fvalue']) ? $field['fvalue'] : 'url'; |
|
614 | 614 | ?> |
615 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
616 | - <label for="<?php echo give_get_field_name( $field ) ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
615 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
616 | + <label for="<?php echo give_get_field_name($field) ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
617 | 617 | <input |
618 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
619 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
618 | + name="<?php echo give_get_field_name($field); ?>" |
|
619 | + id="<?php echo esc_attr($field['id']); ?>" |
|
620 | 620 | type="text" |
621 | 621 | value="<?php echo $field['value']; ?>" |
622 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
622 | + style="<?php echo esc_attr($field['style']); ?>" |
|
623 | 623 | data-fvalue="<?php echo $field['fvalue']; ?>" |
624 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
625 | - /> <input class="give-media-upload button" type="button" value="<?php echo esc_html__( 'Add or Upload File', 'give' ); ?>"> |
|
626 | - <?php echo give_get_field_description( $field ); ?> |
|
624 | + <?php echo give_get_custom_attributes($field); ?> |
|
625 | + /> <input class="give-media-upload button" type="button" value="<?php echo esc_html__('Add or Upload File', 'give'); ?>"> |
|
626 | + <?php echo give_get_field_description($field); ?> |
|
627 | 627 | </p> |
628 | 628 | <?php |
629 | 629 | } |
@@ -637,27 +637,27 @@ discard block |
||
637 | 637 | * |
638 | 638 | * @return void |
639 | 639 | */ |
640 | -function give_default_gateway( $field ) { |
|
640 | +function give_default_gateway($field) { |
|
641 | 641 | global $thepostid, $post; |
642 | 642 | |
643 | 643 | // get all active payment gateways. |
644 | - $gateways = give_get_enabled_payment_gateways( $thepostid ); |
|
644 | + $gateways = give_get_enabled_payment_gateways($thepostid); |
|
645 | 645 | $field['options'] = array(); |
646 | 646 | |
647 | 647 | // Set field option value. |
648 | - if( ! empty( $gateways ) ) { |
|
649 | - foreach ( $gateways as $key => $option ) { |
|
650 | - $field['options'][ $key ] = $option['admin_label']; |
|
648 | + if ( ! empty($gateways)) { |
|
649 | + foreach ($gateways as $key => $option) { |
|
650 | + $field['options'][$key] = $option['admin_label']; |
|
651 | 651 | } |
652 | 652 | } |
653 | 653 | |
654 | 654 | //Add a field to the Give Form admin single post view of this field |
655 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
656 | - $field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] ); |
|
655 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
656 | + $field['options'] = array_merge(array('global' => esc_html__('Global Default', 'give')), $field['options']); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | // Render select field. |
660 | - give_select( $field ); |
|
660 | + give_select($field); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | $field['url'] = isset($field['url']) ? $field['url'] : 'https://givewp.com/documentation'; |
682 | 682 | $field['title'] = isset($field['title']) ? $field['title'] : 'Documentation'; |
683 | 683 | |
684 | - echo '<p class="give-docs-link"><a href="' . esc_url($field['url']) |
|
684 | + echo '<p class="give-docs-link"><a href="'.esc_url($field['url']) |
|
685 | 685 | . '" target="_blank">' |
686 | 686 | . sprintf(esc_html__('Need Help? See docs on "%s"'), $field['title']) |
687 | 687 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
@@ -699,13 +699,13 @@ discard block |
||
699 | 699 | * |
700 | 700 | * @return mixed |
701 | 701 | */ |
702 | -function give_get_field_value( $field, $postid ) { |
|
703 | - if ( isset( $field['attributes']['value'] ) ) { |
|
702 | +function give_get_field_value($field, $postid) { |
|
703 | + if (isset($field['attributes']['value'])) { |
|
704 | 704 | return $field['attributes']['value']; |
705 | 705 | } |
706 | 706 | |
707 | 707 | // Get value from db. |
708 | - $field_value = get_post_meta( $postid, $field['id'], true ); |
|
708 | + $field_value = get_post_meta($postid, $field['id'], true); |
|
709 | 709 | |
710 | 710 | /** |
711 | 711 | * Filter the field value before apply default value. |
@@ -714,11 +714,11 @@ discard block |
||
714 | 714 | * |
715 | 715 | * @param mixed $field_value Field value. |
716 | 716 | */ |
717 | - $field_value = apply_filters( "{$field['id']}_field_value", $field_value, $field, $postid ); |
|
717 | + $field_value = apply_filters("{$field['id']}_field_value", $field_value, $field, $postid); |
|
718 | 718 | |
719 | 719 | |
720 | 720 | // Set default value if no any data saved to db. |
721 | - if ( ! $field_value && isset( $field['default'] ) ) { |
|
721 | + if ( ! $field_value && isset($field['default'])) { |
|
722 | 722 | $field_value = $field['default']; |
723 | 723 | } |
724 | 724 | |
@@ -734,10 +734,10 @@ discard block |
||
734 | 734 | * |
735 | 735 | * @return string |
736 | 736 | */ |
737 | -function give_get_field_description( $field ) { |
|
737 | +function give_get_field_description($field) { |
|
738 | 738 | $field_desc_html = ''; |
739 | - if ( ! empty( $field['description'] ) ) { |
|
740 | - $field_desc_html = '<span class="give-field-description">' . wp_kses_post( $field['description'] ) . '</span>'; |
|
739 | + if ( ! empty($field['description'])) { |
|
740 | + $field_desc_html = '<span class="give-field-description">'.wp_kses_post($field['description']).'</span>'; |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | return $field_desc_html; |
@@ -752,18 +752,18 @@ discard block |
||
752 | 752 | * |
753 | 753 | * @return string |
754 | 754 | */ |
755 | -function give_get_custom_attributes( $field ) { |
|
755 | +function give_get_custom_attributes($field) { |
|
756 | 756 | // Custom attribute handling |
757 | 757 | $custom_attributes = array(); |
758 | 758 | |
759 | - if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) { |
|
759 | + if ( ! empty($field['attributes']) && is_array($field['attributes'])) { |
|
760 | 760 | |
761 | - foreach ( $field['attributes'] as $attribute => $value ) { |
|
762 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; |
|
761 | + foreach ($field['attributes'] as $attribute => $value) { |
|
762 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"'; |
|
763 | 763 | } |
764 | 764 | } |
765 | 765 | |
766 | - return implode( ' ', $custom_attributes ); |
|
766 | + return implode(' ', $custom_attributes); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | /** |
@@ -779,8 +779,8 @@ discard block |
||
779 | 779 | * |
780 | 780 | * @return string |
781 | 781 | */ |
782 | -function give_get_repeater_field_value( $field, $field_group, $fields ) { |
|
783 | - $field_value = ( isset( $field_group[ $field['id'] ] ) ? $field_group[ $field['id'] ] : '' ); |
|
782 | +function give_get_repeater_field_value($field, $field_group, $fields) { |
|
783 | + $field_value = (isset($field_group[$field['id']]) ? $field_group[$field['id']] : ''); |
|
784 | 784 | |
785 | 785 | /** |
786 | 786 | * Filter the specific repeater field value |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | * |
790 | 790 | * @param string $field_id |
791 | 791 | */ |
792 | - $field_value = apply_filters( "give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields ); |
|
792 | + $field_value = apply_filters("give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields); |
|
793 | 793 | |
794 | 794 | /** |
795 | 795 | * Filter the repeater field value |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | * |
799 | 799 | * @param string $field_id |
800 | 800 | */ |
801 | - $field_value = apply_filters( 'give_get_repeater_field_value', $field_value, $field, $field_group, $fields ); |
|
801 | + $field_value = apply_filters('give_get_repeater_field_value', $field_value, $field, $field_group, $fields); |
|
802 | 802 | |
803 | 803 | return $field_value; |
804 | 804 | } |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | * |
817 | 817 | * @return string |
818 | 818 | */ |
819 | -function give_get_repeater_field_id( $field, $fields, $default = false ) { |
|
819 | +function give_get_repeater_field_id($field, $fields, $default = false) { |
|
820 | 820 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
821 | 821 | |
822 | 822 | // Get field id. |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @param string $field_id |
831 | 831 | */ |
832 | - $field_id = apply_filters( "give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default ); |
|
832 | + $field_id = apply_filters("give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default); |
|
833 | 833 | |
834 | 834 | |
835 | 835 | /** |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | * |
840 | 840 | * @param string $field_id |
841 | 841 | */ |
842 | - $field_id = apply_filters( 'give_get_repeater_field_id', $field_id, $field, $fields, $default ); |
|
842 | + $field_id = apply_filters('give_get_repeater_field_id', $field_id, $field, $fields, $default); |
|
843 | 843 | |
844 | 844 | return $field_id; |
845 | 845 | } |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | * |
855 | 855 | * @return string |
856 | 856 | */ |
857 | -function give_get_field_name( $field ) { |
|
858 | - $field_name = esc_attr( empty( $field['repeat'] ) ? $field['id'] : $field['repeatable_field_id'] ); |
|
857 | +function give_get_field_name($field) { |
|
858 | + $field_name = esc_attr(empty($field['repeat']) ? $field['id'] : $field['repeatable_field_id']); |
|
859 | 859 | |
860 | 860 | /** |
861 | 861 | * Filter the field name. |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @param string $field_name |
866 | 866 | */ |
867 | - $field_name = apply_filters( 'give_get_field_name', $field_name, $field ); |
|
867 | + $field_name = apply_filters('give_get_field_name', $field_name, $field); |
|
868 | 868 | |
869 | 869 | return $field_name; |
870 | 870 | } |
@@ -880,38 +880,38 @@ discard block |
||
880 | 880 | * |
881 | 881 | * @return void |
882 | 882 | */ |
883 | -function _give_metabox_form_data_repeater_fields( $fields ) { |
|
883 | +function _give_metabox_form_data_repeater_fields($fields) { |
|
884 | 884 | global $thepostid, $post; |
885 | 885 | |
886 | 886 | // Bailout. |
887 | - if ( ! isset( $fields['fields'] ) || empty( $fields['fields'] ) ) { |
|
887 | + if ( ! isset($fields['fields']) || empty($fields['fields'])) { |
|
888 | 888 | return; |
889 | 889 | } |
890 | 890 | |
891 | - $group_numbering = isset( $fields['options']['group_numbering'] ) ? (int) $fields['options']['group_numbering'] : 0; |
|
892 | - $close_tabs = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0; |
|
891 | + $group_numbering = isset($fields['options']['group_numbering']) ? (int) $fields['options']['group_numbering'] : 0; |
|
892 | + $close_tabs = isset($fields['options']['close_tabs']) ? (int) $fields['options']['close_tabs'] : 0; |
|
893 | 893 | ?> |
894 | 894 | <div class="give-repeatable-field-section" id="<?php echo "{$fields['id']}_field"; ?>" data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>"> |
895 | - <?php if ( ! empty( $fields['name'] ) ) : ?> |
|
895 | + <?php if ( ! empty($fields['name'])) : ?> |
|
896 | 896 | <p class="give-repeater-field-name"><?php echo $fields['name']; ?></p> |
897 | 897 | <?php endif; ?> |
898 | 898 | |
899 | - <?php if ( ! empty( $fields['description'] ) ) : ?> |
|
899 | + <?php if ( ! empty($fields['description'])) : ?> |
|
900 | 900 | <p class="give-repeater-field-description"><?php echo $fields['description']; ?></p> |
901 | 901 | <?php endif; ?> |
902 | 902 | |
903 | 903 | <table class="give-repeatable-fields-section-wrapper" cellspacing="0"> |
904 | 904 | <?php |
905 | - $repeater_field_values = get_post_meta( $thepostid, $fields['id'], true ); |
|
906 | - $header_title = isset( $fields['options']['header_title'] ) |
|
905 | + $repeater_field_values = get_post_meta($thepostid, $fields['id'], true); |
|
906 | + $header_title = isset($fields['options']['header_title']) |
|
907 | 907 | ? $fields['options']['header_title'] |
908 | - : esc_attr__( 'Group', 'give' ); |
|
908 | + : esc_attr__('Group', 'give'); |
|
909 | 909 | |
910 | 910 | $add_default_donation_field = false; |
911 | 911 | |
912 | 912 | // Check if level is not created or we have to add default level. |
913 | - if ( is_array( $repeater_field_values ) && ( $fields_count = count( $repeater_field_values ) ) ) { |
|
914 | - $repeater_field_values = array_values( $repeater_field_values ); |
|
913 | + if (is_array($repeater_field_values) && ($fields_count = count($repeater_field_values))) { |
|
914 | + $repeater_field_values = array_values($repeater_field_values); |
|
915 | 915 | } else { |
916 | 916 | $fields_count = 1; |
917 | 917 | $add_default_donation_field = true; |
@@ -924,73 +924,73 @@ discard block |
||
924 | 924 | <div class="give-row-head give-move"> |
925 | 925 | <button type="button" class="handlediv button-link"><span class="toggle-indicator"></span> |
926 | 926 | </button> |
927 | - <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-</span> |
|
927 | + <span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-</span> |
|
928 | 928 | <h2> |
929 | 929 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
930 | 930 | </h2> |
931 | 931 | </div> |
932 | 932 | <div class="give-row-body"> |
933 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
934 | - <?php if ( ! give_is_field_callback_exist( $field ) ) { |
|
933 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
934 | + <?php if ( ! give_is_field_callback_exist($field)) { |
|
935 | 935 | continue; |
936 | 936 | } ?> |
937 | 937 | <?php |
938 | 938 | $field['repeat'] = true; |
939 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields ); |
|
940 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
939 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields); |
|
940 | + $field['id'] = str_replace(array('[', ']'), array( |
|
941 | 941 | '_', |
942 | 942 | '', |
943 | - ), $field['repeatable_field_id'] ); |
|
943 | + ), $field['repeatable_field_id']); |
|
944 | 944 | ?> |
945 | - <?php give_render_field( $field ); ?> |
|
945 | + <?php give_render_field($field); ?> |
|
946 | 946 | <?php endforeach; ?> |
947 | 947 | </div> |
948 | 948 | </td> |
949 | 949 | </tr> |
950 | 950 | |
951 | - <?php if ( ! empty( $repeater_field_values ) ) : ?> |
|
951 | + <?php if ( ! empty($repeater_field_values)) : ?> |
|
952 | 952 | <!--Stored repeater field group--> |
953 | - <?php foreach ( $repeater_field_values as $index => $field_group ) : ?> |
|
953 | + <?php foreach ($repeater_field_values as $index => $field_group) : ?> |
|
954 | 954 | <tr class="give-row"> |
955 | 955 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
956 | 956 | <div class="give-row-head give-move"> |
957 | 957 | <button type="button" class="handlediv button-link"> |
958 | 958 | <span class="toggle-indicator"></span></button> |
959 | - <sapn class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
959 | + <sapn class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
960 | 960 | </sapn> |
961 | 961 | <h2> |
962 | 962 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
963 | 963 | </h2> |
964 | 964 | </div> |
965 | 965 | <div class="give-row-body"> |
966 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
967 | - <?php if ( ! give_is_field_callback_exist( $field ) ) { |
|
966 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
967 | + <?php if ( ! give_is_field_callback_exist($field)) { |
|
968 | 968 | continue; |
969 | 969 | } ?> |
970 | 970 | <?php |
971 | 971 | $field['repeat'] = true; |
972 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, $index ); |
|
973 | - $field['attributes']['value'] = give_get_repeater_field_value( $field, $field_group, $fields ); |
|
974 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
972 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, $index); |
|
973 | + $field['attributes']['value'] = give_get_repeater_field_value($field, $field_group, $fields); |
|
974 | + $field['id'] = str_replace(array('[', ']'), array( |
|
975 | 975 | '_', |
976 | 976 | '', |
977 | - ), $field['repeatable_field_id'] ); |
|
977 | + ), $field['repeatable_field_id']); |
|
978 | 978 | ?> |
979 | - <?php give_render_field( $field ); ?> |
|
979 | + <?php give_render_field($field); ?> |
|
980 | 980 | <?php endforeach; ?> |
981 | 981 | </div> |
982 | 982 | </td> |
983 | 983 | </tr> |
984 | - <?php endforeach;; ?> |
|
984 | + <?php endforeach; ; ?> |
|
985 | 985 | |
986 | - <?php elseif ( $add_default_donation_field ) : ?> |
|
986 | + <?php elseif ($add_default_donation_field) : ?> |
|
987 | 987 | <!--Default repeater field group--> |
988 | 988 | <tr class="give-row"> |
989 | 989 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
990 | 990 | <div class="give-row-head give-move"> |
991 | 991 | <button type="button" class="handlediv button-link"> |
992 | 992 | <span class="toggle-indicator"></span></button> |
993 | - <sapn class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
993 | + <sapn class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
994 | 994 | </sapn> |
995 | 995 | <h2> |
996 | 996 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
@@ -998,19 +998,19 @@ discard block |
||
998 | 998 | </div> |
999 | 999 | <div class="give-row-body"> |
1000 | 1000 | <?php |
1001 | - foreach ( $fields['fields'] as $field ) : |
|
1002 | - if ( ! give_is_field_callback_exist( $field ) ) { |
|
1001 | + foreach ($fields['fields'] as $field) : |
|
1002 | + if ( ! give_is_field_callback_exist($field)) { |
|
1003 | 1003 | continue; |
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | $field['repeat'] = true; |
1007 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, 0 ); |
|
1008 | - $field['attributes']['value'] = apply_filters( "give_default_field_group_field_{$field['id']}_value", ( ! empty( $field['default'] ) ? $field['default'] : '' ), $field ); |
|
1009 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
1007 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, 0); |
|
1008 | + $field['attributes']['value'] = apply_filters("give_default_field_group_field_{$field['id']}_value", ( ! empty($field['default']) ? $field['default'] : ''), $field); |
|
1009 | + $field['id'] = str_replace(array('[', ']'), array( |
|
1010 | 1010 | '_', |
1011 | 1011 | '', |
1012 | - ), $field['repeatable_field_id'] ); |
|
1013 | - give_render_field( $field ); |
|
1012 | + ), $field['repeatable_field_id']); |
|
1013 | + give_render_field($field); |
|
1014 | 1014 | endforeach; |
1015 | 1015 | ?> |
1016 | 1016 | </div> |
@@ -1021,9 +1021,9 @@ discard block |
||
1021 | 1021 | <tfoot> |
1022 | 1022 | <tr> |
1023 | 1023 | <?php |
1024 | - $add_row_btn_title = isset( $fields['options']['add_button'] ) |
|
1024 | + $add_row_btn_title = isset($fields['options']['add_button']) |
|
1025 | 1025 | ? $add_row_btn_title = $fields['options']['add_button'] |
1026 | - : esc_html__( 'Add Row', 'give' ); |
|
1026 | + : esc_html__('Add Row', 'give'); |
|
1027 | 1027 | ?> |
1028 | 1028 | <td colspan="2" class="give-add-repeater-field-section-row-wrap"> |
1029 | 1029 | <span class="button button-primary give-add-repeater-field-section-row"><?php echo $add_row_btn_title; ?></span> |
@@ -1053,10 +1053,10 @@ discard block |
||
1053 | 1053 | * |
1054 | 1054 | * @param string |
1055 | 1055 | */ |
1056 | - $default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' ); |
|
1056 | + $default_current_tab = apply_filters("give_default_setting_tab_{$current_setting_page}", 'general'); |
|
1057 | 1057 | |
1058 | 1058 | // Get current tab. |
1059 | - $current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( $_GET['tab'] ); |
|
1059 | + $current_tab = empty($_GET['tab']) ? $default_current_tab : urldecode($_GET['tab']); |
|
1060 | 1060 | |
1061 | 1061 | // Output. |
1062 | 1062 | return $current_tab; |
@@ -1080,10 +1080,10 @@ discard block |
||
1080 | 1080 | * |
1081 | 1081 | * @param string |
1082 | 1082 | */ |
1083 | - $default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' ); |
|
1083 | + $default_current_section = apply_filters("give_default_setting_tab_section_{$current_tab}", ''); |
|
1084 | 1084 | |
1085 | 1085 | // Get current section. |
1086 | - $current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( $_REQUEST['section'] ); |
|
1086 | + $current_section = empty($_REQUEST['section']) ? $default_current_section : urldecode($_REQUEST['section']); |
|
1087 | 1087 | |
1088 | 1088 | //Output. |
1089 | 1089 | return $current_section; |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | */ |
1098 | 1098 | function give_get_current_setting_page() { |
1099 | 1099 | // Get current page. |
1100 | - $setting_page = ! empty( $_GET['page'] ) ? urldecode( $_GET['page'] ) : ''; |
|
1100 | + $setting_page = ! empty($_GET['page']) ? urldecode($_GET['page']) : ''; |
|
1101 | 1101 | |
1102 | 1102 | //Output. |
1103 | 1103 | return $setting_page; |
@@ -1116,13 +1116,13 @@ discard block |
||
1116 | 1116 | * |
1117 | 1117 | * @return string |
1118 | 1118 | */ |
1119 | -function _give_display_content_field_value( $field_value, $field, $postid ) { |
|
1120 | - $show_content = get_post_meta( $postid, '_give_content_option', true ); |
|
1119 | +function _give_display_content_field_value($field_value, $field, $postid) { |
|
1120 | + $show_content = get_post_meta($postid, '_give_content_option', true); |
|
1121 | 1121 | |
1122 | 1122 | if ( |
1123 | - ! get_post_meta( $postid, '_give_display_content', true ) |
|
1123 | + ! get_post_meta($postid, '_give_display_content', true) |
|
1124 | 1124 | && $show_content |
1125 | - && ( 'none' !== $show_content ) |
|
1125 | + && ('none' !== $show_content) |
|
1126 | 1126 | ) { |
1127 | 1127 | $field_value = 'enabled'; |
1128 | 1128 | } |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | return $field_value; |
1131 | 1131 | } |
1132 | 1132 | |
1133 | -add_filter( '_give_display_content_field_value', '_give_display_content_field_value', 10, 3 ); |
|
1133 | +add_filter('_give_display_content_field_value', '_give_display_content_field_value', 10, 3); |
|
1134 | 1134 | |
1135 | 1135 | |
1136 | 1136 | /** |
@@ -1146,12 +1146,12 @@ discard block |
||
1146 | 1146 | * |
1147 | 1147 | * @return string |
1148 | 1148 | */ |
1149 | -function _give_content_placement_field_value( $field_value, $field, $postid ) { |
|
1150 | - $show_content = get_post_meta( $postid, '_give_content_option', true ); |
|
1149 | +function _give_content_placement_field_value($field_value, $field, $postid) { |
|
1150 | + $show_content = get_post_meta($postid, '_give_content_option', true); |
|
1151 | 1151 | |
1152 | 1152 | if ( |
1153 | - ! get_post_meta( $postid, '_give_content_placement', true ) |
|
1154 | - && ( 'none' !== $show_content ) |
|
1153 | + ! get_post_meta($postid, '_give_content_placement', true) |
|
1154 | + && ('none' !== $show_content) |
|
1155 | 1155 | ) { |
1156 | 1156 | $field_value = $show_content; |
1157 | 1157 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | return $field_value; |
1160 | 1160 | } |
1161 | 1161 | |
1162 | -add_filter( '_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3 ); |
|
1162 | +add_filter('_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3); |
|
1163 | 1163 | |
1164 | 1164 | |
1165 | 1165 | /** |
@@ -1175,17 +1175,17 @@ discard block |
||
1175 | 1175 | * |
1176 | 1176 | * @return string |
1177 | 1177 | */ |
1178 | -function _give_terms_option_field_value( $field_value, $field, $postid ) { |
|
1179 | - $term_option = get_post_meta( $postid, '_give_terms_option', true ); |
|
1178 | +function _give_terms_option_field_value($field_value, $field, $postid) { |
|
1179 | + $term_option = get_post_meta($postid, '_give_terms_option', true); |
|
1180 | 1180 | |
1181 | - if ( in_array( $term_option, array( 'none', 'yes' ) ) ) { |
|
1182 | - $field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' ); |
|
1181 | + if (in_array($term_option, array('none', 'yes'))) { |
|
1182 | + $field_value = ('yes' === $term_option ? 'enabled' : 'disabled'); |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | return $field_value; |
1186 | 1186 | } |
1187 | 1187 | |
1188 | -add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 ); |
|
1188 | +add_filter('_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3); |
|
1189 | 1189 | |
1190 | 1190 | |
1191 | 1191 | /** |
@@ -1201,17 +1201,17 @@ discard block |
||
1201 | 1201 | * |
1202 | 1202 | * @return string |
1203 | 1203 | */ |
1204 | -function _give_offline_donation_enable_billing_fields_single_field_value( $field_value, $field, $postid ) { |
|
1205 | - $offline_donation = get_post_meta( $postid, '_give_offline_donation_enable_billing_fields_single', true ); |
|
1204 | +function _give_offline_donation_enable_billing_fields_single_field_value($field_value, $field, $postid) { |
|
1205 | + $offline_donation = get_post_meta($postid, '_give_offline_donation_enable_billing_fields_single', true); |
|
1206 | 1206 | |
1207 | - if ( 'on' === $offline_donation ) { |
|
1207 | + if ('on' === $offline_donation) { |
|
1208 | 1208 | $field_value = 'enabled'; |
1209 | 1209 | } |
1210 | 1210 | |
1211 | 1211 | return $field_value; |
1212 | 1212 | } |
1213 | 1213 | |
1214 | -add_filter( '_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3 ); |
|
1214 | +add_filter('_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3); |
|
1215 | 1215 | |
1216 | 1216 | |
1217 | 1217 | /** |
@@ -1227,17 +1227,17 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * @return string |
1229 | 1229 | */ |
1230 | -function _give_custom_amount_field_value( $field_value, $field, $postid ) { |
|
1231 | - $custom_amount = get_post_meta( $postid, '_give_custom_amount', true ); |
|
1230 | +function _give_custom_amount_field_value($field_value, $field, $postid) { |
|
1231 | + $custom_amount = get_post_meta($postid, '_give_custom_amount', true); |
|
1232 | 1232 | |
1233 | - if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) { |
|
1234 | - $field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' ); |
|
1233 | + if (in_array($custom_amount, array('yes', 'no'))) { |
|
1234 | + $field_value = ('yes' === $custom_amount ? 'enabled' : 'disabled'); |
|
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | return $field_value; |
1238 | 1238 | } |
1239 | 1239 | |
1240 | -add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 ); |
|
1240 | +add_filter('_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3); |
|
1241 | 1241 | |
1242 | 1242 | |
1243 | 1243 | /** |
@@ -1253,17 +1253,17 @@ discard block |
||
1253 | 1253 | * |
1254 | 1254 | * @return string |
1255 | 1255 | */ |
1256 | -function _give_goal_option_field_value( $field_value, $field, $postid ) { |
|
1257 | - $goal_option = get_post_meta( $postid, '_give_goal_option', true ); |
|
1256 | +function _give_goal_option_field_value($field_value, $field, $postid) { |
|
1257 | + $goal_option = get_post_meta($postid, '_give_goal_option', true); |
|
1258 | 1258 | |
1259 | - if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) { |
|
1260 | - $field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' ); |
|
1259 | + if (in_array($goal_option, array('yes', 'no'))) { |
|
1260 | + $field_value = ('yes' === $goal_option ? 'enabled' : 'disabled'); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | return $field_value; |
1264 | 1264 | } |
1265 | 1265 | |
1266 | -add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 ); |
|
1266 | +add_filter('_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3); |
|
1267 | 1267 | |
1268 | 1268 | /** |
1269 | 1269 | * Set value for Donation Goal --> close Form. |
@@ -1278,17 +1278,17 @@ discard block |
||
1278 | 1278 | * |
1279 | 1279 | * @return string |
1280 | 1280 | */ |
1281 | -function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) { |
|
1282 | - $close_form = get_post_meta( $postid, '_give_close_form_when_goal_achieved', true ); |
|
1281 | +function _give_close_form_when_goal_achieved_value($field_value, $field, $postid) { |
|
1282 | + $close_form = get_post_meta($postid, '_give_close_form_when_goal_achieved', true); |
|
1283 | 1283 | |
1284 | - if ( in_array( $close_form, array( 'yes', 'no' ) ) ) { |
|
1285 | - $field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' ); |
|
1284 | + if (in_array($close_form, array('yes', 'no'))) { |
|
1285 | + $field_value = ('yes' === $close_form ? 'enabled' : 'disabled'); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | return $field_value; |
1289 | 1289 | } |
1290 | 1290 | |
1291 | -add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 ); |
|
1291 | +add_filter('_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3); |
|
1292 | 1292 | |
1293 | 1293 | |
1294 | 1294 | /** |
@@ -1304,17 +1304,17 @@ discard block |
||
1304 | 1304 | * |
1305 | 1305 | * @return string |
1306 | 1306 | */ |
1307 | -function _give_logged_in_only_value( $field_value, $field, $postid ) { |
|
1308 | - $guest_donation = get_post_meta( $postid, '_give_logged_in_only', true ); |
|
1307 | +function _give_logged_in_only_value($field_value, $field, $postid) { |
|
1308 | + $guest_donation = get_post_meta($postid, '_give_logged_in_only', true); |
|
1309 | 1309 | |
1310 | - if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) { |
|
1311 | - $field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' ); |
|
1310 | + if (in_array($guest_donation, array('yes', 'no'))) { |
|
1311 | + $field_value = ('yes' === $guest_donation ? 'enabled' : 'disabled'); |
|
1312 | 1312 | } |
1313 | 1313 | |
1314 | 1314 | return $field_value; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | -add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 ); |
|
1317 | +add_filter('_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3); |
|
1318 | 1318 | |
1319 | 1319 | /** |
1320 | 1320 | * Set value for Offline Donations --> Offline Donations. |
@@ -1329,17 +1329,17 @@ discard block |
||
1329 | 1329 | * |
1330 | 1330 | * @return string |
1331 | 1331 | */ |
1332 | -function _give_customize_offline_donations_value( $field_value, $field, $postid ) { |
|
1333 | - $customize_offline_text = get_post_meta( $postid, '_give_customize_offline_donations', true ); |
|
1332 | +function _give_customize_offline_donations_value($field_value, $field, $postid) { |
|
1333 | + $customize_offline_text = get_post_meta($postid, '_give_customize_offline_donations', true); |
|
1334 | 1334 | |
1335 | - if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) { |
|
1336 | - $field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' ); |
|
1335 | + if (in_array($customize_offline_text, array('yes', 'no'))) { |
|
1336 | + $field_value = ('yes' === $customize_offline_text ? 'enabled' : 'disabled'); |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | return $field_value; |
1340 | 1340 | } |
1341 | 1341 | |
1342 | -add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 ); |
|
1342 | +add_filter('_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3); |
|
1343 | 1343 | |
1344 | 1344 | |
1345 | 1345 | /** |
@@ -1354,14 +1354,14 @@ discard block |
||
1354 | 1354 | * |
1355 | 1355 | * @return mixed |
1356 | 1356 | */ |
1357 | -function _give_set_multi_level_repeater_field_id( $field_id, $field, $fields, $default ) { |
|
1357 | +function _give_set_multi_level_repeater_field_id($field_id, $field, $fields, $default) { |
|
1358 | 1358 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
1359 | 1359 | $field_id = "{$fields['id']}[{$row_placeholder}][{$field['id']}][level_id]"; |
1360 | 1360 | |
1361 | 1361 | return $field_id; |
1362 | 1362 | } |
1363 | 1363 | |
1364 | -add_filter( 'give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4 ); |
|
1364 | +add_filter('give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4); |
|
1365 | 1365 | |
1366 | 1366 | /** |
1367 | 1367 | * Set repeater field value for multi donation form. |
@@ -1375,13 +1375,13 @@ discard block |
||
1375 | 1375 | * |
1376 | 1376 | * @return mixed |
1377 | 1377 | */ |
1378 | -function _give_set_multi_level_repeater_field_value( $field_value, $field, $field_group, $fields ) { |
|
1379 | - $field_value = $field_group[ $field['id'] ]['level_id']; |
|
1378 | +function _give_set_multi_level_repeater_field_value($field_value, $field, $field_group, $fields) { |
|
1379 | + $field_value = $field_group[$field['id']]['level_id']; |
|
1380 | 1380 | |
1381 | 1381 | return $field_value; |
1382 | 1382 | } |
1383 | 1383 | |
1384 | -add_filter( 'give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4 ); |
|
1384 | +add_filter('give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4); |
|
1385 | 1385 | |
1386 | 1386 | /** |
1387 | 1387 | * Set default value for _give_id field. |
@@ -1392,11 +1392,11 @@ discard block |
||
1392 | 1392 | * |
1393 | 1393 | * @return string |
1394 | 1394 | */ |
1395 | -function _give_set_field_give_id_default_value( $field ) { |
|
1395 | +function _give_set_field_give_id_default_value($field) { |
|
1396 | 1396 | return 0; |
1397 | 1397 | } |
1398 | 1398 | |
1399 | -add_filter( 'give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value' ); |
|
1399 | +add_filter('give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value'); |
|
1400 | 1400 | |
1401 | 1401 | /** |
1402 | 1402 | * Set default value for _give_default field. |
@@ -1407,11 +1407,11 @@ discard block |
||
1407 | 1407 | * |
1408 | 1408 | * @return string |
1409 | 1409 | */ |
1410 | -function _give_set_field_give_default_default_value( $field ) { |
|
1410 | +function _give_set_field_give_default_default_value($field) { |
|
1411 | 1411 | return 'default'; |
1412 | 1412 | } |
1413 | 1413 | |
1414 | -add_filter( 'give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value' ); |
|
1414 | +add_filter('give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value'); |
|
1415 | 1415 | |
1416 | 1416 | /** |
1417 | 1417 | * Set repeater field editor id for field type wysiwyg. |
@@ -1423,11 +1423,11 @@ discard block |
||
1423 | 1423 | * |
1424 | 1424 | * @return string |
1425 | 1425 | */ |
1426 | -function give_repeater_field_set_editor_id( $field_name, $field ) { |
|
1427 | - if ( isset( $field['repeatable_field_id'] ) && 'wysiwyg' == $field['type'] ) { |
|
1428 | - $field_name = '_give_repeater_' . uniqid() . '_wysiwyg'; |
|
1426 | +function give_repeater_field_set_editor_id($field_name, $field) { |
|
1427 | + if (isset($field['repeatable_field_id']) && 'wysiwyg' == $field['type']) { |
|
1428 | + $field_name = '_give_repeater_'.uniqid().'_wysiwyg'; |
|
1429 | 1429 | } |
1430 | 1430 | |
1431 | 1431 | return $field_name; |
1432 | 1432 | } |
1433 | -add_filter( 'give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2 ); |
|
1434 | 1433 | \ No newline at end of file |
1434 | +add_filter('give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2); |
|
1435 | 1435 | \ No newline at end of file |
@@ -113,7 +113,7 @@ |
||
113 | 113 | /** |
114 | 114 | * Adds the "Donation Form" button above the TinyMCE Editor on add/edit screens. |
115 | 115 | * |
116 | - * @return string|bool |
|
116 | + * @return false|null |
|
117 | 117 | * |
118 | 118 | * @since 1.0 |
119 | 119 | */ |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __construct() { |
35 | 35 | |
36 | - if ( is_admin() ) { |
|
37 | - add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins' ), 15 ); |
|
36 | + if (is_admin()) { |
|
37 | + add_filter('mce_external_plugins', array($this, 'mce_external_plugins'), 15); |
|
38 | 38 | |
39 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ) ); |
|
40 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_localize_scripts' ), 13 ); |
|
41 | - add_action( 'media_buttons', array( $this, 'shortcode_button' ) ); |
|
39 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_assets')); |
|
40 | + add_action('admin_enqueue_scripts', array($this, 'admin_localize_scripts'), 13); |
|
41 | + add_action('media_buttons', array($this, 'shortcode_button')); |
|
42 | 42 | } |
43 | 43 | |
44 | - add_action( "wp_ajax_give_shortcode", array( $this, 'shortcode_ajax' ) ); |
|
45 | - add_action( "wp_ajax_nopriv_give_shortcode", array( $this, 'shortcode_ajax' ) ); |
|
44 | + add_action("wp_ajax_give_shortcode", array($this, 'shortcode_ajax')); |
|
45 | + add_action("wp_ajax_nopriv_give_shortcode", array($this, 'shortcode_ajax')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @since 1.0 |
56 | 56 | */ |
57 | - public function mce_external_plugins( $plugin_array ) { |
|
57 | + public function mce_external_plugins($plugin_array) { |
|
58 | 58 | |
59 | - if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) { |
|
59 | + if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages')) { |
|
60 | 60 | return false; |
61 | 61 | } |
62 | 62 | |
63 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
63 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
64 | 64 | |
65 | - $plugin_array['give_shortcode'] = GIVE_PLUGIN_URL . 'assets/js/admin/tinymce/mce-plugin' . $suffix . '.js'; |
|
65 | + $plugin_array['give_shortcode'] = GIVE_PLUGIN_URL.'assets/js/admin/tinymce/mce-plugin'.$suffix.'.js'; |
|
66 | 66 | |
67 | 67 | return $plugin_array; |
68 | 68 | } |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function admin_enqueue_assets() { |
78 | 78 | |
79 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
79 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
80 | 80 | |
81 | 81 | wp_enqueue_script( |
82 | 82 | 'give_shortcode', |
83 | - GIVE_PLUGIN_URL . 'assets/js/admin/admin-shortcodes' . $suffix . '.js', |
|
84 | - array( 'jquery' ), |
|
83 | + GIVE_PLUGIN_URL.'assets/js/admin/admin-shortcodes'.$suffix.'.js', |
|
84 | + array('jquery'), |
|
85 | 85 | GIVE_VERSION, |
86 | 86 | true |
87 | 87 | ); |
@@ -96,17 +96,17 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function admin_localize_scripts() { |
98 | 98 | |
99 | - if ( ! empty( self::$shortcodes ) ) { |
|
99 | + if ( ! empty(self::$shortcodes)) { |
|
100 | 100 | |
101 | 101 | $variables = array(); |
102 | 102 | |
103 | - foreach ( self::$shortcodes as $shortcode => $values ) { |
|
104 | - if ( ! empty( $values['required'] ) ) { |
|
105 | - $variables[ $shortcode ] = $values['required']; |
|
103 | + foreach (self::$shortcodes as $shortcode => $values) { |
|
104 | + if ( ! empty($values['required'])) { |
|
105 | + $variables[$shortcode] = $values['required']; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - wp_localize_script( 'give_shortcode', 'scShortcodes', $variables ); |
|
109 | + wp_localize_script('give_shortcode', 'scShortcodes', $variables); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -123,37 +123,37 @@ discard block |
||
123 | 123 | |
124 | 124 | // If we load wp editor by ajax then $screen will be empty which generate notice if we treat $screen as WP_Screen object. |
125 | 125 | // For example we are loading wp editor by ajax in repeater field. |
126 | - if ( ! ( $screen instanceof WP_Screen ) ) { |
|
126 | + if ( ! ($screen instanceof WP_Screen)) { |
|
127 | 127 | return false; |
128 | 128 | } |
129 | 129 | |
130 | - $shortcode_button_pages = apply_filters( 'give_shortcode_button_pages', array( |
|
130 | + $shortcode_button_pages = apply_filters('give_shortcode_button_pages', array( |
|
131 | 131 | 'post.php', |
132 | 132 | 'page.php', |
133 | 133 | 'post-new.php', |
134 | 134 | 'post-edit.php', |
135 | 135 | 'edit.php', |
136 | 136 | 'edit.php?post_type=page', |
137 | - ) ); |
|
137 | + )); |
|
138 | 138 | |
139 | 139 | // Only run in admin post/page creation and edit screens |
140 | - if ( in_array( $screen->parent_file, $shortcode_button_pages ) |
|
141 | - && apply_filters( 'give_shortcode_button_condition', true ) |
|
142 | - && ! empty( self::$shortcodes ) |
|
140 | + if (in_array($screen->parent_file, $shortcode_button_pages) |
|
141 | + && apply_filters('give_shortcode_button_condition', true) |
|
142 | + && ! empty(self::$shortcodes) |
|
143 | 143 | ) { |
144 | 144 | |
145 | 145 | $shortcodes = array(); |
146 | 146 | |
147 | - foreach ( self::$shortcodes as $shortcode => $values ) { |
|
147 | + foreach (self::$shortcodes as $shortcode => $values) { |
|
148 | 148 | |
149 | 149 | /** |
150 | 150 | * Filters the condition for including the current shortcode |
151 | 151 | * |
152 | 152 | * @since 1.0 |
153 | 153 | */ |
154 | - if ( apply_filters( sanitize_title( $shortcode ) . '_condition', true ) ) { |
|
154 | + if (apply_filters(sanitize_title($shortcode).'_condition', true)) { |
|
155 | 155 | |
156 | - $shortcodes[ $shortcode ] = sprintf( |
|
156 | + $shortcodes[$shortcode] = sprintf( |
|
157 | 157 | '<div class="sc-shortcode mce-menu-item give-shortcode-item-%1$s" data-shortcode="%s">%s</div>', |
158 | 158 | $shortcode, |
159 | 159 | $values['label'], |
@@ -162,37 +162,37 @@ discard block |
||
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - if ( ! empty( $shortcodes ) ) { |
|
165 | + if ( ! empty($shortcodes)) { |
|
166 | 166 | |
167 | 167 | // check current WP version |
168 | - $img = ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) ) |
|
169 | - ? '<img src="' . GIVE_PLUGIN_URL . 'assets/images/give-media.png" />' |
|
170 | - : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons( 'give_grey' ) . ');"></span>'; |
|
168 | + $img = (version_compare(get_bloginfo('version'), '3.5', '<')) |
|
169 | + ? '<img src="'.GIVE_PLUGIN_URL.'assets/images/give-media.png" />' |
|
170 | + : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url('.give_svg_icons('give_grey').');"></span>'; |
|
171 | 171 | |
172 | - reset( $shortcodes ); |
|
172 | + reset($shortcodes); |
|
173 | 173 | |
174 | - if ( count( $shortcodes ) == 1 ) { |
|
174 | + if (count($shortcodes) == 1) { |
|
175 | 175 | |
176 | - $shortcode = key( $shortcodes ); |
|
176 | + $shortcode = key($shortcodes); |
|
177 | 177 | |
178 | 178 | printf( |
179 | 179 | '<button class="button sc-shortcode" data-shortcode="%s">%s</button>', |
180 | 180 | $shortcode, |
181 | - sprintf( '%s %s %s', |
|
181 | + sprintf('%s %s %s', |
|
182 | 182 | $img, |
183 | - esc_html__( 'Insert', 'give' ), |
|
184 | - self::$shortcodes[ $shortcode ]['label'] |
|
183 | + esc_html__('Insert', 'give'), |
|
184 | + self::$shortcodes[$shortcode]['label'] |
|
185 | 185 | ) |
186 | 186 | ); |
187 | 187 | } else { |
188 | 188 | printf( |
189 | - '<div class="sc-wrap">' . |
|
190 | - '<button class="button sc-button">%s %s</button>' . |
|
191 | - '<div class="sc-menu mce-menu">%s</div>' . |
|
189 | + '<div class="sc-wrap">'. |
|
190 | + '<button class="button sc-button">%s %s</button>'. |
|
191 | + '<div class="sc-menu mce-menu">%s</div>'. |
|
192 | 192 | '</div>', |
193 | 193 | $img, |
194 | - esc_html__( 'Give Shortcodes', 'give' ), |
|
195 | - implode( '', array_values( $shortcodes ) ) |
|
194 | + esc_html__('Give Shortcodes', 'give'), |
|
195 | + implode('', array_values($shortcodes)) |
|
196 | 196 | ); |
197 | 197 | } |
198 | 198 | } |
@@ -208,15 +208,15 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function shortcode_ajax() { |
210 | 210 | |
211 | - $shortcode = isset( $_POST['shortcode'] ) ? $_POST['shortcode'] : false; |
|
211 | + $shortcode = isset($_POST['shortcode']) ? $_POST['shortcode'] : false; |
|
212 | 212 | $response = false; |
213 | 213 | |
214 | - if ( $shortcode && array_key_exists( $shortcode, self::$shortcodes ) ) { |
|
214 | + if ($shortcode && array_key_exists($shortcode, self::$shortcodes)) { |
|
215 | 215 | |
216 | - $data = self::$shortcodes[ $shortcode ]; |
|
216 | + $data = self::$shortcodes[$shortcode]; |
|
217 | 217 | |
218 | - if ( ! empty( $data['errors'] ) ) { |
|
219 | - $data['btn_okay'] = array( esc_html__( 'Okay', 'give' ) ); |
|
218 | + if ( ! empty($data['errors'])) { |
|
219 | + $data['btn_okay'] = array(esc_html__('Okay', 'give')); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | $response = array( |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | ); |
229 | 229 | } else { |
230 | 230 | // todo: handle error |
231 | - error_log( print_r( 'AJAX error!', 1 ) ); |
|
231 | + error_log(print_r('AJAX error!', 1)); |
|
232 | 232 | } |
233 | 233 | |
234 | - wp_send_json( $response ); |
|
234 | + wp_send_json($response); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 |
@@ -138,8 +138,8 @@ |
||
138 | 138 | |
139 | 139 | // Only run in admin post/page creation and edit screens |
140 | 140 | if ( in_array( $screen->parent_file, $shortcode_button_pages ) |
141 | - && apply_filters( 'give_shortcode_button_condition', true ) |
|
142 | - && ! empty( self::$shortcodes ) |
|
141 | + && apply_filters( 'give_shortcode_button_condition', true ) |
|
142 | + && ! empty( self::$shortcodes ) |
|
143 | 143 | ) { |
144 | 144 | |
145 | 145 | $shortcodes = array(); |
@@ -464,7 +464,7 @@ |
||
464 | 464 | * |
465 | 465 | * @param WP_Post $payment |
466 | 466 | * |
467 | - * @return mixed |
|
467 | + * @return false|null |
|
468 | 468 | */ |
469 | 469 | function give_offline_payment_receipt_after( $payment ) { |
470 | 470 | // Get payment object. |
@@ -249,10 +249,10 @@ |
||
249 | 249 | $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
250 | 250 | |
251 | 251 | $admin_message .= sprintf( |
252 | - '<a href="%1$s">%2$s</a>', |
|
253 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
254 | - __( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
255 | - ) . "\n\n"; |
|
252 | + '<a href="%1$s">%2$s</a>', |
|
253 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
254 | + __( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
255 | + ) . "\n\n"; |
|
256 | 256 | |
257 | 257 | $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
258 | 258 | $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | // Get offline payment instruction. |
45 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
45 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
46 | 46 | |
47 | 47 | ob_start(); |
48 | 48 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param int $form_id Give form id. |
55 | 55 | */ |
56 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
56 | + do_action('give_before_offline_info_fields', $form_id); |
|
57 | 57 | ?> |
58 | 58 | <fieldset id="give_offline_payment_info"> |
59 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
59 | + <?php echo stripslashes($offline_instructions); ?> |
|
60 | 60 | </fieldset> |
61 | 61 | <?php |
62 | 62 | /** |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $form_id Give form id. |
68 | 68 | */ |
69 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
69 | + do_action('give_after_offline_info_fields', $form_id); |
|
70 | 70 | |
71 | 71 | echo ob_get_clean(); |
72 | 72 | } |
73 | 73 | |
74 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
74 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Give Offline Billing Field |
78 | 78 | * |
79 | 79 | * @param $form_id |
80 | 80 | */ |
81 | -function give_offline_billing_fields( $form_id ) { |
|
81 | +function give_offline_billing_fields($form_id) { |
|
82 | 82 | //Enable Default CC fields (billing info) |
83 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
84 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
83 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
84 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
85 | 85 | |
86 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
86 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
87 | 87 | |
88 | 88 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
89 | 89 | if ( |
90 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
91 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
90 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
91 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
92 | 92 | ) { |
93 | - give_default_cc_address_fields( $form_id ); |
|
93 | + give_default_cc_address_fields($form_id); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
97 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Process the payment |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return void |
107 | 107 | */ |
108 | -function give_offline_process_payment( $purchase_data ) { |
|
108 | +function give_offline_process_payment($purchase_data) { |
|
109 | 109 | |
110 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
110 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
111 | 111 | |
112 | 112 | // setup the payment details |
113 | 113 | $payment_data = array( |
114 | 114 | 'price' => $purchase_data['price'], |
115 | 115 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
116 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
117 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
116 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
117 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
118 | 118 | 'date' => $purchase_data['date'], |
119 | 119 | 'user_email' => $purchase_data['user_email'], |
120 | 120 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -126,20 +126,20 @@ discard block |
||
126 | 126 | |
127 | 127 | |
128 | 128 | // record the pending payment |
129 | - $payment = give_insert_payment( $payment_data ); |
|
129 | + $payment = give_insert_payment($payment_data); |
|
130 | 130 | |
131 | - if ( $payment ) { |
|
132 | - give_offline_send_admin_notice( $payment ); |
|
133 | - give_offline_send_donor_instructions( $payment ); |
|
131 | + if ($payment) { |
|
132 | + give_offline_send_admin_notice($payment); |
|
133 | + give_offline_send_donor_instructions($payment); |
|
134 | 134 | give_send_to_success_page(); |
135 | 135 | } else { |
136 | 136 | // if errors are present, send the user back to the donation form so they can be corrected |
137 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
137 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
142 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
143 | 143 | |
144 | 144 | |
145 | 145 | /** |
@@ -152,59 +152,59 @@ discard block |
||
152 | 152 | * @since 1.0 |
153 | 153 | * @return void |
154 | 154 | */ |
155 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
155 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
156 | 156 | |
157 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
158 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
157 | + $payment_data = give_get_payment_meta($payment_id); |
|
158 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
159 | 159 | |
160 | 160 | //Customize email content depending on whether the single form has been customized |
161 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
161 | + $email_content = give_get_option('global_offline_donation_email'); |
|
162 | 162 | |
163 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
164 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
163 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
164 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
165 | 165 | } |
166 | 166 | |
167 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
167 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Filters the from name. |
171 | 171 | * |
172 | 172 | * @since 1.7 |
173 | 173 | */ |
174 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
174 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
175 | 175 | |
176 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
176 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Filters the from email. |
180 | 180 | * |
181 | 181 | * @since 1.7 |
182 | 182 | */ |
183 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
183 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
184 | 184 | |
185 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
185 | + $to_email = give_get_payment_user_email($payment_id); |
|
186 | 186 | |
187 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
188 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
189 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
187 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
188 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
189 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
190 | 190 | } |
191 | 191 | |
192 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
193 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
192 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
193 | + $subject = give_do_email_tags($subject, $payment_id); |
|
194 | 194 | |
195 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
196 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
195 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
196 | + $message = give_do_email_tags($email_content, $payment_id); |
|
197 | 197 | |
198 | 198 | $emails = Give()->emails; |
199 | 199 | |
200 | - $emails->__set( 'from_name', $from_name ); |
|
201 | - $emails->__set( 'from_email', $from_email ); |
|
202 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
200 | + $emails->__set('from_name', $from_name); |
|
201 | + $emails->__set('from_email', $from_email); |
|
202 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
203 | 203 | |
204 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
205 | - $emails->__set( 'headers', $headers ); |
|
204 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
205 | + $emails->__set('headers', $headers); |
|
206 | 206 | |
207 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
207 | + $emails->send($to_email, $subject, $message, $attachments); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,52 +221,52 @@ discard block |
||
221 | 221 | * @return void |
222 | 222 | * |
223 | 223 | */ |
224 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
224 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
225 | 225 | |
226 | 226 | /* Send an email notification to the admin */ |
227 | 227 | $admin_email = give_get_admin_notice_emails(); |
228 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
228 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
229 | 229 | |
230 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
231 | - $user_data = get_userdata( $user_info['id'] ); |
|
230 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
231 | + $user_data = get_userdata($user_info['id']); |
|
232 | 232 | $name = $user_data->display_name; |
233 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
234 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
233 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
234 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
235 | 235 | } else { |
236 | 236 | $name = $user_info['email']; |
237 | 237 | } |
238 | 238 | |
239 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
239 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
240 | 240 | |
241 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
241 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
242 | 242 | |
243 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
244 | - $admin_message .= __( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' '; |
|
245 | - $admin_message .= __( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
243 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
244 | + $admin_message .= __('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' '; |
|
245 | + $admin_message .= __('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
246 | 246 | |
247 | 247 | |
248 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
249 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
248 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
249 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
250 | 250 | |
251 | 251 | $admin_message .= sprintf( |
252 | 252 | '<a href="%1$s">%2$s</a>', |
253 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
254 | - __( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
255 | - ) . "\n\n"; |
|
253 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
254 | + __('Click Here to View and/or Update Donation Details', 'give') |
|
255 | + )."\n\n"; |
|
256 | 256 | |
257 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
258 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
257 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
258 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
259 | 259 | |
260 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
261 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
260 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
261 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
262 | 262 | |
263 | 263 | //Send Email |
264 | 264 | $emails = Give()->emails; |
265 | - if ( ! empty( $admin_headers ) ) { |
|
266 | - $emails->__set( 'headers', $admin_headers ); |
|
265 | + if ( ! empty($admin_headers)) { |
|
266 | + $emails->__set('headers', $admin_headers); |
|
267 | 267 | } |
268 | 268 | |
269 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
269 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
@@ -278,20 +278,20 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return array |
280 | 280 | */ |
281 | -function give_offline_add_settings( $settings ) { |
|
281 | +function give_offline_add_settings($settings) { |
|
282 | 282 | |
283 | 283 | // Bailout: Do not show offline gateways setting in to metabox if its disabled globally. |
284 | - if ( in_array( 'offline', give_get_option( 'gateways' ) ) ) { |
|
284 | + if (in_array('offline', give_get_option('gateways'))) { |
|
285 | 285 | return $settings; |
286 | 286 | } |
287 | 287 | |
288 | 288 | //Vars |
289 | 289 | $prefix = '_give_'; |
290 | 290 | |
291 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
291 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
292 | 292 | |
293 | 293 | //this gateway isn't active |
294 | - if ( ! $is_gateway_active ) { |
|
294 | + if ( ! $is_gateway_active) { |
|
295 | 295 | //return settings and bounce |
296 | 296 | return $settings; |
297 | 297 | } |
@@ -300,34 +300,34 @@ discard block |
||
300 | 300 | $check_settings = array( |
301 | 301 | |
302 | 302 | array( |
303 | - 'name' => __( 'Offline Donations', 'give' ), |
|
304 | - 'desc' => __( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
305 | - 'id' => $prefix . 'customize_offline_donations', |
|
303 | + 'name' => __('Offline Donations', 'give'), |
|
304 | + 'desc' => __('Do you want to customize the donation instructions for this form?', 'give'), |
|
305 | + 'id' => $prefix.'customize_offline_donations', |
|
306 | 306 | 'type' => 'radio_inline', |
307 | 307 | 'default' => 'global', |
308 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
309 | - 'global' => __( 'Global Option', 'give' ), |
|
310 | - 'enabled' => __( 'Customize', 'give' ), |
|
311 | - 'disabled' => __( 'Disable', 'give' ), |
|
308 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
309 | + 'global' => __('Global Option', 'give'), |
|
310 | + 'enabled' => __('Customize', 'give'), |
|
311 | + 'disabled' => __('Disable', 'give'), |
|
312 | 312 | ) |
313 | 313 | ), |
314 | 314 | ), |
315 | 315 | array( |
316 | - 'name' => __( 'Billing Fields', 'give' ), |
|
317 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
318 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
316 | + 'name' => __('Billing Fields', 'give'), |
|
317 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
318 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
319 | 319 | 'row_classes' => 'give-subfield', |
320 | 320 | 'type' => 'radio_inline', |
321 | 321 | 'default' => 'disabled', |
322 | 322 | 'options' => array( |
323 | - 'enabled' => __( 'Enabled', 'give' ), |
|
324 | - 'disabled' => __( 'Disabled', 'give' ), |
|
323 | + 'enabled' => __('Enabled', 'give'), |
|
324 | + 'disabled' => __('Disabled', 'give'), |
|
325 | 325 | ), |
326 | 326 | ), |
327 | 327 | array( |
328 | - 'id' => $prefix . 'offline_checkout_notes', |
|
329 | - 'name' => __( 'Donation Instructions', 'give' ), |
|
330 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
328 | + 'id' => $prefix.'offline_checkout_notes', |
|
329 | + 'name' => __('Donation Instructions', 'give'), |
|
330 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
331 | 331 | 'default' => give_get_default_offline_donation_content(), |
332 | 332 | 'type' => 'wysiwyg', |
333 | 333 | 'row_classes' => 'give-subfield', |
@@ -336,17 +336,17 @@ discard block |
||
336 | 336 | ) |
337 | 337 | ), |
338 | 338 | array( |
339 | - 'id' => $prefix . 'offline_donation_subject', |
|
340 | - 'name' => __( 'Email Subject', 'give' ), |
|
341 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
342 | - 'default' => __( '{form_title} - Offline Donation Instructions', 'give' ), |
|
339 | + 'id' => $prefix.'offline_donation_subject', |
|
340 | + 'name' => __('Email Subject', 'give'), |
|
341 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
342 | + 'default' => __('{form_title} - Offline Donation Instructions', 'give'), |
|
343 | 343 | 'row_classes' => 'give-subfield', |
344 | 344 | 'type' => 'text' |
345 | 345 | ), |
346 | 346 | array( |
347 | - 'id' => $prefix . 'offline_donation_email', |
|
348 | - 'name' => __( 'Email Instructions', 'give' ), |
|
349 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(), |
|
347 | + 'id' => $prefix.'offline_donation_email', |
|
348 | + 'name' => __('Email Instructions', 'give'), |
|
349 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give').' '.__('Available template tags:', 'give').give_get_emails_tags_list(), |
|
350 | 350 | 'default' => give_get_default_offline_donation_email_content(), |
351 | 351 | 'type' => 'wysiwyg', |
352 | 352 | 'row_classes' => 'give-subfield', |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | 'name' => 'offline_docs', |
359 | 359 | 'type' => 'docs_link', |
360 | 360 | 'url' => 'http://docs.givewp.com/settings-gateway-offline-donations', |
361 | - 'title' => __( 'Offline Donations', 'give' ), |
|
361 | + 'title' => __('Offline Donations', 'give'), |
|
362 | 362 | ), |
363 | 363 | ); |
364 | 364 | |
365 | - return array_merge( $settings, $check_settings ); |
|
365 | + return array_merge($settings, $check_settings); |
|
366 | 366 | } |
367 | 367 | |
368 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
368 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
369 | 369 | |
370 | 370 | |
371 | 371 | /** |
@@ -377,32 +377,32 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function give_get_default_offline_donation_content() { |
379 | 379 | |
380 | - $sitename = get_bloginfo( 'sitename' ); |
|
380 | + $sitename = get_bloginfo('sitename'); |
|
381 | 381 | |
382 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
382 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
383 | 383 | $default_text .= '<ol>'; |
384 | 384 | $default_text .= '<li>'; |
385 | 385 | $default_text .= sprintf( |
386 | 386 | /* translators: %s: site name */ |
387 | - __( 'Make a check payable to "%s"', 'give' ), |
|
387 | + __('Make a check payable to "%s"', 'give'), |
|
388 | 388 | $sitename |
389 | 389 | ); |
390 | 390 | $default_text .= '</li>'; |
391 | 391 | $default_text .= '<li>'; |
392 | 392 | $default_text .= sprintf( |
393 | 393 | /* translators: %s: site name */ |
394 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
394 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
395 | 395 | $sitename |
396 | 396 | ); |
397 | 397 | $default_text .= '</li>'; |
398 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
398 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
399 | 399 | $default_text .= '</ol>'; |
400 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
400 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
401 | 401 | $default_text .= ' <em>123 G Street </em><br>'; |
402 | 402 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
403 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
403 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
404 | 404 | |
405 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
405 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | |
@@ -415,34 +415,34 @@ discard block |
||
415 | 415 | */ |
416 | 416 | function give_get_default_offline_donation_email_content() { |
417 | 417 | |
418 | - $sitename = get_bloginfo( 'sitename' ); |
|
419 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
420 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
418 | + $sitename = get_bloginfo('sitename'); |
|
419 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
420 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
421 | 421 | $default_text .= '<ol>'; |
422 | 422 | $default_text .= '<li>'; |
423 | 423 | $default_text .= sprintf( |
424 | 424 | /* translators: %s: site name */ |
425 | - __( 'Make a check payable to "%s"', 'give' ), |
|
425 | + __('Make a check payable to "%s"', 'give'), |
|
426 | 426 | $sitename |
427 | 427 | ); |
428 | 428 | $default_text .= '</li>'; |
429 | 429 | $default_text .= '<li>'; |
430 | 430 | $default_text .= sprintf( |
431 | 431 | /* translators: %s: site name */ |
432 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
432 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
433 | 433 | $sitename |
434 | 434 | ); |
435 | 435 | $default_text .= '</li>'; |
436 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
436 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
437 | 437 | $default_text .= '</ol>'; |
438 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
438 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
439 | 439 | $default_text .= ' <em>123 G Street </em><br>'; |
440 | 440 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
441 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
442 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
443 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
441 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
442 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
443 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
444 | 444 | |
445 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
445 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -456,17 +456,17 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @return string |
458 | 458 | */ |
459 | -function give_offline_donation_receipt_status_notice( $notice, $id ) { |
|
460 | - $payment = new Give_Payment( $id ); |
|
459 | +function give_offline_donation_receipt_status_notice($notice, $id) { |
|
460 | + $payment = new Give_Payment($id); |
|
461 | 461 | |
462 | - if ( 'offline' !== $payment->gateway || $payment->is_completed() ) { |
|
462 | + if ('offline' !== $payment->gateway || $payment->is_completed()) { |
|
463 | 463 | return $notice; |
464 | 464 | } |
465 | 465 | |
466 | - return give_output_error( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' ); |
|
466 | + return give_output_error(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning'); |
|
467 | 467 | } |
468 | 468 | |
469 | -add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 ); |
|
469 | +add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2); |
|
470 | 470 | |
471 | 471 | /** |
472 | 472 | * Add offline payment instruction on payment receipt. |
@@ -477,26 +477,26 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return mixed |
479 | 479 | */ |
480 | -function give_offline_payment_receipt_after( $payment ) { |
|
480 | +function give_offline_payment_receipt_after($payment) { |
|
481 | 481 | // Get payment object. |
482 | - $payment = new Give_Payment( $payment->ID ); |
|
482 | + $payment = new Give_Payment($payment->ID); |
|
483 | 483 | |
484 | 484 | // Bailout. |
485 | - if ( 'offline' !== $payment->gateway ) { |
|
485 | + if ('offline' !== $payment->gateway) { |
|
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | |
489 | 489 | ?> |
490 | 490 | <tr> |
491 | - <td scope="row"><strong><?php esc_html_e( 'Offline Payment Instruction:', 'give' ); ?></strong></td> |
|
491 | + <td scope="row"><strong><?php esc_html_e('Offline Payment Instruction:', 'give'); ?></strong></td> |
|
492 | 492 | <td> |
493 | - <?php echo give_get_offline_payment_instruction( $payment->form_id, true ); ?> |
|
493 | + <?php echo give_get_offline_payment_instruction($payment->form_id, true); ?> |
|
494 | 494 | </td> |
495 | 495 | </tr> |
496 | 496 | <?php |
497 | 497 | } |
498 | 498 | |
499 | -add_filter( 'give_payment_receipt_after', 'give_offline_payment_receipt_after' ); |
|
499 | +add_filter('give_payment_receipt_after', 'give_offline_payment_receipt_after'); |
|
500 | 500 | |
501 | 501 | /** |
502 | 502 | * Get offline payment instructions. |
@@ -508,27 +508,27 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string |
510 | 510 | */ |
511 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
511 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
512 | 512 | // Bailout. |
513 | - if ( ! $form_id ) { |
|
513 | + if ( ! $form_id) { |
|
514 | 514 | return ''; |
515 | 515 | } |
516 | 516 | |
517 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
518 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
519 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
517 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
518 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
519 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
520 | 520 | $offline_instructions = $global_offline_instruction; |
521 | 521 | |
522 | - if ( give_is_setting_enabled( $post_offline_customization_option ) ) { |
|
522 | + if (give_is_setting_enabled($post_offline_customization_option)) { |
|
523 | 523 | $offline_instructions = $post_offline_instructions; |
524 | 524 | } |
525 | 525 | |
526 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
526 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
527 | 527 | |
528 | 528 | /* translators: %s: form settings url */ |
529 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
529 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
530 | 530 | |
531 | - return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions ); |
|
531 | + return ($wpautop ? wpautop($offline_instructions) : $offline_instructions); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
@@ -542,24 +542,24 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @return array |
544 | 544 | */ |
545 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
545 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
546 | 546 | if ( |
547 | 547 | // Show offline payment gateway if enable for new donation form. |
548 | - ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) |
|
548 | + (false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) |
|
549 | 549 | && $form_id |
550 | - && ! give_is_setting_enabled( get_post_meta( $form_id, '_give_customize_offline_donations', true ), array( |
|
550 | + && ! give_is_setting_enabled(get_post_meta($form_id, '_give_customize_offline_donations', true), array( |
|
551 | 551 | 'enabled', |
552 | 552 | 'global', |
553 | - ) ) |
|
553 | + )) |
|
554 | 554 | ) { |
555 | - unset( $gateway_list['offline'] ); |
|
555 | + unset($gateway_list['offline']); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | // Output. |
559 | 559 | return $gateway_list; |
560 | 560 | } |
561 | 561 | |
562 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
562 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
563 | 563 | |
564 | 564 | /** |
565 | 565 | * Set default gateway to global default payment gateway |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | * |
574 | 574 | * @return void |
575 | 575 | */ |
576 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
577 | - if ( ! give_is_setting_enabled( $meta_value ) && ( 'offline' === get_post_meta( $postid, '_give_default_gateway', true ) ) ) { |
|
578 | - update_post_meta( $postid, '_give_default_gateway', 'global' ); |
|
576 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
577 | + if ( ! give_is_setting_enabled($meta_value) && ('offline' === get_post_meta($postid, '_give_default_gateway', true))) { |
|
578 | + update_post_meta($postid, '_give_default_gateway', 'global'); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
582 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |