@@ -10,61 +10,61 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Load Give file. |
| 18 | -include_once( 'give.php' ); |
|
| 18 | +include_once('give.php'); |
|
| 19 | 19 | |
| 20 | 20 | global $wpdb, $wp_roles; |
| 21 | 21 | |
| 22 | 22 | |
| 23 | -if ( give_get_option( 'uninstall_on_delete' ) === 'on' ) { |
|
| 23 | +if (give_get_option('uninstall_on_delete') === 'on') { |
|
| 24 | 24 | |
| 25 | 25 | // Delete All the Custom Post Types. |
| 26 | - $give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' ); |
|
| 27 | - $give_post_types = array( 'give_forms', 'give_payment', 'give_log' ); |
|
| 28 | - foreach ( $give_post_types as $post_type ) { |
|
| 26 | + $give_taxonomies = array('form_category', 'form_tag', 'give_log_type'); |
|
| 27 | + $give_post_types = array('give_forms', 'give_payment', 'give_log'); |
|
| 28 | + foreach ($give_post_types as $post_type) { |
|
| 29 | 29 | |
| 30 | - $give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) ); |
|
| 31 | - $items = get_posts( array( |
|
| 30 | + $give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type)); |
|
| 31 | + $items = get_posts(array( |
|
| 32 | 32 | 'post_type' => $post_type, |
| 33 | 33 | 'post_status' => 'any', |
| 34 | - 'numberposts' => - 1, |
|
| 34 | + 'numberposts' => -1, |
|
| 35 | 35 | 'fields' => 'ids', |
| 36 | - ) ); |
|
| 36 | + )); |
|
| 37 | 37 | |
| 38 | - if ( $items ) { |
|
| 39 | - foreach ( $items as $item ) { |
|
| 40 | - wp_delete_post( $item, true ); |
|
| 38 | + if ($items) { |
|
| 39 | + foreach ($items as $item) { |
|
| 40 | + wp_delete_post($item, true); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Delete All the Terms & Taxonomies. |
| 46 | - foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) { |
|
| 46 | + foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { |
|
| 47 | 47 | |
| 48 | - $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); |
|
| 48 | + $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); |
|
| 49 | 49 | |
| 50 | 50 | // Delete Terms. |
| 51 | - if ( $terms ) { |
|
| 52 | - foreach ( $terms as $term ) { |
|
| 53 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
| 54 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); |
|
| 51 | + if ($terms) { |
|
| 52 | + foreach ($terms as $term) { |
|
| 53 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
| 54 | + $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Delete Taxonomies. |
| 59 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); |
|
| 59 | + $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s')); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Delete the Plugin Pages. |
| 63 | - $give_created_pages = array( 'success_page', 'failure_page', 'history_page' ); |
|
| 64 | - foreach ( $give_created_pages as $p ) { |
|
| 65 | - $page = give_get_option( $p, false ); |
|
| 66 | - if ( $page ) { |
|
| 67 | - wp_delete_post( $page, true ); |
|
| 63 | + $give_created_pages = array('success_page', 'failure_page', 'history_page'); |
|
| 64 | + foreach ($give_created_pages as $p) { |
|
| 65 | + $page = give_get_option($p, false); |
|
| 66 | + if ($page) { |
|
| 67 | + wp_delete_post($page, true); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -72,20 +72,20 @@ discard block |
||
| 72 | 72 | Give()->roles->remove_caps(); |
| 73 | 73 | |
| 74 | 74 | // Delete the Roles. |
| 75 | - $give_roles = array( 'give_manager', 'give_accountant', 'give_worker' ); |
|
| 76 | - foreach ( $give_roles as $role ) { |
|
| 77 | - remove_role( $role ); |
|
| 75 | + $give_roles = array('give_manager', 'give_accountant', 'give_worker'); |
|
| 76 | + foreach ($give_roles as $role) { |
|
| 77 | + remove_role($role); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Remove all database tables. |
| 81 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' ); |
|
| 82 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' ); |
|
| 83 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' ); |
|
| 81 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors'); |
|
| 82 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers'); |
|
| 83 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta'); |
|
| 84 | 84 | |
| 85 | 85 | // Cleanup Cron Events. |
| 86 | - wp_clear_scheduled_hook( 'give_daily_scheduled_events' ); |
|
| 87 | - wp_clear_scheduled_hook( 'give_daily_cron' ); |
|
| 88 | - wp_clear_scheduled_hook( 'give_weekly_cron' ); |
|
| 86 | + wp_clear_scheduled_hook('give_daily_scheduled_events'); |
|
| 87 | + wp_clear_scheduled_hook('give_daily_cron'); |
|
| 88 | + wp_clear_scheduled_hook('give_weekly_cron'); |
|
| 89 | 89 | |
| 90 | 90 | // Get all options. |
| 91 | 91 | $give_option_names = $wpdb->get_results( |
@@ -96,24 +96,24 @@ discard block |
||
| 96 | 96 | ARRAY_A |
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | - if ( ! empty( $give_option_names ) ) { |
|
| 99 | + if ( ! empty($give_option_names)) { |
|
| 100 | 100 | // Convert option name to transient or option name. |
| 101 | 101 | $new_give_option_names = array(); |
| 102 | 102 | |
| 103 | - foreach ( $give_option_names as $option ) { |
|
| 104 | - $new_give_option_names[] = ( false !== strpos( $option['option_name'], '_transient_' ) ) |
|
| 105 | - ? str_replace( '_transient_', '', $option['option_name'] ) |
|
| 103 | + foreach ($give_option_names as $option) { |
|
| 104 | + $new_give_option_names[] = (false !== strpos($option['option_name'], '_transient_')) |
|
| 105 | + ? str_replace('_transient_', '', $option['option_name']) |
|
| 106 | 106 | : $option['option_name']; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $give_option_names = $new_give_option_names; |
| 110 | 110 | |
| 111 | 111 | // Delete all the Plugin Options. |
| 112 | - foreach ( $give_option_names as $option ) { |
|
| 113 | - if ( false !== strpos( $option, '_transient_' ) ) { |
|
| 114 | - delete_transient( $option ); |
|
| 112 | + foreach ($give_option_names as $option) { |
|
| 113 | + if (false !== strpos($option, '_transient_')) { |
|
| 114 | + delete_transient($option); |
|
| 115 | 115 | } else { |
| 116 | - delete_option( $option ); |
|
| 116 | + delete_option($option); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -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,15 +24,15 @@ discard block |
||
| 24 | 24 | * @global $wp_version |
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | -function give_install( $network_wide = false ) { |
|
| 27 | +function give_install($network_wide = false) { |
|
| 28 | 28 | |
| 29 | 29 | global $wpdb; |
| 30 | 30 | |
| 31 | - if ( is_multisite() && $network_wide ) { |
|
| 31 | + if (is_multisite() && $network_wide) { |
|
| 32 | 32 | |
| 33 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
| 33 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
| 34 | 34 | |
| 35 | - switch_to_blog( $blog_id ); |
|
| 35 | + switch_to_blog($blog_id); |
|
| 36 | 36 | give_run_install(); |
| 37 | 37 | restore_current_blog(); |
| 38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
| 49 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Run the Give Install process. |
@@ -62,24 +62,24 @@ discard block |
||
| 62 | 62 | give_setup_post_types(); |
| 63 | 63 | |
| 64 | 64 | // Clear the permalinks. |
| 65 | - flush_rewrite_rules( false ); |
|
| 65 | + flush_rewrite_rules(false); |
|
| 66 | 66 | |
| 67 | 67 | // Add Upgraded From Option. |
| 68 | - $current_version = get_option( 'give_version' ); |
|
| 69 | - if ( $current_version ) { |
|
| 70 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
| 68 | + $current_version = get_option('give_version'); |
|
| 69 | + if ($current_version) { |
|
| 70 | + update_option('give_version_upgraded_from', $current_version); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Setup some default options. |
| 74 | 74 | $options = array(); |
| 75 | 75 | |
| 76 | 76 | // Checks if the Success Page option exists AND that the page exists. |
| 77 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
| 77 | + if ( ! get_post(give_get_option('success_page'))) { |
|
| 78 | 78 | |
| 79 | 79 | // Donations Confirmation (Success) Page. |
| 80 | 80 | $success = wp_insert_post( |
| 81 | 81 | array( |
| 82 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
| 82 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
| 83 | 83 | 'post_content' => '[give_receipt]', |
| 84 | 84 | 'post_status' => 'publish', |
| 85 | 85 | 'post_author' => 1, |
@@ -93,13 +93,13 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Checks if the Failure Page option exists AND that the page exists. |
| 96 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
| 96 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
| 97 | 97 | |
| 98 | 98 | // Failed Donation Page. |
| 99 | 99 | $failed = wp_insert_post( |
| 100 | 100 | array( |
| 101 | - 'post_title' => esc_html__( 'Transaction Failed', 'give' ), |
|
| 102 | - 'post_content' => esc_html__( 'We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give' ), |
|
| 101 | + 'post_title' => esc_html__('Transaction Failed', 'give'), |
|
| 102 | + 'post_content' => esc_html__('We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give'), |
|
| 103 | 103 | 'post_status' => 'publish', |
| 104 | 104 | 'post_author' => 1, |
| 105 | 105 | 'post_type' => 'page', |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Checks if the History Page option exists AND that the page exists. |
| 114 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
| 114 | + if ( ! get_post(give_get_option('history_page'))) { |
|
| 115 | 115 | // Purchase History (History) Page. |
| 116 | 116 | $history = wp_insert_post( |
| 117 | 117 | array( |
| 118 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
| 118 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
| 119 | 119 | 'post_content' => '[donation_history]', |
| 120 | 120 | 'post_status' => 'publish', |
| 121 | 121 | 'post_author' => 1, |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
| 131 | - if ( empty( $current_version ) ) { |
|
| 131 | + if (empty($current_version)) { |
|
| 132 | 132 | $options['base_country'] = 'US'; |
| 133 | 133 | $options['test_mode'] = 1; |
| 134 | 134 | $options['currency'] = 'USD'; |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Populate the default values. |
| 155 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
| 156 | - update_option( 'give_version', GIVE_VERSION ); |
|
| 155 | + update_option('give_settings', array_merge($give_options, $options)); |
|
| 156 | + update_option('give_version', GIVE_VERSION); |
|
| 157 | 157 | |
| 158 | 158 | // Create Give roles. |
| 159 | 159 | $roles = new Give_Roles(); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $roles->add_caps(); |
| 162 | 162 | |
| 163 | 163 | $api = new Give_API(); |
| 164 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
| 164 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
| 165 | 165 | |
| 166 | 166 | // Create the customers databases. |
| 167 | 167 | @Give()->customers->create_table(); |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | Give()->session->use_php_sessions(); |
| 172 | 172 | |
| 173 | 173 | // Add a temporary option to note that Give pages have been created. |
| 174 | - set_transient( '_give_installed', $options, 30 ); |
|
| 174 | + set_transient('_give_installed', $options, 30); |
|
| 175 | 175 | |
| 176 | - if ( ! $current_version ) { |
|
| 176 | + if ( ! $current_version) { |
|
| 177 | 177 | |
| 178 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 178 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 179 | 179 | |
| 180 | 180 | // When new upgrade routines are added, mark them as complete on fresh install. |
| 181 | 181 | $upgrade_routines = array( |
@@ -184,22 +184,22 @@ discard block |
||
| 184 | 184 | 'upgrade_give_offline_status' |
| 185 | 185 | ); |
| 186 | 186 | |
| 187 | - foreach ( $upgrade_routines as $upgrade ) { |
|
| 188 | - give_set_upgrade_complete( $upgrade ); |
|
| 187 | + foreach ($upgrade_routines as $upgrade) { |
|
| 188 | + give_set_upgrade_complete($upgrade); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // Bail if activating from network, or bulk. |
| 193 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 193 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 194 | 194 | return; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // Add the transient to redirect. |
| 198 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
| 198 | + set_transient('_give_activation_redirect', true, 30); |
|
| 199 | 199 | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
| 202 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
| 203 | 203 | |
| 204 | 204 | /** |
| 205 | 205 | * Network Activated New Site Setup. |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | * @param int $site_id The Site ID. |
| 216 | 216 | * @param array $meta Blog Meta. |
| 217 | 217 | */ |
| 218 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
| 218 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
| 219 | 219 | |
| 220 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
| 220 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
| 221 | 221 | |
| 222 | - switch_to_blog( $blog_id ); |
|
| 222 | + switch_to_blog($blog_id); |
|
| 223 | 223 | give_install(); |
| 224 | 224 | restore_current_blog(); |
| 225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
| 230 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
| 231 | 231 | |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -240,13 +240,13 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return array The tables to drop. |
| 242 | 242 | */ |
| 243 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
| 243 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
| 244 | 244 | |
| 245 | - switch_to_blog( $blog_id ); |
|
| 245 | + switch_to_blog($blog_id); |
|
| 246 | 246 | $customers_db = new Give_DB_Customers(); |
| 247 | 247 | $customer_meta_db = new Give_DB_Customer_Meta(); |
| 248 | 248 | |
| 249 | - if ( $customers_db->installed() ) { |
|
| 249 | + if ($customers_db->installed()) { |
|
| 250 | 250 | $tables[] = $customers_db->table_name; |
| 251 | 251 | $tables[] = $customer_meta_db->table_name; |
| 252 | 252 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
| 259 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | 262 | * Post-installation |
@@ -268,16 +268,16 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | function give_after_install() { |
| 270 | 270 | |
| 271 | - if ( ! is_admin() ) { |
|
| 271 | + if ( ! is_admin()) { |
|
| 272 | 272 | return; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - $give_options = get_transient( '_give_installed' ); |
|
| 276 | - $give_table_check = get_option( '_give_table_check', false ); |
|
| 275 | + $give_options = get_transient('_give_installed'); |
|
| 276 | + $give_table_check = get_option('_give_table_check', false); |
|
| 277 | 277 | |
| 278 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
| 278 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
| 279 | 279 | |
| 280 | - if ( ! @Give()->customer_meta->installed() ) { |
|
| 280 | + if ( ! @Give()->customer_meta->installed()) { |
|
| 281 | 281 | |
| 282 | 282 | // Create the customer meta database |
| 283 | 283 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -285,27 +285,27 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if ( ! @Give()->customers->installed() ) { |
|
| 288 | + if ( ! @Give()->customers->installed()) { |
|
| 289 | 289 | // Create the customers database |
| 290 | 290 | // (this ensures it creates it on multisite instances where it is network activated). |
| 291 | 291 | @Give()->customers->create_table(); |
| 292 | 292 | |
| 293 | - do_action( 'give_after_install', $give_options ); |
|
| 293 | + do_action('give_after_install', $give_options); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
| 296 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
| 297 | 297 | |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | // Delete the transient |
| 301 | - if ( false !== $give_options ) { |
|
| 302 | - delete_transient( '_give_installed' ); |
|
| 301 | + if (false !== $give_options) { |
|
| 302 | + delete_transient('_give_installed'); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | -add_action( 'admin_init', 'give_after_install' ); |
|
| 308 | +add_action('admin_init', 'give_after_install'); |
|
| 309 | 309 | |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -320,11 +320,11 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | global $wp_roles; |
| 322 | 322 | |
| 323 | - if ( ! is_object( $wp_roles ) ) { |
|
| 323 | + if ( ! is_object($wp_roles)) { |
|
| 324 | 324 | return; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
| 327 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
| 328 | 328 | |
| 329 | 329 | // Create Give plugin roles |
| 330 | 330 | $roles = new Give_Roles(); |
@@ -335,4 +335,4 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
| 339 | 338 | \ No newline at end of file |
| 339 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
| 340 | 340 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | // Exit if accessed directly |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param $_banner_details |
| 28 | 28 | */ |
| 29 | - function __construct( $_banner_details ) { |
|
| 29 | + function __construct($_banner_details) { |
|
| 30 | 30 | |
| 31 | 31 | global $current_user; |
| 32 | 32 | $this->banner_details = $_banner_details; |
| 33 | - $this->test_mode = ( $this->banner_details['testing'] == 'true' ) ? true : false; |
|
| 34 | - $this->nag_meta_key = 'give_addon_activation_ignore_' . sanitize_title( $this->banner_details['name'] ); |
|
| 33 | + $this->test_mode = ($this->banner_details['testing'] == 'true') ? true : false; |
|
| 34 | + $this->nag_meta_key = 'give_addon_activation_ignore_'.sanitize_title($this->banner_details['name']); |
|
| 35 | 35 | |
| 36 | 36 | //Get current user |
| 37 | 37 | $this->user_id = $current_user->ID; |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | public function init() { |
| 51 | 51 | |
| 52 | 52 | //Testing? |
| 53 | - if ( $this->test_mode ) { |
|
| 54 | - delete_user_meta( $this->user_id, $this->nag_meta_key ); |
|
| 53 | + if ($this->test_mode) { |
|
| 54 | + delete_user_meta($this->user_id, $this->nag_meta_key); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | //Get the current page to add the notice to |
| 58 | - add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) ); |
|
| 59 | - add_action( 'admin_notices', array( $this, 'give_addon_activation_admin_notice' ) ); |
|
| 58 | + add_action('current_screen', array($this, 'give_addon_notice_ignore')); |
|
| 59 | + add_action('admin_notices', array($this, 'give_addon_activation_admin_notice')); |
|
| 60 | 60 | |
| 61 | 61 | } |
| 62 | 62 | |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | global $pagenow; |
| 71 | 71 | |
| 72 | 72 | //Make sure we're on the plugins page. |
| 73 | - if ( $pagenow !== 'plugins.php' ) { |
|
| 73 | + if ($pagenow !== 'plugins.php') { |
|
| 74 | 74 | return false; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // If the user hasn't already dismissed our alert, |
| 78 | 78 | // Output the activation banner |
| 79 | - if ( ! get_user_meta( $this->user_id, $this->nag_meta_key ) ) { ?> |
|
| 79 | + if ( ! get_user_meta($this->user_id, $this->nag_meta_key)) { ?> |
|
| 80 | 80 | |
| 81 | 81 | <style> |
| 82 | 82 | div.give-addon-alert.updated { |
@@ -155,43 +155,43 @@ discard block |
||
| 155 | 155 | <h3><?php |
| 156 | 156 | printf( |
| 157 | 157 | /* translators: %s: Add-on name */ |
| 158 | - esc_html__( "Thank you for installing Give's %s Add-on!", 'give' ), |
|
| 159 | - '<span>' . $this->banner_details['name'] . '</span>' |
|
| 158 | + esc_html__("Thank you for installing Give's %s Add-on!", 'give'), |
|
| 159 | + '<span>'.$this->banner_details['name'].'</span>' |
|
| 160 | 160 | ); |
| 161 | 161 | ?></h3> |
| 162 | 162 | |
| 163 | 163 | <a href="<?php |
| 164 | 164 | //The Dismiss Button. |
| 165 | - $nag_admin_dismiss_url = 'plugins.php?' . $this->nag_meta_key . '=0'; |
|
| 166 | - echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss"><span |
|
| 165 | + $nag_admin_dismiss_url = 'plugins.php?'.$this->nag_meta_key.'=0'; |
|
| 166 | + echo admin_url($nag_admin_dismiss_url); ?>" class="dismiss"><span |
|
| 167 | 167 | class="dashicons dashicons-dismiss"></span></a> |
| 168 | 168 | |
| 169 | 169 | <div class="alert-actions"> |
| 170 | 170 | |
| 171 | 171 | <?php //Point them to your settings page. |
| 172 | - if ( isset( $this->banner_details['settings_url'] ) ) { ?> |
|
| 172 | + if (isset($this->banner_details['settings_url'])) { ?> |
|
| 173 | 173 | <a href="<?php echo $this->banner_details['settings_url']; ?>"> |
| 174 | - <span class="dashicons dashicons-admin-settings"></span><?php esc_html_e( 'Go to Settings', 'give' ); ?></a> |
|
| 174 | + <span class="dashicons dashicons-admin-settings"></span><?php esc_html_e('Go to Settings', 'give'); ?></a> |
|
| 175 | 175 | <?php } ?> |
| 176 | 176 | |
| 177 | 177 | <?php |
| 178 | 178 | // Show them how to configure the Addon. |
| 179 | - if ( isset( $this->banner_details['documentation_url'] ) ) { ?> |
|
| 179 | + if (isset($this->banner_details['documentation_url'])) { ?> |
|
| 180 | 180 | <a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank"> |
| 181 | 181 | <span class="dashicons dashicons-media-text"></span><?php |
| 182 | 182 | printf( |
| 183 | 183 | /* translators: %s: Add-on name */ |
| 184 | - esc_html__( 'Documentation: %s Add-on', 'give' ), |
|
| 184 | + esc_html__('Documentation: %s Add-on', 'give'), |
|
| 185 | 185 | $this->banner_details['name'] |
| 186 | 186 | ); |
| 187 | 187 | ?></a> |
| 188 | 188 | <?php } ?> |
| 189 | 189 | <?php |
| 190 | 190 | //Let them signup for plugin updates |
| 191 | - if ( isset( $this->banner_details['support_url'] ) ) { ?> |
|
| 191 | + if (isset($this->banner_details['support_url'])) { ?> |
|
| 192 | 192 | |
| 193 | 193 | <a href="<?php echo $this->banner_details['support_url'] ?>" target="_blank"> |
| 194 | - <span class="dashicons dashicons-sos"></span><?php esc_html_e( 'Get Support', 'give' ); ?> |
|
| 194 | + <span class="dashicons dashicons-sos"></span><?php esc_html_e('Get Support', 'give'); ?> |
|
| 195 | 195 | </a> |
| 196 | 196 | |
| 197 | 197 | <?php } ?> |
@@ -215,13 +215,13 @@ discard block |
||
| 215 | 215 | * If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not. |
| 216 | 216 | * See here: http://codex.wordpress.org/Function_Reference/add_user_meta |
| 217 | 217 | */ |
| 218 | - if ( isset( $_GET[ $this->nag_meta_key ] ) && '0' == $_GET[ $this->nag_meta_key ] ) { |
|
| 218 | + if (isset($_GET[$this->nag_meta_key]) && '0' == $_GET[$this->nag_meta_key]) { |
|
| 219 | 219 | |
| 220 | 220 | //Get the global user |
| 221 | 221 | global $current_user; |
| 222 | 222 | $user_id = $current_user->ID; |
| 223 | 223 | |
| 224 | - add_user_meta( $user_id, $this->nag_meta_key, 'true', true ); |
|
| 224 | + add_user_meta($user_id, $this->nag_meta_key, 'true', true); |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -defined( 'ABSPATH' ) or exit; |
|
| 13 | +defined('ABSPATH') or exit; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Give Form widget |
| 17 | 17 | * |
| 18 | 18 | * @since 1.0 |
| 19 | 19 | */ |
| 20 | -class Give_Forms_Widget extends WP_Widget{ |
|
| 20 | +class Give_Forms_Widget extends WP_Widget { |
|
| 21 | 21 | /** |
| 22 | 22 | * The widget class name |
| 23 | 23 | * |
@@ -28,19 +28,19 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * Instantiate the class |
| 30 | 30 | */ |
| 31 | - public function __construct(){ |
|
| 32 | - $this->self = get_class( $this ); |
|
| 31 | + public function __construct() { |
|
| 32 | + $this->self = get_class($this); |
|
| 33 | 33 | |
| 34 | 34 | parent::__construct( |
| 35 | - strtolower( $this->self ), |
|
| 36 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
| 35 | + strtolower($this->self), |
|
| 36 | + esc_html__('Give - Donation Form', 'give'), |
|
| 37 | 37 | array( |
| 38 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
| 38 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
| 39 | 39 | ) |
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
| 43 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
| 42 | + add_action('widgets_init', array($this, 'widget_init')); |
|
| 43 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -50,23 +50,23 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return void |
| 52 | 52 | */ |
| 53 | - public function admin_widget_scripts( $hook ){ |
|
| 53 | + public function admin_widget_scripts($hook) { |
|
| 54 | 54 | // Directories of assets |
| 55 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
| 56 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
| 57 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
| 55 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
| 56 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
| 57 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
| 58 | 58 | |
| 59 | 59 | // Use minified libraries if SCRIPT_DEBUG is turned off |
| 60 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 60 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 61 | 61 | |
| 62 | 62 | // Widget Script |
| 63 | - if ( $hook == 'widgets.php' ) { |
|
| 63 | + if ($hook == 'widgets.php') { |
|
| 64 | 64 | |
| 65 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
| 65 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
| 66 | 66 | |
| 67 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
| 67 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
| 68 | 68 | |
| 69 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 69 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
@@ -77,27 +77,27 @@ discard block |
||
| 77 | 77 | * before_widget, and after_widget. |
| 78 | 78 | * @param array $instance The settings for the particular instance of the widget. |
| 79 | 79 | */ |
| 80 | - public function widget( $args, $instance ){ |
|
| 81 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
| 82 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
| 80 | + public function widget($args, $instance) { |
|
| 81 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 82 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | // If user set float labels to global then check global float label setting and update donation form widget accordingly. |
| 86 | - if( ( 'global' === $instance['float_labels'] ) ) { |
|
| 87 | - $instance['float_labels'] = ( 'on' === give_get_option( 'enable_floatlabels', '' ) ) ? 'enabled' : 'disabled'; |
|
| 86 | + if (('global' === $instance['float_labels'])) { |
|
| 87 | + $instance['float_labels'] = ('on' === give_get_option('enable_floatlabels', '')) ? 'enabled' : 'disabled'; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | echo $args['before_widget']; |
| 91 | 91 | |
| 92 | - do_action( 'give_before_forms_widget' ); |
|
| 92 | + do_action('give_before_forms_widget'); |
|
| 93 | 93 | |
| 94 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
| 94 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
| 95 | 95 | |
| 96 | - give_get_donation_form( $instance ); |
|
| 96 | + give_get_donation_form($instance); |
|
| 97 | 97 | |
| 98 | 98 | echo $args['after_widget']; |
| 99 | 99 | |
| 100 | - do_action( 'give_after_forms_widget' ); |
|
| 100 | + do_action('give_after_forms_widget'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | - public function form( $instance ){ |
|
| 110 | + public function form($instance) { |
|
| 111 | 111 | $defaults = array( |
| 112 | 112 | 'title' => '', |
| 113 | 113 | 'id' => '', |
@@ -115,70 +115,70 @@ discard block |
||
| 115 | 115 | 'display_style' => 'modal', |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 118 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
| 119 | 119 | |
| 120 | 120 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
| 121 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
| 121 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
| 122 | 122 | |
| 123 | 123 | // Query Give Forms |
| 124 | 124 | $args = array( |
| 125 | 125 | 'post_type' => 'give_forms', |
| 126 | - 'posts_per_page' => - 1, |
|
| 126 | + 'posts_per_page' => -1, |
|
| 127 | 127 | 'post_status' => 'publish', |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - $give_forms = get_posts( $args ); |
|
| 130 | + $give_forms = get_posts($args); |
|
| 131 | 131 | |
| 132 | 132 | // Widget: Title |
| 133 | 133 | |
| 134 | 134 | ?><p> |
| 135 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
| 136 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br> |
|
| 137 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
| 135 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
| 136 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br> |
|
| 137 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
| 138 | 138 | </p><?php |
| 139 | 139 | |
| 140 | 140 | // Widget: Give Form |
| 141 | 141 | |
| 142 | 142 | ?><p> |
| 143 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php |
|
| 143 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php |
|
| 144 | 144 | printf( |
| 145 | 145 | /* translators: %s: form singular label */ |
| 146 | - esc_html__( 'Give %s:', 'give' ), |
|
| 146 | + esc_html__('Give %s:', 'give'), |
|
| 147 | 147 | give_get_forms_label_singular() |
| 148 | 148 | ); |
| 149 | 149 | ?></label> |
| 150 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
| 151 | - <option value="current"><?php esc_html_e( '— Select —', 'give' ); ?></option> |
|
| 152 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
| 153 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option> |
|
| 150 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
| 151 | + <option value="current"><?php esc_html_e('— Select —', 'give'); ?></option> |
|
| 152 | + <?php foreach ($give_forms as $give_form) { ?> |
|
| 153 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option> |
|
| 154 | 154 | <?php } ?> |
| 155 | 155 | </select><br> |
| 156 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
| 156 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
| 157 | 157 | </p> |
| 158 | 158 | |
| 159 | 159 | <?php // Widget: Display Style ?> |
| 160 | 160 | <p> |
| 161 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display style:', 'give' ); ?></label><br> |
|
| 162 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
| 163 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
| 164 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label><br> |
|
| 161 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display style:', 'give'); ?></label><br> |
|
| 162 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
| 163 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
| 164 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label><br> |
|
| 165 | 165 | <small class="give-field-description"> |
| 166 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
| 166 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
| 167 | 167 | </small> |
| 168 | 168 | </p> |
| 169 | 169 | |
| 170 | 170 | <?php // Widget: Floating Labels ?> |
| 171 | 171 | <p> |
| 172 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
| 173 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Options', 'give' ); ?></label> |
|
| 174 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
| 175 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
| 172 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
| 173 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Options', 'give'); ?></label> |
|
| 174 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
| 175 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
| 176 | 176 | <small class="give-field-description"> |
| 177 | 177 | <?php |
| 178 | 178 | printf( |
| 179 | 179 | /* translators: %s: https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels */ |
| 180 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
| 181 | - esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' ) |
|
| 180 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
| 181 | + esc_url('https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels') |
|
| 182 | 182 | ); |
| 183 | 183 | ?></small> |
| 184 | 184 | </p><?php |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @return void |
| 191 | 191 | */ |
| 192 | - function widget_init(){ |
|
| 193 | - register_widget( $this->self ); |
|
| 192 | + function widget_init() { |
|
| 193 | + register_widget($this->self); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | - public function update( $new_instance, $old_instance ){ |
|
| 204 | + public function update($new_instance, $old_instance) { |
|
| 205 | 205 | $this->flush_widget_cache(); |
| 206 | 206 | |
| 207 | 207 | return $new_instance; |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return void |
| 214 | 214 | */ |
| 215 | - public function flush_widget_cache(){ |
|
| 216 | - wp_cache_delete( $this->self, 'widget' ); |
|
| 215 | + public function flush_widget_cache() { |
|
| 216 | + wp_cache_delete($this->self, 'widget'); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
@@ -66,23 +66,23 @@ discard block |
||
| 66 | 66 | * @param $args |
| 67 | 67 | * |
| 68 | 68 | */ |
| 69 | - public function __construct( $args ) { |
|
| 69 | + public function __construct($args) { |
|
| 70 | 70 | |
| 71 | 71 | //Only for admins. |
| 72 | - if ( ! is_admin() ) { |
|
| 72 | + if ( ! is_admin()) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | //This plugin is en_US native. |
| 77 | 77 | $this->locale = get_locale(); |
| 78 | - if ( 'en_US' === $this->locale ) { |
|
| 78 | + if ('en_US' === $this->locale) { |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $this->init( $args ); |
|
| 82 | + $this->init($args); |
|
| 83 | 83 | |
| 84 | - if ( ! $this->hide_promo() ) { |
|
| 85 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
| 84 | + if ( ! $this->hide_promo()) { |
|
| 85 | + add_action($this->hook, array($this, 'promo')); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @param array $args |
| 95 | 95 | */ |
| 96 | - private function init( $args ) { |
|
| 97 | - foreach ( $args as $key => $arg ) { |
|
| 96 | + private function init($args) { |
|
| 97 | + foreach ($args as $key => $arg) { |
|
| 98 | 98 | $this->$key = $arg; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | * @return bool |
| 109 | 109 | */ |
| 110 | 110 | private function hide_promo() { |
| 111 | - $hide_promo = get_transient( 'give_i18n_give_promo_hide' ); |
|
| 112 | - if ( ! $hide_promo ) { |
|
| 113 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
| 111 | + $hide_promo = get_transient('give_i18n_give_promo_hide'); |
|
| 112 | + if ( ! $hide_promo) { |
|
| 113 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
| 114 | 114 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
| 115 | - set_transient( 'give_i18n_give_promo_hide', true ); |
|
| 115 | + set_transient('give_i18n_give_promo_hide', true); |
|
| 116 | 116 | $hide_promo = true; |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -131,20 +131,20 @@ discard block |
||
| 131 | 131 | $message = false; |
| 132 | 132 | |
| 133 | 133 | //Using a translation less than 90% complete. |
| 134 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
| 135 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
| 136 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
| 137 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
| 138 | - } elseif ( ! $this->translation_exists ) { |
|
| 139 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
| 134 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
| 135 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
| 136 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
| 137 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
| 138 | + } elseif ( ! $this->translation_exists) { |
|
| 139 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | //Links. |
| 143 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
| 144 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
| 143 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
| 144 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
| 145 | 145 | |
| 146 | 146 | //Message. |
| 147 | - $message = sprintf( $message, esc_html( $this->locale_name ), esc_html( 'Give' ), $this->percent_translated, $registration_link, $translations_link ); |
|
| 147 | + $message = sprintf($message, esc_html($this->locale_name), esc_html('Give'), $this->percent_translated, $registration_link, $translations_link); |
|
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | return $message; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $this->translation_details(); |
| 160 | 160 | $message = $this->promo_message(); |
| 161 | 161 | |
| 162 | - if ( $message ) { ?> |
|
| 162 | + if ($message) { ?> |
|
| 163 | 163 | |
| 164 | 164 | <style> |
| 165 | 165 | /* Banner specific styles */ |
@@ -211,12 +211,12 @@ discard block |
||
| 211 | 211 | <a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a> |
| 212 | 212 | |
| 213 | 213 | <div class="give-i18n-notice-content"> |
| 214 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 214 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
| 215 | 215 | |
| 216 | - <h2 style="margin: 10px 0;"><?php printf( __( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
| 216 | + <h2 style="margin: 10px 0;"><?php printf(__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
| 217 | 217 | <p><?php echo $message; ?></p> |
| 218 | 218 | <p> |
| 219 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
| 219 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
| 220 | 220 | </p> |
| 221 | 221 | </div> |
| 222 | 222 | </div> |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | private function find_or_initialize_translation_details() { |
| 235 | 235 | |
| 236 | - $set = get_transient( 'give_i18n_give_' . $this->locale ); |
|
| 236 | + $set = get_transient('give_i18n_give_'.$this->locale); |
|
| 237 | 237 | |
| 238 | - if ( ! $set ) { |
|
| 238 | + if ( ! $set) { |
|
| 239 | 239 | $set = $this->retrieve_translation_details(); |
| 240 | - set_transient( 'give_i18n_give_' . $this->locale, $set, DAY_IN_SECONDS ); |
|
| 240 | + set_transient('give_i18n_give_'.$this->locale, $set, DAY_IN_SECONDS); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | return $set; |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | private function translation_details() { |
| 252 | 252 | $set = $this->find_or_initialize_translation_details(); |
| 253 | 253 | |
| 254 | - $this->translation_exists = ! is_null( $set ); |
|
| 255 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
| 254 | + $this->translation_exists = ! is_null($set); |
|
| 255 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
| 256 | 256 | |
| 257 | - $this->parse_translation_set( $set ); |
|
| 257 | + $this->parse_translation_set($set); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -266,26 +266,26 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | private function retrieve_translation_details() { |
| 268 | 268 | |
| 269 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
| 269 | + $api_url = trailingslashit($this->glotpress_url); |
|
| 270 | 270 | |
| 271 | - $resp = wp_remote_get( $api_url ); |
|
| 271 | + $resp = wp_remote_get($api_url); |
|
| 272 | 272 | |
| 273 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
| 273 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
| 274 | 274 | return null; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $body = wp_remote_retrieve_body( $resp ); |
|
| 278 | - unset( $resp ); |
|
| 277 | + $body = wp_remote_retrieve_body($resp); |
|
| 278 | + unset($resp); |
|
| 279 | 279 | |
| 280 | - if ( $body ) { |
|
| 281 | - $body = json_decode( $body ); |
|
| 280 | + if ($body) { |
|
| 281 | + $body = json_decode($body); |
|
| 282 | 282 | |
| 283 | - foreach ( $body->translation_sets as $set ) { |
|
| 284 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
| 283 | + foreach ($body->translation_sets as $set) { |
|
| 284 | + if ( ! property_exists($set, 'wp_locale')) { |
|
| 285 | 285 | continue; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if ( $this->locale == $set->wp_locale ) { |
|
| 288 | + if ($this->locale == $set->wp_locale) { |
|
| 289 | 289 | return $set; |
| 290 | 290 | } |
| 291 | 291 | } |
@@ -301,8 +301,8 @@ discard block |
||
| 301 | 301 | * |
| 302 | 302 | * @access private |
| 303 | 303 | */ |
| 304 | - private function parse_translation_set( $set ) { |
|
| 305 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
| 304 | + private function parse_translation_set($set) { |
|
| 305 | + if ($this->translation_exists && is_object($set)) { |
|
| 306 | 306 | $this->locale_name = $set->name; |
| 307 | 307 | $this->percent_translated = $set->percent_translated; |
| 308 | 308 | } else { |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | |
| 42 | 42 | // Exit if accessed directly. |
| 43 | -if ( ! defined( 'ABSPATH' ) ) {
|
|
| 43 | +if ( ! defined('ABSPATH')) {
|
|
| 44 | 44 | exit; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -if ( ! class_exists( 'Give' ) ) : |
|
| 47 | +if ( ! class_exists('Give')) :
|
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Main Give Class |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | * @return Give |
| 196 | 196 | */ |
| 197 | 197 | public static function instance() {
|
| 198 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) {
|
|
| 198 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give)) {
|
|
| 199 | 199 | self::$instance = new Give; |
| 200 | 200 | self::$instance->setup_constants(); |
| 201 | 201 | |
| 202 | - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
|
| 202 | + add_action('plugins_loaded', array(self::$instance, 'load_textdomain'));
|
|
| 203 | 203 | |
| 204 | 204 | self::$instance->includes(); |
| 205 | 205 | self::$instance->roles = new Give_Roles(); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function __clone() {
|
| 234 | 234 | // Cloning instances of the class is forbidden |
| 235 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
| 235 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'give'), '1.0');
|
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function __wakeup() {
|
| 247 | 247 | // Unserializing instances of the class is forbidden. |
| 248 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
| 248 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'give'), '1.0');
|
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -259,33 +259,33 @@ discard block |
||
| 259 | 259 | private function setup_constants() {
|
| 260 | 260 | |
| 261 | 261 | // Plugin version |
| 262 | - if ( ! defined( 'GIVE_VERSION' ) ) {
|
|
| 263 | - define( 'GIVE_VERSION', '1.6.3' ); |
|
| 262 | + if ( ! defined('GIVE_VERSION')) {
|
|
| 263 | + define('GIVE_VERSION', '1.6.3');
|
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | // Plugin Folder Path |
| 267 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
|
|
| 268 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
| 267 | + if ( ! defined('GIVE_PLUGIN_DIR')) {
|
|
| 268 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // Plugin Folder URL |
| 272 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
|
|
| 273 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
| 272 | + if ( ! defined('GIVE_PLUGIN_URL')) {
|
|
| 273 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__));
|
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Plugin Basename aka: "give/give.php" |
| 277 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
|
|
| 278 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
| 277 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) {
|
|
| 278 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // Plugin Root File |
| 282 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
|
|
| 283 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
| 282 | + if ( ! defined('GIVE_PLUGIN_FILE')) {
|
|
| 283 | + define('GIVE_PLUGIN_FILE', __FILE__);
|
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Make sure CAL_GREGORIAN is defined |
| 287 | - if ( ! defined( 'CAL_GREGORIAN' ) ) {
|
|
| 288 | - define( 'CAL_GREGORIAN', 1 ); |
|
| 287 | + if ( ! defined('CAL_GREGORIAN')) {
|
|
| 288 | + define('CAL_GREGORIAN', 1);
|
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
@@ -300,111 +300,111 @@ discard block |
||
| 300 | 300 | private function includes() {
|
| 301 | 301 | global $give_options; |
| 302 | 302 | |
| 303 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
| 303 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
| 304 | 304 | $give_options = give_get_settings(); |
| 305 | 305 | |
| 306 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
| 307 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
| 308 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
| 309 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
| 310 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
| 311 | - |
|
| 312 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
| 313 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
| 314 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
| 315 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
| 316 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php'; |
|
| 317 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customer-meta.php'; |
|
| 318 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php'; |
|
| 319 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
| 320 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
| 321 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
| 322 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
| 323 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
| 324 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
| 325 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
| 326 | - |
|
| 327 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
| 328 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
| 329 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
| 330 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
| 331 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
| 332 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
| 333 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
| 334 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
| 335 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
| 336 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
| 337 | - require_once GIVE_PLUGIN_DIR . 'includes/process-purchase.php'; |
|
| 338 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
| 339 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
| 340 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
| 341 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated-functions.php'; |
|
| 342 | - |
|
| 343 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
| 344 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
| 345 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
| 346 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
| 347 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
| 348 | - |
|
| 349 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
| 350 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
| 351 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
| 352 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
| 353 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
| 354 | - |
|
| 355 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
| 356 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
| 357 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
| 358 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
| 359 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
| 360 | - |
|
| 361 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
|
|
| 362 | - |
|
| 363 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
| 364 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
| 365 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
| 366 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php'; |
|
| 367 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
| 368 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
| 369 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
| 370 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php'; |
|
| 371 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
| 372 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
| 373 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
| 374 | - |
|
| 375 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
| 376 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
| 377 | - |
|
| 378 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php'; |
|
| 379 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php'; |
|
| 380 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php'; |
|
| 381 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
| 382 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
| 383 | - |
|
| 384 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php'; |
|
| 385 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
| 386 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php'; |
|
| 387 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php'; |
|
| 388 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php'; |
|
| 389 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
| 390 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
| 391 | - |
|
| 392 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
| 393 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
| 394 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
| 395 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
| 396 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
| 397 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
| 398 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
| 399 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
| 400 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
| 401 | - |
|
| 402 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 403 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php'; |
|
| 306 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
| 307 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
| 308 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
| 309 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
| 310 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
| 311 | + |
|
| 312 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
| 313 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
| 314 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
| 315 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
| 316 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php'; |
|
| 317 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customer-meta.php'; |
|
| 318 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php'; |
|
| 319 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
| 320 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
| 321 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
| 322 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
| 323 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
| 324 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
| 325 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
| 326 | + |
|
| 327 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
| 328 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
| 329 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
| 330 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
| 331 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
| 332 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
| 333 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
| 334 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
| 335 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
| 336 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
| 337 | + require_once GIVE_PLUGIN_DIR.'includes/process-purchase.php'; |
|
| 338 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
| 339 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
| 340 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
| 341 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated-functions.php'; |
|
| 342 | + |
|
| 343 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
| 344 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
| 345 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
| 346 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
| 347 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
| 348 | + |
|
| 349 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
| 350 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
| 351 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
| 352 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
| 353 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
| 354 | + |
|
| 355 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
| 356 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
| 357 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
| 358 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
| 359 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
| 360 | + |
|
| 361 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
|
|
| 362 | + |
|
| 363 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
| 364 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
| 365 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
| 366 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php'; |
|
| 367 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
| 368 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
| 369 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
| 370 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php'; |
|
| 371 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
| 372 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
| 373 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
| 374 | + |
|
| 375 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
| 376 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
| 377 | + |
|
| 378 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php'; |
|
| 379 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php'; |
|
| 380 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php'; |
|
| 381 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
| 382 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
| 383 | + |
|
| 384 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php'; |
|
| 385 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
| 386 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php'; |
|
| 387 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php'; |
|
| 388 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php'; |
|
| 389 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
| 390 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
| 391 | + |
|
| 392 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
| 393 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
| 394 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
| 395 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
| 396 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
| 397 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
| 398 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
| 399 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
| 400 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
| 401 | + |
|
| 402 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 403 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
| 404 | 404 | |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
| 407 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
| 408 | 408 | |
| 409 | 409 | } |
| 410 | 410 | |
@@ -418,26 +418,26 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | public function load_textdomain() {
|
| 420 | 420 | // Set filter for Give's languages directory |
| 421 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
| 422 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
| 421 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
| 422 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
|
|
| 423 | 423 | |
| 424 | 424 | // Traditional WordPress plugin locale filter |
| 425 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' ); |
|
| 426 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); |
|
| 425 | + $locale = apply_filters('plugin_locale', get_locale(), 'give');
|
|
| 426 | + $mofile = sprintf('%1$s-%2$s.mo', 'give', $locale);
|
|
| 427 | 427 | |
| 428 | 428 | // Setup paths to current locale file |
| 429 | - $mofile_local = $give_lang_dir . $mofile; |
|
| 430 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile; |
|
| 429 | + $mofile_local = $give_lang_dir.$mofile; |
|
| 430 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile; |
|
| 431 | 431 | |
| 432 | - if ( file_exists( $mofile_global ) ) {
|
|
| 432 | + if (file_exists($mofile_global)) {
|
|
| 433 | 433 | // Look in global /wp-content/languages/give folder |
| 434 | - load_textdomain( 'give', $mofile_global ); |
|
| 435 | - } elseif ( file_exists( $mofile_local ) ) {
|
|
| 434 | + load_textdomain('give', $mofile_global);
|
|
| 435 | + } elseif (file_exists($mofile_local)) {
|
|
| 436 | 436 | // Look in local location from filter `give_languages_directory` |
| 437 | - load_textdomain( 'give', $mofile_local ); |
|
| 437 | + load_textdomain('give', $mofile_local);
|
|
| 438 | 438 | } else {
|
| 439 | 439 | // Load the default language files packaged up w/ Give |
| 440 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
| 440 | + load_plugin_textdomain('give', false, $give_lang_dir);
|
|
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
@@ -661,7 +661,7 @@ |
||
| 661 | 661 | * |
| 662 | 662 | * @since 1.6.3 |
| 663 | 663 | * |
| 664 | - * @param $pending_reason |
|
| 664 | + * @param string $pending_reason |
|
| 665 | 665 | * |
| 666 | 666 | * @return string |
| 667 | 667 | */ |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @access private |
| 22 | 22 | * @since 1.0 |
| 23 | 23 | */ |
| 24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
| 24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Process PayPal Purchase. |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
| 35 | +function give_process_paypal_purchase($purchase_data) { |
|
| 36 | 36 | |
| 37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
| 38 | - wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
| 38 | + wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
| 42 | - $price_id = isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : ''; |
|
| 41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
| 42 | + $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : ''; |
|
| 43 | 43 | |
| 44 | 44 | // Collect payment data. |
| 45 | 45 | $payment_data = array( |
@@ -57,101 +57,101 @@ discard block |
||
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | // Record the pending payment. |
| 60 | - $payment_id = give_insert_payment( $payment_data ); |
|
| 60 | + $payment_id = give_insert_payment($payment_data); |
|
| 61 | 61 | |
| 62 | 62 | // Check payment. |
| 63 | - if ( ! $payment_id ) { |
|
| 63 | + if ( ! $payment_id) { |
|
| 64 | 64 | // Record the error. |
| 65 | 65 | give_record_gateway_error( |
| 66 | - esc_html__( 'Payment Error', 'give' ), |
|
| 66 | + esc_html__('Payment Error', 'give'), |
|
| 67 | 67 | sprintf( |
| 68 | 68 | /* translators: %s: payment data */ |
| 69 | - esc_html__( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), |
|
| 70 | - json_encode( $payment_data ) |
|
| 69 | + esc_html__('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), |
|
| 70 | + json_encode($payment_data) |
|
| 71 | 71 | ), |
| 72 | 72 | $payment_id |
| 73 | 73 | ); |
| 74 | 74 | // Problems? Send back. |
| 75 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 75 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 76 | 76 | |
| 77 | 77 | } else { |
| 78 | 78 | |
| 79 | 79 | // Only send to PayPal if the pending payment is created successfully. |
| 80 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
| 80 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
| 81 | 81 | |
| 82 | 82 | // Get the success url. |
| 83 | - $return_url = add_query_arg( array( |
|
| 83 | + $return_url = add_query_arg(array( |
|
| 84 | 84 | 'payment-confirmation' => 'paypal', |
| 85 | 85 | 'payment-id' => $payment_id |
| 86 | 86 | |
| 87 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
| 87 | + ), get_permalink(give_get_option('success_page'))); |
|
| 88 | 88 | |
| 89 | 89 | // Get the PayPal redirect uri. |
| 90 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
| 90 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
| 91 | 91 | |
| 92 | 92 | //Item name - pass level name if variable priced. |
| 93 | 93 | $item_name = $purchase_data['post_data']['give-form-title']; |
| 94 | 94 | |
| 95 | 95 | //Verify has variable prices. |
| 96 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
| 96 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
| 97 | 97 | |
| 98 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 98 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 99 | 99 | |
| 100 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 100 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 101 | 101 | |
| 102 | 102 | //Donation given doesn't match selected level (must be a custom amount). |
| 103 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 104 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 103 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
| 104 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 105 | 105 | //user custom amount text if any, fallback to default if not. |
| 106 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
| 106 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
| 107 | 107 | |
| 108 | 108 | } //Is there any donation level text? |
| 109 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
| 110 | - $item_name .= ' - ' . $item_price_level_text; |
|
| 109 | + elseif ( ! empty($item_price_level_text)) { |
|
| 110 | + $item_name .= ' - '.$item_price_level_text; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | } //Single donation: Custom Amount. |
| 114 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 115 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 114 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
| 115 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 116 | 116 | //user custom amount text if any, fallback to default if not. |
| 117 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
| 117 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Setup PayPal API params. |
| 121 | 121 | $paypal_args = array( |
| 122 | - 'business' => give_get_option( 'paypal_email', false ), |
|
| 122 | + 'business' => give_get_option('paypal_email', false), |
|
| 123 | 123 | 'first_name' => $purchase_data['user_info']['first_name'], |
| 124 | 124 | 'last_name' => $purchase_data['user_info']['last_name'], |
| 125 | 125 | 'email' => $purchase_data['user_email'], |
| 126 | 126 | 'invoice' => $purchase_data['purchase_key'], |
| 127 | 127 | 'amount' => $purchase_data['price'], |
| 128 | - 'item_name' => stripslashes( $item_name ), |
|
| 128 | + 'item_name' => stripslashes($item_name), |
|
| 129 | 129 | 'no_shipping' => '1', |
| 130 | 130 | 'shipping' => '0', |
| 131 | 131 | 'no_note' => '1', |
| 132 | 132 | 'currency_code' => give_get_currency(), |
| 133 | - 'charset' => get_bloginfo( 'charset' ), |
|
| 133 | + 'charset' => get_bloginfo('charset'), |
|
| 134 | 134 | 'custom' => $payment_id, |
| 135 | 135 | 'rm' => '2', |
| 136 | 136 | 'return' => $return_url, |
| 137 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
| 137 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
| 138 | 138 | 'notify_url' => $listener_url, |
| 139 | 139 | 'page_style' => give_get_paypal_page_style(), |
| 140 | - 'cbt' => get_bloginfo( 'name' ), |
|
| 140 | + 'cbt' => get_bloginfo('name'), |
|
| 141 | 141 | 'bn' => 'givewp_SP' |
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | 144 | //Add user address if present. |
| 145 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
| 146 | - $paypal_args['address1'] = isset( $purchase_data['user_info']['address']['line1'] ) ? $purchase_data['user_info']['address']['line1'] : ''; |
|
| 147 | - $paypal_args['address2'] = isset( $purchase_data['user_info']['address']['line2'] ) ? $purchase_data['user_info']['address']['line2'] : ''; |
|
| 148 | - $paypal_args['city'] = isset( $purchase_data['user_info']['address']['city'] ) ? $purchase_data['user_info']['address']['city'] : ''; |
|
| 149 | - $paypal_args['state'] = isset( $purchase_data['user_info']['address']['state'] ) ? $purchase_data['user_info']['address']['state'] : ''; |
|
| 150 | - $paypal_args['country'] = isset( $purchase_data['user_info']['address']['country'] ) ? $purchase_data['user_info']['address']['country'] : ''; |
|
| 145 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
| 146 | + $paypal_args['address1'] = isset($purchase_data['user_info']['address']['line1']) ? $purchase_data['user_info']['address']['line1'] : ''; |
|
| 147 | + $paypal_args['address2'] = isset($purchase_data['user_info']['address']['line2']) ? $purchase_data['user_info']['address']['line2'] : ''; |
|
| 148 | + $paypal_args['city'] = isset($purchase_data['user_info']['address']['city']) ? $purchase_data['user_info']['address']['city'] : ''; |
|
| 149 | + $paypal_args['state'] = isset($purchase_data['user_info']['address']['state']) ? $purchase_data['user_info']['address']['state'] : ''; |
|
| 150 | + $paypal_args['country'] = isset($purchase_data['user_info']['address']['country']) ? $purchase_data['user_info']['address']['country'] : ''; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | //Donations or regular transactions? |
| 154 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
| 154 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
| 155 | 155 | $paypal_extra_args = array( |
| 156 | 156 | 'cmd' => '_xclick', |
| 157 | 157 | ); |
@@ -161,23 +161,23 @@ discard block |
||
| 161 | 161 | ); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
| 165 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
| 164 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
| 165 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
| 166 | 166 | |
| 167 | 167 | // Build query. |
| 168 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
| 168 | + $paypal_redirect .= http_build_query($paypal_args); |
|
| 169 | 169 | |
| 170 | 170 | // Fix for some sites that encode the entities. |
| 171 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
| 171 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
| 172 | 172 | |
| 173 | 173 | // Redirect to PayPal. |
| 174 | - wp_redirect( $paypal_redirect ); |
|
| 174 | + wp_redirect($paypal_redirect); |
|
| 175 | 175 | exit; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
| 180 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | 183 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | function give_listen_for_paypal_ipn() { |
| 189 | 189 | // Regular PayPal IPN |
| 190 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
| 191 | - do_action( 'give_verify_paypal_ipn' ); |
|
| 190 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
| 191 | + do_action('give_verify_paypal_ipn'); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
| 195 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | 198 | * Process PayPal IPN |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | function give_process_paypal_ipn() { |
| 204 | 204 | |
| 205 | 205 | // Check the request method is POST |
| 206 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
| 206 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
| 207 | 207 | return; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | $post_data = ''; |
| 212 | 212 | |
| 213 | 213 | // Fallback just in case post_max_size is lower than needed |
| 214 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 215 | - $post_data = file_get_contents( 'php://input' ); |
|
| 214 | + if (ini_get('allow_url_fopen')) { |
|
| 215 | + $post_data = file_get_contents('php://input'); |
|
| 216 | 216 | } else { |
| 217 | 217 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
| 218 | - ini_set( 'post_max_size', '12M' ); |
|
| 218 | + ini_set('post_max_size', '12M'); |
|
| 219 | 219 | } |
| 220 | 220 | // Start the encoded data collection with notification command |
| 221 | 221 | $encoded_data = 'cmd=_notify-validate'; |
@@ -224,40 +224,40 @@ discard block |
||
| 224 | 224 | $arg_separator = give_get_php_arg_separator_output(); |
| 225 | 225 | |
| 226 | 226 | // Verify there is a post_data |
| 227 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 227 | + if ($post_data || strlen($post_data) > 0) { |
|
| 228 | 228 | // Append the data |
| 229 | - $encoded_data .= $arg_separator . $post_data; |
|
| 229 | + $encoded_data .= $arg_separator.$post_data; |
|
| 230 | 230 | } else { |
| 231 | 231 | // Check if POST is empty |
| 232 | - if ( empty( $_POST ) ) { |
|
| 232 | + if (empty($_POST)) { |
|
| 233 | 233 | // Nothing to do |
| 234 | 234 | return; |
| 235 | 235 | } else { |
| 236 | 236 | // Loop through each POST |
| 237 | - foreach ( $_POST as $key => $value ) { |
|
| 237 | + foreach ($_POST as $key => $value) { |
|
| 238 | 238 | // Encode the value and append the data. |
| 239 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
| 239 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Convert collected post data to an array. |
| 245 | - parse_str( $encoded_data, $encoded_data_array ); |
|
| 245 | + parse_str($encoded_data, $encoded_data_array); |
|
| 246 | 246 | |
| 247 | - foreach ( $encoded_data_array as $key => $value ) { |
|
| 247 | + foreach ($encoded_data_array as $key => $value) { |
|
| 248 | 248 | |
| 249 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
| 250 | - $new_key = str_replace( '&', '&', $key ); |
|
| 251 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
| 249 | + if (false !== strpos($key, 'amp;')) { |
|
| 250 | + $new_key = str_replace('&', '&', $key); |
|
| 251 | + $new_key = str_replace('amp;', '&', $new_key); |
|
| 252 | 252 | |
| 253 | - unset( $encoded_data_array[ $key ] ); |
|
| 254 | - $encoded_data_array[ $new_key ] = $value; |
|
| 253 | + unset($encoded_data_array[$key]); |
|
| 254 | + $encoded_data_array[$new_key] = $value; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
| 260 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
| 260 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
| 261 | 261 | |
| 262 | 262 | $remote_post_vars = array( |
| 263 | 263 | 'method' => 'POST', |
@@ -277,28 +277,28 @@ discard block |
||
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | 279 | // Validate the IPN. |
| 280 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
| 280 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
| 281 | 281 | |
| 282 | - if ( is_wp_error( $api_response ) ) { |
|
| 282 | + if (is_wp_error($api_response)) { |
|
| 283 | 283 | give_record_gateway_error( |
| 284 | - esc_html__( 'IPN Error', 'give' ), |
|
| 284 | + esc_html__('IPN Error', 'give'), |
|
| 285 | 285 | sprintf( |
| 286 | 286 | /* translators: %s: Paypal IPN response */ |
| 287 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
| 288 | - json_encode( $api_response ) |
|
| 287 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
| 288 | + json_encode($api_response) |
|
| 289 | 289 | ) |
| 290 | 290 | ); |
| 291 | 291 | |
| 292 | 292 | return; // Something went wrong |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
| 295 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
| 296 | 296 | give_record_gateway_error( |
| 297 | - esc_html__( 'IPN Error', 'give' ), |
|
| 297 | + esc_html__('IPN Error', 'give'), |
|
| 298 | 298 | sprintf( |
| 299 | 299 | /* translators: %s: Paypal IPN response */ |
| 300 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
| 301 | - json_encode( $api_response ) |
|
| 300 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
| 301 | + json_encode($api_response) |
|
| 302 | 302 | ) |
| 303 | 303 | ); |
| 304 | 304 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Check if $post_data_array has been populated |
| 311 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
| 311 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
| 312 | 312 | return; |
| 313 | 313 | } |
| 314 | 314 | |
@@ -317,21 +317,21 @@ discard block |
||
| 317 | 317 | 'payment_status' => '' |
| 318 | 318 | ); |
| 319 | 319 | |
| 320 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
| 320 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
| 321 | 321 | |
| 322 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
| 322 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
| 323 | 323 | |
| 324 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
| 324 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
| 325 | 325 | // Allow PayPal IPN types to be processed separately. |
| 326 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
| 326 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
| 327 | 327 | } else { |
| 328 | 328 | // Fallback to web accept just in case the txn_type isn't present. |
| 329 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
| 329 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
| 330 | 330 | } |
| 331 | 331 | exit; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
| 334 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | 337 | * Process web accept (one time) payment IPNs. |
@@ -343,127 +343,127 @@ discard block |
||
| 343 | 343 | * |
| 344 | 344 | * @return void |
| 345 | 345 | */ |
| 346 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
| 346 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
| 347 | 347 | |
| 348 | 348 | //Only allow through these transaction types. |
| 349 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower( $data['payment_status'] ) != 'refunded' ) { |
|
| 349 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower($data['payment_status']) != 'refunded') { |
|
| 350 | 350 | return; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | //Need $payment_id to continue. |
| 354 | - if ( empty( $payment_id ) ) { |
|
| 354 | + if (empty($payment_id)) { |
|
| 355 | 355 | return; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | // Collect donation payment details. |
| 359 | 359 | $paypal_amount = $data['mc_gross']; |
| 360 | - $payment_status = strtolower( $data['payment_status'] ); |
|
| 361 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
| 362 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
| 363 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 360 | + $payment_status = strtolower($data['payment_status']); |
|
| 361 | + $currency_code = strtolower($data['mc_currency']); |
|
| 362 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
| 363 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 364 | 364 | |
| 365 | 365 | // Must be a PayPal standard IPN. |
| 366 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
| 366 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
| 367 | 367 | return; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | // Verify payment recipient |
| 371 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
| 371 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
| 372 | 372 | |
| 373 | 373 | give_record_gateway_error( |
| 374 | - esc_html__( 'IPN Error', 'give' ), |
|
| 374 | + esc_html__('IPN Error', 'give'), |
|
| 375 | 375 | sprintf( |
| 376 | 376 | /* translators: %s: Paypal IPN response */ |
| 377 | - esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
| 378 | - json_encode( $data ) |
|
| 377 | + esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
| 378 | + json_encode($data) |
|
| 379 | 379 | ), |
| 380 | 380 | $payment_id |
| 381 | 381 | ); |
| 382 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 383 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
| 382 | + give_update_payment_status($payment_id, 'failed'); |
|
| 383 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give')); |
|
| 384 | 384 | |
| 385 | 385 | return; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | // Verify payment currency. |
| 389 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
| 389 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
| 390 | 390 | |
| 391 | 391 | give_record_gateway_error( |
| 392 | - esc_html__( 'IPN Error', 'give' ), |
|
| 392 | + esc_html__('IPN Error', 'give'), |
|
| 393 | 393 | sprintf( |
| 394 | 394 | /* translators: %s: Paypal IPN response */ |
| 395 | - esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
| 396 | - json_encode( $data ) |
|
| 395 | + esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
| 396 | + json_encode($data) |
|
| 397 | 397 | ), |
| 398 | 398 | $payment_id |
| 399 | 399 | ); |
| 400 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 401 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
| 400 | + give_update_payment_status($payment_id, 'failed'); |
|
| 401 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
| 402 | 402 | |
| 403 | 403 | return; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | //Process refunds & reversed. |
| 407 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
| 408 | - give_process_paypal_refund( $data, $payment_id ); |
|
| 407 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
| 408 | + give_process_paypal_refund($data, $payment_id); |
|
| 409 | 409 | return; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | // Only complete payments once. |
| 413 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
| 413 | + if (get_post_status($payment_id) == 'publish') { |
|
| 414 | 414 | return; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | // Retrieve the total donation amount (before PayPal). |
| 418 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 418 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 419 | 419 | |
| 420 | 420 | //Check that the donation PP and local db amounts match. |
| 421 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 421 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 422 | 422 | // The prices don't match |
| 423 | 423 | give_record_gateway_error( |
| 424 | - esc_html__( 'IPN Error', 'give' ), |
|
| 424 | + esc_html__('IPN Error', 'give'), |
|
| 425 | 425 | sprintf( |
| 426 | 426 | /* translators: %s: Paypal IPN response */ |
| 427 | - esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
| 428 | - json_encode( $data ) |
|
| 427 | + esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
| 428 | + json_encode($data) |
|
| 429 | 429 | ), |
| 430 | 430 | $payment_id |
| 431 | 431 | ); |
| 432 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 433 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
| 432 | + give_update_payment_status($payment_id, 'failed'); |
|
| 433 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
| 434 | 434 | |
| 435 | 435 | return; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | //Process completed donations. |
| 439 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
| 439 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
| 440 | 440 | |
| 441 | 441 | give_insert_payment_note( |
| 442 | 442 | $payment_id, |
| 443 | 443 | sprintf( |
| 444 | 444 | /* translators: %s: Paypal transaction ID */ |
| 445 | - esc_html__( 'PayPal Transaction ID: %s', 'give' ), |
|
| 445 | + esc_html__('PayPal Transaction ID: %s', 'give'), |
|
| 446 | 446 | $data['txn_id'] |
| 447 | 447 | ) |
| 448 | 448 | ); |
| 449 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
| 450 | - give_update_payment_status( $payment_id, 'publish' ); |
|
| 449 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
| 450 | + give_update_payment_status($payment_id, 'publish'); |
|
| 451 | 451 | |
| 452 | - } elseif ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
| 452 | + } elseif ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
| 453 | 453 | |
| 454 | 454 | // Look for possible pending reasons, such as an echeck. |
| 455 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
| 455 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
| 456 | 456 | |
| 457 | - if ( ! empty( $note ) ) { |
|
| 457 | + if ( ! empty($note)) { |
|
| 458 | 458 | |
| 459 | - give_insert_payment_note( $payment_id, $note ); |
|
| 459 | + give_insert_payment_note($payment_id, $note); |
|
| 460 | 460 | |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
| 466 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
| 467 | 467 | |
| 468 | 468 | /** |
| 469 | 469 | * Process PayPal IPN Refunds |
@@ -475,28 +475,28 @@ discard block |
||
| 475 | 475 | * |
| 476 | 476 | * @return void |
| 477 | 477 | */ |
| 478 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
| 478 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
| 479 | 479 | |
| 480 | 480 | // Collect payment details |
| 481 | 481 | |
| 482 | - if ( empty( $payment_id ) ) { |
|
| 482 | + if (empty($payment_id)) { |
|
| 483 | 483 | return; |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
| 486 | + if (get_post_status($payment_id) == 'refunded') { |
|
| 487 | 487 | return; // Only refund payments once |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 490 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 491 | 491 | $refund_amount = $data['payment_gross'] * - 1; |
| 492 | 492 | |
| 493 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 493 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 494 | 494 | |
| 495 | 495 | give_insert_payment_note( |
| 496 | 496 | $payment_id, |
| 497 | 497 | sprintf( |
| 498 | 498 | /* translators: %s: Paypal parent transaction ID */ |
| 499 | - esc_html__( 'Partial PayPal refund processed: %s', 'give' ), |
|
| 499 | + esc_html__('Partial PayPal refund processed: %s', 'give'), |
|
| 500 | 500 | $data['parent_txn_id'] |
| 501 | 501 | ) |
| 502 | 502 | ); |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | $payment_id, |
| 510 | 510 | sprintf( |
| 511 | 511 | /* translators: %s: Paypal parent transaction ID */ |
| 512 | - esc_html__( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), |
|
| 512 | + esc_html__('PayPal Payment #%s Refunded for reason: %s', 'give'), |
|
| 513 | 513 | $data['parent_txn_id'], $data['reason_code'] |
| 514 | 514 | ) |
| 515 | 515 | ); |
@@ -517,11 +517,11 @@ discard block |
||
| 517 | 517 | $payment_id, |
| 518 | 518 | sprintf( |
| 519 | 519 | /* translators: %s: Paypal transaction ID */ |
| 520 | - esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
| 520 | + esc_html__('PayPal Refund Transaction ID: %s', 'give'), |
|
| 521 | 521 | $data['txn_id'] |
| 522 | 522 | ) |
| 523 | 523 | ); |
| 524 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
| 524 | + give_update_payment_status($payment_id, 'refunded'); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |
@@ -533,24 +533,24 @@ discard block |
||
| 533 | 533 | * |
| 534 | 534 | * @return string |
| 535 | 535 | */ |
| 536 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
| 536 | +function give_get_paypal_redirect($ssl_check = false) { |
|
| 537 | 537 | |
| 538 | - if ( is_ssl() || ! $ssl_check ) { |
|
| 538 | + if (is_ssl() || ! $ssl_check) { |
|
| 539 | 539 | $protocal = 'https://'; |
| 540 | 540 | } else { |
| 541 | 541 | $protocal = 'http://'; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | // Check the current payment mode |
| 545 | - if ( give_is_test_mode() ) { |
|
| 545 | + if (give_is_test_mode()) { |
|
| 546 | 546 | // Test mode |
| 547 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 547 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 548 | 548 | } else { |
| 549 | 549 | // Live mode |
| 550 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
| 550 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
| 553 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | /** |
@@ -560,9 +560,9 @@ discard block |
||
| 560 | 560 | * @return string |
| 561 | 561 | */ |
| 562 | 562 | function give_get_paypal_page_style() { |
| 563 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
| 563 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
| 564 | 564 | |
| 565 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
| 565 | + return apply_filters('give_paypal_page_style', $page_style); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -577,26 +577,26 @@ discard block |
||
| 577 | 577 | * @return string |
| 578 | 578 | * |
| 579 | 579 | */ |
| 580 | -function give_paypal_success_page_content( $content ) { |
|
| 580 | +function give_paypal_success_page_content($content) { |
|
| 581 | 581 | |
| 582 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
| 582 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
| 583 | 583 | return $content; |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
| 586 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
| 587 | 587 | |
| 588 | - if ( ! $payment_id ) { |
|
| 588 | + if ( ! $payment_id) { |
|
| 589 | 589 | $session = give_get_purchase_session(); |
| 590 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
| 590 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - $payment = get_post( $payment_id ); |
|
| 594 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
| 593 | + $payment = get_post($payment_id); |
|
| 594 | + if ($payment && 'pending' == $payment->post_status) { |
|
| 595 | 595 | |
| 596 | 596 | // Payment is still pending so show processing indicator to fix the race condition. |
| 597 | 597 | ob_start(); |
| 598 | 598 | |
| 599 | - give_get_template_part( 'payment', 'processing' ); |
|
| 599 | + give_get_template_part('payment', 'processing'); |
|
| 600 | 600 | |
| 601 | 601 | $content = ob_get_clean(); |
| 602 | 602 | |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
| 609 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
| 610 | 610 | |
| 611 | 611 | /** |
| 612 | 612 | * Given a Payment ID, extract the transaction ID |
@@ -617,22 +617,22 @@ discard block |
||
| 617 | 617 | * |
| 618 | 618 | * @return string Transaction ID |
| 619 | 619 | */ |
| 620 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
| 620 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
| 621 | 621 | |
| 622 | 622 | $transaction_id = ''; |
| 623 | - $notes = give_get_payment_notes( $payment_id ); |
|
| 623 | + $notes = give_get_payment_notes($payment_id); |
|
| 624 | 624 | |
| 625 | - foreach ( $notes as $note ) { |
|
| 626 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
| 625 | + foreach ($notes as $note) { |
|
| 626 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
| 627 | 627 | $transaction_id = $match[1]; |
| 628 | 628 | continue; |
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 632 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
| 635 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
| 636 | 636 | |
| 637 | 637 | /** |
| 638 | 638 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -644,16 +644,16 @@ discard block |
||
| 644 | 644 | * |
| 645 | 645 | * @return string A link to the PayPal transaction details |
| 646 | 646 | */ |
| 647 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
| 647 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
| 648 | 648 | |
| 649 | 649 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
| 650 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
| 650 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
| 651 | 651 | |
| 652 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
| 652 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
| 653 | 653 | |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
| 656 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
| 657 | 657 | |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -665,62 +665,62 @@ discard block |
||
| 665 | 665 | * |
| 666 | 666 | * @return string |
| 667 | 667 | */ |
| 668 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
| 668 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
| 669 | 669 | |
| 670 | - switch ( $pending_reason ) { |
|
| 670 | + switch ($pending_reason) { |
|
| 671 | 671 | |
| 672 | 672 | case 'echeck' : |
| 673 | 673 | |
| 674 | - $note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
| 674 | + $note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
| 675 | 675 | |
| 676 | 676 | break; |
| 677 | 677 | |
| 678 | 678 | case 'address' : |
| 679 | 679 | |
| 680 | - $note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
| 680 | + $note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
| 681 | 681 | |
| 682 | 682 | break; |
| 683 | 683 | |
| 684 | 684 | case 'intl' : |
| 685 | 685 | |
| 686 | - $note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
| 686 | + $note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
| 687 | 687 | |
| 688 | 688 | break; |
| 689 | 689 | |
| 690 | 690 | case 'multi-currency' : |
| 691 | 691 | |
| 692 | - $note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
| 692 | + $note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
| 693 | 693 | |
| 694 | 694 | break; |
| 695 | 695 | |
| 696 | 696 | case 'paymentreview' : |
| 697 | 697 | case 'regulatory_review' : |
| 698 | 698 | |
| 699 | - $note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
| 699 | + $note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
| 700 | 700 | |
| 701 | 701 | break; |
| 702 | 702 | |
| 703 | 703 | case 'unilateral' : |
| 704 | 704 | |
| 705 | - $note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
| 705 | + $note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
| 706 | 706 | |
| 707 | 707 | break; |
| 708 | 708 | |
| 709 | 709 | case 'upgrade' : |
| 710 | 710 | |
| 711 | - $note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
| 711 | + $note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
| 712 | 712 | |
| 713 | 713 | break; |
| 714 | 714 | |
| 715 | 715 | case 'verify' : |
| 716 | 716 | |
| 717 | - $note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
| 717 | + $note = esc_html__('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
| 718 | 718 | |
| 719 | 719 | break; |
| 720 | 720 | |
| 721 | 721 | case 'other' : |
| 722 | 722 | |
| 723 | - $note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
| 723 | + $note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
| 724 | 724 | |
| 725 | 725 | break; |
| 726 | 726 | |