@@ -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_Import' ) ) { |
|
16 | +if ( ! class_exists('Give_Settings_Import')) { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Import. |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function __construct() { |
47 | 47 | $this->id = 'import'; |
48 | - $this->label = __( 'Import', 'give' ); |
|
48 | + $this->label = __('Import', 'give'); |
|
49 | 49 | |
50 | 50 | parent::__construct(); |
51 | 51 | |
52 | 52 | // Will display html of the import donation. |
53 | - add_action( 'give_admin_field_tools_import', array( |
|
53 | + add_action('give_admin_field_tools_import', array( |
|
54 | 54 | 'Give_Settings_Import', |
55 | 55 | 'render_import_field', |
56 | - ), 10, 2 ); |
|
56 | + ), 10, 2); |
|
57 | 57 | |
58 | 58 | // Do not use main form for this tab. |
59 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
60 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
61 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
59 | + if (give_get_current_setting_tab() === $this->id) { |
|
60 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
61 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
62 | 62 | |
63 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/import/class-give-import-donations.php'; |
|
64 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/import/class-give-import-core-settings.php'; |
|
63 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/import/class-give-import-donations.php'; |
|
64 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/import/class-give-import-core-settings.php'; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param array $settings |
81 | 81 | */ |
82 | 82 | $settings = apply_filters( |
83 | - 'give_get_settings_' . $this->id, |
|
83 | + 'give_get_settings_'.$this->id, |
|
84 | 84 | array( |
85 | 85 | array( |
86 | 86 | 'id' => 'give_tools_import', |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | ), |
90 | 90 | array( |
91 | 91 | 'id' => 'import', |
92 | - 'name' => __( 'Import', 'give' ), |
|
92 | + 'name' => __('Import', 'give'), |
|
93 | 93 | 'type' => 'tools_import', |
94 | 94 | ), |
95 | 95 | array( |
96 | - 'name' => esc_html__( 'Import Docs Link', 'give' ), |
|
96 | + 'name' => esc_html__('Import Docs Link', 'give'), |
|
97 | 97 | 'id' => 'import_docs_link', |
98 | - 'url' => esc_url( 'http://docs.givewp.com/tools-importer' ), |
|
99 | - 'title' => __( 'Import Tab', 'give' ), |
|
98 | + 'url' => esc_url('http://docs.givewp.com/tools-importer'), |
|
99 | + 'title' => __('Import Tab', 'give'), |
|
100 | 100 | 'type' => 'give_docs_link', |
101 | 101 | ), |
102 | 102 | array( |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param $field |
121 | 121 | * @param $option_value |
122 | 122 | */ |
123 | - public static function render_import_field( $field, $option_value ) { |
|
124 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-imports.php'; |
|
123 | + public static function render_import_field($field, $option_value) { |
|
124 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-imports.php'; |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Admin View: Imports |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if ( ! defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } ?> |
9 | 9 | |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @since 1.8.14 |
20 | 20 | */ |
21 | - do_action( 'give_tools_tab_import_content_top' ); |
|
21 | + do_action('give_tools_tab_import_content_top'); |
|
22 | 22 | ?> |
23 | 23 | |
24 | 24 | <table class="widefat Import-options-table give-table"> |
25 | 25 | <thead> |
26 | 26 | <tr> |
27 | - <th scope="col"><?php esc_html_e( 'Import Type', 'give' ); ?></th> |
|
28 | - <th scope="col"><?php esc_html_e( 'Import Options', 'give' ); ?></th> |
|
27 | + <th scope="col"><?php esc_html_e('Import Type', 'give'); ?></th> |
|
28 | + <th scope="col"><?php esc_html_e('Import Options', 'give'); ?></th> |
|
29 | 29 | </tr> |
30 | 30 | </thead> |
31 | 31 | <tbody> |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @since 1.8.14 |
40 | 40 | */ |
41 | - do_action( 'give_tools_tab_import_table_top' ); |
|
41 | + do_action('give_tools_tab_import_table_top'); |
|
42 | 42 | ?> |
43 | 43 | |
44 | 44 | <tr class="give-Import-pdf-sales-earnings"> |
45 | 45 | <td scope="row" class="row-title"> |
46 | 46 | <h3> |
47 | - <span><?php esc_html_e( 'Import Donations', 'give' ); ?></span> |
|
47 | + <span><?php esc_html_e('Import Donations', 'give'); ?></span> |
|
48 | 48 | </h3> |
49 | - <p><?php esc_html_e( 'Import a CSV of Donations.', 'give' ); ?></p> |
|
49 | + <p><?php esc_html_e('Import a CSV of Donations.', 'give'); ?></p> |
|
50 | 50 | </td> |
51 | 51 | <td> |
52 | - <a class="button" href="<?php echo add_query_arg( array( 'importer-type' => 'import_donations' ) ); ?>"> |
|
53 | - <?php esc_html_e( 'Import CSV', 'give' ); ?> |
|
52 | + <a class="button" href="<?php echo add_query_arg(array('importer-type' => 'import_donations')); ?>"> |
|
53 | + <?php esc_html_e('Import CSV', 'give'); ?> |
|
54 | 54 | </a> |
55 | 55 | </td> |
56 | 56 | </tr> |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | <tr class="give-import-core-settings"> |
59 | 59 | <td scope="row" class="row-title"> |
60 | 60 | <h3> |
61 | - <span><?php esc_html_e( 'Import Give Settings', 'give' ); ?></span> |
|
61 | + <span><?php esc_html_e('Import Give Settings', 'give'); ?></span> |
|
62 | 62 | </h3> |
63 | - <p><?php esc_html_e( 'Import Give\'s settings in JSON format.', 'give' ); ?></p> |
|
63 | + <p><?php esc_html_e('Import Give\'s settings in JSON format.', 'give'); ?></p> |
|
64 | 64 | </td> |
65 | 65 | <td> |
66 | - <a class="button" href="<?php echo add_query_arg( array( 'importer-type' => 'import_core_setting' ) ); ?>"> |
|
67 | - <?php esc_html_e( 'Import JSON', 'give' ); ?> |
|
66 | + <a class="button" href="<?php echo add_query_arg(array('importer-type' => 'import_core_setting')); ?>"> |
|
67 | + <?php esc_html_e('Import JSON', 'give'); ?> |
|
68 | 68 | </a> |
69 | 69 | </td> |
70 | 70 | </tr> |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @since 1.8.14 |
80 | 80 | */ |
81 | - do_action( 'give_tools_tab_import_table_bottom' ); |
|
81 | + do_action('give_tools_tab_import_table_bottom'); |
|
82 | 82 | ?> |
83 | 83 | </tbody> |
84 | 84 | </table> |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @since 1.8.14 |
91 | 91 | */ |
92 | - do_action( 'give_tools_tab_import_content_bottom' ); |
|
92 | + do_action('give_tools_tab_import_content_bottom'); |
|
93 | 93 | ?> |
94 | 94 | |
95 | 95 | </div> |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | * Admin View: Import Core Settings |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if ( ! defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
10 | -if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
10 | +if ( ! current_user_can('manage_give_settings')) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
@@ -16,11 +16,11 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @since 1.8.17 |
18 | 18 | */ |
19 | -do_action( 'give_tools_import_core_settings_main_before' ); |
|
19 | +do_action('give_tools_import_core_settings_main_before'); |
|
20 | 20 | ?> |
21 | 21 | <div id="poststuff"> |
22 | 22 | <div class="postbox"> |
23 | - <h1 class="give-importer-h1" align="center"><?php esc_html_e( 'Import Settings', 'give' ); ?></h1> |
|
23 | + <h1 class="give-importer-h1" align="center"><?php esc_html_e('Import Settings', 'give'); ?></h1> |
|
24 | 24 | <div class="inside give-tools-setting-page-import give-import-core-settings"> |
25 | 25 | <?php |
26 | 26 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @since 1.8.17 |
30 | 30 | */ |
31 | - do_action( 'give_tools_import_core_settings_form_before_start' ); |
|
31 | + do_action('give_tools_import_core_settings_form_before_start'); |
|
32 | 32 | ?> |
33 | 33 | <form method="post" id="give-import-core-settings-form" |
34 | 34 | class="give-import-form tools-setting-page-import tools-setting-page-import" |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @since 1.8.17 |
42 | 42 | */ |
43 | - do_action( 'give_tools_import_core_settings_form_start' ); |
|
43 | + do_action('give_tools_import_core_settings_form_start'); |
|
44 | 44 | ?> |
45 | 45 | |
46 | 46 | <?php |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @since 1.8.17 |
51 | 51 | */ |
52 | - do_action( 'give_tools_import_core_settings_form_end' ); |
|
52 | + do_action('give_tools_import_core_settings_form_end'); |
|
53 | 53 | ?> |
54 | 54 | </form> |
55 | 55 | <?php |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @since 1.8.17 |
60 | 60 | */ |
61 | - do_action( 'give_tools_import_core_settings_form_after_end' ); |
|
61 | + do_action('give_tools_import_core_settings_form_after_end'); |
|
62 | 62 | ?> |
63 | 63 | </div><!-- .inside --> |
64 | 64 | </div><!-- .postbox --> |
@@ -69,4 +69,4 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @since 1.8.17 |
71 | 71 | */ |
72 | -do_action( 'give_tools_import_core_settings_main_after' ); |
|
72 | +do_action('give_tools_import_core_settings_main_after'); |
@@ -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_System_Info' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_System_Info')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_System_Info. |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | 36 | $this->id = 'system-info'; |
37 | - $this->label = esc_html__( 'System Info', 'give' ); |
|
37 | + $this->label = esc_html__('System Info', 'give'); |
|
38 | 38 | |
39 | 39 | parent::__construct(); |
40 | 40 | |
41 | 41 | // Do not use main form for this tab. |
42 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
43 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
44 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
42 | + if (give_get_current_setting_tab() === $this->id) { |
|
43 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
44 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function output() { |
55 | 55 | $GLOBALS['give_hide_save_button'] = true; |
56 | - include_once( 'views/html-admin-page-system-info.php' ); |
|
56 | + include_once('views/html-admin-page-system-info.php'); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | |
110 | 110 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
111 | 111 | if ( isset( $_POST['akismet_spam_protection'] ) |
112 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
113 | - && ! give_check_akismet_key() |
|
112 | + && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
113 | + && ! give_check_akismet_key() |
|
114 | 114 | ) { |
115 | 115 | self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
116 | 116 | |
@@ -792,9 +792,9 @@ discard block |
||
792 | 792 | <td class="give-docs-link" colspan="2"> |
793 | 793 | <?php |
794 | 794 | echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
795 | - . '" target="_blank">' |
|
796 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
797 | - . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
795 | + . '" target="_blank">' |
|
796 | + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
797 | + . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
798 | 798 | ?> |
799 | 799 | </td> |
800 | 800 | </tr><?php |
@@ -465,9 +465,12 @@ discard block |
||
465 | 465 | <?php endforeach; ?> |
466 | 466 | <a href="#" data-id="<?php echo $value['id']; ?>" |
467 | 467 | class="give-repeat-setting-field button-secondary"><?php echo $value['repeat_btn_title']; ?></a> |
468 | - <?php else : ?> |
|
468 | + <?php else { |
|
469 | + : ?> |
|
469 | 470 | <input |
470 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
471 | + name="<?php echo esc_attr( $value['id'] ); |
|
472 | +} |
|
473 | +?>" |
|
471 | 474 | id="<?php echo esc_attr( $value['id'] ); ?>" |
472 | 475 | type="<?php echo esc_attr( $type ); ?>" |
473 | 476 | style="<?php echo esc_attr( $value['css'] ); ?>" |
@@ -533,7 +536,10 @@ discard block |
||
533 | 536 | </th> |
534 | 537 | <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
535 | 538 | <select |
536 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>" |
|
539 | + name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
540 | + echo '[]'; |
|
541 | +} |
|
542 | +?>" |
|
537 | 543 | id="<?php echo esc_attr( $value['id'] ); ?>" |
538 | 544 | style="<?php echo esc_attr( $value['css'] ); ?>" |
539 | 545 | class="<?php echo esc_attr( $value['class'] ); ?>" |
@@ -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; |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param array $settings Array of settings class object. |
74 | 74 | */ |
75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
76 | 76 | |
77 | 77 | return self::$settings; |
78 | 78 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return bool |
87 | 87 | */ |
88 | 88 | public static function verify_nonce() { |
89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
90 | 90 | return false; |
91 | 91 | } |
92 | 92 | |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | public static function save() { |
103 | 103 | $current_tab = give_get_current_setting_tab(); |
104 | 104 | |
105 | - if ( ! self::verify_nonce() ) { |
|
106 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
105 | + if ( ! self::verify_nonce()) { |
|
106 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
107 | 107 | die(); |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
111 | - if ( isset( $_POST['akismet_spam_protection'] ) |
|
112 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
111 | + if (isset($_POST['akismet_spam_protection']) |
|
112 | + && give_is_setting_enabled($_POST['akismet_spam_protection']) |
|
113 | 113 | && ! give_check_akismet_key() |
114 | 114 | ) { |
115 | - self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
|
115 | + self::add_error('give-akismet-protection', __('Please properly configure Akismet to enable SPAM protection.', 'give')); |
|
116 | 116 | |
117 | 117 | return; |
118 | 118 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @since 1.8 |
128 | 128 | */ |
129 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
129 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
130 | 130 | |
131 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
131 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * Trigger Action. |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @since 1.8 |
141 | 141 | */ |
142 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
142 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return void |
154 | 154 | */ |
155 | - public static function add_message( $code, $message ) { |
|
156 | - self::$messages[ $code ] = $message; |
|
155 | + public static function add_message($code, $message) { |
|
156 | + self::$messages[$code] = $message; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public static function add_error( $code, $message ) { |
|
170 | - self::$errors[ $code ] = $message; |
|
169 | + public static function add_error($code, $message) { |
|
170 | + self::$errors[$code] = $message; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | $notice_html = ''; |
181 | 181 | $classes = 'give-notice settings-error notice is-dismissible'; |
182 | 182 | |
183 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
184 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
183 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
184 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
185 | 185 | |
186 | - if ( 0 < count( self::$errors ) ) { |
|
187 | - foreach ( self::$errors as $code => $message ) { |
|
186 | + if (0 < count(self::$errors)) { |
|
187 | + foreach (self::$errors as $code => $message) { |
|
188 | 188 | $notice_html .= sprintf( |
189 | 189 | '<div id="setting-error-%1$s" class="%2$s error" style="display: none"><p><strong>%3$s</strong></p></div>', |
190 | 190 | $code, |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | - if ( 0 < count( self::$messages ) ) { |
|
198 | - foreach ( self::$messages as $code => $message ) { |
|
197 | + if (0 < count(self::$messages)) { |
|
198 | + foreach (self::$messages as $code => $message) { |
|
199 | 199 | $notice_html .= sprintf( |
200 | 200 | '<div id="setting-error-%1$s" class="%2$s updated" style="display: none"><p><strong>%3$s</strong></p></div>', |
201 | 201 | $code, |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | self::$setting_filter_prefix = give_get_current_setting_page(); |
222 | 222 | |
223 | 223 | // Bailout: Exit if setting page is not defined. |
224 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
224 | + if (empty(self::$setting_filter_prefix)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @since 1.8 |
236 | 236 | */ |
237 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
237 | + do_action(self::$setting_filter_prefix.'_start'); |
|
238 | 238 | |
239 | 239 | $current_tab = give_get_current_setting_tab(); |
240 | 240 | |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | /* @var object $current_setting_obj */ |
245 | 245 | $current_setting_obj = new StdClass; |
246 | 246 | |
247 | - foreach ( $all_setting as $setting ) { |
|
247 | + foreach ($all_setting as $setting) { |
|
248 | 248 | if ( |
249 | - method_exists( $setting, 'get_id' ) && |
|
249 | + method_exists($setting, 'get_id') && |
|
250 | 250 | $current_tab === $setting->get_id() |
251 | 251 | ) { |
252 | 252 | $current_setting_obj = $setting; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } |
256 | 256 | |
257 | 257 | // Save settings if data has been posted. |
258 | - if ( ! empty( $_POST ) ) { |
|
258 | + if ( ! empty($_POST)) { |
|
259 | 259 | self::save(); |
260 | 260 | } |
261 | 261 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @since 1.8 |
270 | 270 | */ |
271 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
271 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
272 | 272 | |
273 | 273 | include 'views/html-admin-settings.php'; |
274 | 274 | |
@@ -286,25 +286,25 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @return string|bool |
288 | 288 | */ |
289 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
289 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
290 | 290 | // Bailout. |
291 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
291 | + if (empty($option_name) && empty($field_id)) { |
|
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | |
295 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
295 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
296 | 296 | // Get field value if any. |
297 | - $option_value = get_option( $option_name ); |
|
297 | + $option_value = get_option($option_name); |
|
298 | 298 | |
299 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
300 | - ? $option_value[ $field_id ] |
|
299 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
300 | + ? $option_value[$field_id] |
|
301 | 301 | : $default; |
302 | 302 | } else { |
303 | 303 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
304 | 304 | $option_name = ! $option_name ? $field_id : $option_name; |
305 | 305 | |
306 | 306 | // Get option value if any. |
307 | - $option_value = get_option( $option_name, $default ); |
|
307 | + $option_value = get_option($option_name, $default); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | return $option_value; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @return void |
325 | 325 | */ |
326 | - public static function output_fields( $options, $option_name = '' ) { |
|
326 | + public static function output_fields($options, $option_name = '') { |
|
327 | 327 | $current_tab = give_get_current_setting_tab(); |
328 | 328 | |
329 | 329 | // Field Default values. |
@@ -335,62 +335,62 @@ discard block |
||
335 | 335 | 'desc' => '', |
336 | 336 | 'table_html' => true, |
337 | 337 | 'repeat' => false, |
338 | - 'repeat_btn_title' => __( 'Add Field', 'give' ), |
|
338 | + 'repeat_btn_title' => __('Add Field', 'give'), |
|
339 | 339 | ); |
340 | 340 | |
341 | - foreach ( $options as $value ) { |
|
342 | - if ( ! isset( $value['type'] ) ) { |
|
341 | + foreach ($options as $value) { |
|
342 | + if ( ! isset($value['type'])) { |
|
343 | 343 | continue; |
344 | 344 | } |
345 | 345 | |
346 | 346 | // Set title. |
347 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
347 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
348 | 348 | |
349 | 349 | // Set default setting. |
350 | - $value = wp_parse_args( $value, $defaults ); |
|
350 | + $value = wp_parse_args($value, $defaults); |
|
351 | 351 | |
352 | 352 | // Colorpicker field. |
353 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
354 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
353 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
354 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
355 | 355 | |
356 | 356 | |
357 | 357 | // Custom attribute handling. |
358 | 358 | $custom_attributes = array(); |
359 | 359 | |
360 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
361 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
362 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
360 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
361 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
362 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
366 | 366 | // Description handling. |
367 | - $description = self::get_field_description( $value ); |
|
367 | + $description = self::get_field_description($value); |
|
368 | 368 | |
369 | 369 | // Switch based on type. |
370 | - switch ( $value['type'] ) { |
|
370 | + switch ($value['type']) { |
|
371 | 371 | |
372 | 372 | // Section Titles |
373 | 373 | case 'title': |
374 | - if ( ! empty( $value['title'] ) || ! empty( $value['desc'] ) ) { |
|
374 | + if ( ! empty($value['title']) || ! empty($value['desc'])) { |
|
375 | 375 | ?> |
376 | 376 | <div class="give-setting-tab-header give-setting-tab-header-<?php echo $current_tab; ?>"> |
377 | - <?php if ( ! empty( $value['title'] ) ) : ?> |
|
378 | - <h2><?php echo self::get_field_title( $value ); ?></h2> |
|
377 | + <?php if ( ! empty($value['title'])) : ?> |
|
378 | + <h2><?php echo self::get_field_title($value); ?></h2> |
|
379 | 379 | <hr> |
380 | 380 | <?php endif; ?> |
381 | 381 | |
382 | - <?php if ( ! empty( $value['desc'] ) ) : ?> |
|
383 | - <?php echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); ?> |
|
382 | + <?php if ( ! empty($value['desc'])) : ?> |
|
383 | + <?php echo wpautop(wptexturize(wp_kses_post($value['desc']))); ?> |
|
384 | 384 | <?php endif; ?> |
385 | 385 | </div> |
386 | 386 | <?php |
387 | 387 | } |
388 | 388 | |
389 | - if ( $value['table_html'] ) { |
|
390 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
389 | + if ($value['table_html']) { |
|
390 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
391 | 391 | } |
392 | 392 | |
393 | - if ( ! empty( $value['id'] ) ) { |
|
393 | + if ( ! empty($value['id'])) { |
|
394 | 394 | |
395 | 395 | /** |
396 | 396 | * Trigger Action. |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @since 1.8 |
401 | 401 | */ |
402 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
402 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | break; |
406 | 406 | |
407 | 407 | // Section Ends. |
408 | 408 | case 'sectionend': |
409 | - if ( ! empty( $value['id'] ) ) { |
|
409 | + if ( ! empty($value['id'])) { |
|
410 | 410 | |
411 | 411 | /** |
412 | 412 | * Trigger Action. |
@@ -415,14 +415,14 @@ discard block |
||
415 | 415 | * |
416 | 416 | * @since 1.8 |
417 | 417 | */ |
418 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
418 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
419 | 419 | } |
420 | 420 | |
421 | - if ( $value['table_html'] ) { |
|
421 | + if ($value['table_html']) { |
|
422 | 422 | echo '</table>'; |
423 | 423 | } |
424 | 424 | |
425 | - if ( ! empty( $value['id'] ) ) { |
|
425 | + if ( ! empty($value['id'])) { |
|
426 | 426 | |
427 | 427 | /** |
428 | 428 | * Trigger Action. |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @since 1.8 |
433 | 433 | */ |
434 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
434 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | break; |
@@ -439,51 +439,51 @@ discard block |
||
439 | 439 | // Standard text inputs and subtypes like 'number'. |
440 | 440 | case 'colorpicker': |
441 | 441 | case 'hidden' : |
442 | - $value['wrapper_class'] = empty( $value['wrapper_class'] ) ? 'give-hidden' : trim( $value['wrapper_class'] ) . ' give-hidden'; |
|
442 | + $value['wrapper_class'] = empty($value['wrapper_class']) ? 'give-hidden' : trim($value['wrapper_class']).' give-hidden'; |
|
443 | 443 | case 'text': |
444 | 444 | case 'email': |
445 | 445 | case 'number': |
446 | 446 | case 'password' : |
447 | 447 | $type = $value['type']; |
448 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
448 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
449 | 449 | |
450 | 450 | // Set default value for repeater field if not any value set yet. |
451 | - if ( $value['repeat'] && is_string( $option_value ) ) { |
|
452 | - $option_value = array( $value['default'] ); |
|
451 | + if ($value['repeat'] && is_string($option_value)) { |
|
452 | + $option_value = array($value['default']); |
|
453 | 453 | } |
454 | 454 | ?> |
455 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
455 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
456 | 456 | <th scope="row" class="titledesc"> |
457 | 457 | <label |
458 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
458 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
459 | 459 | </th> |
460 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
461 | - <?php if ( $value['repeat'] ) : ?> |
|
462 | - <?php foreach ( $option_value as $index => $field_value ) : ?> |
|
460 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
461 | + <?php if ($value['repeat']) : ?> |
|
462 | + <?php foreach ($option_value as $index => $field_value) : ?> |
|
463 | 463 | <p> |
464 | 464 | <input |
465 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
466 | - type="<?php echo esc_attr( $type ); ?>" |
|
467 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
468 | - value="<?php echo esc_attr( $field_value ); ?>" |
|
469 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?> <?php echo esc_attr( $value['id'] ); ?>" |
|
470 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
465 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
466 | + type="<?php echo esc_attr($type); ?>" |
|
467 | + style="<?php echo esc_attr($value['css']); ?>" |
|
468 | + value="<?php echo esc_attr($field_value); ?>" |
|
469 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?> <?php echo esc_attr($value['id']); ?>" |
|
470 | + <?php echo implode(' ', $custom_attributes); ?> |
|
471 | 471 | /> |
472 | 472 | <span class="give-remove-setting-field" |
473 | - title="<?php esc_html_e( 'Remove setting field', 'give' ); ?>">-</span> |
|
473 | + title="<?php esc_html_e('Remove setting field', 'give'); ?>">-</span> |
|
474 | 474 | </p> |
475 | 475 | <?php endforeach; ?> |
476 | 476 | <a href="#" data-id="<?php echo $value['id']; ?>" |
477 | 477 | class="give-repeat-setting-field button-secondary"><?php echo $value['repeat_btn_title']; ?></a> |
478 | 478 | <?php else : ?> |
479 | 479 | <input |
480 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
481 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
482 | - type="<?php echo esc_attr( $type ); ?>" |
|
483 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
484 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
485 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
486 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
480 | + name="<?php echo esc_attr($value['id']); ?>" |
|
481 | + id="<?php echo esc_attr($value['id']); ?>" |
|
482 | + type="<?php echo esc_attr($type); ?>" |
|
483 | + style="<?php echo esc_attr($value['css']); ?>" |
|
484 | + value="<?php echo esc_attr($option_value); ?>" |
|
485 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
486 | + <?php echo implode(' ', $custom_attributes); ?> |
|
487 | 487 | /> |
488 | 488 | <?php endif; ?> |
489 | 489 | <?php echo $description; ?> |
@@ -494,24 +494,24 @@ discard block |
||
494 | 494 | // Textarea. |
495 | 495 | case 'textarea': |
496 | 496 | |
497 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
497 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
498 | 498 | |
499 | 499 | ?> |
500 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
500 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
501 | 501 | <th scope="row" class="titledesc"> |
502 | 502 | <label |
503 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
503 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
504 | 504 | </th> |
505 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
505 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
506 | 506 | <textarea |
507 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
508 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
509 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
510 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
507 | + name="<?php echo esc_attr($value['id']); ?>" |
|
508 | + id="<?php echo esc_attr($value['id']); ?>" |
|
509 | + style="<?php echo esc_attr($value['css']); ?>" |
|
510 | + class="<?php echo esc_attr($value['class']); ?>" |
|
511 | 511 | rows="10" |
512 | 512 | cols="60" |
513 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
514 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
513 | + <?php echo implode(' ', $custom_attributes); ?> |
|
514 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
515 | 515 | <?php echo $description; ?> |
516 | 516 | </td> |
517 | 517 | </tr><?php |
@@ -520,47 +520,47 @@ discard block |
||
520 | 520 | // Select boxes. |
521 | 521 | case 'select' : |
522 | 522 | case 'multiselect' : |
523 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
523 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
524 | 524 | |
525 | 525 | /** |
526 | 526 | * insert page in option if missing. |
527 | 527 | * |
528 | 528 | * check success_page setting in general settings. |
529 | 529 | */ |
530 | - if( |
|
531 | - isset( $value['attributes' ] ) && |
|
532 | - false !== strpos( $value['class'], 'give-select-chosen' ) && |
|
533 | - in_array( 'data-search-type', array_keys( $value['attributes' ] ) ) && |
|
534 | - 'pages' == $value['attributes' ]['data-search-type'] && |
|
535 | - ! in_array( $option_value, array_keys( $value['options'] ) ) |
|
530 | + if ( |
|
531 | + isset($value['attributes']) && |
|
532 | + false !== strpos($value['class'], 'give-select-chosen') && |
|
533 | + in_array('data-search-type', array_keys($value['attributes'])) && |
|
534 | + 'pages' == $value['attributes']['data-search-type'] && |
|
535 | + ! in_array($option_value, array_keys($value['options'])) |
|
536 | 536 | ) { |
537 | - $value['options'][$option_value] = get_the_title( $option_value ); |
|
537 | + $value['options'][$option_value] = get_the_title($option_value); |
|
538 | 538 | } |
539 | 539 | ?> |
540 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
540 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
541 | 541 | <th scope="row" class="titledesc"> |
542 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
542 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
543 | 543 | </th> |
544 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
544 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
545 | 545 | <select |
546 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>" |
|
547 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
548 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
549 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
550 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
551 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
546 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') echo '[]'; ?>" |
|
547 | + id="<?php echo esc_attr($value['id']); ?>" |
|
548 | + style="<?php echo esc_attr($value['css']); ?>" |
|
549 | + class="<?php echo esc_attr($value['class']); ?>" |
|
550 | + <?php echo implode(' ', $custom_attributes); ?> |
|
551 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
552 | 552 | > |
553 | 553 | |
554 | 554 | <?php |
555 | - if ( ! empty( $value['options'] ) ) { |
|
556 | - foreach ( $value['options'] as $key => $val ) { |
|
555 | + if ( ! empty($value['options'])) { |
|
556 | + foreach ($value['options'] as $key => $val) { |
|
557 | 557 | ?> |
558 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
558 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
559 | 559 | |
560 | - if ( is_array( $option_value ) ) { |
|
561 | - selected( in_array( $key, $option_value ), true ); |
|
560 | + if (is_array($option_value)) { |
|
561 | + selected(in_array($key, $option_value), true); |
|
562 | 562 | } else { |
563 | - selected( $option_value, $key ); |
|
563 | + selected($option_value, $key); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | ?>><?php echo $val ?></option> |
@@ -576,29 +576,29 @@ discard block |
||
576 | 576 | |
577 | 577 | // Radio inputs. |
578 | 578 | case 'radio_inline' : |
579 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
579 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
580 | 580 | case 'radio' : |
581 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
581 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
582 | 582 | ?> |
583 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
583 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
584 | 584 | <th scope="row" class="titledesc"> |
585 | 585 | <label |
586 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
586 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
587 | 587 | </th> |
588 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
588 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
589 | 589 | <fieldset> |
590 | 590 | <ul> |
591 | 591 | <?php |
592 | - foreach ( $value['options'] as $key => $val ) { |
|
592 | + foreach ($value['options'] as $key => $val) { |
|
593 | 593 | ?> |
594 | 594 | <li> |
595 | 595 | <label><input |
596 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
596 | + name="<?php echo esc_attr($value['id']); ?>" |
|
597 | 597 | value="<?php echo $key; ?>" |
598 | 598 | type="radio" |
599 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
600 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
601 | - <?php checked( $key, $option_value ); ?> |
|
599 | + style="<?php echo esc_attr($value['css']); ?>" |
|
600 | + <?php echo implode(' ', $custom_attributes); ?> |
|
601 | + <?php checked($key, $option_value); ?> |
|
602 | 602 | /> <?php echo $val ?></label> |
603 | 603 | </li> |
604 | 604 | <?php |
@@ -612,22 +612,22 @@ discard block |
||
612 | 612 | |
613 | 613 | // Checkbox input. |
614 | 614 | case 'checkbox' : |
615 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
615 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
616 | 616 | ?> |
617 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
617 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
618 | 618 | <th scope="row" class="titledesc"> |
619 | 619 | <label |
620 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
620 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
621 | 621 | </th> |
622 | 622 | <td class="give-forminp"> |
623 | 623 | <input |
624 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
625 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
624 | + name="<?php echo esc_attr($value['id']); ?>" |
|
625 | + id="<?php echo esc_attr($value['id']); ?>" |
|
626 | 626 | type="checkbox" |
627 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
627 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
628 | 628 | value="1" |
629 | - <?php checked( $option_value, 'on' ); ?> |
|
630 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
629 | + <?php checked($option_value, 'on'); ?> |
|
630 | + <?php echo implode(' ', $custom_attributes); ?> |
|
631 | 631 | /> |
632 | 632 | <?php echo $description; ?> |
633 | 633 | </td> |
@@ -637,29 +637,29 @@ discard block |
||
637 | 637 | |
638 | 638 | // Multi Checkbox input. |
639 | 639 | case 'multicheck' : |
640 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
641 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
640 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
641 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
642 | 642 | ?> |
643 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
643 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
644 | 644 | <th scope="row" class="titledesc"> |
645 | 645 | <label |
646 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
646 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
647 | 647 | </th> |
648 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
648 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
649 | 649 | <fieldset> |
650 | 650 | <ul> |
651 | 651 | <?php |
652 | - foreach ( $value['options'] as $key => $val ) { |
|
652 | + foreach ($value['options'] as $key => $val) { |
|
653 | 653 | ?> |
654 | 654 | <li> |
655 | 655 | <label> |
656 | 656 | <input |
657 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
657 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
658 | 658 | value="<?php echo $key; ?>" |
659 | 659 | type="checkbox" |
660 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
661 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
662 | - <?php if ( in_array( $key, $option_value ) ) { |
|
660 | + style="<?php echo esc_attr($value['css']); ?>" |
|
661 | + <?php echo implode(' ', $custom_attributes); ?> |
|
662 | + <?php if (in_array($key, $option_value)) { |
|
663 | 663 | echo 'checked="checked"'; |
664 | 664 | } ?> |
665 | 665 | /> <?php echo $val ?> |
@@ -678,31 +678,31 @@ discard block |
||
678 | 678 | // File input field. |
679 | 679 | case 'file' : |
680 | 680 | case 'media' : |
681 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
682 | - $button_label = sprintf( __( 'Add or Upload %s', 'give' ), ( 'file' === $value['type'] ? __( 'File', 'give' ) : __( 'Image', 'give' ) ) ); |
|
683 | - $fvalue = empty( $value['fvalue'] ) ? 'url' : $value['fvalue']; |
|
684 | - |
|
685 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
686 | - $preview_image_src = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : ''; |
|
687 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
688 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
681 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
682 | + $button_label = sprintf(__('Add or Upload %s', 'give'), ('file' === $value['type'] ? __('File', 'give') : __('Image', 'give'))); |
|
683 | + $fvalue = empty($value['fvalue']) ? 'url' : $value['fvalue']; |
|
684 | + |
|
685 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
686 | + $preview_image_src = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : ''; |
|
687 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
688 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
689 | 689 | ?> |
690 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
690 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
691 | 691 | <th scope="row" class="titledesc"> |
692 | 692 | <label |
693 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
693 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
694 | 694 | </th> |
695 | 695 | <td class="give-forminp"> |
696 | 696 | <div class="give-field-wrap"> |
697 | 697 | <label for="<?php echo $value['id'] ?>"> |
698 | 698 | <input |
699 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
700 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
699 | + name="<?php echo esc_attr($value['id']); ?>" |
|
700 | + id="<?php echo esc_attr($value['id']); ?>" |
|
701 | 701 | type="text" |
702 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
702 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
703 | 703 | value="<?php echo $option_value; ?>" |
704 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
705 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
704 | + style="<?php echo esc_attr($value['css']); ?>" |
|
705 | + <?php echo implode(' ', $custom_attributes); ?> |
|
706 | 706 | /> <input class="give-upload-button button" type="button" |
707 | 707 | data-fvalue="<?php echo $fvalue; ?>" |
708 | 708 | data-field-type="<?php echo $value['type']; ?>" |
@@ -723,18 +723,18 @@ discard block |
||
723 | 723 | // WordPress Editor. |
724 | 724 | case 'wysiwyg' : |
725 | 725 | // Get option value. |
726 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
726 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
727 | 727 | |
728 | 728 | // Get editor settings. |
729 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
729 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
730 | 730 | ?> |
731 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
731 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
732 | 732 | <th scope="row" class="titledesc"> |
733 | 733 | <label |
734 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
734 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
735 | 735 | </th> |
736 | 736 | <td class="give-forminp"> |
737 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
737 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
738 | 738 | <?php echo $description; ?> |
739 | 739 | </td> |
740 | 740 | </tr><?php |
@@ -742,15 +742,15 @@ discard block |
||
742 | 742 | |
743 | 743 | // Custom: Default gateways setting field. |
744 | 744 | case 'default_gateway' : |
745 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
745 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
746 | 746 | ?> |
747 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
747 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
748 | 748 | <th scope="row" class="titledesc"> |
749 | 749 | <label |
750 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
750 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
751 | 751 | </th> |
752 | 752 | <td class="give-forminp"> |
753 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
753 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
754 | 754 | <?php echo $description; ?> |
755 | 755 | </td> |
756 | 756 | </tr><?php |
@@ -759,13 +759,13 @@ discard block |
||
759 | 759 | // Custom: Email preview buttons field. |
760 | 760 | case 'email_preview_buttons' : |
761 | 761 | ?> |
762 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
762 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
763 | 763 | <th scope="row" class="titledesc"> |
764 | 764 | <label |
765 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
765 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
766 | 766 | </th> |
767 | 767 | <td class="give-forminp"> |
768 | - <?php give_email_preview_buttons_callback( $value ); ?> |
|
768 | + <?php give_email_preview_buttons_callback($value); ?> |
|
769 | 769 | <?php echo $description; ?> |
770 | 770 | </td> |
771 | 771 | </tr><?php |
@@ -779,23 +779,23 @@ discard block |
||
779 | 779 | |
780 | 780 | // Custom: Gateway API key. |
781 | 781 | case 'api_key' : |
782 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
783 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
782 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
783 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
784 | 784 | ?> |
785 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
785 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
786 | 786 | <th scope="row" class="titledesc"> |
787 | 787 | <label |
788 | - for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
788 | + for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
789 | 789 | </th> |
790 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
790 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
791 | 791 | <input |
792 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
793 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
794 | - type="<?php echo esc_attr( $type ); ?>" |
|
795 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
796 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
797 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
798 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
792 | + name="<?php echo esc_attr($value['id']); ?>" |
|
793 | + id="<?php echo esc_attr($value['id']); ?>" |
|
794 | + type="<?php echo esc_attr($type); ?>" |
|
795 | + style="<?php echo esc_attr($value['css']); ?>" |
|
796 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
797 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
798 | + <?php echo implode(' ', $custom_attributes); ?> |
|
799 | 799 | /> <?php echo $description; ?> |
800 | 800 | </td> |
801 | 801 | </tr><?php |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | * |
813 | 813 | * @since 1.0 |
814 | 814 | */ |
815 | - do_action( "give_logs_view_{$current_section}" ); |
|
815 | + do_action("give_logs_view_{$current_section}"); |
|
816 | 816 | |
817 | 817 | echo $description; |
818 | 818 | break; |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | // Custom: Data field. |
821 | 821 | case 'data' : |
822 | 822 | |
823 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
823 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
824 | 824 | |
825 | 825 | echo $description; |
826 | 826 | break; |
@@ -828,12 +828,12 @@ discard block |
||
828 | 828 | // Custom: Give Docs Link field type. |
829 | 829 | case 'give_docs_link' : |
830 | 830 | ?> |
831 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
831 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
832 | 832 | <td class="give-docs-link" colspan="2"> |
833 | 833 | <?php |
834 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
834 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
835 | 835 | . '" target="_blank">' |
836 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
836 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
837 | 837 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
838 | 838 | ?> |
839 | 839 | </td> |
@@ -844,8 +844,8 @@ discard block |
||
844 | 844 | // You can add or handle your custom field action. |
845 | 845 | default: |
846 | 846 | // Get option value. |
847 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
848 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
847 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
848 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
849 | 849 | break; |
850 | 850 | } |
851 | 851 | } |
@@ -861,15 +861,15 @@ discard block |
||
861 | 861 | * |
862 | 862 | * @return string The HTML description of the field. |
863 | 863 | */ |
864 | - public static function get_field_description( $value ) { |
|
864 | + public static function get_field_description($value) { |
|
865 | 865 | $description = ''; |
866 | 866 | |
867 | 867 | // Support for both 'description' and 'desc' args. |
868 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
869 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
868 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
869 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
870 | 870 | |
871 | - if ( ! empty( $value ) ) { |
|
872 | - $description = '<div class="give-field-description">' . wp_kses_post( $value ) . '</div>'; |
|
871 | + if ( ! empty($value)) { |
|
872 | + $description = '<div class="give-field-description">'.wp_kses_post($value).'</div>'; |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | return $description; |
@@ -886,11 +886,11 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return array The description and tip as a 2 element array |
888 | 888 | */ |
889 | - public static function get_field_title( $value ) { |
|
890 | - $title = esc_html( $value['title'] ); |
|
889 | + public static function get_field_title($value) { |
|
890 | + $title = esc_html($value['title']); |
|
891 | 891 | |
892 | 892 | // If html tag detected then allow them to print. |
893 | - if ( strip_tags( $title ) ) { |
|
893 | + if (strip_tags($title)) { |
|
894 | 894 | $title = $value['title']; |
895 | 895 | } |
896 | 896 | |
@@ -909,8 +909,8 @@ discard block |
||
909 | 909 | * |
910 | 910 | * @return bool |
911 | 911 | */ |
912 | - public static function save_fields( $options, $option_name = '' ) { |
|
913 | - if ( empty( $_POST ) ) { |
|
912 | + public static function save_fields($options, $option_name = '') { |
|
913 | + if (empty($_POST)) { |
|
914 | 914 | return false; |
915 | 915 | } |
916 | 916 | |
@@ -918,37 +918,37 @@ discard block |
||
918 | 918 | $update_options = array(); |
919 | 919 | |
920 | 920 | // Loop options and get values to save. |
921 | - foreach ( $options as $option ) { |
|
922 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
921 | + foreach ($options as $option) { |
|
922 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
923 | 923 | continue; |
924 | 924 | } |
925 | 925 | |
926 | 926 | // Get posted value. |
927 | - if ( strstr( $option['id'], '[' ) ) { |
|
928 | - parse_str( $option['id'], $option_name_array ); |
|
929 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
930 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
931 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
927 | + if (strstr($option['id'], '[')) { |
|
928 | + parse_str($option['id'], $option_name_array); |
|
929 | + $field_option_name = current(array_keys($option_name_array)); |
|
930 | + $setting_name = key($option_name_array[$field_option_name]); |
|
931 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
932 | 932 | } else { |
933 | 933 | $field_option_name = $option['id']; |
934 | 934 | $setting_name = ''; |
935 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
935 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | // Format the value based on option type. |
939 | - switch ( $option['type'] ) { |
|
939 | + switch ($option['type']) { |
|
940 | 940 | case 'checkbox' : |
941 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
941 | + $value = is_null($raw_value) ? '' : 'on'; |
|
942 | 942 | break; |
943 | 943 | case 'wysiwyg' : |
944 | 944 | case 'textarea' : |
945 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
945 | + $value = wp_kses_post(trim($raw_value)); |
|
946 | 946 | break; |
947 | 947 | case 'multiselect' : |
948 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
948 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
949 | 949 | break; |
950 | 950 | default : |
951 | - $value = give_clean( $raw_value ); |
|
951 | + $value = give_clean($raw_value); |
|
952 | 952 | break; |
953 | 953 | } |
954 | 954 | |
@@ -957,37 +957,37 @@ discard block |
||
957 | 957 | * |
958 | 958 | * @since 1.8 |
959 | 959 | */ |
960 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
960 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
961 | 961 | |
962 | 962 | /** |
963 | 963 | * Sanitize the value of an option by option name. |
964 | 964 | * |
965 | 965 | * @since 1.8 |
966 | 966 | */ |
967 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
967 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
968 | 968 | |
969 | - if ( is_null( $value ) ) { |
|
969 | + if (is_null($value)) { |
|
970 | 970 | continue; |
971 | 971 | } |
972 | 972 | |
973 | 973 | // Check if option is an array and handle that differently to single values. |
974 | - if ( $field_option_name && $setting_name ) { |
|
975 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
976 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
974 | + if ($field_option_name && $setting_name) { |
|
975 | + if ( ! isset($update_options[$field_option_name])) { |
|
976 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
977 | 977 | } |
978 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
979 | - $update_options[ $field_option_name ] = array(); |
|
978 | + if ( ! is_array($update_options[$field_option_name])) { |
|
979 | + $update_options[$field_option_name] = array(); |
|
980 | 980 | } |
981 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
981 | + $update_options[$field_option_name][$setting_name] = $value; |
|
982 | 982 | } else { |
983 | - $update_options[ $field_option_name ] = $value; |
|
983 | + $update_options[$field_option_name] = $value; |
|
984 | 984 | } |
985 | 985 | } |
986 | 986 | |
987 | 987 | // Save all options in our array or there own option name i.e. option id. |
988 | - if ( empty( $option_name ) ) { |
|
989 | - foreach ( $update_options as $name => $value ) { |
|
990 | - update_option( $name, $value ); |
|
988 | + if (empty($option_name)) { |
|
989 | + foreach ($update_options as $name => $value) { |
|
990 | + update_option($name, $value); |
|
991 | 991 | |
992 | 992 | /** |
993 | 993 | * Trigger action. |
@@ -996,13 +996,13 @@ discard block |
||
996 | 996 | * |
997 | 997 | * @since 1.8 |
998 | 998 | */ |
999 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
999 | + do_action("give_save_option_{$name}", $value, $name); |
|
1000 | 1000 | } |
1001 | 1001 | } else { |
1002 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
1003 | - $update_options = array_merge( $old_options, $update_options ); |
|
1002 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
1003 | + $update_options = array_merge($old_options, $update_options); |
|
1004 | 1004 | |
1005 | - update_option( $option_name, $update_options ); |
|
1005 | + update_option($option_name, $update_options); |
|
1006 | 1006 | |
1007 | 1007 | /** |
1008 | 1008 | * Trigger action. |
@@ -1011,7 +1011,7 @@ discard block |
||
1011 | 1011 | * |
1012 | 1012 | * @since 1.8 |
1013 | 1013 | */ |
1014 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name, $old_options ); |
|
1014 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name, $old_options); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | return true; |
@@ -1040,21 +1040,21 @@ discard block |
||
1040 | 1040 | * |
1041 | 1041 | * @return bool |
1042 | 1042 | */ |
1043 | - public static function is_setting_page( $tab = '', $section = '' ) { |
|
1043 | + public static function is_setting_page($tab = '', $section = '') { |
|
1044 | 1044 | $is_setting_page = false; |
1045 | 1045 | |
1046 | - if( ! is_admin() ) { |
|
1046 | + if ( ! is_admin()) { |
|
1047 | 1047 | return $is_setting_page; |
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | // Check fo setting tab. |
1051 | - if ( ! empty( $tab ) ) { |
|
1052 | - $is_setting_page = ( $tab === give_get_current_setting_tab() ); |
|
1051 | + if ( ! empty($tab)) { |
|
1052 | + $is_setting_page = ($tab === give_get_current_setting_tab()); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | // Check fo setting section. |
1056 | - if ( ! empty( $section ) ) { |
|
1057 | - $is_setting_page = ( $section === give_get_current_setting_section() ); |
|
1056 | + if ( ! empty($section)) { |
|
1057 | + $is_setting_page = ($section === give_get_current_setting_section()); |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | return $is_setting_page; |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | 51 | 'ajax' => false // Does this table support ajax? |
52 | - ) ); |
|
52 | + )); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
68 | - $donation_list_page_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
|
67 | + public function column_default($item, $column_name) { |
|
68 | + $donation_list_page_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); |
|
69 | 69 | |
70 | - switch ( $column_name ) { |
|
70 | + switch ($column_name) { |
|
71 | 71 | case 'complete_sales': |
72 | - $value = $item[ $column_name ] ? |
|
72 | + $value = $item[$column_name] ? |
|
73 | 73 | sprintf( |
74 | 74 | '<a href="%s">%s</a>', |
75 | 75 | add_query_arg( |
@@ -79,13 +79,12 @@ discard block |
||
79 | 79 | ), |
80 | 80 | $donation_list_page_url |
81 | 81 | ), |
82 | - $item[ $column_name ] |
|
83 | - ) : |
|
84 | - $item[ $column_name ]; |
|
82 | + $item[$column_name] |
|
83 | + ) : $item[$column_name]; |
|
85 | 84 | break; |
86 | 85 | |
87 | 86 | case 'pending_sales': |
88 | - $value = $item[ $column_name ] ? |
|
87 | + $value = $item[$column_name] ? |
|
89 | 88 | sprintf( |
90 | 89 | '<a href="%s">%s</a>', |
91 | 90 | add_query_arg( |
@@ -95,13 +94,12 @@ discard block |
||
95 | 94 | ), |
96 | 95 | $donation_list_page_url |
97 | 96 | ), |
98 | - $item[ $column_name ] |
|
99 | - ) : |
|
100 | - $item[ $column_name ]; |
|
97 | + $item[$column_name] |
|
98 | + ) : $item[$column_name]; |
|
101 | 99 | break; |
102 | 100 | |
103 | 101 | case 'total_sales': |
104 | - $value = $item[ $column_name ] ? |
|
102 | + $value = $item[$column_name] ? |
|
105 | 103 | sprintf( |
106 | 104 | '<a href="%s">%s</a>', |
107 | 105 | add_query_arg( |
@@ -110,14 +108,13 @@ discard block |
||
110 | 108 | ), |
111 | 109 | $donation_list_page_url |
112 | 110 | ), |
113 | - $item[ $column_name ] |
|
114 | - ) : |
|
115 | - $item[ $column_name ]; |
|
111 | + $item[$column_name] |
|
112 | + ) : $item[$column_name]; |
|
116 | 113 | |
117 | 114 | break; |
118 | 115 | |
119 | 116 | default: |
120 | - $value = $item[ $column_name ]; |
|
117 | + $value = $item[$column_name]; |
|
121 | 118 | } |
122 | 119 | |
123 | 120 | return $value; |
@@ -132,11 +129,11 @@ discard block |
||
132 | 129 | */ |
133 | 130 | public function get_columns() { |
134 | 131 | $columns = array( |
135 | - 'label' => esc_attr__( 'Gateway', 'give' ), |
|
136 | - 'complete_sales' => esc_attr__( 'Complete Payments', 'give' ), |
|
137 | - 'pending_sales' => esc_attr__( 'Pending / Failed Payments', 'give' ), |
|
138 | - 'total_sales' => esc_attr__( 'Total Payments', 'give' ), |
|
139 | - 'total_donations' => esc_attr__( 'Total Donated', 'give' ) |
|
132 | + 'label' => esc_attr__('Gateway', 'give'), |
|
133 | + 'complete_sales' => esc_attr__('Complete Payments', 'give'), |
|
134 | + 'pending_sales' => esc_attr__('Pending / Failed Payments', 'give'), |
|
135 | + 'total_sales' => esc_attr__('Total Payments', 'give'), |
|
136 | + 'total_donations' => esc_attr__('Total Donated', 'give') |
|
140 | 137 | ); |
141 | 138 | |
142 | 139 | return $columns; |
@@ -151,7 +148,7 @@ discard block |
||
151 | 148 | */ |
152 | 149 | public function get_sortable_columns() { |
153 | 150 | return array( |
154 | - 'total_donations' => array( 'total_donations', false ) |
|
151 | + 'total_donations' => array('total_donations', false) |
|
155 | 152 | ); |
156 | 153 | } |
157 | 154 | |
@@ -164,7 +161,7 @@ discard block |
||
164 | 161 | * @return int Current page number |
165 | 162 | */ |
166 | 163 | public function get_paged() { |
167 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
164 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
168 | 165 | } |
169 | 166 | |
170 | 167 | |
@@ -175,7 +172,7 @@ discard block |
||
175 | 172 | * @since 1.0 |
176 | 173 | * @return void |
177 | 174 | */ |
178 | - public function bulk_actions( $which = '' ) { |
|
175 | + public function bulk_actions($which = '') { |
|
179 | 176 | |
180 | 177 | } |
181 | 178 | |
@@ -187,27 +184,27 @@ discard block |
||
187 | 184 | * |
188 | 185 | * @param string $which |
189 | 186 | */ |
190 | - protected function display_tablenav( $which ) { |
|
187 | + protected function display_tablenav($which) { |
|
191 | 188 | |
192 | - if ( 'top' === $which ) { |
|
193 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
189 | + if ('top' === $which) { |
|
190 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
194 | 191 | } |
195 | 192 | ?> |
196 | - <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
193 | + <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
197 | 194 | |
198 | - <?php if ( 'top' === $which ) { ?> |
|
195 | + <?php if ('top' === $which) { ?> |
|
199 | 196 | <h2 class="alignleft reports-earnings-title screen-reader-text"> |
200 | - <?php _e( 'Donation Methods Report', 'give' ); ?> |
|
197 | + <?php _e('Donation Methods Report', 'give'); ?> |
|
201 | 198 | </h2> |
202 | 199 | <?php } ?> |
203 | 200 | |
204 | 201 | <div class="alignright tablenav-right"> |
205 | 202 | <div class="actions bulkactions"> |
206 | - <?php $this->bulk_actions( $which ); ?> |
|
203 | + <?php $this->bulk_actions($which); ?> |
|
207 | 204 | </div> |
208 | 205 | <?php |
209 | - $this->extra_tablenav( $which ); |
|
210 | - $this->pagination( $which ); |
|
206 | + $this->extra_tablenav($which); |
|
207 | + $this->pagination($which); |
|
211 | 208 | ?> |
212 | 209 | </div> |
213 | 210 | |
@@ -229,17 +226,17 @@ discard block |
||
229 | 226 | * |
230 | 227 | * @return int |
231 | 228 | */ |
232 | - public function give_sort_total_donations( $old_value, $new_value ) { |
|
229 | + public function give_sort_total_donations($old_value, $new_value) { |
|
233 | 230 | // If no sort, default to label. |
234 | - $orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'label'; |
|
231 | + $orderby = ( ! empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'label'; |
|
235 | 232 | |
236 | 233 | //If no order, default to asc. |
237 | - $order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc'; |
|
234 | + $order = ( ! empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc'; |
|
238 | 235 | |
239 | 236 | //Determine sort order. |
240 | - $result = strcmp( $old_value[ $orderby ], $new_value[ $orderby ] ); |
|
237 | + $result = strcmp($old_value[$orderby], $new_value[$orderby]); |
|
241 | 238 | |
242 | - return ( $order === 'asc' ) ? $result : -$result; |
|
239 | + return ($order === 'asc') ? $result : -$result; |
|
243 | 240 | } |
244 | 241 | |
245 | 242 | |
@@ -256,10 +253,10 @@ discard block |
||
256 | 253 | $gateways = give_get_payment_gateways(); |
257 | 254 | $stats = new Give_Payment_Stats(); |
258 | 255 | |
259 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
256 | + foreach ($gateways as $gateway_id => $gateway) { |
|
260 | 257 | |
261 | - $complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' ); |
|
262 | - $pending_count = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) ); |
|
258 | + $complete_count = give_count_sales_by_gateway($gateway_id, 'publish'); |
|
259 | + $pending_count = give_count_sales_by_gateway($gateway_id, array('pending', 'failed')); |
|
263 | 260 | |
264 | 261 | $reports_data[] = array( |
265 | 262 | 'ID' => $gateway_id, |
@@ -267,7 +264,7 @@ discard block |
||
267 | 264 | 'complete_sales' => $complete_count, |
268 | 265 | 'pending_sales' => $pending_count, |
269 | 266 | 'total_sales' => $complete_count + $pending_count, |
270 | - 'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, strtotime('04/13/2015' ), current_time('timestamp' ), $gateway_id ), array( 'sanitize' => false ) ) ), |
|
267 | + 'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, strtotime('04/13/2015'), current_time('timestamp'), $gateway_id), array('sanitize' => false))), |
|
271 | 268 | ); |
272 | 269 | } |
273 | 270 | |
@@ -288,11 +285,11 @@ discard block |
||
288 | 285 | $columns = $this->get_columns(); |
289 | 286 | $hidden = array(); // No hidden columns |
290 | 287 | $sortable = $this->get_sortable_columns(); |
291 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
288 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
292 | 289 | $this->items = $this->reports_data(); |
293 | 290 | |
294 | 291 | // Sort Array when we are sorting data in array. |
295 | - usort( $this->items, array( $this, 'give_sort_total_donations' ) ); |
|
292 | + usort($this->items, array($this, 'give_sort_total_donations')); |
|
296 | 293 | |
297 | 294 | } |
298 | 295 | } |
@@ -10,17 +10,17 @@ |
||
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 | ?> |
17 | 17 | <div class="wrap" id="poststuff"> |
18 | 18 | <div id="give-updates"> |
19 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates Complete', 'give' ); ?></h1> |
|
19 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates Complete', 'give'); ?></h1> |
|
20 | 20 | <hr class="wp-header-end"> |
21 | 21 | |
22 | 22 | <div class="give-update-panel-content"> |
23 | - <p><?php esc_html_e( 'Congratulations! You are running the latest versions of Give and its add-ons.', 'give' ); ?></p> |
|
23 | + <p><?php esc_html_e('Congratulations! You are running the latest versions of Give and its add-ons.', 'give'); ?></p> |
|
24 | 24 | </div> |
25 | 25 | |
26 | 26 | </div> |
@@ -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 | |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | give_ignore_user_abort(); |
42 | 42 | |
43 | 43 | nocache_headers(); |
44 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
45 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
46 | - header( "Expires: 0" ); |
|
44 | + header('Content-Type: text/csv; charset=utf-8'); |
|
45 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
46 | + header("Expires: 0"); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | public function csv_cols() { |
58 | 58 | |
59 | 59 | $cols = array( |
60 | - 'date' => __( 'Date', 'give' ), |
|
61 | - 'donations' => __( 'Donations', 'give' ), |
|
60 | + 'date' => __('Date', 'give'), |
|
61 | + 'donations' => __('Donations', 'give'), |
|
62 | 62 | /* translators: %s: currency */ |
63 | - 'earnings' => sprintf( __( 'Income (%s)', 'give' ), give_currency_symbol('', true) ) |
|
63 | + 'earnings' => sprintf(__('Income (%s)', 'give'), give_currency_symbol('', true)) |
|
64 | 64 | ); |
65 | 65 | |
66 | 66 | return $cols; |
@@ -75,28 +75,28 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function get_data() { |
77 | 77 | |
78 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
79 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
80 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
81 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
78 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
79 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
80 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
81 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
82 | 82 | |
83 | 83 | $data = array(); |
84 | 84 | $year = $start_year; |
85 | 85 | $stats = new Give_Payment_Stats; |
86 | 86 | |
87 | - while ( $year <= $end_year ) { |
|
87 | + while ($year <= $end_year) { |
|
88 | 88 | |
89 | - if ( $year == $start_year && $year == $end_year ) { |
|
89 | + if ($year == $start_year && $year == $end_year) { |
|
90 | 90 | |
91 | 91 | $m1 = $start_month; |
92 | 92 | $m2 = $end_month; |
93 | 93 | |
94 | - } elseif ( $year == $start_year ) { |
|
94 | + } elseif ($year == $start_year) { |
|
95 | 95 | |
96 | 96 | $m1 = $start_month; |
97 | 97 | $m2 = 12; |
98 | 98 | |
99 | - } elseif ( $year == $end_year ) { |
|
99 | + } elseif ($year == $end_year) { |
|
100 | 100 | |
101 | 101 | $m1 = 1; |
102 | 102 | $m2 = $end_month; |
@@ -108,28 +108,28 @@ discard block |
||
108 | 108 | |
109 | 109 | } |
110 | 110 | |
111 | - while ( $m1 <= $m2 ) { |
|
111 | + while ($m1 <= $m2) { |
|
112 | 112 | |
113 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
114 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
113 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
114 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
115 | 115 | |
116 | 116 | $data[] = array( |
117 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
118 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
119 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ), array( 'sanitize' => false ) ), |
|
117 | + 'date' => date_i18n('F Y', $date1), |
|
118 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
119 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2), array('sanitize' => false)), |
|
120 | 120 | ); |
121 | 121 | |
122 | - $m1 ++; |
|
122 | + $m1++; |
|
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | 126 | |
127 | - $year ++; |
|
127 | + $year++; |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
132 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
131 | + $data = apply_filters('give_export_get_data', $data); |
|
132 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
133 | 133 | |
134 | 134 | return $data; |
135 | 135 | } |
@@ -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,9 +35,9 @@ 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 ); |
|
39 | - add_filter( 'woocommerce_disable_admin_bar', array( $this, 'manage_admin_dashboard' ), 10, 1 ); |
|
40 | - add_filter( 'woocommerce_prevent_admin_access', array( $this, 'manage_admin_dashboard' ), 10 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | + add_filter('woocommerce_disable_admin_bar', array($this, 'manage_admin_dashboard'), 10, 1); |
|
40 | + add_filter('woocommerce_prevent_admin_access', array($this, 'manage_admin_dashboard'), 10); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return void |
52 | 52 | */ |
53 | 53 | public function add_roles() { |
54 | - add_role( 'give_manager', __( 'Give Manager', 'give' ), array( |
|
54 | + add_role('give_manager', __('Give Manager', 'give'), array( |
|
55 | 55 | 'read' => true, |
56 | 56 | 'edit_posts' => true, |
57 | 57 | 'delete_posts' => true, |
@@ -80,25 +80,25 @@ discard block |
||
80 | 80 | 'publish_posts' => true, |
81 | 81 | 'read_private_pages' => true, |
82 | 82 | 'read_private_posts' => true, |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | |
85 | - add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array( |
|
85 | + add_role('give_accountant', __('Give Accountant', 'give'), array( |
|
86 | 86 | 'read' => true, |
87 | 87 | 'edit_posts' => false, |
88 | 88 | 'delete_posts' => false, |
89 | - ) ); |
|
89 | + )); |
|
90 | 90 | |
91 | - add_role( 'give_worker', __( 'Give Worker', 'give' ), array( |
|
91 | + add_role('give_worker', __('Give Worker', 'give'), array( |
|
92 | 92 | 'read' => true, |
93 | 93 | 'edit_posts' => true, |
94 | 94 | 'edit_pages' => true, |
95 | 95 | 'upload_files' => true, |
96 | 96 | 'delete_posts' => false, |
97 | - ) ); |
|
97 | + )); |
|
98 | 98 | |
99 | - add_role( 'give_donor', __( 'Give Donor', 'give' ), array( |
|
99 | + add_role('give_donor', __('Give Donor', 'give'), array( |
|
100 | 100 | 'read' => true, |
101 | - ) ); |
|
101 | + )); |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
@@ -117,53 +117,53 @@ discard block |
||
117 | 117 | public function add_caps() { |
118 | 118 | global $wp_roles; |
119 | 119 | |
120 | - if ( class_exists( 'WP_Roles' ) ) { |
|
121 | - if ( ! isset( $wp_roles ) ) { |
|
120 | + if (class_exists('WP_Roles')) { |
|
121 | + if ( ! isset($wp_roles)) { |
|
122 | 122 | $wp_roles = new WP_Roles(); |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if ( is_object( $wp_roles ) ) { |
|
127 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
129 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
130 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
126 | + if (is_object($wp_roles)) { |
|
127 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
128 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
129 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
130 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
131 | 131 | |
132 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
133 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
134 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
135 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
136 | - $wp_roles->add_cap( 'administrator', 'view_give_payments' ); |
|
132 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
133 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
134 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
135 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
136 | + $wp_roles->add_cap('administrator', 'view_give_payments'); |
|
137 | 137 | |
138 | 138 | // Add the main post type capabilities. |
139 | 139 | $capabilities = $this->get_core_caps(); |
140 | - foreach ( $capabilities as $cap_group ) { |
|
141 | - foreach ( $cap_group as $cap ) { |
|
142 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
143 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
140 | + foreach ($capabilities as $cap_group) { |
|
141 | + foreach ($cap_group as $cap) { |
|
142 | + $wp_roles->add_cap('administrator', $cap); |
|
143 | + $wp_roles->add_cap('give_manager', $cap); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Add Capabilities to Give Workers User Role. |
148 | - $wp_roles->add_cap( 'give_worker', 'edit_give_payments' ); |
|
149 | - $wp_roles->add_cap( 'give_worker', 'delete_give_forms' ); |
|
150 | - $wp_roles->add_cap( 'give_worker', 'delete_others_give_forms' ); |
|
151 | - $wp_roles->add_cap( 'give_worker', 'delete_private_give_forms' ); |
|
152 | - $wp_roles->add_cap( 'give_worker', 'delete_published_give_forms' ); |
|
153 | - $wp_roles->add_cap( 'give_worker', 'edit_give_forms' ); |
|
154 | - $wp_roles->add_cap( 'give_worker', 'edit_others_give_forms' ); |
|
155 | - $wp_roles->add_cap( 'give_worker', 'edit_private_give_forms' ); |
|
156 | - $wp_roles->add_cap( 'give_worker', 'edit_published_give_forms' ); |
|
157 | - $wp_roles->add_cap( 'give_worker', 'publish_give_forms' ); |
|
158 | - $wp_roles->add_cap( 'give_worker', 'read_private_give_forms' ); |
|
148 | + $wp_roles->add_cap('give_worker', 'edit_give_payments'); |
|
149 | + $wp_roles->add_cap('give_worker', 'delete_give_forms'); |
|
150 | + $wp_roles->add_cap('give_worker', 'delete_others_give_forms'); |
|
151 | + $wp_roles->add_cap('give_worker', 'delete_private_give_forms'); |
|
152 | + $wp_roles->add_cap('give_worker', 'delete_published_give_forms'); |
|
153 | + $wp_roles->add_cap('give_worker', 'edit_give_forms'); |
|
154 | + $wp_roles->add_cap('give_worker', 'edit_others_give_forms'); |
|
155 | + $wp_roles->add_cap('give_worker', 'edit_private_give_forms'); |
|
156 | + $wp_roles->add_cap('give_worker', 'edit_published_give_forms'); |
|
157 | + $wp_roles->add_cap('give_worker', 'publish_give_forms'); |
|
158 | + $wp_roles->add_cap('give_worker', 'read_private_give_forms'); |
|
159 | 159 | |
160 | 160 | // Add Capabilities to Give Accountant User Role. |
161 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
162 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
163 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
164 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
165 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
166 | - $wp_roles->add_cap( 'give_accountant', 'view_give_payments' ); |
|
161 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
162 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
163 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
164 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
165 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
166 | + $wp_roles->add_cap('give_accountant', 'view_give_payments'); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | } |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | public function get_core_caps() { |
182 | 182 | $capabilities = array(); |
183 | 183 | |
184 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
184 | + $capability_types = array('give_form', 'give_payment'); |
|
185 | 185 | |
186 | - foreach ( $capability_types as $capability_type ) { |
|
187 | - $capabilities[ $capability_type ] = array( |
|
186 | + foreach ($capability_types as $capability_type) { |
|
187 | + $capabilities[$capability_type] = array( |
|
188 | 188 | // Post type. |
189 | 189 | "edit_{$capability_type}", |
190 | 190 | "read_{$capability_type}", |
@@ -230,22 +230,22 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return array $caps Meta capabilities. |
232 | 232 | */ |
233 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
233 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
234 | 234 | |
235 | - switch ( $cap ) { |
|
235 | + switch ($cap) { |
|
236 | 236 | |
237 | 237 | case 'view_give_form_stats' : |
238 | 238 | |
239 | - if ( empty( $args[0] ) ) { |
|
239 | + if (empty($args[0])) { |
|
240 | 240 | break; |
241 | 241 | } |
242 | 242 | |
243 | - $form = get_post( $args[0] ); |
|
244 | - if ( empty( $form ) ) { |
|
243 | + $form = get_post($args[0]); |
|
244 | + if (empty($form)) { |
|
245 | 245 | break; |
246 | 246 | } |
247 | 247 | |
248 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
248 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
249 | 249 | $caps = array(); |
250 | 250 | } |
251 | 251 | |
@@ -272,57 +272,57 @@ discard block |
||
272 | 272 | |
273 | 273 | global $wp_roles; |
274 | 274 | |
275 | - if ( class_exists( 'WP_Roles' ) ) { |
|
276 | - if ( ! isset( $wp_roles ) ) { |
|
275 | + if (class_exists('WP_Roles')) { |
|
276 | + if ( ! isset($wp_roles)) { |
|
277 | 277 | $wp_roles = new WP_Roles(); |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - if ( is_object( $wp_roles ) ) { |
|
281 | + if (is_object($wp_roles)) { |
|
282 | 282 | // Give Manager Capabilities. |
283 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
284 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
285 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
286 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
283 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
284 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
285 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
286 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
287 | 287 | |
288 | 288 | // Site Administrator Capabilities. |
289 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
290 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
291 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
292 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
293 | - $wp_roles->remove_cap( 'administrator', 'view_give_payments' ); |
|
289 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
290 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
291 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
292 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
293 | + $wp_roles->remove_cap('administrator', 'view_give_payments'); |
|
294 | 294 | |
295 | 295 | // Remove the Main Post Type Capabilities. |
296 | 296 | $capabilities = $this->get_core_caps(); |
297 | 297 | |
298 | - foreach ( $capabilities as $cap_group ) { |
|
299 | - foreach ( $cap_group as $cap ) { |
|
300 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
301 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
298 | + foreach ($capabilities as $cap_group) { |
|
299 | + foreach ($cap_group as $cap) { |
|
300 | + $wp_roles->remove_cap('give_manager', $cap); |
|
301 | + $wp_roles->remove_cap('administrator', $cap); |
|
302 | 302 | |
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | 306 | // Remove capabilities from the Give Worker role. |
307 | - $wp_roles->remove_cap( 'give_worker', 'edit_give_payments' ); |
|
308 | - $wp_roles->remove_cap( 'give_worker', 'delete_give_forms' ); |
|
309 | - $wp_roles->remove_cap( 'give_worker', 'delete_others_give_forms' ); |
|
310 | - $wp_roles->remove_cap( 'give_worker', 'delete_private_give_forms' ); |
|
311 | - $wp_roles->remove_cap( 'give_worker', 'delete_published_give_forms' ); |
|
312 | - $wp_roles->remove_cap( 'give_worker', 'edit_give_forms' ); |
|
313 | - $wp_roles->remove_cap( 'give_worker', 'edit_others_give_forms' ); |
|
314 | - $wp_roles->remove_cap( 'give_worker', 'edit_private_give_forms' ); |
|
315 | - $wp_roles->remove_cap( 'give_worker', 'edit_published_give_forms' ); |
|
316 | - $wp_roles->remove_cap( 'give_worker', 'publish_give_forms' ); |
|
317 | - $wp_roles->remove_cap( 'give_worker', 'read_private_give_forms' ); |
|
307 | + $wp_roles->remove_cap('give_worker', 'edit_give_payments'); |
|
308 | + $wp_roles->remove_cap('give_worker', 'delete_give_forms'); |
|
309 | + $wp_roles->remove_cap('give_worker', 'delete_others_give_forms'); |
|
310 | + $wp_roles->remove_cap('give_worker', 'delete_private_give_forms'); |
|
311 | + $wp_roles->remove_cap('give_worker', 'delete_published_give_forms'); |
|
312 | + $wp_roles->remove_cap('give_worker', 'edit_give_forms'); |
|
313 | + $wp_roles->remove_cap('give_worker', 'edit_others_give_forms'); |
|
314 | + $wp_roles->remove_cap('give_worker', 'edit_private_give_forms'); |
|
315 | + $wp_roles->remove_cap('give_worker', 'edit_published_give_forms'); |
|
316 | + $wp_roles->remove_cap('give_worker', 'publish_give_forms'); |
|
317 | + $wp_roles->remove_cap('give_worker', 'read_private_give_forms'); |
|
318 | 318 | |
319 | 319 | // Remove Capabilities from Give Accountant User Role. |
320 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
321 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
322 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
323 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
324 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_payments' ); |
|
325 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_payments' ); |
|
320 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
321 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
322 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
323 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
324 | + $wp_roles->remove_cap('give_accountant', 'edit_give_payments'); |
|
325 | + $wp_roles->remove_cap('give_accountant', 'view_give_payments'); |
|
326 | 326 | |
327 | 327 | } |
328 | 328 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $current_user = wp_get_current_user(); |
346 | 346 | |
347 | 347 | // If user with "Give Accountant" user role is logged-in . |
348 | - if ( 0 !== $current_user->ID && in_array( 'give_accountant', (array) $current_user->roles, true ) ) { |
|
348 | + if (0 !== $current_user->ID && in_array('give_accountant', (array) $current_user->roles, true)) { |
|
349 | 349 | |
350 | 350 | // Return false, means no prevention. |
351 | 351 | return false; |