@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,49 +23,49 @@ discard block |
||
| 23 | 23 | function give_setup_post_types() { |
| 24 | 24 | |
| 25 | 25 | // Give Forms single post and archive options. |
| 26 | - $give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) ); |
|
| 27 | - $give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) ); |
|
| 26 | + $give_forms_singular = give_is_setting_enabled(give_get_option('forms_singular')); |
|
| 27 | + $give_forms_archives = give_is_setting_enabled(give_get_option('forms_archives')); |
|
| 28 | 28 | |
| 29 | 29 | // Enable/Disable give_forms links if form is saving. |
| 30 | - if ( Give_Admin_Settings::is_saving_settings() ) { |
|
| 31 | - if ( isset( $_POST['forms_singular'] ) ) { |
|
| 32 | - $give_forms_singular = give_is_setting_enabled( give_clean( $_POST['forms_singular'] ) ); |
|
| 30 | + if (Give_Admin_Settings::is_saving_settings()) { |
|
| 31 | + if (isset($_POST['forms_singular'])) { |
|
| 32 | + $give_forms_singular = give_is_setting_enabled(give_clean($_POST['forms_singular'])); |
|
| 33 | 33 | flush_rewrite_rules(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( isset( $_POST['forms_archives'] ) ) { |
|
| 37 | - $give_forms_archives = give_is_setting_enabled( give_clean( $_POST['forms_archives'] ) ); |
|
| 36 | + if (isset($_POST['forms_archives'])) { |
|
| 37 | + $give_forms_archives = give_is_setting_enabled(give_clean($_POST['forms_archives'])); |
|
| 38 | 38 | flush_rewrite_rules(); |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
| 42 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
| 43 | 43 | // Support for old 'GIVE_FORMS_SLUG' constant |
| 44 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
| 44 | + if (defined('GIVE_FORMS_SLUG')) { |
|
| 45 | 45 | $give_forms_slug = GIVE_FORMS_SLUG; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 48 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
| 49 | 49 | 'slug' => $give_forms_slug, |
| 50 | 50 | 'with_front' => false, |
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
| 54 | - 'name' => __( 'Donation Forms', 'give' ), |
|
| 55 | - 'singular_name' => __( 'Form', 'give' ), |
|
| 56 | - 'add_new' => __( 'Add Form', 'give' ), |
|
| 57 | - 'add_new_item' => __( 'Add New Donation Form', 'give' ), |
|
| 58 | - 'edit_item' => __( 'Edit Donation Form', 'give' ), |
|
| 59 | - 'new_item' => __( 'New Form', 'give' ), |
|
| 60 | - 'all_items' => __( 'All Forms', 'give' ), |
|
| 61 | - 'view_item' => __( 'View Form', 'give' ), |
|
| 62 | - 'search_items' => __( 'Search Forms', 'give' ), |
|
| 63 | - 'not_found' => __( 'No forms found.', 'give' ), |
|
| 64 | - 'not_found_in_trash' => __( 'No forms found in Trash.', 'give' ), |
|
| 53 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
| 54 | + 'name' => __('Donation Forms', 'give'), |
|
| 55 | + 'singular_name' => __('Form', 'give'), |
|
| 56 | + 'add_new' => __('Add Form', 'give'), |
|
| 57 | + 'add_new_item' => __('Add New Donation Form', 'give'), |
|
| 58 | + 'edit_item' => __('Edit Donation Form', 'give'), |
|
| 59 | + 'new_item' => __('New Form', 'give'), |
|
| 60 | + 'all_items' => __('All Forms', 'give'), |
|
| 61 | + 'view_item' => __('View Form', 'give'), |
|
| 62 | + 'search_items' => __('Search Forms', 'give'), |
|
| 63 | + 'not_found' => __('No forms found.', 'give'), |
|
| 64 | + 'not_found_in_trash' => __('No forms found in Trash.', 'give'), |
|
| 65 | 65 | 'parent_item_colon' => '', |
| 66 | - 'menu_name' => apply_filters( 'give_menu_name', __( 'Donations', 'give' ) ), |
|
| 67 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ), |
|
| 68 | - ) ); |
|
| 66 | + 'menu_name' => apply_filters('give_menu_name', __('Donations', 'give')), |
|
| 67 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', __('Donation Form', 'give')), |
|
| 68 | + )); |
|
| 69 | 69 | |
| 70 | 70 | // Default give_forms supports. |
| 71 | 71 | $give_form_supports = array( |
@@ -77,14 +77,14 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | // Has the user disabled the excerpt? |
| 80 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) { |
|
| 81 | - unset( $give_form_supports[2] ); |
|
| 80 | + if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) { |
|
| 81 | + unset($give_form_supports[2]); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Has user disabled the featured image? |
| 85 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 86 | - unset( $give_form_supports[1] ); |
|
| 87 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
| 85 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 86 | + unset($give_form_supports[1]); |
|
| 87 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $give_forms_args = array( |
@@ -99,42 +99,42 @@ discard block |
||
| 99 | 99 | 'has_archive' => $give_forms_archives, |
| 100 | 100 | 'menu_icon' => 'dashicons-give', |
| 101 | 101 | 'hierarchical' => false, |
| 102 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
| 102 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
| 103 | 103 | ); |
| 104 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
| 104 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
| 105 | 105 | |
| 106 | 106 | /** Donation Post Type */ |
| 107 | 107 | $payment_labels = array( |
| 108 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
| 109 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
| 110 | - 'add_new' => __( 'Add New', 'give' ), |
|
| 111 | - 'add_new_item' => __( 'Add New Donation', 'give' ), |
|
| 112 | - 'edit_item' => __( 'Edit Donation', 'give' ), |
|
| 113 | - 'new_item' => __( 'New Donation', 'give' ), |
|
| 114 | - 'all_items' => __( 'All Donations', 'give' ), |
|
| 115 | - 'view_item' => __( 'View Donation', 'give' ), |
|
| 116 | - 'search_items' => __( 'Search Donations', 'give' ), |
|
| 117 | - 'not_found' => __( 'No donations found.', 'give' ), |
|
| 118 | - 'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ), |
|
| 108 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
| 109 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
| 110 | + 'add_new' => __('Add New', 'give'), |
|
| 111 | + 'add_new_item' => __('Add New Donation', 'give'), |
|
| 112 | + 'edit_item' => __('Edit Donation', 'give'), |
|
| 113 | + 'new_item' => __('New Donation', 'give'), |
|
| 114 | + 'all_items' => __('All Donations', 'give'), |
|
| 115 | + 'view_item' => __('View Donation', 'give'), |
|
| 116 | + 'search_items' => __('Search Donations', 'give'), |
|
| 117 | + 'not_found' => __('No donations found.', 'give'), |
|
| 118 | + 'not_found_in_trash' => __('No donations found in Trash.', 'give'), |
|
| 119 | 119 | 'parent_item_colon' => '', |
| 120 | - 'menu_name' => __( 'Donations', 'give' ), |
|
| 120 | + 'menu_name' => __('Donations', 'give'), |
|
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | 123 | $payment_args = array( |
| 124 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
| 124 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
| 125 | 125 | 'public' => false, |
| 126 | 126 | 'query_var' => false, |
| 127 | 127 | 'rewrite' => false, |
| 128 | 128 | 'map_meta_cap' => true, |
| 129 | 129 | 'capability_type' => 'give_payment', |
| 130 | - 'supports' => array( 'title' ), |
|
| 130 | + 'supports' => array('title'), |
|
| 131 | 131 | 'can_export' => true, |
| 132 | 132 | ); |
| 133 | - register_post_type( 'give_payment', $payment_args ); |
|
| 133 | + register_post_type('give_payment', $payment_args); |
|
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
| 137 | +add_action('init', 'give_setup_post_types', 1); |
|
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -147,30 +147,30 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function give_setup_taxonomies() { |
| 149 | 149 | |
| 150 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
| 150 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
| 151 | 151 | |
| 152 | 152 | /** Categories */ |
| 153 | 153 | $category_labels = array( |
| 154 | - 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
|
| 155 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
| 156 | - 'search_items' => __( 'Search Categories', 'give' ), |
|
| 157 | - 'all_items' => __( 'All Categories', 'give' ), |
|
| 158 | - 'parent_item' => __( 'Parent Category', 'give' ), |
|
| 159 | - 'parent_item_colon' => __( 'Parent Category:', 'give' ), |
|
| 160 | - 'edit_item' => __( 'Edit Category', 'give' ), |
|
| 161 | - 'update_item' => __( 'Update Category', 'give' ), |
|
| 162 | - 'add_new_item' => __( 'Add New Category', 'give' ), |
|
| 163 | - 'new_item_name' => __( 'New Category Name', 'give' ), |
|
| 164 | - 'menu_name' => __( 'Categories', 'give' ), |
|
| 154 | + 'name' => _x('Form Categories', 'taxonomy general name', 'give'), |
|
| 155 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
| 156 | + 'search_items' => __('Search Categories', 'give'), |
|
| 157 | + 'all_items' => __('All Categories', 'give'), |
|
| 158 | + 'parent_item' => __('Parent Category', 'give'), |
|
| 159 | + 'parent_item_colon' => __('Parent Category:', 'give'), |
|
| 160 | + 'edit_item' => __('Edit Category', 'give'), |
|
| 161 | + 'update_item' => __('Update Category', 'give'), |
|
| 162 | + 'add_new_item' => __('Add New Category', 'give'), |
|
| 163 | + 'new_item_name' => __('New Category Name', 'give'), |
|
| 164 | + 'menu_name' => __('Categories', 'give'), |
|
| 165 | 165 | ); |
| 166 | 166 | |
| 167 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
| 167 | + $category_args = apply_filters('give_forms_category_args', array( |
|
| 168 | 168 | 'hierarchical' => true, |
| 169 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
| 169 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
| 170 | 170 | 'show_ui' => true, |
| 171 | 171 | 'query_var' => 'give_forms_category', |
| 172 | 172 | 'rewrite' => array( |
| 173 | - 'slug' => $slug . '/category', |
|
| 173 | + 'slug' => $slug.'/category', |
|
| 174 | 174 | 'with_front' => false, |
| 175 | 175 | 'hierarchical' => true, |
| 176 | 176 | ), |
@@ -185,26 +185,26 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | /** Tags */ |
| 187 | 187 | $tag_labels = array( |
| 188 | - 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
|
| 189 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
| 190 | - 'search_items' => __( 'Search Tags', 'give' ), |
|
| 191 | - 'all_items' => __( 'All Tags', 'give' ), |
|
| 192 | - 'parent_item' => __( 'Parent Tag', 'give' ), |
|
| 193 | - 'parent_item_colon' => __( 'Parent Tag:', 'give' ), |
|
| 194 | - 'edit_item' => __( 'Edit Tag', 'give' ), |
|
| 195 | - 'update_item' => __( 'Update Tag', 'give' ), |
|
| 196 | - 'add_new_item' => __( 'Add New Tag', 'give' ), |
|
| 197 | - 'new_item_name' => __( 'New Tag Name', 'give' ), |
|
| 198 | - 'menu_name' => __( 'Tags', 'give' ), |
|
| 199 | - 'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ), |
|
| 188 | + 'name' => _x('Form Tags', 'taxonomy general name', 'give'), |
|
| 189 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
| 190 | + 'search_items' => __('Search Tags', 'give'), |
|
| 191 | + 'all_items' => __('All Tags', 'give'), |
|
| 192 | + 'parent_item' => __('Parent Tag', 'give'), |
|
| 193 | + 'parent_item_colon' => __('Parent Tag:', 'give'), |
|
| 194 | + 'edit_item' => __('Edit Tag', 'give'), |
|
| 195 | + 'update_item' => __('Update Tag', 'give'), |
|
| 196 | + 'add_new_item' => __('Add New Tag', 'give'), |
|
| 197 | + 'new_item_name' => __('New Tag Name', 'give'), |
|
| 198 | + 'menu_name' => __('Tags', 'give'), |
|
| 199 | + 'choose_from_most_used' => __('Choose from most used tags.', 'give'), |
|
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
| 202 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
| 203 | 203 | 'hierarchical' => false, |
| 204 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
| 204 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
| 205 | 205 | 'show_ui' => true, |
| 206 | 206 | 'query_var' => 'give_forms_tag', |
| 207 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
| 207 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
| 208 | 208 | 'capabilities' => array( |
| 209 | 209 | 'manage_terms' => 'manage_give_form_terms', |
| 210 | 210 | 'edit_terms' => 'edit_give_form_terms', |
@@ -215,36 +215,36 @@ discard block |
||
| 215 | 215 | ); |
| 216 | 216 | |
| 217 | 217 | // Does the user want category? |
| 218 | - $enable_category = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
| 218 | + $enable_category = give_is_setting_enabled(give_get_option('categories', 'disabled')); |
|
| 219 | 219 | |
| 220 | 220 | // Does the user want tag? |
| 221 | - $enable_tag = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
| 221 | + $enable_tag = give_is_setting_enabled(give_get_option('tags', 'disabled')); |
|
| 222 | 222 | |
| 223 | 223 | // Enable/Disable category and tag if form is saving. |
| 224 | - if ( Give_Admin_Settings::is_saving_settings() ) { |
|
| 225 | - if ( isset( $_POST['categories'] ) ) { |
|
| 226 | - $enable_category = give_is_setting_enabled( give_clean( $_POST['categories'] ) ); |
|
| 224 | + if (Give_Admin_Settings::is_saving_settings()) { |
|
| 225 | + if (isset($_POST['categories'])) { |
|
| 226 | + $enable_category = give_is_setting_enabled(give_clean($_POST['categories'])); |
|
| 227 | 227 | flush_rewrite_rules(); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if ( isset( $_POST['tags'] ) ) { |
|
| 231 | - $enable_tag = give_is_setting_enabled( give_clean( $_POST['tags'] ) ); |
|
| 230 | + if (isset($_POST['tags'])) { |
|
| 231 | + $enable_tag = give_is_setting_enabled(give_clean($_POST['tags'])); |
|
| 232 | 232 | flush_rewrite_rules(); |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if ( $enable_category ) { |
|
| 237 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
| 238 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
| 236 | + if ($enable_category) { |
|
| 237 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
| 238 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if ( $enable_tag ) { |
|
| 242 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
| 243 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
| 241 | + if ($enable_tag) { |
|
| 242 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
| 243 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
| 247 | +add_action('init', 'give_setup_taxonomies', 0); |
|
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | */ |
| 256 | 256 | function give_get_default_form_labels() { |
| 257 | 257 | $defaults = array( |
| 258 | - 'singular' => __( 'Form', 'give' ), |
|
| 259 | - 'plural' => __( 'Forms', 'give' ), |
|
| 258 | + 'singular' => __('Form', 'give'), |
|
| 259 | + 'plural' => __('Forms', 'give'), |
|
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
| 262 | + return apply_filters('give_default_form_name', $defaults); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | * |
| 272 | 272 | * @return string $defaults['singular'] Singular label |
| 273 | 273 | */ |
| 274 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
| 274 | +function give_get_forms_label_singular($lowercase = false) { |
|
| 275 | 275 | $defaults = give_get_default_form_labels(); |
| 276 | 276 | |
| 277 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
| 277 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | * @since 1.0 |
| 284 | 284 | * @return string $defaults['plural'] Plural label |
| 285 | 285 | */ |
| 286 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
| 286 | +function give_get_forms_label_plural($lowercase = false) { |
|
| 287 | 287 | $defaults = give_get_default_form_labels(); |
| 288 | 288 | |
| 289 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
| 289 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -298,24 +298,24 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @return string $title New placeholder text |
| 300 | 300 | */ |
| 301 | -function give_change_default_title( $title ) { |
|
| 301 | +function give_change_default_title($title) { |
|
| 302 | 302 | // If a frontend plugin uses this filter (check extensions before changing this function) |
| 303 | - if ( ! is_admin() ) { |
|
| 304 | - $title = __( 'Enter form title here', 'give' ); |
|
| 303 | + if ( ! is_admin()) { |
|
| 304 | + $title = __('Enter form title here', 'give'); |
|
| 305 | 305 | |
| 306 | 306 | return $title; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | $screen = get_current_screen(); |
| 310 | 310 | |
| 311 | - if ( 'give_forms' == $screen->post_type ) { |
|
| 312 | - $title = __( 'Enter form title here', 'give' ); |
|
| 311 | + if ('give_forms' == $screen->post_type) { |
|
| 312 | + $title = __('Enter form title here', 'give'); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | return $title; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
| 318 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * Registers Custom Post Statuses which are used by the Payments |
@@ -325,67 +325,67 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | function give_register_post_type_statuses() { |
| 327 | 327 | // Payment Statuses |
| 328 | - register_post_status( 'refunded', array( |
|
| 329 | - 'label' => __( 'Refunded', 'give' ), |
|
| 328 | + register_post_status('refunded', array( |
|
| 329 | + 'label' => __('Refunded', 'give'), |
|
| 330 | 330 | 'public' => true, |
| 331 | 331 | 'exclude_from_search' => false, |
| 332 | 332 | 'show_in_admin_all_list' => true, |
| 333 | 333 | 'show_in_admin_status_list' => true, |
| 334 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ), |
|
| 335 | - ) ); |
|
| 336 | - register_post_status( 'failed', array( |
|
| 337 | - 'label' => __( 'Failed', 'give' ), |
|
| 334 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'), |
|
| 335 | + )); |
|
| 336 | + register_post_status('failed', array( |
|
| 337 | + 'label' => __('Failed', 'give'), |
|
| 338 | 338 | 'public' => true, |
| 339 | 339 | 'exclude_from_search' => false, |
| 340 | 340 | 'show_in_admin_all_list' => true, |
| 341 | 341 | 'show_in_admin_status_list' => true, |
| 342 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ), |
|
| 343 | - ) ); |
|
| 344 | - register_post_status( 'revoked', array( |
|
| 345 | - 'label' => __( 'Revoked', 'give' ), |
|
| 342 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'), |
|
| 343 | + )); |
|
| 344 | + register_post_status('revoked', array( |
|
| 345 | + 'label' => __('Revoked', 'give'), |
|
| 346 | 346 | 'public' => true, |
| 347 | 347 | 'exclude_from_search' => false, |
| 348 | 348 | 'show_in_admin_all_list' => true, |
| 349 | 349 | 'show_in_admin_status_list' => true, |
| 350 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ), |
|
| 351 | - ) ); |
|
| 352 | - register_post_status( 'cancelled', array( |
|
| 353 | - 'label' => __( 'Cancelled', 'give' ), |
|
| 350 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'), |
|
| 351 | + )); |
|
| 352 | + register_post_status('cancelled', array( |
|
| 353 | + 'label' => __('Cancelled', 'give'), |
|
| 354 | 354 | 'public' => true, |
| 355 | 355 | 'exclude_from_search' => false, |
| 356 | 356 | 'show_in_admin_all_list' => true, |
| 357 | 357 | 'show_in_admin_status_list' => true, |
| 358 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ), |
|
| 359 | - ) ); |
|
| 360 | - register_post_status( 'abandoned', array( |
|
| 361 | - 'label' => __( 'Abandoned', 'give' ), |
|
| 358 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'), |
|
| 359 | + )); |
|
| 360 | + register_post_status('abandoned', array( |
|
| 361 | + 'label' => __('Abandoned', 'give'), |
|
| 362 | 362 | 'public' => true, |
| 363 | 363 | 'exclude_from_search' => false, |
| 364 | 364 | 'show_in_admin_all_list' => true, |
| 365 | 365 | 'show_in_admin_status_list' => true, |
| 366 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ), |
|
| 367 | - ) ); |
|
| 368 | - register_post_status( 'processing', array( |
|
| 369 | - 'label' => _x( 'Processing', 'Processing payment status', 'give' ), |
|
| 366 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'), |
|
| 367 | + )); |
|
| 368 | + register_post_status('processing', array( |
|
| 369 | + 'label' => _x('Processing', 'Processing payment status', 'give'), |
|
| 370 | 370 | 'public' => true, |
| 371 | 371 | 'exclude_from_search' => false, |
| 372 | 372 | 'show_in_admin_all_list' => true, |
| 373 | 373 | 'show_in_admin_status_list' => true, |
| 374 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' ) |
|
| 375 | - ) ); |
|
| 374 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give') |
|
| 375 | + )); |
|
| 376 | 376 | |
| 377 | - register_post_status( 'preapproval', array( |
|
| 378 | - 'label' => _x( 'Preapproval', 'Preapproval payment status', 'give' ), |
|
| 377 | + register_post_status('preapproval', array( |
|
| 378 | + 'label' => _x('Preapproval', 'Preapproval payment status', 'give'), |
|
| 379 | 379 | 'public' => true, |
| 380 | 380 | 'exclude_from_search' => false, |
| 381 | 381 | 'show_in_admin_all_list' => true, |
| 382 | 382 | 'show_in_admin_status_list' => true, |
| 383 | - 'label_count' => _n_noop( 'Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give' ), |
|
| 384 | - ) ); |
|
| 383 | + 'label_count' => _n_noop('Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give'), |
|
| 384 | + )); |
|
| 385 | 385 | |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
| 388 | +add_action('init', 'give_register_post_type_statuses'); |
|
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | 391 | * Updated Messages |
@@ -398,27 +398,27 @@ discard block |
||
| 398 | 398 | * |
| 399 | 399 | * @return array $messages New post updated messages |
| 400 | 400 | */ |
| 401 | -function give_updated_messages( $messages ) { |
|
| 401 | +function give_updated_messages($messages) { |
|
| 402 | 402 | global $post, $post_ID; |
| 403 | 403 | |
| 404 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) { |
|
| 404 | + if ( ! give_is_setting_enabled(give_get_option('forms_singular'))) { |
|
| 405 | 405 | |
| 406 | 406 | $messages['give_forms'] = array( |
| 407 | - 1 => __( 'Form updated.', 'give' ), |
|
| 408 | - 4 => __( 'Form updated.', 'give' ), |
|
| 409 | - 6 => __( 'Form published.', 'give' ), |
|
| 410 | - 7 => __( 'Form saved.', 'give' ), |
|
| 411 | - 8 => __( 'Form submitted.', 'give' ), |
|
| 407 | + 1 => __('Form updated.', 'give'), |
|
| 408 | + 4 => __('Form updated.', 'give'), |
|
| 409 | + 6 => __('Form published.', 'give'), |
|
| 410 | + 7 => __('Form saved.', 'give'), |
|
| 411 | + 8 => __('Form submitted.', 'give'), |
|
| 412 | 412 | ); |
| 413 | 413 | |
| 414 | 414 | } else { |
| 415 | 415 | |
| 416 | 416 | $messages['give_forms'] = array( |
| 417 | - 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 418 | - 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 419 | - 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 420 | - 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 421 | - 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
| 417 | + 1 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 418 | + 4 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 419 | + 6 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form published.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 420 | + 7 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form saved.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 421 | + 8 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form submitted.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
| 422 | 422 | ); |
| 423 | 423 | |
| 424 | 424 | } |
@@ -426,24 +426,24 @@ discard block |
||
| 426 | 426 | return $messages; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
| 429 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
| 430 | 430 | |
| 431 | 431 | /** |
| 432 | 432 | * Ensure post thumbnail support is turned on |
| 433 | 433 | */ |
| 434 | 434 | function give_add_thumbnail_support() { |
| 435 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 435 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 436 | 436 | return; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
| 440 | - add_theme_support( 'post-thumbnails' ); |
|
| 439 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
| 440 | + add_theme_support('post-thumbnails'); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
| 443 | + add_post_type_support('give_forms', 'thumbnail'); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
| 446 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | 449 | * Give Sidebars |
@@ -454,21 +454,21 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | // Single Give Forms (disabled if single turned off in settings) |
| 456 | 456 | if ( |
| 457 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) |
|
| 458 | - && give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) |
|
| 457 | + give_is_setting_enabled(give_get_option('forms_singular')) |
|
| 458 | + && give_is_setting_enabled(give_get_option('form_sidebar')) |
|
| 459 | 459 | ) { |
| 460 | 460 | |
| 461 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
| 462 | - 'name' => __( 'Give Single Form Sidebar', 'give' ), |
|
| 461 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
| 462 | + 'name' => __('Give Single Form Sidebar', 'give'), |
|
| 463 | 463 | 'id' => 'give-forms-sidebar', |
| 464 | - 'description' => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
| 464 | + 'description' => __('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
| 465 | 465 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
| 466 | 466 | 'after_widget' => '</div>', |
| 467 | 467 | 'before_title' => '<h3 class="widgettitle widget-title">', |
| 468 | 468 | 'after_title' => '</h3>', |
| 469 | - ) ) ); |
|
| 469 | + ))); |
|
| 470 | 470 | |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
| 474 | +add_action('widgets_init', 'give_widgets_init', 999); |
|
@@ -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 | |
@@ -24,16 +24,16 @@ discard block |
||
| 24 | 24 | // Default, built-in gateways |
| 25 | 25 | $gateways = array( |
| 26 | 26 | 'paypal' => array( |
| 27 | - 'admin_label' => __( 'PayPal Standard', 'give' ), |
|
| 28 | - 'checkout_label' => __( 'PayPal', 'give' ), |
|
| 27 | + 'admin_label' => __('PayPal Standard', 'give'), |
|
| 28 | + 'checkout_label' => __('PayPal', 'give'), |
|
| 29 | 29 | ), |
| 30 | 30 | 'manual' => array( |
| 31 | - 'admin_label' => __( 'Test Donation', 'give' ), |
|
| 32 | - 'checkout_label' => __( 'Test Donation', 'give' ) |
|
| 31 | + 'admin_label' => __('Test Donation', 'give'), |
|
| 32 | + 'checkout_label' => __('Test Donation', 'give') |
|
| 33 | 33 | ), |
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
| 36 | + return apply_filters('give_payment_gateways', $gateways); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -46,24 +46,24 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return array $gateway_list All the available gateways |
| 48 | 48 | */ |
| 49 | -function give_get_enabled_payment_gateways( $form_id = 0 ) { |
|
| 49 | +function give_get_enabled_payment_gateways($form_id = 0) { |
|
| 50 | 50 | |
| 51 | 51 | $gateways = give_get_payment_gateways(); |
| 52 | 52 | |
| 53 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
| 53 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
| 54 | 54 | |
| 55 | 55 | $gateway_list = array(); |
| 56 | 56 | |
| 57 | - foreach ( $gateways as $key => $gateway ) { |
|
| 58 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
| 59 | - $gateway_list[ $key ] = $gateway; |
|
| 57 | + foreach ($gateways as $key => $gateway) { |
|
| 58 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
| 59 | + $gateway_list[$key] = $gateway; |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Set order of payment gateway in list. |
| 64 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
| 64 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
| 65 | 65 | |
| 66 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id ); |
|
| 66 | + return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return boolean true if enabled, false otherwise |
| 77 | 77 | */ |
| 78 | -function give_is_gateway_active( $gateway ) { |
|
| 78 | +function give_is_gateway_active($gateway) { |
|
| 79 | 79 | $gateways = give_get_enabled_payment_gateways(); |
| 80 | 80 | |
| 81 | - $ret = array_key_exists( $gateway, $gateways ); |
|
| 81 | + $ret = array_key_exists($gateway, $gateways); |
|
| 82 | 82 | |
| 83 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
| 83 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -92,23 +92,23 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return string Gateway ID |
| 94 | 94 | */ |
| 95 | -function give_get_default_gateway( $form_id ) { |
|
| 95 | +function give_get_default_gateway($form_id) { |
|
| 96 | 96 | |
| 97 | 97 | $give_options = give_get_settings(); |
| 98 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
| 99 | - $form_default = give_get_meta( $form_id, '_give_default_gateway', true ); |
|
| 98 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
| 99 | + $form_default = give_get_meta($form_id, '_give_default_gateway', true); |
|
| 100 | 100 | |
| 101 | 101 | // Single Form settings varies compared to the Global default settings. |
| 102 | - if ( ! empty( $form_default ) && |
|
| 102 | + if ( ! empty($form_default) && |
|
| 103 | 103 | $form_id !== null && |
| 104 | 104 | $default !== $form_default && |
| 105 | 105 | $form_default !== 'global' && |
| 106 | - give_is_gateway_active( $form_default ) |
|
| 106 | + give_is_gateway_active($form_default) |
|
| 107 | 107 | ) { |
| 108 | 108 | $default = $form_default; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return apply_filters( 'give_default_gateway', $default ); |
|
| 111 | + return apply_filters('give_default_gateway', $default); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -120,18 +120,18 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return string Gateway admin label |
| 122 | 122 | */ |
| 123 | -function give_get_gateway_admin_label( $gateway ) { |
|
| 123 | +function give_get_gateway_admin_label($gateway) { |
|
| 124 | 124 | $gateways = give_get_payment_gateways(); |
| 125 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
| 126 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
| 125 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
| 126 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
| 127 | 127 | |
| 128 | - if ( $gateway == 'manual' && $payment ) { |
|
| 129 | - if ( give_donation_amount( $payment ) == 0 ) { |
|
| 130 | - $label = __( 'Test Donation', 'give' ); |
|
| 128 | + if ($gateway == 'manual' && $payment) { |
|
| 129 | + if (give_donation_amount($payment) == 0) { |
|
| 130 | + $label = __('Test Donation', 'give'); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
| 134 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -143,15 +143,15 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @return string Checkout label for the gateway |
| 145 | 145 | */ |
| 146 | -function give_get_gateway_checkout_label( $gateway ) { |
|
| 146 | +function give_get_gateway_checkout_label($gateway) { |
|
| 147 | 147 | $gateways = give_get_payment_gateways(); |
| 148 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
| 148 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
| 149 | 149 | |
| 150 | - if ( $gateway == 'manual' ) { |
|
| 151 | - $label = __( 'Test Donation', 'give' ); |
|
| 150 | + if ($gateway == 'manual') { |
|
| 151 | + $label = __('Test Donation', 'give'); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
| 154 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return array Options the gateway supports |
| 165 | 165 | */ |
| 166 | -function give_get_gateway_supports( $gateway ) { |
|
| 166 | +function give_get_gateway_supports($gateway) { |
|
| 167 | 167 | $gateways = give_get_enabled_payment_gateways(); |
| 168 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
| 168 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
| 169 | 169 | |
| 170 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
| 170 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @return void |
| 182 | 182 | */ |
| 183 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
| 183 | +function give_send_to_gateway($gateway, $payment_data) { |
|
| 184 | 184 | |
| 185 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
| 185 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | 188 | * Fires while loading payment gateway via AJAX. |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param array $payment_data All the payment data to be sent to the gateway. |
| 195 | 195 | */ |
| 196 | - do_action( "give_gateway_{$gateway}", $payment_data ); |
|
| 196 | + do_action("give_gateway_{$gateway}", $payment_data); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
@@ -207,34 +207,34 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return string $enabled_gateway The slug of the gateway |
| 209 | 209 | */ |
| 210 | -function give_get_chosen_gateway( $form_id ) { |
|
| 210 | +function give_get_chosen_gateway($form_id) { |
|
| 211 | 211 | |
| 212 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
| 212 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
| 213 | 213 | |
| 214 | 214 | // Back to check if 'form-id' is present. |
| 215 | - if ( empty( $request_form_id ) ) { |
|
| 216 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
| 215 | + if (empty($request_form_id)) { |
|
| 216 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - $request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : ''; |
|
| 219 | + $request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : ''; |
|
| 220 | 220 | $chosen = false; |
| 221 | 221 | |
| 222 | 222 | // If both 'payment-mode' and 'form-id' then set for only this form. |
| 223 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
| 223 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
| 224 | 224 | $chosen = $request_payment_mode; |
| 225 | - } elseif ( empty( $request_form_id ) && $request_payment_mode ) { |
|
| 225 | + } elseif (empty($request_form_id) && $request_payment_mode) { |
|
| 226 | 226 | // If no 'form-id' but there is 'payment-mode'. |
| 227 | 227 | $chosen = $request_payment_mode; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // Get the enable gateway based of chosen var. |
| 231 | - if ( $chosen && give_is_gateway_active( $chosen ) ) { |
|
| 232 | - $enabled_gateway = urldecode( $chosen ); |
|
| 231 | + if ($chosen && give_is_gateway_active($chosen)) { |
|
| 232 | + $enabled_gateway = urldecode($chosen); |
|
| 233 | 233 | } else { |
| 234 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
| 234 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
| 237 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
| 238 | 238 | |
| 239 | 239 | } |
| 240 | 240 | |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return int ID of the new log entry |
| 254 | 254 | */ |
| 255 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
| 256 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
| 255 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
| 256 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * |
| 267 | 267 | * @return int |
| 268 | 268 | */ |
| 269 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
| 269 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
| 270 | 270 | |
| 271 | 271 | $ret = 0; |
| 272 | 272 | $args = array( |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | 'fields' => 'ids', |
| 279 | 279 | ); |
| 280 | 280 | |
| 281 | - $payments = new WP_Query( $args ); |
|
| 281 | + $payments = new WP_Query($args); |
|
| 282 | 282 | |
| 283 | - if ( $payments ) { |
|
| 283 | + if ($payments) { |
|
| 284 | 284 | $ret = $payments->post_count; |
| 285 | 285 | } |
| 286 | 286 | |
@@ -297,27 +297,27 @@ discard block |
||
| 297 | 297 | * |
| 298 | 298 | * @return array $gateways All the available gateways |
| 299 | 299 | */ |
| 300 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
| 300 | +function give_get_ordered_payment_gateways($gateways) { |
|
| 301 | 301 | |
| 302 | 302 | // Get gateways setting. |
| 303 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
| 303 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
| 304 | 304 | |
| 305 | 305 | // Return from here if we do not have gateways setting. |
| 306 | - if ( empty( $gateways_setting ) ) { |
|
| 306 | + if (empty($gateways_setting)) { |
|
| 307 | 307 | return $gateways; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Reverse array to order payment gateways. |
| 311 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
| 311 | + $gateways_setting = array_reverse($gateways_setting); |
|
| 312 | 312 | |
| 313 | 313 | // Reorder gateways array |
| 314 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
| 314 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
| 315 | 315 | |
| 316 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
| 317 | - unset( $gateways[ $gateway_key ] ); |
|
| 316 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
| 317 | + unset($gateways[$gateway_key]); |
|
| 318 | 318 | |
| 319 | - if ( ! empty( $new_gateway_value ) ) { |
|
| 320 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
| 319 | + if ( ! empty($new_gateway_value)) { |
|
| 320 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | |
@@ -328,5 +328,5 @@ discard block |
||
| 328 | 328 | * |
| 329 | 329 | * @param array $gateways All the available gateways |
| 330 | 330 | */ |
| 331 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
| 331 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
| 332 | 332 | } |
| 333 | 333 | \ No newline at end of file |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Exit if accessed directly. |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if ( ! defined('ABSPATH')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Add give command. |
| 15 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
| 15 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @subcommand logo |
| 78 | 78 | */ |
| 79 | - public function ascii( $args, $assoc_args ) { |
|
| 80 | - WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) ); |
|
| 79 | + public function ascii($args, $assoc_args) { |
|
| 80 | + WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt')); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -102,54 +102,54 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @subcommand details |
| 104 | 104 | */ |
| 105 | - public function details( $args, $assoc_args ) { |
|
| 105 | + public function details($args, $assoc_args) { |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Plugin Information |
| 109 | 109 | */ |
| 110 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
| 110 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * General Information. |
| 114 | 114 | */ |
| 115 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
| 115 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
| 116 | 116 | |
| 117 | - $success_page = give_get_option( 'success_page' ); |
|
| 118 | - $failure_page = give_get_option( 'failure_page' ); |
|
| 119 | - $history_page = give_get_option( 'history_page' ); |
|
| 117 | + $success_page = give_get_option('success_page'); |
|
| 118 | + $failure_page = give_get_option('failure_page'); |
|
| 119 | + $history_page = give_get_option('history_page'); |
|
| 120 | 120 | |
| 121 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 122 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 123 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 124 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
| 121 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
| 122 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
| 123 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
| 124 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * Currency Information. |
| 128 | 128 | */ |
| 129 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
| 129 | + $default_gateway = give_get_option('default_gateway'); |
|
| 130 | 130 | |
| 131 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
| 131 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
| 132 | 132 | |
| 133 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
| 134 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
| 135 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
| 136 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
| 137 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
| 138 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
| 139 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
| 133 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
| 134 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
| 135 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
| 136 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
| 137 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
| 138 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
| 139 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
| 140 | 140 | |
| 141 | 141 | // Payment gateways Information. |
| 142 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
| 143 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
| 142 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
| 143 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
| 144 | 144 | |
| 145 | - if ( ! empty( $gateways ) ) { |
|
| 145 | + if ( ! empty($gateways)) { |
|
| 146 | 146 | self::$counter = 1; |
| 147 | - foreach ( $gateways as $gateway ) { |
|
| 148 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
| 149 | - self::$counter ++; |
|
| 147 | + foreach ($gateways as $gateway) { |
|
| 148 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
| 149 | + self::$counter++; |
|
| 150 | 150 | } |
| 151 | 151 | } else { |
| 152 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
| 152 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @subcommand forms |
| 183 | 183 | */ |
| 184 | - public function forms( $args, $assoc_args ) { |
|
| 184 | + public function forms($args, $assoc_args) { |
|
| 185 | 185 | global $wp_query; |
| 186 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
| 187 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
| 186 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
| 187 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
| 188 | 188 | $start = time(); |
| 189 | 189 | |
| 190 | 190 | // Cache previous number query var. |
| 191 | 191 | $is_set_number = $cache_per_page = false; |
| 192 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 192 | + if (isset($wp_query->query_vars['number'])) { |
|
| 193 | 193 | $cache_per_page = $wp_query->query_vars['number']; |
| 194 | 194 | $is_set_number = true; |
| 195 | 195 | } |
@@ -198,22 +198,22 @@ discard block |
||
| 198 | 198 | $wp_query->query_vars['number'] = $number; |
| 199 | 199 | |
| 200 | 200 | // Get forms. |
| 201 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
| 201 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
| 202 | 202 | |
| 203 | 203 | // Reset number query var. |
| 204 | - if ( $is_set_number ) { |
|
| 204 | + if ($is_set_number) { |
|
| 205 | 205 | $wp_query->query_vars['number'] = $cache_per_page; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Bailout. |
| 209 | - if ( array_key_exists( 'error', $forms ) ) { |
|
| 209 | + if (array_key_exists('error', $forms)) { |
|
| 210 | 210 | |
| 211 | - WP_CLI::warning( $forms['error'] ); |
|
| 211 | + WP_CLI::warning($forms['error']); |
|
| 212 | 212 | |
| 213 | 213 | return; |
| 214 | - } elseif ( empty( $forms['forms'] ) ) { |
|
| 214 | + } elseif (empty($forms['forms'])) { |
|
| 215 | 215 | |
| 216 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
| 216 | + WP_CLI::error(__('No forms found.', 'give')); |
|
| 217 | 217 | |
| 218 | 218 | return; |
| 219 | 219 | } |
@@ -221,25 +221,25 @@ discard block |
||
| 221 | 221 | // Param to check if form typeis already showed or not. |
| 222 | 222 | $is_show_form_type = false; |
| 223 | 223 | |
| 224 | - if ( 1 === count( $forms ) && $form_id ) { |
|
| 224 | + if (1 === count($forms) && $form_id) { |
|
| 225 | 225 | // Show single form. |
| 226 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
| 227 | - switch ( $key ) { |
|
| 226 | + foreach ($forms['forms'][0] as $key => $info) { |
|
| 227 | + switch ($key) { |
|
| 228 | 228 | case 'stats': |
| 229 | - $this->color_main_heading( ucfirst( $key ) ); |
|
| 229 | + $this->color_main_heading(ucfirst($key)); |
|
| 230 | 230 | |
| 231 | - foreach ( $info as $heading => $data ) { |
|
| 232 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
| 233 | - switch ( $heading ) { |
|
| 231 | + foreach ($info as $heading => $data) { |
|
| 232 | + $this->color_sub_heading(ucfirst($heading)); |
|
| 233 | + switch ($heading) { |
|
| 234 | 234 | default: |
| 235 | - foreach ( $data as $subheading => $subdata ) { |
|
| 235 | + foreach ($data as $subheading => $subdata) { |
|
| 236 | 236 | |
| 237 | - switch ( $subheading ) { |
|
| 237 | + switch ($subheading) { |
|
| 238 | 238 | case 'earnings': |
| 239 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
| 239 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
| 240 | 240 | break; |
| 241 | 241 | default: |
| 242 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
| 242 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -249,26 +249,26 @@ discard block |
||
| 249 | 249 | case 'pricing': |
| 250 | 250 | case 'info': |
| 251 | 251 | default: |
| 252 | - $this->color_main_heading( ucfirst( $key ) ); |
|
| 252 | + $this->color_main_heading(ucfirst($key)); |
|
| 253 | 253 | |
| 254 | 254 | // Show form type. |
| 255 | - if ( ! $is_show_form_type ) { |
|
| 256 | - $form = new Give_Donate_Form( $form_id ); |
|
| 255 | + if ( ! $is_show_form_type) { |
|
| 256 | + $form = new Give_Donate_Form($form_id); |
|
| 257 | 257 | $is_show_form_type = true; |
| 258 | 258 | |
| 259 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
| 259 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - foreach ( $info as $heading => $data ) { |
|
| 262 | + foreach ($info as $heading => $data) { |
|
| 263 | 263 | |
| 264 | - switch ( $heading ) { |
|
| 264 | + switch ($heading) { |
|
| 265 | 265 | case 'id': |
| 266 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
| 266 | + WP_CLI::log($this->color_message($heading, $data)); |
|
| 267 | 267 | break; |
| 268 | 268 | |
| 269 | 269 | default: |
| 270 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
| 271 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
| 270 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
| 271 | + WP_CLI::log($this->color_message($heading, $data)); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | }// End switch(). |
@@ -279,37 +279,37 @@ discard block |
||
| 279 | 279 | $is_table_first_row_set = false; |
| 280 | 280 | $table_column_count = 0; |
| 281 | 281 | |
| 282 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
| 282 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
| 283 | 283 | |
| 284 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
| 284 | + foreach ($forms['forms'] as $index => $form_data) { |
|
| 285 | 285 | |
| 286 | 286 | // Default table data. |
| 287 | 287 | $table_first_row = array(); |
| 288 | 288 | $table_row = array(); |
| 289 | 289 | |
| 290 | - foreach ( $form_data['info'] as $key => $form ) { |
|
| 290 | + foreach ($form_data['info'] as $key => $form) { |
|
| 291 | 291 | |
| 292 | 292 | // Do not show thumbnail, content and link in table. |
| 293 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
| 293 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
| 294 | 294 | continue; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if ( ! $is_table_first_row_set ) { |
|
| 297 | + if ( ! $is_table_first_row_set) { |
|
| 298 | 298 | $table_first_row[] = $key; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | $table_row[] = $form; |
| 302 | 302 | |
| 303 | - if ( 'status' === $key ) { |
|
| 303 | + if ('status' === $key) { |
|
| 304 | 304 | // First array item will be an form id in our case. |
| 305 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
| 305 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
| 306 | 306 | |
| 307 | 307 | $table_row[] = $form->get_type(); |
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // Set table first row. |
| 312 | - if ( ! $is_table_first_row_set ) { |
|
| 312 | + if ( ! $is_table_first_row_set) { |
|
| 313 | 313 | |
| 314 | 314 | // Add extra column to table. |
| 315 | 315 | $table_first_row[] = 'type'; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | $table_data[] = $table_row; |
| 323 | 323 | }// End foreach(). |
| 324 | 324 | |
| 325 | - $this->display_table( $table_data ); |
|
| 325 | + $this->display_table($table_data); |
|
| 326 | 326 | }// End if(). |
| 327 | 327 | } |
| 328 | 328 | |
@@ -375,59 +375,59 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @subcommand donors |
| 377 | 377 | */ |
| 378 | - public function donors( $args, $assoc_args ) { |
|
| 378 | + public function donors($args, $assoc_args) { |
|
| 379 | 379 | global $wp_query; |
| 380 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
| 381 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
| 382 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
| 383 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
| 384 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
| 385 | - $form_id = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0; |
|
| 386 | - $format = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table'; |
|
| 380 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
| 381 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
| 382 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
| 383 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
| 384 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
| 385 | + $form_id = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0; |
|
| 386 | + $format = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table'; |
|
| 387 | 387 | $start = time(); |
| 388 | 388 | |
| 389 | - if ( $create ) { |
|
| 390 | - if ( 80 < $create ) { |
|
| 391 | - WP_CLI::warning( 'Currently we can only generate maximum 80 donors.', 'give' ); |
|
| 389 | + if ($create) { |
|
| 390 | + if (80 < $create) { |
|
| 391 | + WP_CLI::warning('Currently we can only generate maximum 80 donors.', 'give'); |
|
| 392 | 392 | $create = 80; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $number = 1; |
| 396 | 396 | |
| 397 | - if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) { |
|
| 398 | - WP_CLI::warning( 'Wrong email address provided.', 'give' ); |
|
| 397 | + if (isset($assoc_args['email']) && ! is_email($email)) { |
|
| 398 | + WP_CLI::warning('Wrong email address provided.', 'give'); |
|
| 399 | 399 | |
| 400 | 400 | return; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | // Create one or more donors. |
| 404 | - if ( ! $email ) { |
|
| 404 | + if ( ! $email) { |
|
| 405 | 405 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
| 406 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
| 406 | + $number = is_numeric($create) ? absint($create) : 1; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - for ( $i = 0; $i < $number; $i ++ ) { |
|
| 409 | + for ($i = 0; $i < $number; $i++) { |
|
| 410 | 410 | $name = $name ? $name : $this->get_random_name(); |
| 411 | - $email = $email ? $email : $this->get_random_email( $name ); |
|
| 411 | + $email = $email ? $email : $this->get_random_email($name); |
|
| 412 | 412 | |
| 413 | 413 | $args = array( |
| 414 | 414 | 'email' => $email, |
| 415 | 415 | 'name' => $name, |
| 416 | 416 | ); |
| 417 | 417 | |
| 418 | - $donor_id = Give()->donors->add( $args ); |
|
| 418 | + $donor_id = Give()->donors->add($args); |
|
| 419 | 419 | |
| 420 | - if ( $donor_id ) { |
|
| 421 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) ); |
|
| 420 | + if ($donor_id) { |
|
| 421 | + WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id))); |
|
| 422 | 422 | } else { |
| 423 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
| 423 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | // Reset email and name to false so it is generated on the next loop (if creating donors). |
| 427 | 427 | $email = $name = false; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
| 430 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
| 431 | 431 | |
| 432 | 432 | } else { |
| 433 | 433 | // Counter. |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | // Cache previous number query var. |
| 443 | 443 | $is_set_number = $cache_per_page = false; |
| 444 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 444 | + if (isset($wp_query->query_vars['number'])) { |
|
| 445 | 445 | $cache_per_page = $wp_query->query_vars['number']; |
| 446 | 446 | $is_set_number = true; |
| 447 | 447 | } |
@@ -450,24 +450,24 @@ discard block |
||
| 450 | 450 | $wp_query->query_vars['number'] = $number; |
| 451 | 451 | |
| 452 | 452 | // Get donors. |
| 453 | - if ( $form_id ) { |
|
| 453 | + if ($form_id) { |
|
| 454 | 454 | // @TODO: Allow user to get a list of donors by donation status. |
| 455 | - $donors = $this->get_donors_by_form_id( $form_id ); |
|
| 455 | + $donors = $this->get_donors_by_form_id($form_id); |
|
| 456 | 456 | } else { |
| 457 | - $donors = $this->api->get_donors( $search ); |
|
| 457 | + $donors = $this->api->get_donors($search); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | // Reset number query var. |
| 461 | - if ( $is_set_number ) { |
|
| 461 | + if ($is_set_number) { |
|
| 462 | 462 | $wp_query->query_vars['number'] = $cache_per_page; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if ( isset( $donors['error'] ) ) { |
|
| 466 | - WP_CLI::error( $donors['error'] ); |
|
| 465 | + if (isset($donors['error'])) { |
|
| 466 | + WP_CLI::error($donors['error']); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - if ( empty( $donors ) ) { |
|
| 470 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
| 469 | + if (empty($donors)) { |
|
| 470 | + WP_CLI::error(__('No donors found.', 'give')); |
|
| 471 | 471 | |
| 472 | 472 | return; |
| 473 | 473 | } |
@@ -475,24 +475,24 @@ discard block |
||
| 475 | 475 | $table_data = array(); |
| 476 | 476 | $is_table_first_row_set = false; |
| 477 | 477 | |
| 478 | - foreach ( $donors['donors'] as $donor_data ) { |
|
| 478 | + foreach ($donors['donors'] as $donor_data) { |
|
| 479 | 479 | // Set default table row data. |
| 480 | - $table_first_row = array( __( 's_no', 'give' ) ); |
|
| 481 | - $table_row = array( self::$counter ); |
|
| 480 | + $table_first_row = array(__('s_no', 'give')); |
|
| 481 | + $table_row = array(self::$counter); |
|
| 482 | 482 | |
| 483 | - foreach ( $donor_data as $key => $donor ) { |
|
| 484 | - switch ( $key ) { |
|
| 483 | + foreach ($donor_data as $key => $donor) { |
|
| 484 | + switch ($key) { |
|
| 485 | 485 | case 'stats': |
| 486 | - foreach ( $donor as $heading => $data ) { |
|
| 486 | + foreach ($donor as $heading => $data) { |
|
| 487 | 487 | |
| 488 | 488 | // Get first row. |
| 489 | - if ( ! $is_table_first_row_set ) { |
|
| 489 | + if ( ! $is_table_first_row_set) { |
|
| 490 | 490 | $table_first_row[] = $heading; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - switch ( $heading ) { |
|
| 493 | + switch ($heading) { |
|
| 494 | 494 | case 'total_spent': |
| 495 | - $table_row[] = give_currency_filter( $data ); |
|
| 495 | + $table_row[] = give_currency_filter($data); |
|
| 496 | 496 | break; |
| 497 | 497 | |
| 498 | 498 | default: |
@@ -503,10 +503,10 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | case 'info': |
| 505 | 505 | default: |
| 506 | - foreach ( $donor as $heading => $data ) { |
|
| 506 | + foreach ($donor as $heading => $data) { |
|
| 507 | 507 | |
| 508 | 508 | // Get first row. |
| 509 | - if ( ! $is_table_first_row_set ) { |
|
| 509 | + if ( ! $is_table_first_row_set) { |
|
| 510 | 510 | $table_first_row[] = $heading; |
| 511 | 511 | } |
| 512 | 512 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | // Add first row data to table data. |
| 519 | - if ( ! $is_table_first_row_set ) { |
|
| 519 | + if ( ! $is_table_first_row_set) { |
|
| 520 | 520 | $table_data[] = $table_first_row; |
| 521 | 521 | $is_table_first_row_set = true; |
| 522 | 522 | } |
@@ -525,44 +525,44 @@ discard block |
||
| 525 | 525 | $table_data[] = $table_row; |
| 526 | 526 | |
| 527 | 527 | // Increase counter. |
| 528 | - self::$counter ++; |
|
| 528 | + self::$counter++; |
|
| 529 | 529 | }// End foreach(). |
| 530 | 530 | |
| 531 | - switch ( $format ) { |
|
| 531 | + switch ($format) { |
|
| 532 | 532 | case 'json': |
| 533 | 533 | $table_column_name = $table_data[0]; |
| 534 | - unset( $table_data[0] ); |
|
| 534 | + unset($table_data[0]); |
|
| 535 | 535 | |
| 536 | 536 | $new_table_data = array(); |
| 537 | - foreach ( $table_data as $index => $data ) { |
|
| 538 | - foreach ( $data as $key => $value ) { |
|
| 539 | - $new_table_data[ $index ][ $table_column_name[ $key ] ] = $value; |
|
| 537 | + foreach ($table_data as $index => $data) { |
|
| 538 | + foreach ($data as $key => $value) { |
|
| 539 | + $new_table_data[$index][$table_column_name[$key]] = $value; |
|
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - WP_CLI::log( json_encode( $new_table_data ) ); |
|
| 543 | + WP_CLI::log(json_encode($new_table_data)); |
|
| 544 | 544 | break; |
| 545 | 545 | |
| 546 | 546 | case 'csv': |
| 547 | - $file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv'; |
|
| 548 | - $fp = fopen( $file_path, 'w' ); |
|
| 547 | + $file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv'; |
|
| 548 | + $fp = fopen($file_path, 'w'); |
|
| 549 | 549 | |
| 550 | - if ( is_writable( $file_path ) ) { |
|
| 551 | - foreach ( $table_data as $fields ) { |
|
| 552 | - fputcsv( $fp, $fields ); |
|
| 550 | + if (is_writable($file_path)) { |
|
| 551 | + foreach ($table_data as $fields) { |
|
| 552 | + fputcsv($fp, $fields); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - fclose( $fp ); |
|
| 555 | + fclose($fp); |
|
| 556 | 556 | |
| 557 | - WP_CLI::success( "Donors list csv created successfully: {$file_path}" ); |
|
| 557 | + WP_CLI::success("Donors list csv created successfully: {$file_path}"); |
|
| 558 | 558 | } else { |
| 559 | - WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" ); |
|
| 559 | + WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)"); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | break; |
| 563 | 563 | |
| 564 | 564 | default: |
| 565 | - $this->display_table( $table_data ); |
|
| 565 | + $this->display_table($table_data); |
|
| 566 | 566 | }// End switch(). |
| 567 | 567 | }// End if(). |
| 568 | 568 | } |
@@ -592,13 +592,13 @@ discard block |
||
| 592 | 592 | * |
| 593 | 593 | * @subcommand donations |
| 594 | 594 | */ |
| 595 | - public function donations( $args, $assoc_args ) { |
|
| 595 | + public function donations($args, $assoc_args) { |
|
| 596 | 596 | global $wp_query; |
| 597 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
| 597 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
| 598 | 598 | |
| 599 | 599 | // Cache previous number query var. |
| 600 | 600 | $is_set_number = $cache_per_page = false; |
| 601 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 601 | + if (isset($wp_query->query_vars['number'])) { |
|
| 602 | 602 | $cache_per_page = $wp_query->query_vars['number']; |
| 603 | 603 | $is_set_number = true; |
| 604 | 604 | } |
@@ -610,46 +610,46 @@ discard block |
||
| 610 | 610 | $donations = $this->api->get_recent_donations(); |
| 611 | 611 | |
| 612 | 612 | // Reset number query var. |
| 613 | - if ( $is_set_number ) { |
|
| 613 | + if ($is_set_number) { |
|
| 614 | 614 | $wp_query->query_vars['number'] = $cache_per_page; |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - if ( empty( $donations ) ) { |
|
| 618 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
| 617 | + if (empty($donations)) { |
|
| 618 | + WP_CLI::error(__('No donations found.', 'give')); |
|
| 619 | 619 | |
| 620 | 620 | return; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | self::$counter = 1; |
| 624 | 624 | |
| 625 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
| 626 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
| 627 | - self::$counter ++; |
|
| 625 | + foreach ($donations['donations'] as $key => $donation) { |
|
| 626 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
| 627 | + self::$counter++; |
|
| 628 | 628 | |
| 629 | - foreach ( $donation as $column => $data ) { |
|
| 629 | + foreach ($donation as $column => $data) { |
|
| 630 | 630 | |
| 631 | - if ( is_array( $data ) ) { |
|
| 632 | - $this->color_sub_heading( $column ); |
|
| 633 | - foreach ( $data as $subcolumn => $subdata ) { |
|
| 631 | + if (is_array($data)) { |
|
| 632 | + $this->color_sub_heading($column); |
|
| 633 | + foreach ($data as $subcolumn => $subdata) { |
|
| 634 | 634 | |
| 635 | 635 | // Decode html codes. |
| 636 | - switch ( $subcolumn ) { |
|
| 636 | + switch ($subcolumn) { |
|
| 637 | 637 | case 'name': |
| 638 | - $subdata = html_entity_decode( $subdata ); |
|
| 638 | + $subdata = html_entity_decode($subdata); |
|
| 639 | 639 | break; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
| 643 | - if ( is_array( $subdata ) ) { |
|
| 643 | + if (is_array($subdata)) { |
|
| 644 | 644 | continue; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
| 647 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
| 648 | 648 | } |
| 649 | 649 | continue; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
| 652 | + WP_CLI::log($this->color_message($column, $data)); |
|
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | 655 | } |
@@ -689,27 +689,27 @@ discard block |
||
| 689 | 689 | * |
| 690 | 690 | * @return void |
| 691 | 691 | */ |
| 692 | - public function report( $args, $assoc_args ) { |
|
| 692 | + public function report($args, $assoc_args) { |
|
| 693 | 693 | $stats = new Give_Payment_Stats(); |
| 694 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
| 695 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
| 696 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
| 697 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
| 694 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
| 695 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
| 696 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
| 697 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
| 698 | 698 | |
| 699 | - if ( ! empty( $date ) ) { |
|
| 699 | + if ( ! empty($date)) { |
|
| 700 | 700 | $start_date = $date; |
| 701 | 701 | $end_date = false; |
| 702 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
| 702 | + } elseif (empty($date) && empty($start_date)) { |
|
| 703 | 703 | $start_date = 'this_month'; |
| 704 | 704 | $end_date = false; |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | // Get stats. |
| 708 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
| 709 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
| 708 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
| 709 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
| 710 | 710 | |
| 711 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) ); |
|
| 712 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
| 711 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings))); |
|
| 712 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | |
@@ -736,27 +736,27 @@ discard block |
||
| 736 | 736 | * |
| 737 | 737 | * @subcommand cache |
| 738 | 738 | */ |
| 739 | - public function cache( $args, $assoc_args ) { |
|
| 740 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
| 739 | + public function cache($args, $assoc_args) { |
|
| 740 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
| 741 | 741 | |
| 742 | 742 | // Bailout. |
| 743 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
| 744 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
| 743 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
| 744 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
| 745 | 745 | |
| 746 | 746 | return; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - switch ( $action ) { |
|
| 749 | + switch ($action) { |
|
| 750 | 750 | case 'delete': |
| 751 | 751 | // Reset counter. |
| 752 | 752 | self::$counter = 1; |
| 753 | 753 | |
| 754 | - if ( $this->delete_stats_transients() ) { |
|
| 754 | + if ($this->delete_stats_transients()) { |
|
| 755 | 755 | // Report .eading. |
| 756 | - WP_CLI::success( 'Give cache deleted.' ); |
|
| 756 | + WP_CLI::success('Give cache deleted.'); |
|
| 757 | 757 | } else { |
| 758 | 758 | // Report .eading. |
| 759 | - WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' ); |
|
| 759 | + WP_CLI::warning('We did not find any Give plugin cache to delete :)'); |
|
| 760 | 760 | } |
| 761 | 761 | break; |
| 762 | 762 | } |
@@ -785,27 +785,27 @@ discard block |
||
| 785 | 785 | ARRAY_A |
| 786 | 786 | ); |
| 787 | 787 | |
| 788 | - if ( ! empty( $stat_option_names ) ) { |
|
| 788 | + if ( ! empty($stat_option_names)) { |
|
| 789 | 789 | |
| 790 | - foreach ( $stat_option_names as $option_name ) { |
|
| 790 | + foreach ($stat_option_names as $option_name) { |
|
| 791 | 791 | $error = false; |
| 792 | 792 | $option_name = $option_name['option_name']; |
| 793 | 793 | |
| 794 | - switch ( true ) { |
|
| 795 | - case ( false !== strpos( $option_name, 'transient' ) ): |
|
| 796 | - $option_name = str_replace( '_transient_', '', $option_name ); |
|
| 797 | - $error = delete_transient( $option_name ); |
|
| 794 | + switch (true) { |
|
| 795 | + case (false !== strpos($option_name, 'transient')): |
|
| 796 | + $option_name = str_replace('_transient_', '', $option_name); |
|
| 797 | + $error = delete_transient($option_name); |
|
| 798 | 798 | break; |
| 799 | 799 | |
| 800 | 800 | default: |
| 801 | - $error = delete_option( $option_name ); |
|
| 801 | + $error = delete_option($option_name); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - if ( $error ) { |
|
| 805 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
| 806 | - self::$counter ++; |
|
| 804 | + if ($error) { |
|
| 805 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
| 806 | + self::$counter++; |
|
| 807 | 807 | } else { |
| 808 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
| 808 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
| 809 | 809 | } |
| 810 | 810 | } |
| 811 | 811 | |
@@ -826,13 +826,13 @@ discard block |
||
| 826 | 826 | * |
| 827 | 827 | * @return string |
| 828 | 828 | */ |
| 829 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
| 829 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
| 830 | 830 | // Add colon. |
| 831 | - if ( $colon ) { |
|
| 832 | - $heading = $heading . ': '; |
|
| 831 | + if ($colon) { |
|
| 832 | + $heading = $heading.': '; |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
| 835 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | |
@@ -847,8 +847,8 @@ discard block |
||
| 847 | 847 | * |
| 848 | 848 | * @return void |
| 849 | 849 | */ |
| 850 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
| 851 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
| 850 | + private function color_main_heading($heading, $color = 'g') { |
|
| 851 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | /** |
@@ -861,8 +861,8 @@ discard block |
||
| 861 | 861 | * |
| 862 | 862 | * @return void |
| 863 | 863 | */ |
| 864 | - private function color_sub_heading( $subheading ) { |
|
| 865 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
| 864 | + private function color_sub_heading($subheading) { |
|
| 865 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | |
@@ -876,17 +876,17 @@ discard block |
||
| 876 | 876 | * |
| 877 | 877 | * @return void |
| 878 | 878 | */ |
| 879 | - private function display_table( $data ) { |
|
| 879 | + private function display_table($data) { |
|
| 880 | 880 | $table = new \cli\Table(); |
| 881 | 881 | |
| 882 | 882 | // Set table header. |
| 883 | - $table->setHeaders( $data[0] ); |
|
| 883 | + $table->setHeaders($data[0]); |
|
| 884 | 884 | |
| 885 | 885 | // Remove table header. |
| 886 | - unset( $data[0] ); |
|
| 886 | + unset($data[0]); |
|
| 887 | 887 | |
| 888 | 888 | // Set table data. |
| 889 | - $table->setRows( $data ); |
|
| 889 | + $table->setRows($data); |
|
| 890 | 890 | |
| 891 | 891 | // Display table. |
| 892 | 892 | $table->display(); |
@@ -903,14 +903,14 @@ discard block |
||
| 903 | 903 | * @return array |
| 904 | 904 | */ |
| 905 | 905 | |
| 906 | - private function get_donors_by_form_id( $form_id ) { |
|
| 906 | + private function get_donors_by_form_id($form_id) { |
|
| 907 | 907 | $donors = array(); |
| 908 | 908 | |
| 909 | 909 | $donations = new Give_Payments_Query( |
| 910 | 910 | array( |
| 911 | - 'give_forms' => array( $form_id ), |
|
| 912 | - 'number' => - 1, |
|
| 913 | - 'status' => array( 'publish' ), |
|
| 911 | + 'give_forms' => array($form_id), |
|
| 912 | + 'number' => -1, |
|
| 913 | + 'status' => array('publish'), |
|
| 914 | 914 | ) |
| 915 | 915 | ); |
| 916 | 916 | |
@@ -918,16 +918,16 @@ discard block |
||
| 918 | 918 | $skip_donors = array(); |
| 919 | 919 | |
| 920 | 920 | /* @var Give_Payment|object $donation Payment object. */ |
| 921 | - foreach ( $donations as $donation ) { |
|
| 921 | + foreach ($donations as $donation) { |
|
| 922 | 922 | |
| 923 | - if ( in_array( $donation->customer_id, $skip_donors, true ) ) { |
|
| 923 | + if (in_array($donation->customer_id, $skip_donors, true)) { |
|
| 924 | 924 | continue; |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - if ( ! empty( $donors ) ) { |
|
| 928 | - $donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) ); |
|
| 927 | + if ( ! empty($donors)) { |
|
| 928 | + $donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id))); |
|
| 929 | 929 | } else { |
| 930 | - $donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) ); |
|
| 930 | + $donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id)); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | $skip_donors[] = $donation->customer_id; |
@@ -972,15 +972,15 @@ discard block |
||
| 972 | 972 | ); |
| 973 | 973 | |
| 974 | 974 | // Generate a random forename. |
| 975 | - $random_name = $names[ mt_rand( 0, sizeof( $names ) - 1 ) ]; |
|
| 975 | + $random_name = $names[mt_rand(0, sizeof($names) - 1)]; |
|
| 976 | 976 | |
| 977 | 977 | // Generate a random surname. |
| 978 | - $random_surname = $surnames[ mt_rand( 0, sizeof( $surnames ) - 1 ) ]; |
|
| 978 | + $random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)]; |
|
| 979 | 979 | |
| 980 | 980 | // Generate name. |
| 981 | 981 | $name = "{$random_name} {$random_surname}"; |
| 982 | 982 | |
| 983 | - if ( in_array( $name, $this->new_donor_names ) ) { |
|
| 983 | + if (in_array($name, $this->new_donor_names)) { |
|
| 984 | 984 | $name = $this->get_random_name(); |
| 985 | 985 | } |
| 986 | 986 | |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | * |
| 1000 | 1000 | * @return string |
| 1001 | 1001 | */ |
| 1002 | - private function get_random_email( $name ) { |
|
| 1003 | - return implode( '.', explode( ' ', strtolower( $name ) ) ) . '@test.com'; |
|
| 1002 | + private function get_random_email($name) { |
|
| 1003 | + return implode('.', explode(' ', strtolower($name))).'@test.com'; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | } |
@@ -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 | |
@@ -25,26 +25,26 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_load_scripts() { |
| 27 | 27 | |
| 28 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
| 29 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
| 30 | - $scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false; |
|
| 28 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
| 29 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
| 30 | + $scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false; |
|
| 31 | 31 | |
| 32 | 32 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
| 33 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 33 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 34 | 34 | |
| 35 | 35 | // Localize / PHP to AJAX vars. |
| 36 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( |
|
| 36 | + $localize_give_vars = apply_filters('give_global_script_vars', array( |
|
| 37 | 37 | 'ajaxurl' => give_get_ajax_url(), |
| 38 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
| 38 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
| 39 | 39 | 'currency' => give_get_currency(), |
| 40 | - 'currency_sign' => give_currency_filter( '' ), |
|
| 40 | + 'currency_sign' => give_currency_filter(''), |
|
| 41 | 41 | 'currency_pos' => give_get_currency_position(), |
| 42 | 42 | 'thousands_separator' => give_get_price_thousand_separator(), |
| 43 | 43 | 'decimal_separator' => give_get_price_decimal_separator(), |
| 44 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), |
|
| 45 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), |
|
| 46 | - 'general_loading' => __( 'Loading...', 'give' ), |
|
| 47 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), |
|
| 44 | + 'no_gateway' => __('Please select a payment method.', 'give'), |
|
| 45 | + 'bad_minimum' => __('The minimum custom donation amount for this form is', 'give'), |
|
| 46 | + 'general_loading' => __('Loading...', 'give'), |
|
| 47 | + 'purchase_loading' => __('Please Wait...', 'give'), |
|
| 48 | 48 | 'number_decimals' => give_get_price_decimals(), |
| 49 | 49 | 'give_version' => GIVE_VERSION, |
| 50 | 50 | 'magnific_options' => apply_filters( |
@@ -58,83 +58,83 @@ discard block |
||
| 58 | 58 | 'give_form_translation_js', |
| 59 | 59 | array( |
| 60 | 60 | // Field name Validation message. |
| 61 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), |
|
| 62 | - 'give_first' => __( 'Please enter your first name.', 'give' ), |
|
| 63 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), |
|
| 64 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), |
|
| 65 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), |
|
| 66 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), |
|
| 67 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), |
|
| 61 | + 'payment-mode' => __('Please select payment mode.', 'give'), |
|
| 62 | + 'give_first' => __('Please enter your first name.', 'give'), |
|
| 63 | + 'give_email' => __('Please enter a valid email address.', 'give'), |
|
| 64 | + 'give_user_login' => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'), |
|
| 65 | + 'give_user_pass' => __('Enter a password.', 'give'), |
|
| 66 | + 'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'), |
|
| 67 | + 'give_agree_to_terms' => __('You must agree to the terms and conditions.', 'give'), |
|
| 68 | 68 | ) |
| 69 | 69 | ), |
| 70 | - 'confirm_email_sent_message' => __( 'Please check your email and click on the link to access your complete donation history.', 'give' ), |
|
| 71 | - ) ); |
|
| 70 | + 'confirm_email_sent_message' => __('Please check your email and click on the link to access your complete donation history.', 'give'), |
|
| 71 | + )); |
|
| 72 | 72 | |
| 73 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
| 73 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
| 74 | 74 | 'ajaxurl' => give_get_ajax_url(), |
| 75 | - 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ), |
|
| 76 | - 'loading' => __( 'Loading', 'give' ), |
|
| 75 | + 'ajaxNonce' => wp_create_nonce('give_ajax_nonce'), |
|
| 76 | + 'loading' => __('Loading', 'give'), |
|
| 77 | 77 | // General loading message. |
| 78 | - 'select_option' => __( 'Please select an option', 'give' ), |
|
| 78 | + 'select_option' => __('Please select an option', 'give'), |
|
| 79 | 79 | // Variable pricing error with multi-donation option enabled. |
| 80 | - 'default_gateway' => give_get_default_gateway( null ), |
|
| 81 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
| 80 | + 'default_gateway' => give_get_default_gateway(null), |
|
| 81 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
| 82 | 82 | 'number_decimals' => give_get_price_decimals(), |
| 83 | - ) ); |
|
| 83 | + )); |
|
| 84 | 84 | |
| 85 | 85 | // DEBUG is On. |
| 86 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
| 86 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
| 87 | 87 | |
| 88 | - if ( give_is_cc_verify_enabled() ) { |
|
| 89 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 90 | - wp_enqueue_script( 'give-cc-validator' ); |
|
| 88 | + if (give_is_cc_verify_enabled()) { |
|
| 89 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 90 | + wp_enqueue_script('give-cc-validator'); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 94 | - wp_enqueue_script( 'give-float-labels' ); |
|
| 93 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 94 | + wp_enqueue_script('give-float-labels'); |
|
| 95 | 95 | |
| 96 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 97 | - wp_enqueue_script( 'give-blockui' ); |
|
| 96 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 97 | + wp_enqueue_script('give-blockui'); |
|
| 98 | 98 | |
| 99 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 100 | - wp_enqueue_script( 'give-qtip' ); |
|
| 99 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 100 | + wp_enqueue_script('give-qtip'); |
|
| 101 | 101 | |
| 102 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 103 | - wp_enqueue_script( 'give-accounting' ); |
|
| 102 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 103 | + wp_enqueue_script('give-accounting'); |
|
| 104 | 104 | |
| 105 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 106 | - wp_enqueue_script( 'give-magnific' ); |
|
| 105 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 106 | + wp_enqueue_script('give-magnific'); |
|
| 107 | 107 | |
| 108 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-donations' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 109 | - wp_enqueue_script( 'give-checkout-global' ); |
|
| 108 | + wp_register_script('give-checkout-global', $js_dir.'give-donations'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 109 | + wp_enqueue_script('give-checkout-global'); |
|
| 110 | 110 | |
| 111 | 111 | // General scripts. |
| 112 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 113 | - wp_enqueue_script( 'give-scripts' ); |
|
| 112 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 113 | + wp_enqueue_script('give-scripts'); |
|
| 114 | 114 | |
| 115 | 115 | // Load AJAX scripts, if enabled. |
| 116 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 117 | - wp_enqueue_script( 'give-ajax' ); |
|
| 116 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 117 | + wp_enqueue_script('give-ajax'); |
|
| 118 | 118 | |
| 119 | 119 | // Localize / Pass AJAX vars from PHP, |
| 120 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars ); |
|
| 121 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
| 120 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars); |
|
| 121 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
| 122 | 122 | |
| 123 | 123 | } else { |
| 124 | 124 | |
| 125 | 125 | // DEBUG is OFF (one JS file to rule them all!). |
| 126 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
| 127 | - wp_enqueue_script( 'give' ); |
|
| 126 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
| 127 | + wp_enqueue_script('give'); |
|
| 128 | 128 | |
| 129 | 129 | // Localize / Pass AJAX vars from PHP. |
| 130 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
|
| 131 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
| 130 | + wp_localize_script('give', 'give_global_vars', $localize_give_vars); |
|
| 131 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
| 137 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * Register styles. |
@@ -147,16 +147,16 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function give_register_styles() { |
| 149 | 149 | |
| 150 | - if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
|
| 150 | + if ( ! give_is_setting_enabled(give_get_option('css'))) { |
|
| 151 | 151 | return; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); |
|
| 155 | - wp_enqueue_style( 'give-styles' ); |
|
| 154 | + wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); |
|
| 155 | + wp_enqueue_style('give-styles'); |
|
| 156 | 156 | |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
| 159 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
| 160 | 160 | |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -169,19 +169,19 @@ discard block |
||
| 169 | 169 | function give_get_stylesheet_uri() { |
| 170 | 170 | |
| 171 | 171 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
| 172 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 172 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 173 | 173 | |
| 174 | 174 | // LTR or RTL files. |
| 175 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
| 175 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
| 176 | 176 | |
| 177 | - $file = 'give' . $direction . $suffix . '.css'; |
|
| 177 | + $file = 'give'.$direction.$suffix.'.css'; |
|
| 178 | 178 | $templates_dir = give_get_theme_template_dir_name(); |
| 179 | 179 | |
| 180 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
| 181 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
| 182 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
| 183 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css'; |
|
| 184 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
| 180 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
| 181 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css'; |
|
| 182 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
| 183 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css'; |
|
| 184 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
| 185 | 185 | |
| 186 | 186 | $uri = false; |
| 187 | 187 | |
@@ -191,23 +191,23 @@ discard block |
||
| 191 | 191 | * followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
| 192 | 192 | * This allows users to copy just give.css to their theme. |
| 193 | 193 | */ |
| 194 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
| 195 | - if ( ! empty( $nonmin ) ) { |
|
| 196 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
| 194 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
| 195 | + if ( ! empty($nonmin)) { |
|
| 196 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
| 197 | 197 | } else { |
| 198 | - $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
| 198 | + $uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
| 199 | 199 | } |
| 200 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
| 201 | - if ( ! empty( $nonmin ) ) { |
|
| 202 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css'; |
|
| 200 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
| 201 | + if ( ! empty($nonmin)) { |
|
| 202 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css'; |
|
| 203 | 203 | } else { |
| 204 | - $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
| 204 | + $uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
| 205 | 205 | } |
| 206 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
| 207 | - $uri = trailingslashit( give_get_templates_url() ) . $file; |
|
| 206 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
| 207 | + $uri = trailingslashit(give_get_templates_url()).$file; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - return apply_filters( 'give_get_stylesheet_uri', $uri ); |
|
| 210 | + return apply_filters('give_get_stylesheet_uri', $uri); |
|
| 211 | 211 | |
| 212 | 212 | } |
| 213 | 213 | |
@@ -224,79 +224,79 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @return void |
| 226 | 226 | */ |
| 227 | -function give_load_admin_scripts( $hook ) { |
|
| 227 | +function give_load_admin_scripts($hook) { |
|
| 228 | 228 | |
| 229 | 229 | global $post, $post_type; |
| 230 | 230 | |
| 231 | 231 | $give_options = give_get_settings(); |
| 232 | 232 | |
| 233 | 233 | // Directories of assets. |
| 234 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
| 235 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
| 236 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
| 234 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
| 235 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
| 236 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
| 237 | 237 | |
| 238 | 238 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
| 239 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 239 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 240 | 240 | |
| 241 | 241 | // LTR or RTL files. |
| 242 | - $direction = ( is_rtl() ) ? '-rtl' : ''; |
|
| 242 | + $direction = (is_rtl()) ? '-rtl' : ''; |
|
| 243 | 243 | |
| 244 | 244 | // Global Admin. |
| 245 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
| 246 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
| 245 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
| 246 | + wp_enqueue_style('give-admin-bar-notification'); |
|
| 247 | 247 | |
| 248 | 248 | // Give Admin Only. |
| 249 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
| 249 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
| 250 | 250 | return; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | // CSS. |
| 254 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
| 255 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
| 256 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION ); |
|
| 257 | - wp_enqueue_style( 'give-admin' ); |
|
| 258 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
| 259 | - wp_enqueue_style( 'jquery-chosen' ); |
|
| 260 | - wp_enqueue_style( 'thickbox' ); |
|
| 261 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 254 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
| 255 | + wp_enqueue_style('jquery-ui-css'); |
|
| 256 | + wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION); |
|
| 257 | + wp_enqueue_style('give-admin'); |
|
| 258 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
| 259 | + wp_enqueue_style('jquery-chosen'); |
|
| 260 | + wp_enqueue_style('thickbox'); |
|
| 261 | + wp_enqueue_style('wp-color-picker'); |
|
| 262 | 262 | |
| 263 | 263 | |
| 264 | 264 | // JS. |
| 265 | - wp_register_script( 'give-selector-cache', $js_plugins . 'selector-cache' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 266 | - wp_enqueue_script( 'give-selector-cache' ); |
|
| 265 | + wp_register_script('give-selector-cache', $js_plugins.'selector-cache'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 266 | + wp_enqueue_script('give-selector-cache'); |
|
| 267 | 267 | |
| 268 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
| 269 | - wp_enqueue_script( 'jquery-chosen' ); |
|
| 268 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
| 269 | + wp_enqueue_script('jquery-chosen'); |
|
| 270 | 270 | |
| 271 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 272 | - wp_enqueue_script( 'give-accounting' ); |
|
| 271 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 272 | + wp_enqueue_script('give-accounting'); |
|
| 273 | 273 | |
| 274 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 275 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 276 | - wp_enqueue_script( 'thickbox' ); |
|
| 274 | + wp_enqueue_script('wp-color-picker'); |
|
| 275 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 276 | + wp_enqueue_script('thickbox'); |
|
| 277 | 277 | |
| 278 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'jquery-query' ), GIVE_VERSION, false ); |
|
| 279 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
| 278 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'jquery-query'), GIVE_VERSION, false); |
|
| 279 | + wp_enqueue_script('give-admin-scripts'); |
|
| 280 | 280 | |
| 281 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
| 282 | - wp_enqueue_script( 'jquery-flot' ); |
|
| 281 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
| 282 | + wp_enqueue_script('jquery-flot'); |
|
| 283 | 283 | |
| 284 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 285 | - wp_enqueue_script( 'give-qtip' ); |
|
| 284 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 285 | + wp_enqueue_script('give-qtip'); |
|
| 286 | 286 | |
| 287 | - wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 288 | - wp_enqueue_script( 'give-repeatable-fields' ); |
|
| 287 | + wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 288 | + wp_enqueue_script('give-repeatable-fields'); |
|
| 289 | 289 | |
| 290 | 290 | // Forms CPT Script. |
| 291 | - if ( $post_type === 'give_forms' ) { |
|
| 292 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 293 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
| 291 | + if ($post_type === 'give_forms') { |
|
| 292 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 293 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Settings Scripts. |
| 297 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) { |
|
| 298 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 299 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
| 297 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
| 298 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 299 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Price Separators. |
@@ -304,87 +304,87 @@ discard block |
||
| 304 | 304 | $decimal_separator = give_get_price_decimal_separator(); |
| 305 | 305 | |
| 306 | 306 | // Localize strings & variables for JS. |
| 307 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
| 308 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
| 307 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
| 308 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
| 309 | 309 | 'give_version' => GIVE_VERSION, |
| 310 | 310 | 'thousands_separator' => $thousand_separator, |
| 311 | 311 | 'decimal_separator' => $decimal_separator, |
| 312 | - 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
|
| 313 | - 'delete_payment' => __( 'Are you sure you want to delete this payment?', 'give' ), |
|
| 314 | - 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
|
| 315 | - 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
|
| 316 | - 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ), |
|
| 317 | - 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
|
| 318 | - 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
|
| 319 | - 'one_option' => __( 'Choose a form', 'give' ), |
|
| 320 | - 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
|
| 321 | - 'currency_sign' => give_currency_filter( '' ), |
|
| 322 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
| 312 | + 'quick_edit_warning' => __('Not available for variable priced forms.', 'give'), |
|
| 313 | + 'delete_payment' => __('Are you sure you want to delete this payment?', 'give'), |
|
| 314 | + 'delete_payment_note' => __('Are you sure you want to delete this note?', 'give'), |
|
| 315 | + 'revoke_api_key' => __('Are you sure you want to revoke this API key?', 'give'), |
|
| 316 | + 'regenerate_api_key' => __('Are you sure you want to regenerate this API key?', 'give'), |
|
| 317 | + 'resend_receipt' => __('Are you sure you want to resend the donation receipt?', 'give'), |
|
| 318 | + 'disconnect_user' => __('Are you sure you want to disconnect the user from this donor?', 'give'), |
|
| 319 | + 'one_option' => __('Choose a form', 'give'), |
|
| 320 | + 'one_or_more_option' => __('Choose one or more forms', 'give'), |
|
| 321 | + 'currency_sign' => give_currency_filter(''), |
|
| 322 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
| 323 | 323 | 'currency_decimals' => give_get_price_decimals(), |
| 324 | - 'batch_export_no_class' => __( 'You must choose a method.', 'give' ), |
|
| 325 | - 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ), |
|
| 326 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
| 327 | - 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ), |
|
| 328 | - 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ), |
|
| 329 | - 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ), |
|
| 324 | + 'batch_export_no_class' => __('You must choose a method.', 'give'), |
|
| 325 | + 'batch_export_no_reqs' => __('Required fields not completed.', 'give'), |
|
| 326 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
| 327 | + 'delete_test_donor' => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'), |
|
| 328 | + 'delete_import_donor' => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'), |
|
| 329 | + 'price_format_guide' => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator), |
|
| 330 | 330 | /* translators : %s: Donation form options metabox */ |
| 331 | - 'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ), |
|
| 332 | - 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
| 333 | - 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ), |
|
| 334 | - 'search_placeholder' => __( 'Type to search all forms', 'give' ), |
|
| 335 | - 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
|
| 336 | - 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
|
| 337 | - 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
|
| 338 | - 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ), |
|
| 331 | + 'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'), |
|
| 332 | + 'matched_success_failure_page' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
| 333 | + 'dismiss_notice_text' => __('Dismiss this notice.', 'give'), |
|
| 334 | + 'search_placeholder' => __('Type to search all forms', 'give'), |
|
| 335 | + 'search_placeholder_donor' => __('Type to search all donors', 'give'), |
|
| 336 | + 'search_placeholder_country' => __('Type to search all countries', 'give'), |
|
| 337 | + 'search_placeholder_state' => __('Type to search all states/provinces', 'give'), |
|
| 338 | + 'remove_from_bulk_delete' => __('Remove from Bulk Delete', 'give'), |
|
| 339 | 339 | 'donors_bulk_action' => array( |
| 340 | - 'no_donor_selected' => __( 'You must choose at least one or more donors to delete.', 'give' ), |
|
| 341 | - 'no_action_selected' => __( 'You must select a bulk action to proceed.', 'give' ), |
|
| 340 | + 'no_donor_selected' => __('You must choose at least one or more donors to delete.', 'give'), |
|
| 341 | + 'no_action_selected' => __('You must select a bulk action to proceed.', 'give'), |
|
| 342 | 342 | ), |
| 343 | 343 | 'donations_bulk_action' => array( |
| 344 | 344 | 'delete' => array( |
| 345 | - 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ), |
|
| 346 | - 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
|
| 347 | - 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
|
| 345 | + 'zero' => __('You must choose at least one or more donations to delete.', 'give'), |
|
| 346 | + 'single' => __('Are you sure you want to permanently delete this donation?', 'give'), |
|
| 347 | + 'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'), |
|
| 348 | 348 | ), |
| 349 | 349 | 'resend-receipt' => array( |
| 350 | - 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
|
| 351 | - 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
|
| 352 | - 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
|
| 350 | + 'zero' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'), |
|
| 351 | + 'single' => __('Are you sure you want to resend the email receipt to this recipient?', 'give'), |
|
| 352 | + 'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'), |
|
| 353 | 353 | ), |
| 354 | 354 | 'set-to-status' => array( |
| 355 | - 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
|
| 356 | - 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
|
| 357 | - 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
|
| 355 | + 'zero' => __('You must choose at least one or more donations to set status to {status}.', 'give'), |
|
| 356 | + 'single' => __('Are you sure you want to set status of this donation to {status}?', 'give'), |
|
| 357 | + 'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'), |
|
| 358 | 358 | ), |
| 359 | 359 | ), |
| 360 | 360 | 'metabox_fields' => array( |
| 361 | 361 | 'media' => array( |
| 362 | - 'button_title' => __( 'Choose Image', 'give' ), |
|
| 362 | + 'button_title' => __('Choose Image', 'give'), |
|
| 363 | 363 | ), |
| 364 | 364 | 'file' => array( |
| 365 | - 'button_title' => __( 'Choose File', 'give' ), |
|
| 365 | + 'button_title' => __('Choose File', 'give'), |
|
| 366 | 366 | ), |
| 367 | 367 | ), |
| 368 | 368 | 'chosen' => array( |
| 369 | - 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
|
| 370 | - 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
|
| 369 | + 'no_results_msg' => __('No results match {search_term}', 'give'), |
|
| 370 | + 'ajax_search_msg' => __('Searching results for match {search_term}', 'give'), |
|
| 371 | 371 | ), |
| 372 | - 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ), |
|
| 373 | - 'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ), |
|
| 374 | - 'error_message' => __( 'Something went wrong kindly try again!', 'give' ), |
|
| 372 | + 'db_update_confirmation_msg_button' => __('Run Updates', 'give'), |
|
| 373 | + 'db_update_confirmation_msg' => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give'), |
|
| 374 | + 'error_message' => __('Something went wrong kindly try again!', 'give'), |
|
| 375 | 375 | 'give_donation_import' => 'give_donation_import', |
| 376 | 376 | 'core_settings_import' => 'give_core_settings_import', |
| 377 | - 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ), |
|
| 378 | - ) ); |
|
| 377 | + 'setting_not_save_message' => __('Changes you made may not be saved.', 'give'), |
|
| 378 | + )); |
|
| 379 | 379 | |
| 380 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) { |
|
| 380 | + if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) { |
|
| 381 | 381 | // call for new media manager. |
| 382 | 382 | wp_enqueue_media(); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
| 387 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * Admin Give Icon |
@@ -399,13 +399,13 @@ discard block |
||
| 399 | 399 | ?> |
| 400 | 400 | <style type="text/css" media="screen"> |
| 401 | 401 | |
| 402 | - <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?> |
|
| 402 | + <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?> |
|
| 403 | 403 | @font-face { |
| 404 | 404 | font-family: 'give-icomoon'; |
| 405 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
| 406 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
| 407 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
| 408 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
| 405 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>'); |
|
| 406 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), |
|
| 407 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), |
|
| 408 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); |
|
| 409 | 409 | font-weight: normal; |
| 410 | 410 | font-style: normal; |
| 411 | 411 | } |
@@ -424,4 +424,4 @@ discard block |
||
| 424 | 424 | <?php |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
| 427 | +add_action('admin_head', 'give_admin_icon'); |
|
@@ -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 | |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_get_actions() { |
| 27 | 27 | |
| 28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
| 28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
| 29 | 29 | |
| 30 | 30 | // Add backward compatibility to give-action param ( $_GET ) |
| 31 | - if ( empty( $_get_action ) ) { |
|
| 32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
| 31 | + if (empty($_get_action)) { |
|
| 32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ( isset( $_get_action ) ) { |
|
| 35 | + if (isset($_get_action)) { |
|
| 36 | 36 | /** |
| 37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
| 38 | 38 | * |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param array $_GET Array of HTTP GET variables. |
| 42 | 42 | */ |
| 43 | - do_action( "give_{$_get_action}", $_GET ); |
|
| 43 | + do_action("give_{$_get_action}", $_GET); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | -add_action( 'init', 'give_get_actions' ); |
|
| 48 | +add_action('init', 'give_get_actions'); |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | function give_post_actions() { |
| 60 | 60 | |
| 61 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
| 61 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
| 62 | 62 | |
| 63 | 63 | // Add backward compatibility to give-action param ( $_POST ). |
| 64 | - if ( empty( $_post_action ) ) { |
|
| 65 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
| 64 | + if (empty($_post_action)) { |
|
| 65 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if ( isset( $_post_action ) ) { |
|
| 68 | + if (isset($_post_action)) { |
|
| 69 | 69 | /** |
| 70 | 70 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
| 71 | 71 | * |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @param array $_POST Array of HTTP POST variables. |
| 75 | 75 | */ |
| 76 | - do_action( "give_{$_post_action}", $_POST ); |
|
| 76 | + do_action("give_{$_post_action}", $_POST); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | -add_action( 'init', 'give_post_actions' ); |
|
| 81 | +add_action('init', 'give_post_actions'); |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Connect WordPress user with Donor. |
@@ -90,29 +90,29 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | -function give_connect_donor_to_wpuser( $user_id, $user_data ) { |
|
| 93 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
| 94 | 94 | /* @var Give_Donor $donor */ |
| 95 | - $donor = new Give_Donor( $user_data['user_email'] ); |
|
| 95 | + $donor = new Give_Donor($user_data['user_email']); |
|
| 96 | 96 | |
| 97 | 97 | // Validate donor id and check if do nor is already connect to wp user or not. |
| 98 | - if ( $donor->id && ! $donor->user_id ) { |
|
| 98 | + if ($donor->id && ! $donor->user_id) { |
|
| 99 | 99 | |
| 100 | 100 | // Update donor user_id. |
| 101 | - if ( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
| 102 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
| 103 | - $donor->add_note( $donor_note ); |
|
| 101 | + if ($donor->update(array('user_id' => $user_id))) { |
|
| 102 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
| 103 | + $donor->add_note($donor_note); |
|
| 104 | 104 | |
| 105 | 105 | // Update user_id meta in payments. |
| 106 | - if ( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
|
| 107 | - foreach ( $donations as $donation ) { |
|
| 108 | - give_update_meta( $donation, '_give_payment_user_id', $user_id ); |
|
| 106 | + if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) { |
|
| 107 | + foreach ($donations as $donation) { |
|
| 108 | + give_update_meta($donation, '_give_payment_user_id', $user_id); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
| 115 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -126,45 +126,45 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | function give_validate_license_when_site_migrated() { |
| 128 | 128 | // Store current site address if not already stored. |
| 129 | - $home_url_parts = parse_url( home_url() ); |
|
| 130 | - $home_url = isset( $home_url_parts['host'] ) ? $home_url_parts['host'] : false; |
|
| 131 | - $home_url .= isset( $home_url_parts['path'] ) ? $home_url_parts['path'] : ''; |
|
| 132 | - $site_address_before_migrate = get_option( 'give_site_address_before_migrate' ); |
|
| 129 | + $home_url_parts = parse_url(home_url()); |
|
| 130 | + $home_url = isset($home_url_parts['host']) ? $home_url_parts['host'] : false; |
|
| 131 | + $home_url .= isset($home_url_parts['path']) ? $home_url_parts['path'] : ''; |
|
| 132 | + $site_address_before_migrate = get_option('give_site_address_before_migrate'); |
|
| 133 | 133 | |
| 134 | 134 | // Need $home_url to proceed. |
| 135 | - if ( ! $home_url ) { |
|
| 135 | + if ( ! $home_url) { |
|
| 136 | 136 | return; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Save site address. |
| 140 | - if ( ! $site_address_before_migrate ) { |
|
| 140 | + if ( ! $site_address_before_migrate) { |
|
| 141 | 141 | // Update site address. |
| 142 | - update_option( 'give_site_address_before_migrate', $home_url ); |
|
| 142 | + update_option('give_site_address_before_migrate', $home_url); |
|
| 143 | 143 | |
| 144 | 144 | return; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Backwards compat. for before when we were storing URL scheme. |
| 148 | - if ( strpos( $site_address_before_migrate, 'http' ) ) { |
|
| 149 | - $site_address_before_migrate = parse_url( $site_address_before_migrate ); |
|
| 150 | - $site_address_before_migrate = isset( $site_address_before_migrate['host'] ) ? $site_address_before_migrate['host'] : false; |
|
| 148 | + if (strpos($site_address_before_migrate, 'http')) { |
|
| 149 | + $site_address_before_migrate = parse_url($site_address_before_migrate); |
|
| 150 | + $site_address_before_migrate = isset($site_address_before_migrate['host']) ? $site_address_before_migrate['host'] : false; |
|
| 151 | 151 | |
| 152 | 152 | // Add path for multisite installs. |
| 153 | - $site_address_before_migrate .= isset( $site_address_before_migrate['path'] ) ? $site_address_before_migrate['path'] : ''; |
|
| 153 | + $site_address_before_migrate .= isset($site_address_before_migrate['path']) ? $site_address_before_migrate['path'] : ''; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // If the two URLs don't match run CRON. |
| 157 | - if ( $home_url !== $site_address_before_migrate ) { |
|
| 157 | + if ($home_url !== $site_address_before_migrate) { |
|
| 158 | 158 | // Immediately run cron. |
| 159 | - wp_schedule_single_event( time(), 'give_validate_license_when_site_migrated' ); |
|
| 159 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
| 160 | 160 | |
| 161 | 161 | // Update site address. |
| 162 | - update_option( 'give_site_address_before_migrate', $home_url ); |
|
| 162 | + update_option('give_site_address_before_migrate', $home_url); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
| 167 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
|
| 168 | 168 | |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -174,19 +174,19 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @param $data |
| 176 | 176 | */ |
| 177 | -function give_donor_batch_export_complete( $data ) { |
|
| 177 | +function give_donor_batch_export_complete($data) { |
|
| 178 | 178 | // Remove donor ids cache. |
| 179 | 179 | if ( |
| 180 | - isset( $data['class'] ) |
|
| 180 | + isset($data['class']) |
|
| 181 | 181 | && 'Give_Batch_Donors_Export' === $data['class'] |
| 182 | - && ! empty( $data['forms'] ) |
|
| 183 | - && isset( $data['give_export_option']['query_id'] ) |
|
| 182 | + && ! empty($data['forms']) |
|
| 183 | + && isset($data['give_export_option']['query_id']) |
|
| 184 | 184 | ) { |
| 185 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
| 185 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | -add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
| 189 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
|
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | 192 | * Print css for wordpress setting pages. |
@@ -197,12 +197,12 @@ discard block |
||
| 197 | 197 | /* @var WP_Screen $screen */ |
| 198 | 198 | $screen = get_current_screen(); |
| 199 | 199 | |
| 200 | - if ( ! ( $screen instanceof WP_Screen ) ) { |
|
| 200 | + if ( ! ($screen instanceof WP_Screen)) { |
|
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - switch ( true ) { |
|
| 205 | - case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ): |
|
| 204 | + switch (true) { |
|
| 205 | + case ('plugins' === $screen->base || 'plugins-network' === $screen->base): |
|
| 206 | 206 | ?> |
| 207 | 207 | <style> |
| 208 | 208 | tr.active.update + tr.give-addon-notice-tr td { |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | -add_action( 'admin_head', 'give_admin_quick_css' ); |
|
| 242 | +add_action('admin_head', 'give_admin_quick_css'); |
|
| 243 | 243 | |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -251,28 +251,28 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return void |
| 253 | 253 | */ |
| 254 | -function give_set_donation_levels_max_min_amount( $form_id ) { |
|
| 254 | +function give_set_donation_levels_max_min_amount($form_id) { |
|
| 255 | 255 | if ( |
| 256 | - ( 'set' === $_POST['_give_price_option'] ) || |
|
| 257 | - ( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) || |
|
| 258 | - ! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) ) |
|
| 256 | + ('set' === $_POST['_give_price_option']) || |
|
| 257 | + (in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) || |
|
| 258 | + ! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount')) |
|
| 259 | 259 | ) { |
| 260 | 260 | // Delete old meta. |
| 261 | - give_delete_meta( $form_id, '_give_levels_minimum_amount' ); |
|
| 262 | - give_delete_meta( $form_id, '_give_levels_maximum_amount' ); |
|
| 261 | + give_delete_meta($form_id, '_give_levels_minimum_amount'); |
|
| 262 | + give_delete_meta($form_id, '_give_levels_maximum_amount'); |
|
| 263 | 263 | |
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Sanitize donation level amounts. |
| 268 | - $donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts ); |
|
| 268 | + $donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts); |
|
| 269 | 269 | |
| 270 | - $min_amount = min( $donation_levels_amounts ); |
|
| 271 | - $max_amount = max( $donation_levels_amounts ); |
|
| 270 | + $min_amount = min($donation_levels_amounts); |
|
| 271 | + $max_amount = max($donation_levels_amounts); |
|
| 272 | 272 | |
| 273 | 273 | // Set Minimum and Maximum amount for Multi Level Donation Forms. |
| 274 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 ); |
|
| 275 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 ); |
|
| 274 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0); |
|
| 275 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | -add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 ); |
|
| 279 | 278 | \ No newline at end of file |
| 279 | +add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30); |
|
| 280 | 280 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -53,21 +53,21 @@ discard block |
||
| 53 | 53 | * @since 1.8.9 |
| 54 | 54 | */ |
| 55 | 55 | public function __construct() { |
| 56 | - add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 ); |
|
| 57 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
| 56 | + add_action('admin_notices', array($this, 'render_admin_notices'), 999); |
|
| 57 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
| 58 | 58 | |
| 59 | - add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 ); |
|
| 60 | - add_action( 'give_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) ); |
|
| 61 | - add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) ); |
|
| 59 | + add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999); |
|
| 60 | + add_action('give_donation_form_before_personal_info', array($this, 'render_frontend_notices')); |
|
| 61 | + add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices')); |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Backward compatibility for deprecated params. |
| 65 | 65 | * |
| 66 | 66 | * @since 1.8.14 |
| 67 | 67 | */ |
| 68 | - add_filter( 'give_register_notice_args', array( $this, 'bc_deprecated_params' ) ); |
|
| 69 | - add_filter( 'give_frontend_errors_args', array( $this, 'bc_deprecated_params' ) ); |
|
| 70 | - add_filter( 'give_frontend_notice_args', array( $this, 'bc_deprecated_params' ) ); |
|
| 68 | + add_filter('give_register_notice_args', array($this, 'bc_deprecated_params')); |
|
| 69 | + add_filter('give_frontend_errors_args', array($this, 'bc_deprecated_params')); |
|
| 70 | + add_filter('give_frontend_notice_args', array($this, 'bc_deprecated_params')); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return array |
| 82 | 82 | */ |
| 83 | - public function bc_deprecated_params( $args ) { |
|
| 83 | + public function bc_deprecated_params($args) { |
|
| 84 | 84 | /** |
| 85 | 85 | * Param: auto_dismissible |
| 86 | 86 | * deprecated in 1.8.14 |
| 87 | 87 | * |
| 88 | 88 | * Check if auto_dismissible is set and it true then unset and change dismissible parameter value to auto |
| 89 | 89 | */ |
| 90 | - if ( isset( $args['auto_dismissible'] ) ) { |
|
| 91 | - if ( ! empty( $args['auto_dismissible'] ) ) { |
|
| 90 | + if (isset($args['auto_dismissible'])) { |
|
| 91 | + if ( ! empty($args['auto_dismissible'])) { |
|
| 92 | 92 | $args['dismissible'] = 'auto'; |
| 93 | 93 | } |
| 94 | 94 | // unset auto_dismissible as it has been deprecated. |
| 95 | - unset( $args['auto_dismissible'] ); |
|
| 95 | + unset($args['auto_dismissible']); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return $args; |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return bool |
| 110 | 110 | */ |
| 111 | - public function register_notice( $notice_args ) { |
|
| 111 | + public function register_notice($notice_args) { |
|
| 112 | 112 | // Bailout. |
| 113 | - if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) { |
|
| 113 | + if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) { |
|
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -159,39 +159,39 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @since 1.8.14 |
| 161 | 161 | */ |
| 162 | - $notice_args = apply_filters( 'give_register_notice_args', $notice_args ); |
|
| 162 | + $notice_args = apply_filters('give_register_notice_args', $notice_args); |
|
| 163 | 163 | |
| 164 | 164 | // Set extra dismiss links if any. |
| 165 | - if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) { |
|
| 165 | + if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) { |
|
| 166 | 166 | |
| 167 | - preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link ); |
|
| 167 | + preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link); |
|
| 168 | 168 | |
| 169 | - if ( ! empty( $extra_notice_dismiss_link ) ) { |
|
| 170 | - $extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 ); |
|
| 171 | - foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) { |
|
| 169 | + if ( ! empty($extra_notice_dismiss_link)) { |
|
| 170 | + $extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3); |
|
| 171 | + foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) { |
|
| 172 | 172 | // Create array og key ==> value by parsing query string created after renaming data attributes. |
| 173 | - $data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array( |
|
| 173 | + $data_attribute_query_str = str_replace(array('data-', '-', '"'), array( |
|
| 174 | 174 | '', |
| 175 | 175 | '_', |
| 176 | 176 | '', |
| 177 | - ), implode( '&', $extra_notice_dismiss_link ) ); |
|
| 177 | + ), implode('&', $extra_notice_dismiss_link)); |
|
| 178 | 178 | |
| 179 | - $notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str ); |
|
| 179 | + $notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
| 185 | - self::$notices[ $notice_args['id'] ] = $notice_args; |
|
| 185 | + self::$notices[$notice_args['id']] = $notice_args; |
|
| 186 | 186 | |
| 187 | 187 | // Auto set show param if not already set. |
| 188 | - if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) { |
|
| 189 | - self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true; |
|
| 188 | + if ( ! isset(self::$notices[$notice_args['id']]['show'])) { |
|
| 189 | + self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // Auto set time interval for shortly. |
| 193 | - if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) { |
|
| 194 | - self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
| 193 | + if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) { |
|
| 194 | + self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | return true; |
@@ -205,51 +205,51 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function render_admin_notices() { |
| 207 | 207 | // Bailout. |
| 208 | - if ( empty( self::$notices ) ) { |
|
| 208 | + if (empty(self::$notices)) { |
|
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | $output = ''; |
| 213 | 213 | |
| 214 | - foreach ( self::$notices as $notice_id => $notice ) { |
|
| 214 | + foreach (self::$notices as $notice_id => $notice) { |
|
| 215 | 215 | // Check flag set to true to show notice. |
| 216 | - if ( ! $notice['show'] ) { |
|
| 216 | + if ( ! $notice['show']) { |
|
| 217 | 217 | continue; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | // Render custom html. |
| 222 | - if( ! empty( $notice['description_html'] ) ) { |
|
| 222 | + if ( ! empty($notice['description_html'])) { |
|
| 223 | 223 | $output .= "{$notice['description_html']} \n"; |
| 224 | 224 | continue; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // Check if notice dismissible or not. |
| 228 | - if ( ! self::$has_auto_dismissible_notice ) { |
|
| 229 | - self::$has_auto_dismissible_notice = ( 'auto' === $notice['dismissible'] ); |
|
| 228 | + if ( ! self::$has_auto_dismissible_notice) { |
|
| 229 | + self::$has_auto_dismissible_notice = ('auto' === $notice['dismissible']); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Check if notice dismissible or not. |
| 233 | - if ( ! self::$has_dismiss_interval_notice ) { |
|
| 233 | + if ( ! self::$has_dismiss_interval_notice) { |
|
| 234 | 234 | self::$has_dismiss_interval_notice = $notice['dismiss_interval']; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] ); |
|
| 237 | + $css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']); |
|
| 238 | 238 | |
| 239 | - $css_class = 'give-notice notice ' . ( empty( $notice['dismissible'] ) ? 'non' : 'is' ) . "-dismissible {$notice['type']} notice-{$notice['type']}"; |
|
| 240 | - $output .= sprintf( |
|
| 241 | - '<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">' . " \n", |
|
| 239 | + $css_class = 'give-notice notice '.(empty($notice['dismissible']) ? 'non' : 'is')."-dismissible {$notice['type']} notice-{$notice['type']}"; |
|
| 240 | + $output .= sprintf( |
|
| 241 | + '<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">'." \n", |
|
| 242 | 242 | $css_id, |
| 243 | 243 | $css_class, |
| 244 | - give_clean( $notice['dismissible'] ), |
|
| 244 | + give_clean($notice['dismissible']), |
|
| 245 | 245 | $notice['dismissible_type'], |
| 246 | 246 | $notice['dismiss_interval'], |
| 247 | 247 | $notice['id'], |
| 248 | - empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ), |
|
| 248 | + empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"), |
|
| 249 | 249 | $notice['dismiss_interval_time'] |
| 250 | 250 | ); |
| 251 | 251 | |
| 252 | - $output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" ); |
|
| 252 | + $output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>"); |
|
| 253 | 253 | $output .= "</div> \n"; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -267,18 +267,18 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @param int $form_id |
| 269 | 269 | */ |
| 270 | - public function render_frontend_notices( $form_id = 0 ) { |
|
| 270 | + public function render_frontend_notices($form_id = 0) { |
|
| 271 | 271 | $errors = give_get_errors(); |
| 272 | 272 | |
| 273 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0; |
|
| 273 | + $request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0; |
|
| 274 | 274 | |
| 275 | 275 | // Sanity checks first: Ensure that gateway returned errors display on the appropriate form. |
| 276 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
| 276 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( $errors ) { |
|
| 281 | - self::print_frontend_errors( $errors ); |
|
| 280 | + if ($errors) { |
|
| 281 | + self::print_frontend_errors($errors); |
|
| 282 | 282 | |
| 283 | 283 | give_clear_errors(); |
| 284 | 284 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @access private |
| 292 | 292 | */ |
| 293 | 293 | private function print_js() { |
| 294 | - if ( self::$has_auto_dismissible_notice ) : |
|
| 294 | + if (self::$has_auto_dismissible_notice) : |
|
| 295 | 295 | ?> |
| 296 | 296 | <script> |
| 297 | 297 | jQuery(document).ready(function () { |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | <?php |
| 308 | 308 | endif; |
| 309 | 309 | |
| 310 | - if ( self::$has_dismiss_interval_notice ) : |
|
| 310 | + if (self::$has_dismiss_interval_notice) : |
|
| 311 | 311 | ?> |
| 312 | 312 | <script> |
| 313 | 313 | jQuery(document).ready(function () { |
@@ -386,29 +386,29 @@ discard block |
||
| 386 | 386 | * @access public |
| 387 | 387 | */ |
| 388 | 388 | public function dismiss_notices() { |
| 389 | - $_post = give_clean( $_POST ); |
|
| 390 | - $notice_id = esc_attr( $_post['notice_id'] ); |
|
| 389 | + $_post = give_clean($_POST); |
|
| 390 | + $notice_id = esc_attr($_post['notice_id']); |
|
| 391 | 391 | |
| 392 | 392 | // Bailout. |
| 393 | 393 | if ( |
| 394 | - empty( $notice_id ) || |
|
| 395 | - empty( $_post['dismissible_type'] ) || |
|
| 396 | - empty( $_post['dismiss_interval'] ) || |
|
| 397 | - ! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' ) |
|
| 394 | + empty($notice_id) || |
|
| 395 | + empty($_post['dismissible_type']) || |
|
| 396 | + empty($_post['dismiss_interval']) || |
|
| 397 | + ! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce') |
|
| 398 | 398 | ) { |
| 399 | 399 | wp_send_json_error(); |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] ); |
|
| 403 | - if ( 'user' === $_post['dismissible_type'] ) { |
|
| 402 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']); |
|
| 403 | + if ('user' === $_post['dismissible_type']) { |
|
| 404 | 404 | $current_user = wp_get_current_user(); |
| 405 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID ); |
|
| 405 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - $notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null; |
|
| 408 | + $notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null; |
|
| 409 | 409 | |
| 410 | 410 | // Save option to hide notice. |
| 411 | - Give_Cache::set( $notice_key, true, $notice_dismiss_time, true ); |
|
| 411 | + Give_Cache::set($notice_key, true, $notice_dismiss_time, true); |
|
| 412 | 412 | |
| 413 | 413 | wp_send_json_success(); |
| 414 | 414 | } |
@@ -426,18 +426,18 @@ discard block |
||
| 426 | 426 | * |
| 427 | 427 | * @return string |
| 428 | 428 | */ |
| 429 | - public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) { |
|
| 429 | + public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) { |
|
| 430 | 430 | $notice_key = "_give_notice_{$notice_id}"; |
| 431 | 431 | |
| 432 | - if ( ! empty( $dismiss_interval ) ) { |
|
| 432 | + if ( ! empty($dismiss_interval)) { |
|
| 433 | 433 | $notice_key .= "_{$dismiss_interval}"; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if ( $user_id ) { |
|
| 436 | + if ($user_id) { |
|
| 437 | 437 | $notice_key .= "_{$user_id}"; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - $notice_key = sanitize_key( $notice_key ); |
|
| 440 | + $notice_key = sanitize_key($notice_key); |
|
| 441 | 441 | |
| 442 | 442 | return $notice_key; |
| 443 | 443 | } |
@@ -450,11 +450,11 @@ discard block |
||
| 450 | 450 | * |
| 451 | 451 | * @return string |
| 452 | 452 | */ |
| 453 | - public function get_dismiss_link( $notice_args ) { |
|
| 453 | + public function get_dismiss_link($notice_args) { |
|
| 454 | 454 | $notice_args = wp_parse_args( |
| 455 | 455 | $notice_args, |
| 456 | 456 | array( |
| 457 | - 'title' => __( 'Click here', 'give' ), |
|
| 457 | + 'title' => __('Click here', 'give'), |
|
| 458 | 458 | 'dismissible_type' => '', |
| 459 | 459 | 'dismiss_interval' => '', |
| 460 | 460 | 'dismiss_interval_time' => null, |
@@ -481,31 +481,31 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @return bool|null |
| 483 | 483 | */ |
| 484 | - public function is_notice_dismissed( $notice ) { |
|
| 485 | - $notice_key = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] ); |
|
| 484 | + public function is_notice_dismissed($notice) { |
|
| 485 | + $notice_key = $this->get_notice_key($notice['id'], $notice['dismiss_interval']); |
|
| 486 | 486 | $is_notice_dismissed = false; |
| 487 | 487 | |
| 488 | - if ( 'user' === $notice['dismissible_type'] ) { |
|
| 488 | + if ('user' === $notice['dismissible_type']) { |
|
| 489 | 489 | $current_user = wp_get_current_user(); |
| 490 | - $notice_key = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID ); |
|
| 490 | + $notice_key = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - $notice_data = Give_Cache::get( $notice_key, true ); |
|
| 493 | + $notice_data = Give_Cache::get($notice_key, true); |
|
| 494 | 494 | |
| 495 | 495 | // Find notice dismiss link status if notice has extra dismissible links. |
| 496 | - if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) { |
|
| 496 | + if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) { |
|
| 497 | 497 | |
| 498 | - foreach ( $notice['extra_links'] as $extra_link ) { |
|
| 499 | - $new_notice_data = wp_parse_args( $extra_link, $notice ); |
|
| 500 | - unset( $new_notice_data['extra_links'] ); |
|
| 498 | + foreach ($notice['extra_links'] as $extra_link) { |
|
| 499 | + $new_notice_data = wp_parse_args($extra_link, $notice); |
|
| 500 | + unset($new_notice_data['extra_links']); |
|
| 501 | 501 | |
| 502 | - if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) { |
|
| 502 | + if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) { |
|
| 503 | 503 | return $is_notice_dismissed; |
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data ); |
|
| 508 | + $is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data); |
|
| 509 | 509 | |
| 510 | 510 | return $is_notice_dismissed; |
| 511 | 511 | } |
@@ -519,9 +519,9 @@ discard block |
||
| 519 | 519 | * |
| 520 | 520 | * @param array $errors |
| 521 | 521 | */ |
| 522 | - public static function print_frontend_errors( $errors ) { |
|
| 522 | + public static function print_frontend_errors($errors) { |
|
| 523 | 523 | // Bailout. |
| 524 | - if ( ! $errors ) { |
|
| 524 | + if ( ! $errors) { |
|
| 525 | 525 | return; |
| 526 | 526 | } |
| 527 | 527 | |
@@ -536,37 +536,37 @@ discard block |
||
| 536 | 536 | ); |
| 537 | 537 | |
| 538 | 538 | // Note: we will remove give_errors class in future. |
| 539 | - $classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) ); |
|
| 539 | + $classes = apply_filters('give_error_class', array('give_notices', 'give_errors')); |
|
| 540 | 540 | |
| 541 | - echo sprintf( '<div class="%s">', implode( ' ', $classes ) ); |
|
| 541 | + echo sprintf('<div class="%s">', implode(' ', $classes)); |
|
| 542 | 542 | |
| 543 | 543 | // Loop error codes and display errors. |
| 544 | - foreach ( $errors as $error_id => $error ) { |
|
| 544 | + foreach ($errors as $error_id => $error) { |
|
| 545 | 545 | // Backward compatibility v<1.8.11 |
| 546 | - if ( is_string( $error ) ) { |
|
| 546 | + if (is_string($error)) { |
|
| 547 | 547 | $error = array( |
| 548 | 548 | 'message' => $error, |
| 549 | 549 | 'notice_args' => array(), |
| 550 | 550 | ); |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - $notice_args = wp_parse_args( $error['notice_args'], $default_notice_args ); |
|
| 553 | + $notice_args = wp_parse_args($error['notice_args'], $default_notice_args); |
|
| 554 | 554 | |
| 555 | 555 | /** |
| 556 | 556 | * Filter to modify Frontend Errors args before errors is display. |
| 557 | 557 | * |
| 558 | 558 | * @since 1.8.14 |
| 559 | 559 | */ |
| 560 | - $notice_args = apply_filters( 'give_frontend_errors_args', $notice_args ); |
|
| 560 | + $notice_args = apply_filters('give_frontend_errors_args', $notice_args); |
|
| 561 | 561 | |
| 562 | 562 | echo sprintf( |
| 563 | 563 | '<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d"> |
| 564 | 564 | <p><strong>%4$s</strong>: %5$s</p> |
| 565 | 565 | </div>', |
| 566 | 566 | $error_id, |
| 567 | - give_clean( $notice_args['dismissible'] ), |
|
| 568 | - absint( $notice_args['dismiss_interval'] ), |
|
| 569 | - esc_html__( 'Error', 'give' ), |
|
| 567 | + give_clean($notice_args['dismissible']), |
|
| 568 | + absint($notice_args['dismiss_interval']), |
|
| 569 | + esc_html__('Error', 'give'), |
|
| 570 | 570 | $error['message'] |
| 571 | 571 | ); |
| 572 | 572 | } |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | * |
| 589 | 589 | * @return string |
| 590 | 590 | */ |
| 591 | - public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) { |
|
| 592 | - if ( empty( $message ) ) { |
|
| 591 | + public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) { |
|
| 592 | + if (empty($message)) { |
|
| 593 | 593 | return ''; |
| 594 | 594 | } |
| 595 | 595 | |
@@ -603,14 +603,14 @@ discard block |
||
| 603 | 603 | 'dismiss_interval' => 5000, |
| 604 | 604 | ); |
| 605 | 605 | |
| 606 | - $notice_args = wp_parse_args( $notice_args, $default_notice_args ); |
|
| 606 | + $notice_args = wp_parse_args($notice_args, $default_notice_args); |
|
| 607 | 607 | |
| 608 | 608 | /** |
| 609 | 609 | * Filter to modify Frontend notice args before notices is display. |
| 610 | 610 | * |
| 611 | 611 | * @since 1.8.14 |
| 612 | 612 | */ |
| 613 | - $notice_args = apply_filters( 'give_frontend_notice_args', $notice_args ); |
|
| 613 | + $notice_args = apply_filters('give_frontend_notice_args', $notice_args); |
|
| 614 | 614 | |
| 615 | 615 | // Note: we will remove give_errors class in future. |
| 616 | 616 | $error = sprintf( |
@@ -620,12 +620,12 @@ discard block |
||
| 620 | 620 | </p> |
| 621 | 621 | </div>', |
| 622 | 622 | $notice_type, |
| 623 | - give_clean( $notice_args['dismissible'] ), |
|
| 624 | - absint( $notice_args['dismiss_interval'] ), |
|
| 623 | + give_clean($notice_args['dismissible']), |
|
| 624 | + absint($notice_args['dismiss_interval']), |
|
| 625 | 625 | $message |
| 626 | 626 | ); |
| 627 | 627 | |
| 628 | - if ( ! $echo ) { |
|
| 628 | + if ( ! $echo) { |
|
| 629 | 629 | return $error; |
| 630 | 630 | } |
| 631 | 631 | |
@@ -645,24 +645,24 @@ discard block |
||
| 645 | 645 | * |
| 646 | 646 | * @return string |
| 647 | 647 | */ |
| 648 | - public function print_admin_notices( $notice_args = array() ) { |
|
| 648 | + public function print_admin_notices($notice_args = array()) { |
|
| 649 | 649 | // Bailout. |
| 650 | - if ( empty( $notice_args['description'] ) ) { |
|
| 650 | + if (empty($notice_args['description'])) { |
|
| 651 | 651 | return ''; |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - $defaults = array( |
|
| 654 | + $defaults = array( |
|
| 655 | 655 | 'id' => '', |
| 656 | 656 | 'echo' => true, |
| 657 | 657 | 'notice_type' => 'warning', |
| 658 | 658 | 'dismissible' => true, |
| 659 | 659 | ); |
| 660 | - $notice_args = wp_parse_args( $notice_args, $defaults ); |
|
| 660 | + $notice_args = wp_parse_args($notice_args, $defaults); |
|
| 661 | 661 | |
| 662 | 662 | $output = ''; |
| 663 | - $css_id = ! empty( $notice_args['id'] ) ? $notice_args['id'] : uniqid( 'give-inline-notice-' ); |
|
| 663 | + $css_id = ! empty($notice_args['id']) ? $notice_args['id'] : uniqid('give-inline-notice-'); |
|
| 664 | 664 | $css_class = "notice-{$notice_args['notice_type']} give-notice notice inline"; |
| 665 | - $css_class .= ( $notice_args['dismissible'] ) ? ' is-dismissible' : ''; |
|
| 665 | + $css_class .= ($notice_args['dismissible']) ? ' is-dismissible' : ''; |
|
| 666 | 666 | $output .= sprintf( |
| 667 | 667 | '<div id="%1$s" class="%2$s"><p>%3$s</p></div>', |
| 668 | 668 | $css_id, |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | $notice_args['description'] |
| 671 | 671 | ); |
| 672 | 672 | |
| 673 | - if ( ! $notice_args['echo'] ) { |
|
| 673 | + if ( ! $notice_args['echo']) { |
|
| 674 | 674 | return $output; |
| 675 | 675 | } |
| 676 | 676 | |
@@ -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_Earnings_Report' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Earnings_Report')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Earnings_Report. |
@@ -35,16 +35,16 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function __construct() { |
| 37 | 37 | $this->id = 'earnings'; |
| 38 | - $this->label = esc_html__( 'Income', 'give' ); |
|
| 38 | + $this->label = esc_html__('Income', 'give'); |
|
| 39 | 39 | |
| 40 | 40 | parent::__construct(); |
| 41 | 41 | |
| 42 | - add_action( 'give_admin_field_report_earnings', array( $this, 'render_report_earnings_field' ), 10, 2 ); |
|
| 42 | + add_action('give_admin_field_report_earnings', array($this, 'render_report_earnings_field'), 10, 2); |
|
| 43 | 43 | |
| 44 | 44 | // Do not use main form for this tab. |
| 45 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
| 46 | - add_action( 'give-reports_open_form', '__return_empty_string' ); |
|
| 47 | - add_action( 'give-reports_close_form', '__return_empty_string' ); |
|
| 45 | + if (give_get_current_setting_tab() === $this->id) { |
|
| 46 | + add_action('give-reports_open_form', '__return_empty_string'); |
|
| 47 | + add_action('give-reports_close_form', '__return_empty_string'); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param array $settings |
| 65 | 65 | */ |
| 66 | 66 | $settings = apply_filters( |
| 67 | - 'give_get_settings_' . $this->id, |
|
| 67 | + 'give_get_settings_'.$this->id, |
|
| 68 | 68 | array( |
| 69 | 69 | array( |
| 70 | 70 | 'id' => 'give_tools_earnings', |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | ), |
| 74 | 74 | array( |
| 75 | 75 | 'id' => 'earnings', |
| 76 | - 'name' => esc_html__( 'Income', 'give' ), |
|
| 76 | + 'name' => esc_html__('Income', 'give'), |
|
| 77 | 77 | 'type' => 'report_earnings', |
| 78 | 78 | ), |
| 79 | 79 | array( |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | * @param $field |
| 98 | 98 | * @param $option_value |
| 99 | 99 | */ |
| 100 | - public function render_report_earnings_field( $field, $option_value ) { |
|
| 101 | - do_action( 'give_reports_view_earnings' ); |
|
| 100 | + public function render_report_earnings_field($field, $option_value) { |
|
| 101 | + do_action('give_reports_view_earnings'); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -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_Forms_Report' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Forms_Report')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Forms_Report. |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct() { |
| 36 | 36 | $this->id = 'forms'; |
| 37 | - $this->label = esc_html__( 'Forms', 'give' ); |
|
| 37 | + $this->label = esc_html__('Forms', 'give'); |
|
| 38 | 38 | |
| 39 | 39 | parent::__construct(); |
| 40 | 40 | |
| 41 | - add_action( 'give_admin_field_report_forms', array( $this, 'render_report_forms_field' ), 10, 2 ); |
|
| 41 | + add_action('give_admin_field_report_forms', array($this, 'render_report_forms_field'), 10, 2); |
|
| 42 | 42 | |
| 43 | 43 | // Do not use main form for this tab. |
| 44 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
| 45 | - add_action( 'give-reports_open_form', '__return_empty_string' ); |
|
| 46 | - add_action( 'give-reports_close_form', '__return_empty_string' ); |
|
| 44 | + if (give_get_current_setting_tab() === $this->id) { |
|
| 45 | + add_action('give-reports_open_form', '__return_empty_string'); |
|
| 46 | + add_action('give-reports_close_form', '__return_empty_string'); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param array $settings |
| 64 | 64 | */ |
| 65 | 65 | $settings = apply_filters( |
| 66 | - 'give_get_settings_' . $this->id, |
|
| 66 | + 'give_get_settings_'.$this->id, |
|
| 67 | 67 | array( |
| 68 | 68 | array( |
| 69 | 69 | 'id' => 'give_reports_forms', |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ), |
| 73 | 73 | array( |
| 74 | 74 | 'id' => 'forms', |
| 75 | - 'name' => esc_html__( 'Forms', 'give' ), |
|
| 75 | + 'name' => esc_html__('Forms', 'give'), |
|
| 76 | 76 | 'type' => 'report_forms', |
| 77 | 77 | ), |
| 78 | 78 | array( |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | * @param $field |
| 97 | 97 | * @param $option_value |
| 98 | 98 | */ |
| 99 | - public function render_report_forms_field( $field, $option_value ) { |
|
| 100 | - do_action( 'give_reports_view_forms' ); |
|
| 99 | + public function render_report_forms_field($field, $option_value) { |
|
| 100 | + do_action('give_reports_view_forms'); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | // Exit if accessed directly. |
| 19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 19 | +if ( ! defined('ABSPATH')) { |
|
| 20 | 20 | exit; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | 31 | function give_reports_page() { |
| 32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' ); |
|
| 33 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
| 32 | + $current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); |
|
| 33 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
| 34 | 34 | $views = give_reports_default_views(); |
| 35 | 35 | ?> |
| 36 | 36 | <div class="wrap give-settings-page"> |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | <h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1> |
| 39 | 39 | |
| 40 | 40 | <h2 class="nav-tab-wrapper"> |
| 41 | - <?php foreach ( $views as $tab => $label ) { ?> |
|
| 42 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 41 | + <?php foreach ($views as $tab => $label) { ?> |
|
| 42 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 43 | 43 | 'tab' => $tab, |
| 44 | 44 | 'settings-updated' => false, |
| 45 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a> |
|
| 45 | + ), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a> |
|
| 46 | 46 | <?php } ?> |
| 47 | - <?php if ( current_user_can( 'export_give_reports' ) ) { ?> |
|
| 48 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 47 | + <?php if (current_user_can('export_give_reports')) { ?> |
|
| 48 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 49 | 49 | 'tab' => 'export', |
| 50 | 50 | 'settings-updated' => false, |
| 51 | - ), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a> |
|
| 51 | + ), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a> |
|
| 52 | 52 | <?php } |
| 53 | 53 | /** |
| 54 | 54 | * Fires in the report tabs. |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @since 1.0 |
| 59 | 59 | */ |
| 60 | - do_action( 'give_reports_tabs' ); |
|
| 60 | + do_action('give_reports_tabs'); |
|
| 61 | 61 | ?> |
| 62 | 62 | </h2> |
| 63 | 63 | |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @since 1.0 |
| 69 | 69 | */ |
| 70 | - do_action( 'give_reports_page_top' ); |
|
| 70 | + do_action('give_reports_page_top'); |
|
| 71 | 71 | |
| 72 | 72 | // Set $active_tab prior to hook firing. |
| 73 | - if ( in_array( $active_tab, array_keys( $views ) ) ) { |
|
| 73 | + if (in_array($active_tab, array_keys($views))) { |
|
| 74 | 74 | $active_tab = 'reports'; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @since 1.0 |
| 81 | 81 | */ |
| 82 | - do_action( "give_reports_tab_{$active_tab}" ); |
|
| 82 | + do_action("give_reports_tab_{$active_tab}"); |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Fires after the report page. |
| 86 | 86 | * |
| 87 | 87 | * @since 1.0 |
| 88 | 88 | */ |
| 89 | - do_action( 'give_reports_page_bottom' ); |
|
| 89 | + do_action('give_reports_page_bottom'); |
|
| 90 | 90 | ?> |
| 91 | 91 | </div><!-- .wrap --> |
| 92 | 92 | <?php |
@@ -100,12 +100,12 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | function give_reports_default_views() { |
| 102 | 102 | $views = array( |
| 103 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
| 104 | - 'forms' => esc_html__( 'Forms', 'give' ), |
|
| 105 | - 'gateways' => esc_html__( 'Donation Methods', 'give' ), |
|
| 103 | + 'earnings' => esc_html__('Income', 'give'), |
|
| 104 | + 'forms' => esc_html__('Forms', 'give'), |
|
| 105 | + 'gateways' => esc_html__('Donation Methods', 'give'), |
|
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - $views = apply_filters( 'give_report_views', $views ); |
|
| 108 | + $views = apply_filters('give_report_views', $views); |
|
| 109 | 109 | |
| 110 | 110 | return $views; |
| 111 | 111 | } |
@@ -120,15 +120,15 @@ discard block |
||
| 120 | 120 | * @since 1.0 |
| 121 | 121 | * @return string $view Report View |
| 122 | 122 | */ |
| 123 | -function give_get_reporting_view( $default = 'earnings' ) { |
|
| 123 | +function give_get_reporting_view($default = 'earnings') { |
|
| 124 | 124 | |
| 125 | - if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { |
|
| 125 | + if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { |
|
| 126 | 126 | $view = $default; |
| 127 | 127 | } else { |
| 128 | 128 | $view = $_GET['view']; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - return apply_filters( 'give_get_reporting_view', $view ); |
|
| 131 | + return apply_filters('give_get_reporting_view', $view); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | function give_reports_tab_reports() { |
| 141 | 141 | |
| 142 | - if( ! current_user_can( 'view_give_reports' ) ) { |
|
| 143 | - wp_die( __( 'You do not have permission to access this report', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 142 | + if ( ! current_user_can('view_give_reports')) { |
|
| 143 | + wp_die(__('You do not have permission to access this report', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $current_view = 'earnings'; |
| 147 | 147 | $views = give_reports_default_views(); |
| 148 | 148 | |
| 149 | - if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) { |
|
| 149 | + if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) { |
|
| 150 | 150 | $current_view = $_GET['tab']; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @since 1.0 |
| 157 | 157 | */ |
| 158 | - do_action( "give_reports_view_{$current_view}" ); |
|
| 158 | + do_action("give_reports_view_{$current_view}"); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' ); |
|
| 161 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); |
|
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | 164 | * Renders the Reports Page Views Drop Downs |
@@ -168,19 +168,19 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | function give_report_views() { |
| 170 | 170 | $views = give_reports_default_views(); |
| 171 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings'; |
|
| 171 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings'; |
|
| 172 | 172 | /** |
| 173 | 173 | * Fires before the report page actions form. |
| 174 | 174 | * |
| 175 | 175 | * @since 1.0 |
| 176 | 176 | */ |
| 177 | - do_action( 'give_report_view_actions_before' ); |
|
| 177 | + do_action('give_report_view_actions_before'); |
|
| 178 | 178 | ?> |
| 179 | 179 | <form id="give-reports-filter" method="get"> |
| 180 | 180 | <select id="give-reports-view" name="view"> |
| 181 | - <option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option> |
|
| 182 | - <?php foreach ( $views as $view_id => $label ) : ?> |
|
| 183 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
| 181 | + <option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option> |
|
| 182 | + <?php foreach ($views as $view_id => $label) : ?> |
|
| 183 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
| 184 | 184 | <?php endforeach; ?> |
| 185 | 185 | </select> |
| 186 | 186 | |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @since 1.0 |
| 194 | 194 | */ |
| 195 | - do_action( 'give_report_view_actions' ); |
|
| 195 | + do_action('give_report_view_actions'); |
|
| 196 | 196 | ?> |
| 197 | 197 | |
| 198 | 198 | <input type="hidden" name="post_type" value="give_forms"/> |
| 199 | 199 | <input type="hidden" name="page" value="give-reports"/> |
| 200 | - <?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?> |
|
| 200 | + <?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?> |
|
| 201 | 201 | </form> |
| 202 | 202 | <?php |
| 203 | 203 | /** |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @since 1.0 |
| 207 | 207 | */ |
| 208 | - do_action( 'give_report_view_actions_after' ); |
|
| 208 | + do_action('give_report_view_actions_after'); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | function give_reports_forms_table() { |
| 220 | 220 | |
| 221 | - if ( isset( $_GET['form-id'] ) ) { |
|
| 221 | + if (isset($_GET['form-id'])) { |
|
| 222 | 222 | return; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' ); |
|
| 225 | + include(dirname(__FILE__).'/class-form-reports-table.php'); |
|
| 226 | 226 | |
| 227 | 227 | $give_table = new Give_Form_Reports_Table(); |
| 228 | 228 | $give_table->prepare_items(); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | <?php |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' ); |
|
| 237 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); |
|
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | 240 | * Renders the detailed report for a specific give form. |
@@ -243,20 +243,20 @@ discard block |
||
| 243 | 243 | * @return void |
| 244 | 244 | */ |
| 245 | 245 | function give_reports_form_details() { |
| 246 | - if ( ! isset( $_GET['form-id'] ) ) { |
|
| 246 | + if ( ! isset($_GET['form-id'])) { |
|
| 247 | 247 | return; |
| 248 | 248 | } |
| 249 | 249 | ?> |
| 250 | 250 | <div class="tablenav top reports-forms-details-wrap"> |
| 251 | 251 | <div class="actions bulkactions"> |
| 252 | - <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button> |
|
| 252 | + <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button> |
|
| 253 | 253 | </div> |
| 254 | 254 | </div> |
| 255 | 255 | <?php |
| 256 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) ); |
|
| 256 | + give_reports_graph_of_form(absint($_GET['form-id'])); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' ); |
|
| 259 | +add_action('give_reports_view_forms', 'give_reports_form_details'); |
|
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | 262 | * Renders the Gateways Table |
@@ -267,14 +267,14 @@ discard block |
||
| 267 | 267 | * @return void |
| 268 | 268 | */ |
| 269 | 269 | function give_reports_gateways_table() { |
| 270 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' ); |
|
| 270 | + include(dirname(__FILE__).'/class-gateways-reports-table.php'); |
|
| 271 | 271 | |
| 272 | 272 | $give_table = new Give_Gateway_Reports_Table(); |
| 273 | 273 | $give_table->prepare_items(); |
| 274 | 274 | $give_table->display(); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' ); |
|
| 277 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); |
|
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | 280 | * Renders the Reports Earnings Graphs |
@@ -285,13 +285,13 @@ discard block |
||
| 285 | 285 | function give_reports_earnings() { |
| 286 | 286 | ?> |
| 287 | 287 | <div class="tablenav top reports-table-nav"> |
| 288 | - <h2 class="reports-earnings-title screen-reader-text"><?php _e( 'Income Report', 'give' ); ?></h2> |
|
| 288 | + <h2 class="reports-earnings-title screen-reader-text"><?php _e('Income Report', 'give'); ?></h2> |
|
| 289 | 289 | </div> |
| 290 | 290 | <?php |
| 291 | 291 | give_reports_graph(); |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' ); |
|
| 294 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); |
|
| 295 | 295 | |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | function give_estimated_monthly_stats() { |
| 304 | 304 | |
| 305 | - $estimated = Give_Cache::get( 'give_estimated_monthly_stats', true ); |
|
| 305 | + $estimated = Give_Cache::get('give_estimated_monthly_stats', true); |
|
| 306 | 306 | |
| 307 | - if ( false === $estimated ) { |
|
| 307 | + if (false === $estimated) { |
|
| 308 | 308 | |
| 309 | 309 | $estimated = array( |
| 310 | 310 | 'earnings' => 0, |
@@ -313,22 +313,22 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | $stats = new Give_Payment_Stats; |
| 315 | 315 | |
| 316 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' ); |
|
| 317 | - $to_date_sales = $stats->get_sales( 0, 'this_month' ); |
|
| 316 | + $to_date_earnings = $stats->get_earnings(0, 'this_month'); |
|
| 317 | + $to_date_sales = $stats->get_sales(0, 'this_month'); |
|
| 318 | 318 | |
| 319 | - $current_day = date( 'd', current_time( 'timestamp' ) ); |
|
| 320 | - $current_month = date( 'n', current_time( 'timestamp' ) ); |
|
| 321 | - $current_year = date( 'Y', current_time( 'timestamp' ) ); |
|
| 322 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year ); |
|
| 319 | + $current_day = date('d', current_time('timestamp')); |
|
| 320 | + $current_month = date('n', current_time('timestamp')); |
|
| 321 | + $current_year = date('Y', current_time('timestamp')); |
|
| 322 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); |
|
| 323 | 323 | |
| 324 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month; |
|
| 325 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month; |
|
| 324 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month; |
|
| 325 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month; |
|
| 326 | 326 | |
| 327 | 327 | // Cache for one day |
| 328 | - Give_Cache::set( 'give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true ); |
|
| 328 | + Give_Cache::set('give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - return maybe_unserialize( $estimated ); |
|
| 331 | + return maybe_unserialize($estimated); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | function give_reports_set_form_method() { |
| 342 | 342 | return 'get'; |
| 343 | 343 | } |
| 344 | -add_filter( 'give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10 ); |
|
| 345 | -add_filter( 'give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10 ); |
|
| 344 | +add_filter('give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10); |
|
| 345 | +add_filter('give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10); |
|
| 346 | 346 | |
| 347 | 347 | // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file. |